From 7b66699b70792643d6a89ca6d72b1ba46effb179 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 12 Jun 2026 19:13:02 +0200 Subject: [PATCH 01/30] 26.2-rc-2 Co-authored-by: Bjarne Koll Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Pedro <3602279+Doc94@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com> --- build-data/paper.at | 2 + gradle.properties | 8 +- .../paper/entity/ai/VanillaGoal.java | 23 +- .../paper/registry/keys/AttributeKeys.java | 35 ++ .../paper/registry/keys/BiomeKeys.java | 7 + .../paper/registry/keys/BlockTypeKeys.java | 196 ++++++++ .../paper/registry/keys/DamageTypeKeys.java | 7 + .../registry/keys/DataComponentTypeKeys.java | 7 + .../paper/registry/keys/GameEventKeys.java | 7 + .../paper/registry/keys/ItemTypeKeys.java | 217 ++++++++ .../paper/registry/keys/JukeboxSongKeys.java | 7 + .../paper/registry/keys/SoundEventKeys.java | 462 ++++++++++++++++++ .../keys/SulfurCubeArchetypeKeys.java | 124 +++++ .../registry/keys/tags/BlockTypeTagKeys.java | 123 ++++- .../registry/keys/tags/DamageTypeTagKeys.java | 7 + .../registry/keys/tags/EntityTypeTagKeys.java | 7 + .../registry/keys/tags/ItemTypeTagKeys.java | 119 +++++ .../co/aikar/timings/TimedEventExecutor.java | 2 +- .../main/java/co/aikar/util/LoadingMap.java | 2 +- .../com/destroystokyo/paper/MaterialTags.java | 15 +- .../event/entity/CreeperIgniteEvent.java | 26 +- .../entity/SlimeChangeDirectionEvent.java | 6 +- .../event/entity/SlimePathfindEvent.java | 10 +- .../paper/event/entity/SlimeSwimEvent.java | 6 +- .../entity/SlimeTargetLivingEntityEvent.java | 6 +- .../paper/event/entity/SlimeWanderEvent.java | 6 +- .../io/papermc/paper/InternalAPIBridge.java | 86 ++-- .../datacomponent/DataComponentTypes.java | 6 +- .../item/ChargedProjectiles.java | 8 +- .../item/ItemComponentTypesBridge.java | 2 + .../datacomponent/item/SulfurCubeContent.java | 29 ++ .../paper/event/entity/EntityIgniteEvent.java | 66 +++ .../papermc/paper/registry/RegistryKey.java | 6 + .../data/BannerPatternRegistryEntry.java | 12 +- .../registry/data/CatTypeRegistryEntry.java | 12 +- .../data/ChickenVariantRegistryEntry.java | 18 +- .../data/CowVariantRegistryEntry.java | 18 +- .../data/DamageTypeRegistryEntry.java | 10 +- .../data/EnchantmentRegistryEntry.java | 74 +-- .../data/FrogVariantRegistryEntry.java | 6 +- .../registry/data/GameEventRegistryEntry.java | 6 +- .../data/InstrumentRegistryEntry.java | 8 +- .../data/JukeboxSongRegistryEntry.java | 2 +- .../data/PaintingVariantRegistryEntry.java | 30 +- .../data/PigVariantRegistryEntry.java | 18 +- .../SulfurCubeArchetypeRegistryEntry.java | 375 ++++++++++++++ .../data/WolfVariantRegistryEntry.java | 36 +- .../ZombieNautilusVariantRegistryEntry.java | 12 +- .../data/client/ClientTextureAsset.java | 2 +- .../paper/registry/event/RegistryEvents.java | 3 + .../paper/registry/holder/RegistryHolder.java | 1 + .../java/io/papermc/paper/tag/EntityTags.java | 2 +- .../papermc/paper/text/PaperComponents.java | 15 +- .../io/papermc/paper/util/BoundChecker.java | 7 +- .../src/main/java/org/bukkit/Bukkit.java | 4 +- .../src/main/java/org/bukkit/Effect.java | 2 + .../main/java/org/bukkit/EntityEffect.java | 2 +- .../src/main/java/org/bukkit/GameEvent.java | 2 + .../src/main/java/org/bukkit/JukeboxSong.java | 2 + .../src/main/java/org/bukkit/Material.java | 37 +- .../main/java/org/bukkit/MusicInstrument.java | 2 +- .../src/main/java/org/bukkit/Particle.java | 73 +++ .../src/main/java/org/bukkit/Server.java | 14 +- paper-api/src/main/java/org/bukkit/Sound.java | 132 +++++ paper-api/src/main/java/org/bukkit/Tag.java | 77 ++- .../main/java/org/bukkit/Translatable.java | 1 + .../main/java/org/bukkit/UnsafeValues.java | 159 +----- .../src/main/java/org/bukkit/WorldType.java | 4 +- .../java/org/bukkit/attribute/Attribute.java | 20 + .../src/main/java/org/bukkit/block/Bed.java | 6 +- .../src/main/java/org/bukkit/block/Biome.java | 2 + .../main/java/org/bukkit/block/BlockType.java | 61 ++- .../java/org/bukkit/block/PotentSulfur.java | 7 + .../block/data/type/PointedDripstone.java | 79 +-- .../bukkit/block/data/type/PotentSulfur.java | 36 ++ .../bukkit/block/data/type/Speleothem.java | 81 +++ .../command/defaults/VersionCommand.java | 15 +- .../java/org/bukkit/damage/DamageEffect.java | 3 +- .../java/org/bukkit/damage/DamageSource.java | 5 +- .../java/org/bukkit/damage/DamageType.java | 2 + .../org/bukkit/entity/AbstractCubeMob.java | 41 ++ .../src/main/java/org/bukkit/entity/Cat.java | 4 +- .../main/java/org/bukkit/entity/Chicken.java | 4 +- .../src/main/java/org/bukkit/entity/Cow.java | 4 +- .../java/org/bukkit/entity/EntityType.java | 15 +- .../java/org/bukkit/entity/MagmaCube.java | 2 +- .../src/main/java/org/bukkit/entity/Pig.java | 4 +- .../main/java/org/bukkit/entity/Player.java | 2 +- .../main/java/org/bukkit/entity/Slime.java | 36 +- .../java/org/bukkit/entity/SulfurCube.java | 113 +++++ .../entity/EntityDamageByBlockEvent.java | 1 + .../event/entity/EntityDamageEvent.java | 13 +- .../org/bukkit/event/entity/PigZapEvent.java | 25 +- .../bukkit/event/entity/SlimeSplitEvent.java | 10 +- .../event/player/PlayerAnimationEvent.java | 1 - .../player/PlayerGameModeChangeEvent.java | 2 +- .../bukkit/event/player/PlayerKickEvent.java | 2 +- .../org/bukkit/inventory/EquipmentSlot.java | 2 +- .../java/org/bukkit/inventory/ItemStack.java | 35 +- .../java/org/bukkit/inventory/ItemType.java | 94 +++- .../java/org/bukkit/inventory/MenuType.java | 2 +- .../org/bukkit/inventory/meta/ItemMeta.java | 2 +- .../org/bukkit/plugin/java/JavaPlugin.java | 6 +- .../plugin/messaging/StandardMessenger.java | 4 +- .../java/org/bukkit/scoreboard/Criteria.java | 3 +- .../java/org/bukkit/tag/DamageTypeTags.java | 2 + .../messaging/StandardMessengerTest.java | 17 + .../java/io/papermc/generator/Rewriters.java | 6 +- .../generator/registry/RegistryEntries.java | 6 +- .../simple/CraftBlockEntityStateMapping.java | 4 +- .../types/simple/EntityTypeRewriter.java | 175 +++---- .../types/simple/trial/PoseRewriter.java | 18 +- .../types/simple/trial/TokenTypeSets.java | 30 ++ .../trial/VillagerProfessionRewriter.java | 11 +- .../generator/types/goal/MobGoalNames.java | 9 +- .../generator/utils/BlockStateMapping.java | 14 +- paper-server/build.gradle.kts | 4 +- ...ion-and-add-advanced-packet-support.patch} | 32 +- ...=> 0002-Entity-Activation-Range-2.0.patch} | 79 +-- ...> 0003-Optimize-Voxel-Shape-Merging.patch} | 8 +- ...04-optimize-dirt-and-snow-spreading.patch} | 2 +- ...city-compression-and-cipher-natives.patch} | 27 +- ...-Oversized-block-entities-in-chunks.patch} | 2 +- ...Optimize-Bit-Operations-by-inlining.patch} | 26 +- ...> 0008-Remove-streams-from-hot-code.patch} | 0 ...er-Remove-Streams-Optimized-collect.patch} | 0 ...-Eigencraft-redstone-implementation.patch} | 4 +- ...ate-Current-redstone-implementation.patch} | 16 +- ...Incremental-chunk-and-player-saving.patch} | 34 +- ...lush-support-to-Log4j-AsyncAppender.patch} | 0 ... 0014-Improve-keepalive-ping-system.patch} | 0 ...15-Optimise-EntityScheduler-ticking.patch} | 20 +- ...0-Anti-Xray.patch => 0016-Anti-Xray.patch} | 87 ++-- ...lay-open-close-callbacks-for-chests.patch} | 8 +- ...ove-exact-choice-recipe-ingredients.patch} | 4 +- .../0001-Moonrise-optimisation-patches.patch | 0 .../0002-Rewrite-dataconverter-system.patch | 0 ...004-Allow-Saving-of-Oversized-Chunks.patch | 0 ...oalSelector-Goal.Flag-Set-operations.patch | 0 ...er-desync-when-new-players-are-added.patch | 0 ...-data-to-disk-if-it-serializes-witho.patch | 0 ...018-Entity-load-save-limit-per-chunk.patch | 0 ...culate-regionfile-header-if-it-is-co.patch | 0 ...onfiles-on-save-configuration-option.patch | 0 ...on-checking-in-player-move-packet-ha.patch | 0 ...0026-DataConverter-Moonrise-co-fixes.patch | 0 .../0027-Optional-per-player-mob-spawns.patch | 0 ...ng-PreCreatureSpawnEvent-with-per-pl.patch | 0 .../0029-Optimize-Hoppers.patch | 0 .../intersection_barrel.json.patch | 5 +- .../noise_settings/amplified.json.patch | 2 +- .../noise_settings/large_biomes.json.patch | 2 +- .../noise_settings/overworld.json.patch | 2 +- .../net/minecraft/ChatFormatting.java.patch | 22 - .../net/minecraft/CrashReport.java.patch | 2 +- .../SimpleCriterionTrigger.java.patch | 52 -- .../LocationPredicate.java.patch | 4 +- .../SimpleCriterionTrigger.java.patch | 19 + .../minecraft/commands/Commands.java.patch | 22 +- .../net/minecraft/core/BlockPos.java.patch | 6 +- .../cauldron/CauldronInteractions.java.patch | 18 +- .../core/component/DataComponents.java.patch | 4 +- .../BoatDispenseItemBehavior.java.patch | 2 +- .../dispenser/DispenseItemBehavior.java.patch | 171 +++---- ...intAndSteelDispenseItemBehavior.java.patch | 31 ++ .../ShearsDispenseItemBehavior.java.patch | 2 +- .../ShulkerBoxDispenseBehavior.java.patch | 8 +- .../dispenser/SpawnEggItemBehavior.java.patch | 13 +- ...urCubeBlockDispenseItemBehavior.java.patch | 24 + .../registries/BuiltInRegistries.java.patch | 8 +- .../loot/packs/VanillaChestLoot.java.patch | 2 +- .../framework/GameTestServer.java.patch | 8 +- .../framework/StructureUtils.java.patch | 2 +- .../TestEnvironmentDefinition.java.patch | 24 +- .../net/minecraft/nbt/NbtIo.java.patch | 8 +- .../minecraft/network/Connection.java.patch | 30 +- .../network/chat/ComponentUtils.java.patch | 39 +- .../network/chat/MutableComponent.java.patch | 2 +- .../network/chat/TextColor.java.patch | 33 -- ...tboundContainerSetContentPacket.java.patch | 2 +- .../ClientboundSetPlayerTeamPacket.java.patch | 24 +- .../minecraft/resources/Identifier.java.patch | 6 +- .../resources/RegistryDataLoader.java.patch | 2 +- .../net/minecraft/server/Bootstrap.java.patch | 4 +- .../net/minecraft/server/Main.java.patch | 44 +- .../server/MinecraftServer.java.patch | 56 +-- .../server/PlayerAdvancements.java.patch | 16 +- .../server/commands/DeOpCommands.java.patch | 11 - .../commands/DifficultyCommand.java.patch | 2 +- .../server/commands/EffectCommands.java.patch | 14 +- .../commands/GameModeCommand.java.patch | 7 +- .../server/commands/PlaceCommand.java.patch | 2 +- .../server/commands/RideCommand.java.patch | 6 +- .../server/commands/SummonCommand.java.patch | 8 +- .../server/commands/TimeCommand.java.patch | 12 +- .../commands/WaypointCommand.java.patch | 2 +- .../dedicated/DedicatedServer.java.patch | 50 +- .../DedicatedServerProperties.java.patch | 6 +- .../dedicated/ServerWatchdog.java.patch | 2 +- .../server/gui/MinecraftServerGui.java.patch | 12 +- .../server/gui/StatsComponent.java.patch | 2 +- .../MinecraftGameRuleServiceImpl.java.patch | 44 +- .../server/level/ChunkMap.java.patch | 24 +- .../server/level/PlayerSpawnFinder.java.patch | 10 +- .../server/level/ServerChunkCache.java.patch | 18 +- .../server/level/ServerEntity.java.patch | 16 +- .../server/level/ServerLevel.java.patch | 121 +++-- .../server/level/ServerPlayer.java.patch | 176 +++---- .../server/level/TicketType.java.patch | 4 +- .../server/level/WorldGenRegion.java.patch | 33 +- .../ServerCommonPacketListenerImpl.java.patch | 2 +- .../ServerConnectionListener.java.patch | 8 +- .../ServerGamePacketListenerImpl.java.patch | 253 +++++----- ...rverHandshakePacketListenerImpl.java.patch | 2 +- .../ServerLoginPacketListenerImpl.java.patch | 25 +- .../NotificationManager.java.patch | 2 +- .../server/players/BanListEntry.java.patch | 6 +- .../server/players/PlayerList.java.patch | 46 +- .../server/players/ProfileResolver.java.patch | 2 +- .../server/rcon/thread/RconClient.java.patch | 2 +- .../minecraft/util/TickThrottler.java.patch | 4 +- .../net/minecraft/util/Util.java.patch | 18 +- .../util/datafix/DataFixers.java.patch | 2 +- .../util/filefix/FileFixerUpper.java.patch | 20 + .../fixes/LegacyStructureFileFix.java.patch | 2 +- .../util/random/WeightedList.java.patch | 2 +- .../world/RandomizableContainer.java.patch | 4 +- .../damagesource/CombatTracker.java.patch | 17 +- .../damagesource/DamageSource.java.patch | 8 +- .../world/entity/AreaEffectCloud.java.patch | 2 +- .../entity/{animal => }/Bucketable.java.patch | 12 +- .../world/entity/ConversionType.java.patch | 2 +- .../minecraft/world/entity/Entity.java.patch | 222 +++++---- .../world/entity/EntityType.java.patch | 52 +- .../world/entity/ExperienceOrb.java.patch | 20 +- .../world/entity/Leashable.java.patch | 20 - .../world/entity/LivingEntity.java.patch | 409 +++++++--------- .../net/minecraft/world/entity/Mob.java.patch | 95 ++-- .../attributes/AttributeInstance.java.patch | 2 +- .../ai/attributes/Attributes.java.patch | 10 +- .../ai/behavior/HarvestFarmland.java.patch | 2 +- .../entity/ai/behavior/RamTarget.java.patch | 10 +- .../ai/behavior/WorkAtComposter.java.patch | 12 - .../GroundPathNavigation.java.patch | 8 +- .../animal/AgeableWaterCreature.java.patch | 9 + .../entity/animal/allay/Allay.java.patch | 31 +- .../animal/armadillo/Armadillo.java.patch | 27 +- .../entity/animal/axolotl/Axolotl.java.patch | 6 +- .../world/entity/animal/bee/Bee.java.patch | 30 +- .../entity/animal/camel/Camel.java.patch | 10 +- .../entity/animal/chicken/Chicken.java.patch | 15 - .../entity/animal/cow/AbstractCow.java.patch | 2 +- .../entity/animal/cow/MushroomCow.java.patch | 20 +- .../entity/animal/dolphin/Dolphin.java.patch | 14 +- .../equine/AbstractChestedHorse.java.patch | 14 +- .../entity/animal/equine/Llama.java.patch | 6 +- .../animal/equine/SkeletonHorse.java.patch | 2 +- .../animal/equine/TraderLlama.java.patch | 10 +- .../world/entity/animal/feline/Cat.java.patch | 8 +- .../entity/animal/feline/Ocelot.java.patch | 4 +- .../entity/animal/fish/WaterAnimal.java.patch | 9 + .../world/entity/animal/fox/Fox.java.patch | 53 +- .../world/entity/animal/frog/Frog.java.patch | 2 +- .../entity/animal/frog/Tadpole.java.patch | 10 +- .../world/entity/animal/goat/Goat.java.patch | 6 +- .../animal/golem/CopperGolem.java.patch | 34 +- .../entity/animal/golem/IronGolem.java.patch | 4 +- .../entity/animal/golem/SnowGolem.java.patch | 22 +- .../animal/happyghast/HappyGhast.java.patch | 4 +- .../animal/nautilus/Nautilus.java.patch | 4 +- .../entity/animal/panda/Panda.java.patch | 35 +- .../world/entity/animal/pig/Pig.java.patch | 4 +- .../entity/animal/rabbit/Rabbit.java.patch | 6 +- .../entity/animal/sheep/Sheep.java.patch | 26 +- .../entity/animal/sniffer/Sniffer.java.patch | 4 +- .../entity/animal/squid/Squid.java.patch | 11 - .../entity/animal/turtle/Turtle.java.patch | 20 +- .../world/entity/animal/wolf/Wolf.java.patch | 12 +- .../boss/enderdragon/EndCrystal.java.patch | 6 +- .../boss/enderdragon/EnderDragon.java.patch | 87 ++-- .../entity/boss/wither/WitherBoss.java.patch | 2 +- .../entity/decoration/ArmorStand.java.patch | 75 ++- .../entity/decoration/ItemFrame.java.patch | 18 +- .../LeashFenceKnotEntity.java.patch | 6 +- .../entity/decoration/Mannequin.java.patch | 2 +- .../decoration/painting/Painting.java.patch | 2 +- .../entity/item/FallingBlockEntity.java.patch | 18 +- .../world/entity/item/ItemEntity.java.patch | 37 +- .../world/entity/item/PrimedTnt.java.patch | 18 +- .../world/entity/monster/Creeper.java.patch | 19 + .../entity/monster/ElderGuardian.java.patch | 2 +- .../world/entity/monster/Ghast.java.patch | 2 +- .../world/entity/monster/Monster.java.patch | 2 +- .../world/entity/monster/Ravager.java.patch | 4 +- .../world/entity/monster/Shulker.java.patch | 6 +- .../entity/monster/Silverfish.java.patch | 8 +- .../world/entity/monster/Slime.java.patch | 216 -------- .../world/entity/monster/Strider.java.patch | 2 +- .../world/entity/monster/Vex.java.patch | 10 +- .../world/entity/monster/Witch.java.patch | 8 +- .../entity/monster/breeze/Breeze.java.patch | 4 +- .../monster/creaking/Creaking.java.patch | 10 +- .../cubemob/AbstractCubeMob.java.patch | 192 ++++++++ .../entity/monster/cubemob/Slime.java.patch | 29 ++ .../monster/cubemob/SulfurCube.java.patch | 153 ++++++ .../entity/monster/hoglin/Hoglin.java.patch | 9 +- .../entity/monster/illager/Evoker.java.patch | 2 +- .../monster/illager/Vindicator.java.patch | 2 +- .../monster/piglin/AbstractPiglin.java.patch | 4 +- .../entity/monster/piglin/Piglin.java.patch | 34 +- .../entity/monster/piglin/PiglinAi.java.patch | 40 +- .../entity/monster/skeleton/Bogged.java.patch | 22 +- .../monster/skeleton/Skeleton.java.patch | 6 +- .../skeleton/WitherSkeleton.java.patch | 6 +- .../monster/spider/CaveSpider.java.patch | 4 +- .../entity/monster/spider/Spider.java.patch | 6 +- .../monster/warden/AngerManagement.java.patch | 2 +- .../entity/monster/warden/Warden.java.patch | 4 +- .../entity/monster/zombie/Drowned.java.patch | 2 +- .../entity/monster/zombie/Husk.java.patch | 10 +- .../entity/monster/zombie/Zombie.java.patch | 34 +- .../monster/zombie/ZombieVillager.java.patch | 12 +- .../world/entity/npc/CatSpawner.java.patch | 2 +- .../npc/villager/AbstractVillager.java.patch | 25 +- .../entity/npc/villager/Villager.java.patch | 20 +- .../WanderingTraderSpawner.java.patch | 8 +- .../world/entity/player/Player.java.patch | 71 +-- .../entity/projectile/EvokerFangs.java.patch | 4 +- .../entity/projectile/EyeOfEnder.java.patch | 6 +- .../FireworkRocketEntity.java.patch | 2 +- .../entity/projectile/FishingHook.java.patch | 28 +- .../entity/projectile/LlamaSpit.java.patch | 7 +- .../projectile/ShulkerBullet.java.patch | 12 +- .../projectile/arrow/AbstractArrow.java.patch | 34 +- .../entity/projectile/arrow/Arrow.java.patch | 2 +- .../projectile/arrow/SpectralArrow.java.patch | 2 +- .../projectile/arrow/ThrownTrident.java.patch | 8 +- .../DragonFireball.java.patch | 2 +- .../LargeFireball.java.patch | 6 +- .../SmallFireball.java.patch | 10 +- .../hurtingprojectile/WitherSkull.java.patch | 6 +- .../windcharge/AbstractWindCharge.java.patch | 8 +- .../windcharge/BreezeWindCharge.java.patch | 4 +- .../windcharge/WindCharge.java.patch | 4 +- .../Snowball.java.patch | 2 +- .../ThrownEgg.java.patch | 4 +- .../ThrownEnderpearl.java.patch | 16 +- .../ThrownExperienceBottle.java.patch | 2 +- .../ThrownLingeringPotion.java.patch | 4 +- .../ThrownSplashPotion.java.patch | 10 +- .../world/entity/raid/Raid.java.patch | 32 +- .../world/entity/raid/Raider.java.patch | 15 +- .../vehicle/boat/AbstractBoat.java.patch | 2 +- .../minecart/AbstractMinecart.java.patch | 14 +- .../vehicle/minecart/MinecartTNT.java.patch | 42 +- .../minecart/NewMinecartBehavior.java.patch | 10 +- .../AbstractContainerMenu.java.patch | 16 +- .../inventory/AbstractFurnaceMenu.java.patch | 8 +- .../world/inventory/BeaconMenu.java.patch | 45 +- .../inventory/CartographyTableMenu.java.patch | 4 +- .../world/inventory/GrindstoneMenu.java.patch | 6 +- .../world/inventory/LoomMenu.java.patch | 2 +- .../world/inventory/ResultSlot.java.patch | 4 +- .../inventory/StonecutterMenu.java.patch | 4 +- .../world/item/ArmorStandItem.java.patch | 2 +- .../minecraft/world/item/AxeItem.java.patch | 4 +- .../minecraft/world/item/BlockItem.java.patch | 8 +- .../minecraft/world/item/BowItem.java.patch | 2 +- .../world/item/BucketItem.java.patch | 68 +-- .../world/item/CrossbowItem.java.patch | 2 +- .../world/item/EndCrystalItem.java.patch | 4 +- .../world/item/HangingEntityItem.java.patch | 4 +- .../world/item/HoneycombItem.java.patch | 2 +- .../minecraft/world/item/ItemStack.java.patch | 87 ++-- .../world/item/MobBucketItem.java.patch | 15 +- .../world/item/SpawnEggItem.java.patch | 21 +- .../item/alchemy/PotionContents.java.patch | 4 +- .../component/ChargedProjectiles.java.patch | 22 +- .../world/item/crafting/Ingredient.java.patch | 2 +- .../item/equipment/Equippable.java.patch | 2 +- .../world/level/BaseSpawner.java.patch | 16 +- .../minecraft/world/level/ChunkPos.java.patch | 6 +- .../minecraft/world/level/Level.java.patch | 41 +- .../world/level/LevelSettings.java.patch | 2 +- .../world/level/NaturalSpawner.java.patch | 36 +- .../world/level/ServerExplosion.java.patch | 10 +- .../level/biome/MobSpawnSettings.java.patch | 2 +- .../level/block/AbstractSkullBlock.java.patch | 2 +- .../world/level/block/BeaconBlock.java.patch | 2 +- .../world/level/block/BedBlock.java.patch | 23 +- .../world/level/block/BeehiveBlock.java.patch | 10 +- .../world/level/block/BellBlock.java.patch | 6 +- .../level/block/BlastFurnaceBlock.java.patch | 2 +- .../world/level/block/Block.java.patch | 45 +- .../level/block/BrewingStandBlock.java.patch | 2 +- .../level/block/CampfireBlock.java.patch | 4 +- .../level/block/CarvedPumpkinBlock.java.patch | 6 +- .../block/CeilingHangingSignBlock.java.patch | 4 +- .../world/level/block/ChestBlock.java.patch | 10 +- .../world/level/block/CommandBlock.java.patch | 10 +- .../level/block/ComparatorBlock.java.patch | 11 +- .../block/CopperGolemStatueBlock.java.patch | 4 +- .../world/level/block/CrafterBlock.java.patch | 6 +- .../block/DaylightDetectorBlock.java.patch | 2 +- .../level/block/DetectorRailBlock.java.patch | 2 +- .../world/level/block/DiodeBlock.java.patch | 8 - .../level/block/DispenserBlock.java.patch | 4 +- .../level/block/EndPortalBlock.java.patch | 2 +- .../level/block/EnderChestBlock.java.patch | 2 +- .../level/block/FenceGateBlock.java.patch | 2 +- .../level/block/FrogspawnBlock.java.patch | 2 +- .../world/level/block/FurnaceBlock.java.patch | 2 +- .../world/level/block/HopperBlock.java.patch | 10 +- .../level/block/InfestedBlock.java.patch | 2 +- .../world/level/block/LecternBlock.java.patch | 10 +- .../level/block/MultifaceSpreader.java.patch | 2 +- .../level/block/NetherPortalBlock.java.patch | 24 +- .../block/PointedDripstoneBlock.java.patch | 50 +- .../level/block/RedstoneTorchBlock.java.patch | 6 +- .../level/block/RespawnAnchorBlock.java.patch | 2 +- .../world/level/block/SaplingBlock.java.patch | 30 +- .../level/block/SculkCatalystBlock.java.patch | 2 +- .../level/block/SculkSensorBlock.java.patch | 8 +- .../level/block/SculkShriekerBlock.java.patch | 6 +- .../level/block/ShulkerBoxBlock.java.patch | 8 +- .../world/level/block/SignBlock.java.patch | 8 +- .../world/level/block/SmokerBlock.java.patch | 2 +- .../level/block/SnifferEggBlock.java.patch | 4 +- .../world/level/block/SpawnerBlock.java.patch | 2 +- .../level/block/SpeleothemBlock.java.patch | 45 ++ .../block/SweetBerryBushBlock.java.patch | 2 +- .../world/level/block/TntBlock.java.patch | 10 +- .../level/block/TrapDoorBlock.java.patch | 2 +- .../level/block/TripWireBlock.java.patch | 2 +- .../block/WallHangingSignBlock.java.patch | 4 +- .../level/block/WitherSkullBlock.java.patch | 2 +- .../block/entity/BeaconBlockEntity.java.patch | 16 +- .../entity/BeehiveBlockEntity.java.patch | 2 +- .../block/entity/BellBlockEntity.java.patch | 10 +- .../level/block/entity/BlockEntity.java.patch | 22 +- .../entity/BrewingStandBlockEntity.java.patch | 2 +- .../entity/CampfireBlockEntity.java.patch | 2 +- .../ChiseledBookShelfBlockEntity.java.patch | 2 +- .../entity/CrafterBlockEntity.java.patch | 2 +- .../CreakingHeartBlockEntity.java.patch | 4 +- .../block/entity/HopperBlockEntity.java.patch | 6 +- .../block/entity/JigsawBlockEntity.java.patch | 2 +- ...andomizableContainerBlockEntity.java.patch | 2 +- .../SculkShriekerBlockEntity.java.patch | 4 +- .../block/entity/ShelfBlockEntity.java.patch | 2 +- .../entity/ShulkerBoxBlockEntity.java.patch | 6 +- .../block/entity/SignBlockEntity.java.patch | 2 +- .../block/entity/TestBlockEntity.java.patch | 8 + .../entity/TestInstanceBlockEntity.java.patch | 8 + .../trialspawner/PlayerDetector.java.patch | 2 +- .../TrialSpawnerStateData.java.patch | 2 +- .../entity/vault/VaultServerData.java.patch | 6 +- .../block/piston/PistonBaseBlock.java.patch | 10 +- .../block/state/BlockBehaviour.java.patch | 31 +- .../world/level/border/WorldBorder.java.patch | 19 +- .../world/level/chunk/ChunkAccess.java.patch | 2 +- .../level/chunk/ChunkGenerator.java.patch | 21 +- .../level/chunk/EmptyLevelChunk.java.patch | 2 +- .../world/level/chunk/LevelChunk.java.patch | 8 +- .../level/chunk/LevelChunkSection.java.patch | 12 +- .../storage/RegionFileStorage.java.patch | 2 +- .../dimension/end/EnderDragonFight.java.patch | 18 +- .../level/gameevent/GameEvent.java.patch | 2 +- .../vibrations/VibrationSystem.java.patch | 8 +- .../levelgen/DensityFunctions.java.patch | 4 +- .../NoiseBasedChunkGenerator.java.patch | 10 +- .../level/levelgen/PhantomSpawner.java.patch | 2 +- .../structure/StructurePiece.java.patch | 30 +- .../DesertPyramidStructure.java.patch | 2 +- .../structures/EndCityPieces.java.patch | 2 +- .../structures/IglooPieces.java.patch | 12 +- .../structures/MineshaftPieces.java.patch | 4 +- .../NetherFortressPieces.java.patch | 4 +- .../structures/OceanRuinPieces.java.patch | 20 +- .../structures/StrongholdPieces.java.patch | 4 +- .../StructureTemplate.java.patch | 24 +- .../CollectingNeighborUpdater.java.patch | 2 +- .../storage/LevelStorageSource.java.patch | 11 +- .../level/storage/PrimaryLevelData.java.patch | 2 +- .../world/scores/PlayerTeam.java.patch | 6 +- .../block/impl/CraftPointedDripstone.java | 14 +- .../block/impl/CraftPotentSulfur.java | 32 ++ .../block/impl/CraftSulfurSpike.java | 67 +++ .../paper/PaperVersionFetcher.java | 12 +- .../paper/entity/ai/MobGoalHelper.java | 9 +- .../destroystokyo/paper/gui/RAMDetails.java | 13 +- .../network/PaperLegacyStatusClient.java | 2 +- .../profile/PaperAuthenticationService.java | 2 +- .../paper/PaperServerInternalAPIBridge.java | 146 +++++- .../paper/adventure/PaperAdventure.java | 46 +- .../paper/command/PaperVersionCommand.java | 4 +- .../argument/VanillaArgumentProviderImpl.java | 14 +- .../subcommands/DumpListenersCommand.java | 2 +- .../configuration/WorldConfiguration.java | 25 +- .../connection/PaperPlayerGameConnection.java | 4 +- .../datacomponent/DataComponentAdapters.java | 2 + .../item/ItemComponentTypesBridgesImpl.java | 15 +- .../item/PaperBundleContents.java | 12 +- .../item/PaperChargedProjectiles.java | 12 +- .../item/PaperItemAdventurePredicate.java | 6 +- .../item/PaperItemContainerContents.java | 18 +- .../item/PaperSulfurCubeContent.java | 20 + .../item/PaperWritableBookContent.java | 4 +- .../papermc/paper/entity/PaperBucketable.java | 2 +- .../paper/registry/PaperRegistries.java | 4 + .../data/PaperCatTypeRegistryEntry.java | 14 +- .../PaperChickenVariantRegistryEntry.java | 14 +- .../data/PaperCowVariantRegistryEntry.java | 14 +- .../data/PaperDamageTypeRegistryEntry.java | 3 +- .../data/PaperEnchantmentRegistryEntry.java | 3 +- .../data/PaperFrogVariantRegistryEntry.java | 10 +- .../PaperPaintingVariantRegistryEntry.java | 3 +- .../data/PaperPigVariantRegistryEntry.java | 14 +- ...PaperSulfurCubeArchetypeRegistryEntry.java | 205 ++++++++ .../data/PaperWolfVariantRegistryEntry.java | 30 +- ...perZombieNautilusVariantRegistryEntry.java | 20 +- .../data/dialog/PaperDialogCodecs.java | 4 +- .../data/dialog/body/ItemDialogBodyImpl.java | 2 +- .../paper/registry/data/util/Conversions.java | 21 +- .../holder/InlinedRegistryHolderImpl.java | 2 - .../holder/ReferenceRegistryHolderImpl.java | 2 - .../tag/PaperPreFlattenTagRegistrar.java | 5 +- .../io/papermc/paper/util/CountingOps.java | 10 + .../java/io/papermc/paper/util/MCUtil.java | 69 ++- .../papermc/paper/util/StackWalkerUtil.java | 2 +- .../OversizedItemComponentSanitizer.java | 2 +- .../papermc/paper/world/PaperWorldLoader.java | 12 +- .../world/saveddata/PaperLevelOverrides.java | 10 +- .../OptionallyFlatBedrockConditionSource.java | 9 +- .../bukkit/craftbukkit/CraftCrashReport.java | 6 +- .../org/bukkit/craftbukkit/CraftParticle.java | 24 + .../org/bukkit/craftbukkit/CraftServer.java | 54 +- .../org/bukkit/craftbukkit/CraftWorld.java | 47 +- .../craftbukkit/block/CapturedBlockState.java | 4 +- .../bukkit/craftbukkit/block/CraftBeacon.java | 4 +- .../bukkit/craftbukkit/block/CraftBed.java | 56 --- .../bukkit/craftbukkit/block/CraftBlock.java | 31 +- .../craftbukkit/block/CraftBlockState.java | 6 +- .../craftbukkit/block/CraftBlockStates.java | 99 ++-- .../craftbukkit/block/CraftContainer.java | 4 +- .../craftbukkit/block/CraftPotentSulfur.java | 27 + .../block/data/CraftBlockData.java | 2 + .../entity/CraftAbstractCubeMob.java | 35 ++ .../bukkit/craftbukkit/entity/CraftBoat.java | 29 +- .../craftbukkit/entity/CraftCopperGolem.java | 4 +- .../craftbukkit/entity/CraftEntity.java | 3 +- .../entity/CraftEntitySnapshot.java | 3 +- .../craftbukkit/entity/CraftEntityType.java | 7 +- .../craftbukkit/entity/CraftEntityTypes.java | 286 +++++------ .../craftbukkit/entity/CraftLivingEntity.java | 33 +- .../craftbukkit/entity/CraftMagmaCube.java | 8 +- .../entity/CraftPiglinAbstract.java | 2 +- .../craftbukkit/entity/CraftPlayer.java | 7 +- .../bukkit/craftbukkit/entity/CraftSlime.java | 29 +- .../craftbukkit/entity/CraftSulfurCube.java | 105 ++++ .../bukkit/craftbukkit/entity/CraftVex.java | 5 +- .../craftbukkit/entity/CraftVillager.java | 2 +- .../craftbukkit/entity/CraftZoglin.java | 2 +- .../craftbukkit/entity/CraftZombie.java | 2 +- .../craftbukkit/event/CraftEventFactory.java | 147 +++--- .../generator/CraftLimitedRegion.java | 3 +- .../craftbukkit/generator/CraftWorldInfo.java | 4 +- .../craftbukkit/inventory/CraftItemMetas.java | 2 +- .../craftbukkit/inventory/CraftItemStack.java | 210 ++++++-- .../craftbukkit/inventory/CraftItemType.java | 2 +- .../inventory/CraftMerchantCustom.java | 4 +- .../inventory/CraftMetaArmorStand.java | 5 +- .../craftbukkit/inventory/CraftMetaItem.java | 22 +- .../potion/CraftPotionEffectType.java | 2 +- .../craftbukkit/scoreboard/CraftTeam.java | 27 +- .../spawner/PaperSharedSpawnerLogic.java | 9 +- .../craftbukkit/structure/CraftStructure.java | 3 +- .../bukkit/craftbukkit/util/ApiVersion.java | 2 + .../bukkit/craftbukkit/util/Commodore.java | 12 +- .../craftbukkit/util/CraftChatMessage.java | 38 +- .../craftbukkit/util/CraftMagicNumbers.java | 338 ++----------- .../util/TransformerLevelAccessor.java | 2 +- .../minecraft/datapacks/paper/pack.mcmeta | 4 +- .../advancement/AdvancementFrameTest.java | 5 +- .../BukkitCommandConversionTest.java | 2 +- .../paper/effects/EffectCategoryTest.java | 4 +- .../test/java/org/bukkit/ParticleTest.java | 47 ++ .../craftbukkit/entity/EntityTypesTest.java | 2 + .../craftbukkit/inventory/ItemMetaTest.java | 16 +- .../craftbukkit/inventory/ItemTypeTest.java | 13 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 5 + .../org/bukkit/support/DummyServerHelper.java | 2 +- .../provider/RegistriesArgumentProvider.java | 4 + snapshot-todos.txt | 1 + 594 files changed, 7921 insertions(+), 5010 deletions(-) create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/SulfurCubeArchetypeKeys.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/SulfurCubeContent.java create mode 100644 paper-api/src/main/java/io/papermc/paper/event/entity/EntityIgniteEvent.java create mode 100644 paper-api/src/main/java/io/papermc/paper/registry/data/SulfurCubeArchetypeRegistryEntry.java rename {paper-server => paper-api}/src/main/java/io/papermc/paper/util/BoundChecker.java (93%) create mode 100644 paper-api/src/main/java/org/bukkit/block/PotentSulfur.java create mode 100644 paper-api/src/main/java/org/bukkit/block/data/type/PotentSulfur.java create mode 100644 paper-api/src/main/java/org/bukkit/block/data/type/Speleothem.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/SulfurCube.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/TokenTypeSets.java rename paper-server/patches/features/{0003-Optimize-Connection-and-add-advanced-packet-support.patch => 0001-Optimize-Connection-and-add-advanced-packet-support.patch} (94%) rename paper-server/patches/features/{0005-Entity-Activation-Range-2.0.patch => 0002-Entity-Activation-Range-2.0.patch} (93%) rename paper-server/patches/features/{0006-Optimize-Voxel-Shape-Merging.patch => 0003-Optimize-Voxel-Shape-Merging.patch} (96%) rename paper-server/patches/features/{0007-optimize-dirt-and-snow-spreading.patch => 0004-optimize-dirt-and-snow-spreading.patch} (98%) rename paper-server/patches/features/{0008-Use-Velocity-compression-and-cipher-natives.patch => 0005-Use-Velocity-compression-and-cipher-natives.patch} (95%) rename paper-server/patches/features/{0010-Handle-Oversized-block-entities-in-chunks.patch => 0006-Handle-Oversized-block-entities-in-chunks.patch} (97%) rename paper-server/patches/features/{0011-Optimize-Bit-Operations-by-inlining.patch => 0007-Optimize-Bit-Operations-by-inlining.patch} (92%) rename paper-server/patches/features/{0012-Remove-streams-from-hot-code.patch => 0008-Remove-streams-from-hot-code.patch} (100%) rename paper-server/patches/features/{0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch => 0009-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch} (100%) rename paper-server/patches/features/{0015-Eigencraft-redstone-implementation.patch => 0010-Eigencraft-redstone-implementation.patch} (99%) rename paper-server/patches/features/{0016-Add-Alternate-Current-redstone-implementation.patch => 0011-Add-Alternate-Current-redstone-implementation.patch} (99%) rename paper-server/patches/features/{0020-Incremental-chunk-and-player-saving.patch => 0012-Incremental-chunk-and-player-saving.patch} (86%) rename paper-server/patches/features/{0023-Add-explicit-flush-support-to-Log4j-AsyncAppender.patch => 0013-Add-explicit-flush-support-to-Log4j-AsyncAppender.patch} (100%) rename paper-server/patches/features/{0024-Improve-keepalive-ping-system.patch => 0014-Improve-keepalive-ping-system.patch} (100%) rename paper-server/patches/features/{0025-Optimise-EntityScheduler-ticking.patch => 0015-Optimise-EntityScheduler-ticking.patch} (77%) rename paper-server/patches/features/{0030-Anti-Xray.patch => 0016-Anti-Xray.patch} (90%) rename paper-server/patches/features/{0031-Delay-open-close-callbacks-for-chests.patch => 0017-Delay-open-close-callbacks-for-chests.patch} (94%) rename paper-server/patches/features/{0032-Improve-exact-choice-recipe-ingredients.patch => 0018-Improve-exact-choice-recipe-ingredients.patch} (99%) rename paper-server/patches/{features => features_unapplied}/0001-Moonrise-optimisation-patches.patch (100%) rename paper-server/patches/{features => features_unapplied}/0002-Rewrite-dataconverter-system.patch (100%) rename paper-server/patches/{features => features_unapplied}/0004-Allow-Saving-of-Oversized-Chunks.patch (100%) rename paper-server/patches/{features => features_unapplied}/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch (100%) rename paper-server/patches/{features => features_unapplied}/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch (100%) rename paper-server/patches/{features => features_unapplied}/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch (100%) rename paper-server/patches/{features => features_unapplied}/0018-Entity-load-save-limit-per-chunk.patch (100%) rename paper-server/patches/{features => features_unapplied}/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch (100%) rename paper-server/patches/{features => features_unapplied}/0021-Flush-regionfiles-on-save-configuration-option.patch (100%) rename paper-server/patches/{features => features_unapplied}/0022-Optimise-collision-checking-in-player-move-packet-ha.patch (100%) rename paper-server/patches/{features => features_unapplied}/0026-DataConverter-Moonrise-co-fixes.patch (100%) rename paper-server/patches/{features => features_unapplied}/0027-Optional-per-player-mob-spawns.patch (100%) rename paper-server/patches/{features => features_unapplied}/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch (100%) rename paper-server/patches/{features => features_unapplied}/0029-Optimize-Hoppers.patch (100%) delete mode 100644 paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch rename paper-server/patches/sources/net/minecraft/advancements/{criterion => predicates}/LocationPredicate.java.patch (79%) create mode 100644 paper-server/patches/sources/net/minecraft/advancements/triggers/SimpleCriterionTrigger.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/core/dispenser/FlintAndSteelDispenseItemBehavior.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/core/dispenser/SulfurCubeBlockDispenseItemBehavior.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/server/commands/DeOpCommands.java.patch rename paper-server/patches/sources/net/minecraft/world/entity/{animal => }/Bucketable.java.patch (85%) delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/AbstractCubeMob.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/Slime.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/SpeleothemBlock.java.patch create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotentSulfur.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSulfurSpike.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSulfurCubeContent.java create mode 100644 paper-server/src/main/java/io/papermc/paper/registry/data/PaperSulfurCubeArchetypeRegistryEntry.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftPotentSulfur.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCubeMob.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSulfurCube.java create mode 100644 snapshot-todos.txt diff --git a/build-data/paper.at b/build-data/paper.at index fc06d593c438..5112a0f2b6cb 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -408,6 +408,8 @@ public net.minecraft.world.entity.monster.Vex hasLimitedLife public net.minecraft.world.entity.monster.Vex limitedLifeTicks public net.minecraft.world.entity.monster.Vex owner public net.minecraft.world.entity.monster.Witch usingTime +public net.minecraft.world.entity.monster.cubemob.SulfurCube MAX_FUSE +public net.minecraft.world.entity.monster.cubemob.SulfurCube setFuse(I)V public net.minecraft.world.entity.monster.hoglin.Hoglin cannotBeHunted public net.minecraft.world.entity.monster.hoglin.Hoglin isImmuneToZombification()Z public net.minecraft.world.entity.monster.hoglin.Hoglin timeInOverworld diff --git a/gradle.properties b/gradle.properties index 99224ed0a3a6..1dbdbe4ad184 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ group=io.papermc.paper -mcVersion=26.1.2 +mcVersion=26.2-pre-5 # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target -apiVersion=26.1.2 -channel=STABLE +apiVersion=26.2 +channel=ALPHA # Set to true while updating Minecraft version -updatingMinecraft=false +updatingMinecraft=true org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java index f094d7ee906e..8cc389cf42dd 100644 --- a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java +++ b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java @@ -4,6 +4,7 @@ import io.papermc.paper.annotation.GeneratedClass; import io.papermc.paper.entity.SchoolableFish; import org.bukkit.NamespacedKey; +import org.bukkit.entity.AbstractCubeMob; import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.AbstractSkeleton; import org.bukkit.entity.AbstractVillager; @@ -39,11 +40,11 @@ import org.bukkit.entity.Shulker; import org.bukkit.entity.Silverfish; import org.bukkit.entity.SkeletonHorse; -import org.bukkit.entity.Slime; import org.bukkit.entity.Spellcaster; import org.bukkit.entity.Spider; import org.bukkit.entity.Squid; import org.bukkit.entity.Strider; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.Tameable; import org.bukkit.entity.Turtle; import org.bukkit.entity.Vex; @@ -70,6 +71,14 @@ @NullMarked @GeneratedClass public interface VanillaGoal extends Goal { + GoalKey CUBE_MOB_ATTACK = create("cube_mob_attack", AbstractCubeMob.class); + + GoalKey CUBE_MOB_FLOAT = create("cube_mob_float", AbstractCubeMob.class); + + GoalKey CUBE_MOB_KEEP_ON_JUMPING = create("cube_mob_keep_on_jumping", AbstractCubeMob.class); + + GoalKey CUBE_MOB_RANDOM_DIRECTION = create("cube_mob_random_direction", AbstractCubeMob.class); + GoalKey HORSE_MOUNT_PANIC = create("horse_mount_panic", AbstractHorse.class); GoalKey HORSE_RANDOM_STAND = create("horse_random_stand", AbstractHorse.class); @@ -290,6 +299,8 @@ public interface VanillaGoal extends Goal { GoalKey RESET_UNIVERSAL_ANGER = create("reset_universal_anger", Mob.class); + GoalKey SULFUR_CUBE_TEMPT = create("sulfur_cube_tempt", Mob.class); + GoalKey TEMPT_FOR_NON_PATHFINDERS = create("tempt_for_non_pathfinders", Mob.class); GoalKey USE_ITEM = create("use_item", Mob.class); @@ -384,14 +395,6 @@ public interface VanillaGoal extends Goal { GoalKey SKELETON_HORSE_SKELETON_TRAP = create("skeleton_horse_skeleton_trap", SkeletonHorse.class); - GoalKey SLIME_ATTACK = create("slime_attack", Slime.class); - - GoalKey SLIME_FLOAT = create("slime_float", Slime.class); - - GoalKey SLIME_KEEP_ON_JUMPING = create("slime_keep_on_jumping", Slime.class); - - GoalKey SLIME_RANDOM_DIRECTION = create("slime_random_direction", Slime.class); - GoalKey SPELLCASTER_CASTING_SPELL = create("spellcaster_casting_spell", Spellcaster.class); GoalKey SPIDER = create("spider", Spider.class); @@ -404,6 +407,8 @@ public interface VanillaGoal extends Goal { GoalKey STRIDER_GO_TO_LAVA = create("strider_go_to_lava", Strider.class); + GoalKey SULFUR_CUBE_SEARCH_FOR_ITEMS = create("sulfur_cube_search_for_items", SulfurCube.class); + GoalKey FOLLOW_OWNER = create("follow_owner", Tameable.class); GoalKey NON_TAME_RANDOM = create("non_tame_random", Tameable.class); diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java index 2707310af274..e784f43a5f46 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java @@ -25,6 +25,13 @@ @NullMarked @GeneratedClass public final class AttributeKeys { + /** + * {@code minecraft:air_drag_modifier} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey AIR_DRAG_MODIFIER = create(key("air_drag_modifier")); + /** * {@code minecraft:armor} * @@ -60,6 +67,13 @@ public final class AttributeKeys { */ public static final TypedKey ATTACK_SPEED = create(key("attack_speed")); + /** + * {@code minecraft:below_name_distance} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BELOW_NAME_DISTANCE = create(key("below_name_distance")); + /** * {@code minecraft:block_break_speed} * @@ -74,6 +88,13 @@ public final class AttributeKeys { */ public static final TypedKey BLOCK_INTERACTION_RANGE = create(key("block_interaction_range")); + /** + * {@code minecraft:bounciness} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BOUNCINESS = create(key("bounciness")); + /** * {@code minecraft:burning_time} * @@ -123,6 +144,13 @@ public final class AttributeKeys { */ public static final TypedKey FOLLOW_RANGE = create(key("follow_range")); + /** + * {@code minecraft:friction_modifier} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FRICTION_MODIFIER = create(key("friction_modifier")); + /** * {@code minecraft:gravity} * @@ -186,6 +214,13 @@ public final class AttributeKeys { */ public static final TypedKey MOVEMENT_SPEED = create(key("movement_speed")); + /** + * {@code minecraft:name_tag_distance} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NAME_TAG_DISTANCE = create(key("name_tag_distance")); + /** * {@code minecraft:oxygen_bonus} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java index 983878bb6832..378234fe87c2 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java @@ -396,6 +396,13 @@ public final class BiomeKeys { */ public static final TypedKey STONY_SHORE = create(key("stony_shore")); + /** + * {@code minecraft:sulfur_caves} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_CAVES = create(key("sulfur_caves")); + /** * {@code minecraft:sunflower_plains} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java index 19df41713a1e..9a9b396384b2 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java @@ -1348,6 +1348,13 @@ public final class BlockTypeKeys { */ public static final TypedKey CHISELED_BOOKSHELF = create(key("chiseled_bookshelf")); + /** + * {@code minecraft:chiseled_cinnabar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHISELED_CINNABAR = create(key("chiseled_cinnabar")); + /** * {@code minecraft:chiseled_copper} * @@ -1411,6 +1418,13 @@ public final class BlockTypeKeys { */ public static final TypedKey CHISELED_STONE_BRICKS = create(key("chiseled_stone_bricks")); + /** + * {@code minecraft:chiseled_sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHISELED_SULFUR = create(key("chiseled_sulfur")); + /** * {@code minecraft:chiseled_tuff} * @@ -1439,6 +1453,62 @@ public final class BlockTypeKeys { */ public static final TypedKey CHORUS_PLANT = create(key("chorus_plant")); + /** + * {@code minecraft:cinnabar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR = create(key("cinnabar")); + + /** + * {@code minecraft:cinnabar_brick_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICK_SLAB = create(key("cinnabar_brick_slab")); + + /** + * {@code minecraft:cinnabar_brick_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICK_STAIRS = create(key("cinnabar_brick_stairs")); + + /** + * {@code minecraft:cinnabar_brick_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICK_WALL = create(key("cinnabar_brick_wall")); + + /** + * {@code minecraft:cinnabar_bricks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICKS = create(key("cinnabar_bricks")); + + /** + * {@code minecraft:cinnabar_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_SLAB = create(key("cinnabar_slab")); + + /** + * {@code minecraft:cinnabar_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_STAIRS = create(key("cinnabar_stairs")); + + /** + * {@code minecraft:cinnabar_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_WALL = create(key("cinnabar_wall")); + /** * {@code minecraft:clay} * @@ -5275,6 +5345,34 @@ public final class BlockTypeKeys { */ public static final TypedKey POLISHED_BLACKSTONE_WALL = create(key("polished_blackstone_wall")); + /** + * {@code minecraft:polished_cinnabar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR = create(key("polished_cinnabar")); + + /** + * {@code minecraft:polished_cinnabar_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR_SLAB = create(key("polished_cinnabar_slab")); + + /** + * {@code minecraft:polished_cinnabar_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR_STAIRS = create(key("polished_cinnabar_stairs")); + + /** + * {@code minecraft:polished_cinnabar_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR_WALL = create(key("polished_cinnabar_wall")); + /** * {@code minecraft:polished_deepslate} * @@ -5345,6 +5443,34 @@ public final class BlockTypeKeys { */ public static final TypedKey POLISHED_GRANITE_STAIRS = create(key("polished_granite_stairs")); + /** + * {@code minecraft:polished_sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR = create(key("polished_sulfur")); + + /** + * {@code minecraft:polished_sulfur_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR_SLAB = create(key("polished_sulfur_slab")); + + /** + * {@code minecraft:polished_sulfur_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR_STAIRS = create(key("polished_sulfur_stairs")); + + /** + * {@code minecraft:polished_sulfur_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR_WALL = create(key("polished_sulfur_wall")); + /** * {@code minecraft:polished_tuff} * @@ -5387,6 +5513,13 @@ public final class BlockTypeKeys { */ public static final TypedKey POTATOES = create(key("potatoes")); + /** + * {@code minecraft:potent_sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POTENT_SULFUR = create(key("potent_sulfur")); + /** * {@code minecraft:potted_acacia_sapling} * @@ -6969,6 +7102,69 @@ public final class BlockTypeKeys { */ public static final TypedKey SUGAR_CANE = create(key("sugar_cane")); + /** + * {@code minecraft:sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR = create(key("sulfur")); + + /** + * {@code minecraft:sulfur_brick_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICK_SLAB = create(key("sulfur_brick_slab")); + + /** + * {@code minecraft:sulfur_brick_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICK_STAIRS = create(key("sulfur_brick_stairs")); + + /** + * {@code minecraft:sulfur_brick_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICK_WALL = create(key("sulfur_brick_wall")); + + /** + * {@code minecraft:sulfur_bricks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICKS = create(key("sulfur_bricks")); + + /** + * {@code minecraft:sulfur_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_SLAB = create(key("sulfur_slab")); + + /** + * {@code minecraft:sulfur_spike} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_SPIKE = create(key("sulfur_spike")); + + /** + * {@code minecraft:sulfur_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_STAIRS = create(key("sulfur_stairs")); + + /** + * {@code minecraft:sulfur_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_WALL = create(key("sulfur_wall")); + /** * {@code minecraft:sunflower} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java index 5e878a9384df..b5809a47faff 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java @@ -319,6 +319,13 @@ public final class DamageTypeKeys { */ public static final TypedKey STING = create(key("sting")); + /** + * {@code minecraft:sulfur_cube_hot} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_CUBE_HOT = create(key("sulfur_cube_hot")); + /** * {@code minecraft:sweet_berry_bush} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java index 76f44313dc63..9e3163600070 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java @@ -648,6 +648,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey STORED_ENCHANTMENTS = create(key("stored_enchantments")); + /** + * {@code minecraft:sulfur_cube_content} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_CUBE_CONTENT = create(key("sulfur_cube_content")); + /** * {@code minecraft:suspicious_stew_effects} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java index 4483f4d56be1..09433d3f9d1b 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java @@ -88,6 +88,13 @@ public final class GameEventKeys { */ public static final TypedKey BLOCK_PLACE = create(key("block_place")); + /** + * {@code minecraft:bounce} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BOUNCE = create(key("bounce")); + /** * {@code minecraft:container_close} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java index edd4923254b8..5f499232d1b1 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java @@ -1670,6 +1670,13 @@ public final class ItemTypeKeys { */ public static final TypedKey CHISELED_BOOKSHELF = create(key("chiseled_bookshelf")); + /** + * {@code minecraft:chiseled_cinnabar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHISELED_CINNABAR = create(key("chiseled_cinnabar")); + /** * {@code minecraft:chiseled_copper} * @@ -1733,6 +1740,13 @@ public final class ItemTypeKeys { */ public static final TypedKey CHISELED_STONE_BRICKS = create(key("chiseled_stone_bricks")); + /** + * {@code minecraft:chiseled_sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHISELED_SULFUR = create(key("chiseled_sulfur")); + /** * {@code minecraft:chiseled_tuff} * @@ -1768,6 +1782,62 @@ public final class ItemTypeKeys { */ public static final TypedKey CHORUS_PLANT = create(key("chorus_plant")); + /** + * {@code minecraft:cinnabar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR = create(key("cinnabar")); + + /** + * {@code minecraft:cinnabar_brick_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICK_SLAB = create(key("cinnabar_brick_slab")); + + /** + * {@code minecraft:cinnabar_brick_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICK_STAIRS = create(key("cinnabar_brick_stairs")); + + /** + * {@code minecraft:cinnabar_brick_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICK_WALL = create(key("cinnabar_brick_wall")); + + /** + * {@code minecraft:cinnabar_bricks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_BRICKS = create(key("cinnabar_bricks")); + + /** + * {@code minecraft:cinnabar_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_SLAB = create(key("cinnabar_slab")); + + /** + * {@code minecraft:cinnabar_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_STAIRS = create(key("cinnabar_stairs")); + + /** + * {@code minecraft:cinnabar_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CINNABAR_WALL = create(key("cinnabar_wall")); + /** * {@code minecraft:clay} * @@ -5863,6 +5933,13 @@ public final class ItemTypeKeys { */ public static final TypedKey MUSIC_DISC_BLOCKS = create(key("music_disc_blocks")); + /** + * {@code minecraft:music_disc_bounce} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MUSIC_DISC_BOUNCE = create(key("music_disc_bounce")); + /** * {@code minecraft:music_disc_cat} * @@ -7179,6 +7256,34 @@ public final class ItemTypeKeys { */ public static final TypedKey POLISHED_BLACKSTONE_WALL = create(key("polished_blackstone_wall")); + /** + * {@code minecraft:polished_cinnabar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR = create(key("polished_cinnabar")); + + /** + * {@code minecraft:polished_cinnabar_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR_SLAB = create(key("polished_cinnabar_slab")); + + /** + * {@code minecraft:polished_cinnabar_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR_STAIRS = create(key("polished_cinnabar_stairs")); + + /** + * {@code minecraft:polished_cinnabar_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_CINNABAR_WALL = create(key("polished_cinnabar_wall")); + /** * {@code minecraft:polished_deepslate} * @@ -7249,6 +7354,34 @@ public final class ItemTypeKeys { */ public static final TypedKey POLISHED_GRANITE_STAIRS = create(key("polished_granite_stairs")); + /** + * {@code minecraft:polished_sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR = create(key("polished_sulfur")); + + /** + * {@code minecraft:polished_sulfur_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR_SLAB = create(key("polished_sulfur_slab")); + + /** + * {@code minecraft:polished_sulfur_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR_STAIRS = create(key("polished_sulfur_stairs")); + + /** + * {@code minecraft:polished_sulfur_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POLISHED_SULFUR_WALL = create(key("polished_sulfur_wall")); + /** * {@code minecraft:polished_tuff} * @@ -7305,6 +7438,13 @@ public final class ItemTypeKeys { */ public static final TypedKey POTATO = create(key("potato")); + /** + * {@code minecraft:potent_sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POTENT_SULFUR = create(key("potent_sulfur")); + /** * {@code minecraft:potion} * @@ -9076,6 +9216,83 @@ public final class ItemTypeKeys { */ public static final TypedKey SUGAR_CANE = create(key("sugar_cane")); + /** + * {@code minecraft:sulfur} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR = create(key("sulfur")); + + /** + * {@code minecraft:sulfur_brick_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICK_SLAB = create(key("sulfur_brick_slab")); + + /** + * {@code minecraft:sulfur_brick_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICK_STAIRS = create(key("sulfur_brick_stairs")); + + /** + * {@code minecraft:sulfur_brick_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICK_WALL = create(key("sulfur_brick_wall")); + + /** + * {@code minecraft:sulfur_bricks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_BRICKS = create(key("sulfur_bricks")); + + /** + * {@code minecraft:sulfur_cube_bucket} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_CUBE_BUCKET = create(key("sulfur_cube_bucket")); + + /** + * {@code minecraft:sulfur_cube_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_CUBE_SPAWN_EGG = create(key("sulfur_cube_spawn_egg")); + + /** + * {@code minecraft:sulfur_slab} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_SLAB = create(key("sulfur_slab")); + + /** + * {@code minecraft:sulfur_spike} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_SPIKE = create(key("sulfur_spike")); + + /** + * {@code minecraft:sulfur_stairs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_STAIRS = create(key("sulfur_stairs")); + + /** + * {@code minecraft:sulfur_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SULFUR_WALL = create(key("sulfur_wall")); + /** * {@code minecraft:sunflower} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java index c723e9162cac..25c31fbcd62d 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java @@ -53,6 +53,13 @@ public final class JukeboxSongKeys { */ public static final TypedKey BLOCKS = create(key("blocks")); + /** + * {@code minecraft:bounce} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BOUNCE = create(key("bounce")); + /** * {@code minecraft:cat} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java index 876765f6a74e..0015ab3092dd 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -1376,6 +1376,41 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_CHORUS_FLOWER_GROW = create(key("block.chorus_flower.grow")); + /** + * {@code minecraft:block.cinnabar.break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_CINNABAR_BREAK = create(key("block.cinnabar.break")); + + /** + * {@code minecraft:block.cinnabar.fall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_CINNABAR_FALL = create(key("block.cinnabar.fall")); + + /** + * {@code minecraft:block.cinnabar.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_CINNABAR_HIT = create(key("block.cinnabar.hit")); + + /** + * {@code minecraft:block.cinnabar.place} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_CINNABAR_PLACE = create(key("block.cinnabar.place")); + + /** + * {@code minecraft:block.cinnabar.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_CINNABAR_STEP = create(key("block.cinnabar.step")); + /** * {@code minecraft:block.cobweb.break} * @@ -4029,6 +4064,76 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_PORTAL_TRIGGER = create(key("block.portal.trigger")); + /** + * {@code minecraft:block.potent_sulfur.break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_BREAK = create(key("block.potent_sulfur.break")); + + /** + * {@code minecraft:block.potent_sulfur.fall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_FALL = create(key("block.potent_sulfur.fall")); + + /** + * {@code minecraft:block.potent_sulfur.geyser_continuous_eruption} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_GEYSER_CONTINUOUS_ERUPTION = create(key("block.potent_sulfur.geyser_continuous_eruption")); + + /** + * {@code minecraft:block.potent_sulfur.geyser_continuous_eruption_active} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_GEYSER_CONTINUOUS_ERUPTION_ACTIVE = create(key("block.potent_sulfur.geyser_continuous_eruption_active")); + + /** + * {@code minecraft:block.potent_sulfur.geyser_eruption} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_GEYSER_ERUPTION = create(key("block.potent_sulfur.geyser_eruption")); + + /** + * {@code minecraft:block.potent_sulfur.geyser_eruption_active} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_GEYSER_ERUPTION_ACTIVE = create(key("block.potent_sulfur.geyser_eruption_active")); + + /** + * {@code minecraft:block.potent_sulfur.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_HIT = create(key("block.potent_sulfur.hit")); + + /** + * {@code minecraft:block.potent_sulfur.noxious_gas} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_NOXIOUS_GAS = create(key("block.potent_sulfur.noxious_gas")); + + /** + * {@code minecraft:block.potent_sulfur.place} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_PLACE = create(key("block.potent_sulfur.place")); + + /** + * {@code minecraft:block.potent_sulfur.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_POTENT_SULFUR_STEP = create(key("block.potent_sulfur.step")); + /** * {@code minecraft:block.powder_snow.break} * @@ -5100,6 +5205,83 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_STONE_PRESSURE_PLATE_CLICK_ON = create(key("block.stone_pressure_plate.click_on")); + /** + * {@code minecraft:block.sulfur.break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_BREAK = create(key("block.sulfur.break")); + + /** + * {@code minecraft:block.sulfur.fall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_FALL = create(key("block.sulfur.fall")); + + /** + * {@code minecraft:block.sulfur.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_HIT = create(key("block.sulfur.hit")); + + /** + * {@code minecraft:block.sulfur.place} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_PLACE = create(key("block.sulfur.place")); + + /** + * {@code minecraft:block.sulfur.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_STEP = create(key("block.sulfur.step")); + + /** + * {@code minecraft:block.sulfur_spike.break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_SPIKE_BREAK = create(key("block.sulfur_spike.break")); + + /** + * {@code minecraft:block.sulfur_spike.fall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_SPIKE_FALL = create(key("block.sulfur_spike.fall")); + + /** + * {@code minecraft:block.sulfur_spike.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_SPIKE_HIT = create(key("block.sulfur_spike.hit")); + + /** + * {@code minecraft:block.sulfur_spike.land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_SPIKE_LAND = create(key("block.sulfur_spike.land")); + + /** + * {@code minecraft:block.sulfur_spike.place} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_SPIKE_PLACE = create(key("block.sulfur_spike.place")); + + /** + * {@code minecraft:block.sulfur_spike.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SULFUR_SPIKE_STEP = create(key("block.sulfur_spike.step")); + /** * {@code minecraft:block.suspicious_gravel.break} * @@ -10462,6 +10644,41 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_SLIME_SQUISH_SMALL = create(key("entity.slime.squish_small")); + /** + * {@code minecraft:entity.small_sulfur_cube.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SMALL_SULFUR_CUBE_DEATH = create(key("entity.small_sulfur_cube.death")); + + /** + * {@code minecraft:entity.small_sulfur_cube.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SMALL_SULFUR_CUBE_EAT = create(key("entity.small_sulfur_cube.eat")); + + /** + * {@code minecraft:entity.small_sulfur_cube.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SMALL_SULFUR_CUBE_HURT = create(key("entity.small_sulfur_cube.hurt")); + + /** + * {@code minecraft:entity.small_sulfur_cube.jump} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SMALL_SULFUR_CUBE_JUMP = create(key("entity.small_sulfur_cube.jump")); + + /** + * {@code minecraft:entity.small_sulfur_cube.squish} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SMALL_SULFUR_CUBE_SQUISH = create(key("entity.small_sulfur_cube.squish")); + /** * {@code minecraft:entity.sniffer.death} * @@ -10749,6 +10966,223 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_STRIDER_STEP_LAVA = create(key("entity.strider.step_lava")); + /** + * {@code minecraft:entity.sulfur_cube.absorb} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_ABSORB = create(key("entity.sulfur_cube.absorb")); + + /** + * {@code minecraft:entity.sulfur_cube.bounce} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_BOUNCE = create(key("entity.sulfur_cube.bounce")); + + /** + * {@code minecraft:entity.sulfur_cube.bouncy.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_BOUNCY_HIT = create(key("entity.sulfur_cube.bouncy.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.bouncy.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_BOUNCY_PUSH = create(key("entity.sulfur_cube.bouncy.push")); + + /** + * {@code minecraft:entity.sulfur_cube.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_DEATH = create(key("entity.sulfur_cube.death")); + + /** + * {@code minecraft:entity.sulfur_cube.eject} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_EJECT = create(key("entity.sulfur_cube.eject")); + + /** + * {@code minecraft:entity.sulfur_cube.explosive.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_EXPLOSIVE_HIT = create(key("entity.sulfur_cube.explosive.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.explosive.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_EXPLOSIVE_PUSH = create(key("entity.sulfur_cube.explosive.push")); + + /** + * {@code minecraft:entity.sulfur_cube.fast_flat.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_FAST_FLAT_HIT = create(key("entity.sulfur_cube.fast_flat.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.fast_flat.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_FAST_FLAT_PUSH = create(key("entity.sulfur_cube.fast_flat.push")); + + /** + * {@code minecraft:entity.sulfur_cube.fast_sliding.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_FAST_SLIDING_HIT = create(key("entity.sulfur_cube.fast_sliding.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.fast_sliding.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_FAST_SLIDING_PUSH = create(key("entity.sulfur_cube.fast_sliding.push")); + + /** + * {@code minecraft:entity.sulfur_cube.high_resistance.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_HIGH_RESISTANCE_HIT = create(key("entity.sulfur_cube.high_resistance.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.high_resistance.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_HIGH_RESISTANCE_PUSH = create(key("entity.sulfur_cube.high_resistance.push")); + + /** + * {@code minecraft:entity.sulfur_cube.hot.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_HOT_HIT = create(key("entity.sulfur_cube.hot.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.hot.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_HOT_PUSH = create(key("entity.sulfur_cube.hot.push")); + + /** + * {@code minecraft:entity.sulfur_cube.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_HURT = create(key("entity.sulfur_cube.hurt")); + + /** + * {@code minecraft:entity.sulfur_cube.jump} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_JUMP = create(key("entity.sulfur_cube.jump")); + + /** + * {@code minecraft:entity.sulfur_cube.light.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_LIGHT_HIT = create(key("entity.sulfur_cube.light.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.light.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_LIGHT_PUSH = create(key("entity.sulfur_cube.light.push")); + + /** + * {@code minecraft:entity.sulfur_cube.regular.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_REGULAR_HIT = create(key("entity.sulfur_cube.regular.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.regular.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_REGULAR_PUSH = create(key("entity.sulfur_cube.regular.push")); + + /** + * {@code minecraft:entity.sulfur_cube.slow_bouncy.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_SLOW_BOUNCY_HIT = create(key("entity.sulfur_cube.slow_bouncy.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.slow_bouncy.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_SLOW_BOUNCY_PUSH = create(key("entity.sulfur_cube.slow_bouncy.push")); + + /** + * {@code minecraft:entity.sulfur_cube.slow_flat.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_SLOW_FLAT_HIT = create(key("entity.sulfur_cube.slow_flat.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.slow_flat.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_SLOW_FLAT_PUSH = create(key("entity.sulfur_cube.slow_flat.push")); + + /** + * {@code minecraft:entity.sulfur_cube.slow_sliding.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_SLOW_SLIDING_HIT = create(key("entity.sulfur_cube.slow_sliding.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.slow_sliding.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_SLOW_SLIDING_PUSH = create(key("entity.sulfur_cube.slow_sliding.push")); + + /** + * {@code minecraft:entity.sulfur_cube.squish} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_SQUISH = create(key("entity.sulfur_cube.squish")); + + /** + * {@code minecraft:entity.sulfur_cube.sticky.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_STICKY_HIT = create(key("entity.sulfur_cube.sticky.hit")); + + /** + * {@code minecraft:entity.sulfur_cube.sticky.push} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_SULFUR_CUBE_STICKY_PUSH = create(key("entity.sulfur_cube.sticky.push")); + /** * {@code minecraft:entity.tadpole.death} * @@ -12303,6 +12737,13 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_BUCKET_EMPTY_POWDER_SNOW = create(key("item.bucket.empty_powder_snow")); + /** + * {@code minecraft:item.bucket.empty_sulfur_cube} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_BUCKET_EMPTY_SULFUR_CUBE = create(key("item.bucket.empty_sulfur_cube")); + /** * {@code minecraft:item.bucket.empty_tadpole} * @@ -12345,6 +12786,13 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_BUCKET_FILL_POWDER_SNOW = create(key("item.bucket.fill_powder_snow")); + /** + * {@code minecraft:item.bucket.fill_sulfur_cube} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_BUCKET_FILL_SULFUR_CUBE = create(key("item.bucket.fill_sulfur_cube")); + /** * {@code minecraft:item.bucket.fill_tadpole} * @@ -13080,6 +13528,13 @@ public final class SoundEventKeys { */ public static final TypedKey MUSIC_OVERWORLD_STONY_PEAKS = create(key("music.overworld.stony_peaks")); + /** + * {@code minecraft:music.overworld.sulfur_caves} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MUSIC_OVERWORLD_SULFUR_CAVES = create(key("music.overworld.sulfur_caves")); + /** * {@code minecraft:music.overworld.swamp} * @@ -13122,6 +13577,13 @@ public final class SoundEventKeys { */ public static final TypedKey MUSIC_DISC_BLOCKS = create(key("music_disc.blocks")); + /** + * {@code minecraft:music_disc.bounce} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MUSIC_DISC_BOUNCE = create(key("music_disc.bounce")); + /** * {@code minecraft:music_disc.cat} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SulfurCubeArchetypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SulfurCubeArchetypeKeys.java new file mode 100644 index 000000000000..056e5d571bba --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SulfurCubeArchetypeKeys.java @@ -0,0 +1,124 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.annotation.GeneratedClass; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.entity.SulfurCube; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#SULFUR_CUBE_ARCHETYPE}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedClass +public final class SulfurCubeArchetypeKeys { + /** + * {@code minecraft:bouncy} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BOUNCY = create(key("bouncy")); + + /** + * {@code minecraft:explosive} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey EXPLOSIVE = create(key("explosive")); + + /** + * {@code minecraft:fast_flat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FAST_FLAT = create(key("fast_flat")); + + /** + * {@code minecraft:fast_sliding} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FAST_SLIDING = create(key("fast_sliding")); + + /** + * {@code minecraft:high_resistance} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HIGH_RESISTANCE = create(key("high_resistance")); + + /** + * {@code minecraft:hot} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HOT = create(key("hot")); + + /** + * {@code minecraft:light} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LIGHT = create(key("light")); + + /** + * {@code minecraft:regular} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey REGULAR = create(key("regular")); + + /** + * {@code minecraft:slow_bouncy} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SLOW_BOUNCY = create(key("slow_bouncy")); + + /** + * {@code minecraft:slow_flat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SLOW_FLAT = create(key("slow_flat")); + + /** + * {@code minecraft:slow_sliding} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SLOW_SLIDING = create(key("slow_sliding")); + + /** + * {@code minecraft:sticky} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STICKY = create(key("sticky")); + + private SulfurCubeArchetypeKeys() { + } + + /** + * Creates a typed key for {@link SulfurCube.Archetype} in the registry {@code minecraft:sulfur_cube_archetype}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { + return TypedKey.create(RegistryKey.SULFUR_CUBE_ARCHETYPE, key); + } +} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java index fba1331fc5bd..f4745ea9ab3c 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java @@ -298,6 +298,20 @@ public final class BlockTypeTagKeys { */ public static final TagKey CAULDRONS = create(key("cauldrons")); + /** + * {@code #minecraft:causes_continuous_geyser_eruptions} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAUSES_CONTINUOUS_GEYSER_ERUPTIONS = create(key("causes_continuous_geyser_eruptions")); + + /** + * {@code #minecraft:causes_periodic_geyser_eruptions} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAUSES_PERIODIC_GEYSER_ERUPTIONS = create(key("causes_periodic_geyser_eruptions")); + /** * {@code #minecraft:cave_vines} * @@ -355,11 +369,18 @@ public final class BlockTypeTagKeys { public static final TagKey COMPLETES_FIND_TREE_TUTORIAL = create(key("completes_find_tree_tutorial")); /** - * {@code #minecraft:concrete_powder} + * {@code #minecraft:concrete} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CONCRETE = create(key("concrete")); + + /** + * {@code #minecraft:concrete_powders} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TagKey CONCRETE_POWDER = create(key("concrete_powder")); + public static final TagKey CONCRETE_POWDERS = create(key("concrete_powders")); /** * {@code #minecraft:convertable_to_mud} @@ -459,6 +480,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey DEEPSLATE_ORE_REPLACEABLES = create(key("deepslate_ore_replaceables")); + /** + * {@code #minecraft:default_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey DEFAULT_IMMUNE_TO = create(key("default_immune_to")); + /** * {@code #minecraft:diamond_ores} * @@ -613,6 +641,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey FOREST_ROCK_CAN_PLACE_ON = create(key("forest_rock_can_place_on")); + /** + * {@code #minecraft:fox_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey FOX_IMMUNE_TO = create(key("fox_immune_to")); + /** * {@code #minecraft:foxes_spawnable_on} * @@ -641,6 +676,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey GEODE_INVALID_BLOCKS = create(key("geode_invalid_blocks")); + /** + * {@code #minecraft:glazed_terracotta} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey GLAZED_TERRACOTTA = create(key("glazed_terracotta")); + /** * {@code #minecraft:goats_spawnable_on} * @@ -1068,6 +1110,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey PLANKS = create(key("planks")); + /** + * {@code #minecraft:polar_bear_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey POLAR_BEAR_IMMUNE_TO = create(key("polar_bear_immune_to")); + /** * {@code #minecraft:polar_bears_spawnable_on_alternate} * @@ -1173,6 +1222,27 @@ public final class BlockTypeTagKeys { */ public static final TagKey SCULK_REPLACEABLE_WORLD_GEN = create(key("sculk_replaceable_world_gen")); + /** + * {@code #minecraft:shears_extreme_breaking_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SHEARS_EXTREME_BREAKING_SPEED = create(key("shears_extreme_breaking_speed")); + + /** + * {@code #minecraft:shears_major_breaking_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SHEARS_MAJOR_BREAKING_SPEED = create(key("shears_major_breaking_speed")); + + /** + * {@code #minecraft:shears_minor_breaking_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SHEARS_MINOR_BREAKING_SPEED = create(key("shears_minor_breaking_speed")); + /** * {@code #minecraft:shulker_boxes} * @@ -1236,6 +1306,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey SNOW = create(key("snow")); + /** + * {@code #minecraft:snow_golem_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SNOW_GOLEM_IMMUNE_TO = create(key("snow_golem_immune_to")); + /** * {@code #minecraft:soul_fire_base_blocks} * @@ -1250,6 +1327,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey SOUL_SPEED_BLOCKS = create(key("soul_speed_blocks")); + /** + * {@code #minecraft:speleothems} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SPELEOTHEMS = create(key("speleothems")); + /** * {@code #minecraft:spruce_logs} * @@ -1299,6 +1383,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey STONE_PRESSURE_PLATES = create(key("stone_pressure_plates")); + /** + * {@code #minecraft:stray_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey STRAY_IMMUNE_TO = create(key("stray_immune_to")); + /** * {@code #minecraft:strider_warm_blocks} * @@ -1313,6 +1404,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey SUBSTRATE_OVERWORLD = create(key("substrate_overworld")); + /** + * {@code #minecraft:sulfur_spike_replaceable_blocks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_SPIKE_REPLACEABLE_BLOCKS = create(key("sulfur_spike_replaceable_blocks")); + /** * {@code #minecraft:support_override_cactus_flower} * @@ -1537,6 +1635,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey SUPPORTS_WITHER_ROSE = create(key("supports_wither_rose")); + /** + * {@code #minecraft:suppresses_bounce} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SUPPRESSES_BOUNCE = create(key("suppresses_bounce")); + /** * {@code #minecraft:sword_efficient} * @@ -1677,6 +1782,20 @@ public final class BlockTypeTagKeys { */ public static final TagKey WITHER_IMMUNE = create(key("wither_immune")); + /** + * {@code #minecraft:wither_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey WITHER_IMMUNE_TO = create(key("wither_immune_to")); + + /** + * {@code #minecraft:wither_skeleton_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey WITHER_SKELETON_IMMUNE_TO = create(key("wither_skeleton_immune_to")); + /** * {@code #minecraft:wither_summon_base_blocks} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java index 54670346e3e1..eadc17cb50ba 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java @@ -242,6 +242,13 @@ public final class DamageTypeTagKeys { */ public static final TagKey PANIC_ENVIRONMENTAL_CAUSES = create(key("panic_environmental_causes")); + /** + * {@code #minecraft:sulfur_cube_with_block_immune_to} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_WITH_BLOCK_IMMUNE_TO = create(key("sulfur_cube_with_block_immune_to")); + /** * {@code #minecraft:witch_resistant_to} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java index e1cd2c06e838..d060ed307ebc 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java @@ -277,6 +277,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey NON_CONTROLLING_RIDER = create(key("non_controlling_rider")); + /** + * {@code #minecraft:not_affected_by_geysers} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NOT_AFFECTED_BY_GEYSERS = create(key("not_affected_by_geysers")); + /** * {@code #minecraft:not_scary_for_pufferfish} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java index 1a73196592a0..85f5dece02f6 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java @@ -277,6 +277,20 @@ public final class ItemTypeTagKeys { */ public static final TagKey COMPLETES_FIND_TREE_TUTORIAL = create(key("completes_find_tree_tutorial")); + /** + * {@code #minecraft:concrete} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CONCRETE = create(key("concrete")); + + /** + * {@code #minecraft:concrete_powders} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CONCRETE_POWDERS = create(key("concrete_powders")); + /** * {@code #minecraft:copper} * @@ -648,6 +662,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey GAZE_DISGUISE_EQUIPMENT = create(key("gaze_disguise_equipment")); + /** + * {@code #minecraft:glazed_terracotta} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey GLAZED_TERRACOTTA = create(key("glazed_terracotta")); + /** * {@code #minecraft:goat_food} * @@ -1292,6 +1313,104 @@ public final class ItemTypeTagKeys { */ public static final TagKey STRIDER_TEMPT_ITEMS = create(key("strider_tempt_items")); + /** + * {@code #minecraft:sulfur_cube_archetype/bouncy} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_BOUNCY = create(key("sulfur_cube_archetype/bouncy")); + + /** + * {@code #minecraft:sulfur_cube_archetype/explosive} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_EXPLOSIVE = create(key("sulfur_cube_archetype/explosive")); + + /** + * {@code #minecraft:sulfur_cube_archetype/fast_flat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_FAST_FLAT = create(key("sulfur_cube_archetype/fast_flat")); + + /** + * {@code #minecraft:sulfur_cube_archetype/fast_sliding} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_FAST_SLIDING = create(key("sulfur_cube_archetype/fast_sliding")); + + /** + * {@code #minecraft:sulfur_cube_archetype/high_resistance} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_HIGH_RESISTANCE = create(key("sulfur_cube_archetype/high_resistance")); + + /** + * {@code #minecraft:sulfur_cube_archetype/hot} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_HOT = create(key("sulfur_cube_archetype/hot")); + + /** + * {@code #minecraft:sulfur_cube_archetype/light} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_LIGHT = create(key("sulfur_cube_archetype/light")); + + /** + * {@code #minecraft:sulfur_cube_archetype/regular} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_REGULAR = create(key("sulfur_cube_archetype/regular")); + + /** + * {@code #minecraft:sulfur_cube_archetype/slow_bouncy} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_SLOW_BOUNCY = create(key("sulfur_cube_archetype/slow_bouncy")); + + /** + * {@code #minecraft:sulfur_cube_archetype/slow_flat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_SLOW_FLAT = create(key("sulfur_cube_archetype/slow_flat")); + + /** + * {@code #minecraft:sulfur_cube_archetype/slow_sliding} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_SLOW_SLIDING = create(key("sulfur_cube_archetype/slow_sliding")); + + /** + * {@code #minecraft:sulfur_cube_archetype/sticky} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_ARCHETYPE_STICKY = create(key("sulfur_cube_archetype/sticky")); + + /** + * {@code #minecraft:sulfur_cube_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_FOOD = create(key("sulfur_cube_food")); + + /** + * {@code #minecraft:sulfur_cube_swallowable} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SULFUR_CUBE_SWALLOWABLE = create(key("sulfur_cube_swallowable")); + /** * {@code #minecraft:swords} * diff --git a/paper-api/src/main/java/co/aikar/timings/TimedEventExecutor.java b/paper-api/src/main/java/co/aikar/timings/TimedEventExecutor.java index 157617933a77..7ae751c3a10b 100644 --- a/paper-api/src/main/java/co/aikar/timings/TimedEventExecutor.java +++ b/paper-api/src/main/java/co/aikar/timings/TimedEventExecutor.java @@ -80,7 +80,7 @@ public void execute(@NotNull Listener listener, @NotNull Event event) throws Eve executor.execute(listener, event); return; } - try (Timing ignored = timings.startTiming()){ + try (Timing ignored = timings.startTiming()) { executor.execute(listener, event); } } diff --git a/paper-api/src/main/java/co/aikar/util/LoadingMap.java b/paper-api/src/main/java/co/aikar/util/LoadingMap.java index 207b6853a0cb..8e52a649ca04 100644 --- a/paper-api/src/main/java/co/aikar/util/LoadingMap.java +++ b/paper-api/src/main/java/co/aikar/util/LoadingMap.java @@ -178,7 +178,7 @@ public static Map newHashAutoMap(@Nullable final Class * @param loadFactor Load factor to use * @param Key Type of the Map * @param Value Type of the Map - * @return Map that auto instantiates on .get() + * @return Map that auto instantiates on .get() */ @NotNull public static Map newHashAutoMap(@NotNull final Class valueClass, int initialCapacity, float loadFactor) { diff --git a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java index 710acf711c94..3e51627b3048 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -71,7 +71,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy */ public static final MaterialSetTag BUCKETS = new MaterialSetTag(keyFor("buckets")) .endsWith("BUCKET") - .ensureSize("BUCKETS", 11).lock(); + .ensureSize("BUCKETS", 12).lock(); /** * Covers coal and charcoal. @@ -104,10 +104,10 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy /** * Covers all colors of concrete powder. * - * @deprecated in favour of {@link Tag#CONCRETE_POWDER} + * @deprecated in favour of {@link Tag#CONCRETE_POWDERS} */ @Deprecated(since = "1.21.8") - public static final MaterialSetTag CONCRETE_POWDER = replacedBy(Tag.CONCRETE_POWDER); + public static final MaterialSetTag CONCRETE_POWDER = replacedBy(Tag.CONCRETE_POWDERS); /** * Covers the two types of cooked fish. @@ -170,10 +170,11 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy /** * Covers all glazed terracotta blocks. + * + * @deprecated in favour of {@link Tag#GLAZED_TERRACOTTA} */ - public static final MaterialSetTag GLAZED_TERRACOTTA = new MaterialSetTag(keyFor("glazed_terracotta")) - .endsWith("GLAZED_TERRACOTTA") - .ensureSize("GLAZED_TERRACOTTA", 16).lock(); + @Deprecated(since = "26.2") + public static final MaterialSetTag GLAZED_TERRACOTTA = replacedBy(Tag.GLAZED_TERRACOTTA); /** * Covers the colors of stained terracotta. @@ -341,7 +342,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy */ public static final MaterialSetTag SPAWN_EGGS = new MaterialSetTag(keyFor("spawn_eggs")) .endsWith("_SPAWN_EGG") - .ensureSize("SPAWN_EGGS", 87).lock(); + .ensureSize("SPAWN_EGGS", 88).lock(); /** * Covers all colors of stained glass. diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java index 8b97cc830aa8..d92d2ca55b2f 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java @@ -1,9 +1,11 @@ package com.destroystokyo.paper.event.entity; +import io.papermc.paper.event.entity.EntityIgniteEvent; import org.bukkit.entity.Creeper; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityEvent; +import org.checkerframework.checker.index.qual.Positive; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; @@ -13,16 +15,13 @@ * {@link Creeper#setIgnited(boolean)}. */ @NullMarked -public class CreeperIgniteEvent extends EntityEvent implements Cancellable { - - private static final HandlerList HANDLER_LIST = new HandlerList(); +public class CreeperIgniteEvent extends EntityIgniteEvent { private boolean ignited; - private boolean cancelled; @ApiStatus.Internal public CreeperIgniteEvent(final Creeper creeper, final boolean ignited) { - super(creeper); + super(creeper, creeper.getMaxFuseTicks()); this.ignited = ignited; } @@ -40,21 +39,22 @@ public void setIgnited(final boolean ignited) { } @Override - public boolean isCancelled() { - return this.cancelled; + public @Positive int getFuseTime() { + return this.getEntity().getMaxFuseTicks(); } @Override - public void setCancelled(final boolean cancel) { - this.cancelled = cancel; + public void setFuseTime(final @Positive int ticks) { + this.getEntity().setMaxFuseTicks(ticks); } @Override - public HandlerList getHandlers() { - return HANDLER_LIST; + public boolean isCancelled() { + return super.isCancelled(); } - public static HandlerList getHandlerList() { - return HANDLER_LIST; + @Override + public void setCancelled(final boolean cancel) { + super.setCancelled(cancel); } } diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java index a5d4442b53c4..b62e38e1117e 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java @@ -1,6 +1,6 @@ package com.destroystokyo.paper.event.entity; -import org.bukkit.entity.Slime; +import org.bukkit.entity.AbstractCubeMob; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; @@ -16,8 +16,8 @@ public class SlimeChangeDirectionEvent extends SlimePathfindEvent { private float yaw; @ApiStatus.Internal - public SlimeChangeDirectionEvent(final Slime slime, final float yaw) { - super(slime); + public SlimeChangeDirectionEvent(final AbstractCubeMob cubeMob, final float yaw) { + super(cubeMob); this.yaw = yaw; } diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java index d481d116452f..e524e531c0f9 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java @@ -1,6 +1,6 @@ package com.destroystokyo.paper.event.entity; -import org.bukkit.entity.Slime; +import org.bukkit.entity.AbstractCubeMob; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityEvent; @@ -21,8 +21,8 @@ public class SlimePathfindEvent extends EntityEvent implements Cancellable { private boolean cancelled; @ApiStatus.Internal - public SlimePathfindEvent(final Slime slime) { - super(slime); + public SlimePathfindEvent(final AbstractCubeMob cubeMob) { + super(cubeMob); } /** @@ -31,8 +31,8 @@ public SlimePathfindEvent(final Slime slime) { * @return The Slime that is pathfinding. */ @Override - public Slime getEntity() { - return (Slime) super.getEntity(); + public AbstractCubeMob getEntity() { + return (AbstractCubeMob) super.getEntity(); } @Override diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java index 4233ea3012c0..78f383d4edd8 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java @@ -1,6 +1,6 @@ package com.destroystokyo.paper.event.entity; -import org.bukkit.entity.Slime; +import org.bukkit.entity.AbstractCubeMob; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; @@ -14,7 +14,7 @@ public class SlimeSwimEvent extends SlimeWanderEvent { @ApiStatus.Internal - public SlimeSwimEvent(final Slime slime) { - super(slime); + public SlimeSwimEvent(final AbstractCubeMob cubeMob) { + super(cubeMob); } } diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java index ba7369aab0c2..7a0206cd7f8b 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java @@ -1,7 +1,7 @@ package com.destroystokyo.paper.event.entity; +import org.bukkit.entity.AbstractCubeMob; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Slime; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; @@ -17,8 +17,8 @@ public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent { private final LivingEntity target; @ApiStatus.Internal - public SlimeTargetLivingEntityEvent(final Slime slime, final LivingEntity target) { - super(slime); + public SlimeTargetLivingEntityEvent(final AbstractCubeMob cubeMob, final LivingEntity target) { + super(cubeMob); this.target = target; } diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java index 0ea085c4a1cf..dee7d2807c95 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java @@ -1,6 +1,6 @@ package com.destroystokyo.paper.event.entity; -import org.bukkit.entity.Slime; +import org.bukkit.entity.AbstractCubeMob; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; @@ -14,7 +14,7 @@ public class SlimeWanderEvent extends SlimePathfindEvent { @ApiStatus.Internal - public SlimeWanderEvent(final Slime slime) { - super(slime); + public SlimeWanderEvent(final AbstractCubeMob cubeMob) { + super(cubeMob); } } diff --git a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java index 4daea5617d76..5a039f815a29 100644 --- a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java @@ -1,22 +1,37 @@ package io.papermc.paper; import com.destroystokyo.paper.SkinParts; +import com.destroystokyo.paper.util.VersionFetcher; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.datacomponent.item.ResolvableProfile; import io.papermc.paper.entity.poi.PoiType; +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; import io.papermc.paper.world.damagesource.CombatEntry; import io.papermc.paper.world.damagesource.FallLocationType; +import java.io.IOException; import java.util.Set; +import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.function.Predicate; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.flattener.ComponentFlattener; import net.kyori.adventure.util.Services; import org.bukkit.GameRule; +import org.bukkit.NamespacedKey; +import org.bukkit.Statistic; +import org.bukkit.attribute.Attributable; import org.bukkit.block.Biome; +import org.bukkit.command.CommandSender; import org.bukkit.damage.DamageEffect; import org.bukkit.damage.DamageSource; +import org.bukkit.damage.DamageType; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pose; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jspecify.annotations.NullMarked; @@ -45,52 +60,12 @@ class Holder { return Holder.INSTANCE; } - /** - * Creates a damage effect instance for the passed key. - * - * @param key the string key. - * @return the damage effect. - */ - DamageEffect getDamageEffect(String key); - - /** - * Creates an occupancy instance for the passed enum entry name. - * - * @param enumNameEntry the enum entry - * @return the occupancy - */ - PoiType.Occupancy createOccupancy(String enumNameEntry); - - /** - * Constructs the legacy custom biome instance for the biome enum. - * - * @return the created biome. - */ @Deprecated(forRemoval = true, since = "1.21.5") @ApiStatus.ScheduledForRemoval(inVersion = "1.22") Biome constructLegacyCustomBiome(); - /** - * Creates a new combat entry. - *

- * The fall location and fall distance will be calculated from the entity's current state. - * - * @param entity entity - * @param damageSource damage source - * @param damage damage amount - * @return new combat entry - */ CombatEntry createCombatEntry(LivingEntity entity, DamageSource damageSource, float damage); - /** - * Creates a new combat entry - * - * @param damageSource damage source - * @param damage damage amount - * @param fallLocationType fall location type - * @param fallDistance fall distance - * @return combat entry - */ CombatEntry createCombatEntry(DamageSource damageSource, float damage, @Nullable FallLocationType fallLocationType, float fallDistance); /** @@ -113,4 +88,35 @@ class Holder { GameRule legacyGameRuleBridge(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass); Set validMannequinPoses(); + + PoiType.Occupancy createOccupancy(String enumNameEntry); + + DamageSource.Builder createDamageSourceBuilder(DamageType damageType); + + DamageEffect getDamageEffect(String key); + + String getTranslationKey(EntityType entityType); + + /* + * Called once by the version command on first use, then cached. + */ + default VersionFetcher getVersionFetcher() { + return new VersionFetcher.DummyVersionFetcher(); + } + + ItemStack deserializeItem(byte[] data); + + boolean hasDefaultEntityAttributes(NamespacedKey entityKey); + + Attributable getDefaultEntityAttributes(NamespacedKey entityKey); + + String getStatisticCriteriaKey(Statistic statistic); + + LifecycleEventManager createPluginLifecycleEventManager(JavaPlugin plugin, BooleanSupplier registrationCheck); + + ItemStack createEmptyStack(); + + Component resolveWithContext(Component component, @Nullable CommandSender context, @Nullable Entity scoreboardSubject, boolean bypassPermissions) throws IOException; + + ComponentFlattener componentFlattener(); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java index c126cbf5f353..28c7ebb3b4e4 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java @@ -34,6 +34,7 @@ import io.papermc.paper.datacomponent.item.Repairable; import io.papermc.paper.datacomponent.item.ResolvableProfile; import io.papermc.paper.datacomponent.item.SeededContainerLoot; +import io.papermc.paper.datacomponent.item.SulfurCubeContent; import io.papermc.paper.datacomponent.item.SuspiciousStewEffects; import io.papermc.paper.datacomponent.item.SwingAnimation; import io.papermc.paper.datacomponent.item.Tool; @@ -351,6 +352,7 @@ public final class DataComponentTypes { */ public static final DataComponentType.Valued BLOCK_DATA = valued("block_state"); // bees + public static final DataComponentType.Valued SULFUR_CUBE_CONTENT = valued("sulfur_cube_content"); // /** // * Holds the lock state of a container-like block, // * copied to container block when placed. @@ -394,7 +396,7 @@ public final class DataComponentTypes { public static final DataComponentType.Valued SHEEP_COLOR = valued("sheep/color"); public static final DataComponentType.Valued SHULKER_COLOR = valued("shulker/color"); - private static DataComponentType.NonValued unvalued(final @KeyPattern.Value String key) { + private static DataComponentType.NonValued unvalued(@KeyPattern.Value final String key) { final DataComponentType dataComponentType = Registry.DATA_COMPONENT_TYPE.getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); if (dataComponentType instanceof DataComponentType.NonValued) { return (DataComponentType.NonValued) dataComponentType; @@ -403,7 +405,7 @@ private static DataComponentType.NonValued unvalued(final @KeyPattern.Value Stri } @SuppressWarnings("unchecked") - private static DataComponentType.Valued valued(final @KeyPattern.Value String key) { + private static DataComponentType.Valued valued(@KeyPattern.Value final String key) { final DataComponentType dataComponentType = Registry.DATA_COMPONENT_TYPE.getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); if (dataComponentType instanceof DataComponentType.Valued) { return (DataComponentType.Valued) dataComponentType; diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java index aac079e1d805..9002812165d4 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ChargedProjectiles.java @@ -45,21 +45,21 @@ interface Builder extends DataComponentBuilder { /** * Adds a projectile to be loaded in this builder. * - * @param stack projectile + * @param item projectile * @return the builder for chaining * @see #projectiles() */ @Contract(value = "_ -> this", mutates = "this") - Builder add(ItemStack stack); + Builder add(ItemStack item); /** * Adds projectiles to be loaded in this builder. * - * @param stacks projectiles + * @param items projectiles * @return the builder for chaining * @see #projectiles() */ @Contract(value = "_ -> this", mutates = "this") - Builder addAll(List stacks); + Builder addAll(List items); } } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java index c74366daa72f..035ce6d18f11 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java @@ -129,4 +129,6 @@ static ItemComponentTypesBridge bridge() { SwingAnimation.Builder swingAnimation(); KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, float minSpeed, float minRelativeSpeed); + + SulfurCubeContent sulfurCubeContent(ItemStack absorbedItem); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SulfurCubeContent.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SulfurCubeContent.java new file mode 100644 index 000000000000..bfc671bfb182 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SulfurCubeContent.java @@ -0,0 +1,29 @@ +package io.papermc.paper.datacomponent.item; + +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; + +/** + * Holds the item absorbed by a sulfur cube. + * @see io.papermc.paper.datacomponent.DataComponentTypes#SULFUR_CUBE_CONTENT + */ +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface SulfurCubeContent { + + @Contract(value = "_ -> new", pure = true) + static SulfurCubeContent sulfurCubeContent(final ItemStack absorbedItem) { + return ItemComponentTypesBridge.bridge().sulfurCubeContent(absorbedItem); + } + + /** + * Gets the item absorbed by the cube. + * + * @return the item absorbed + */ + @Contract(pure = true) + ItemStack absorbedItem(); +} diff --git a/paper-api/src/main/java/io/papermc/paper/event/entity/EntityIgniteEvent.java b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityIgniteEvent.java new file mode 100644 index 000000000000..aa3979eef77d --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityIgniteEvent.java @@ -0,0 +1,66 @@ +package io.papermc.paper.event.entity; + +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.checkerframework.checker.index.qual.Positive; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +import static io.papermc.paper.util.BoundChecker.requirePositive; + +/** + * Called when an entity is ignited often by fire or redstone power. + */ +@NullMarked +public class EntityIgniteEvent extends EntityEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private int fuseTime; + private boolean cancelled; + + @ApiStatus.Internal + public EntityIgniteEvent(final Entity entity, final int fuseTime) { + super(entity); + this.fuseTime = fuseTime; + } + + /** + * Gets the amount of ticks required for this entity to explode. + * + * @return the amount of ticks required + */ + public @Positive int getFuseTime() { + return this.fuseTime; + } + + /** + * Sets the amount of ticks required for this entity to explode. + * + * @param ticks the amount of ticks required + */ + public void setFuseTime(final @Positive int ticks) { + this.fuseTime = requirePositive(ticks, "ticks"); + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(final boolean cancel) { + this.cancelled = cancel; + } + + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java index 10a595cb6f60..aba87eec0445 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java @@ -27,6 +27,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Frog; import org.bukkit.entity.Pig; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; import org.bukkit.entity.ZombieNautilus; @@ -252,6 +253,11 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { * @see io.papermc.paper.registry.keys.ZombieNautilusVariantKeys */ RegistryKey ZOMBIE_NAUTILUS_VARIANT = create("zombie_nautilus_variant"); + /** + * Data-driven registry for sulfur cube archetypes. + * @see io.papermc.paper.registry.keys.SulfurCubeArchetypeKeys + */ + RegistryKey SULFUR_CUBE_ARCHETYPE = create("sulfur_cube_archetype"); /** * Data-driven registry for dialogs. * @see io.papermc.paper.registry.keys.DialogKeys diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/BannerPatternRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/BannerPatternRegistryEntry.java index 8ca672a5bb5c..57e63f41225a 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/BannerPatternRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/BannerPatternRegistryEntry.java @@ -16,14 +16,14 @@ public interface BannerPatternRegistryEntry { /** * Provides the asset id of the pattern type, which is the location of the sprite to use. * - * @return the asset id. + * @return the asset id */ Key assetId(); /** * Provides the translation key for displaying the pattern inside the banner's tooltip. * - * @return the translation key. + * @return the translation key */ String translationKey(); @@ -43,8 +43,8 @@ interface Builder extends BannerPatternRegistryEntry, RegistryBuilder { /** * Sets the client texture asset of the cat type, which is the location of the texture to use. * - * @param clientTextureAsset the client texture asset. - * @return this builder instance. + * @param clientTextureAsset the client texture asset + * @return this builder instance * @see CatTypeRegistryEntry#clientTextureAsset() */ @Contract(value = "_ -> this", mutates = "this") @@ -53,8 +53,8 @@ interface Builder extends CatTypeRegistryEntry, RegistryBuilder { /** * Sets the client texture asset of the cat type for baby cats. * - * @param babyClientTextureAsset the baby client texture asset. - * @return this builder instance. + * @param babyClientTextureAsset the baby client texture asset + * @return this builder instance * @see CatTypeRegistryEntry#babyClientTextureAsset() */ @Contract(value = "_ -> this", mutates = "this") diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/ChickenVariantRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/ChickenVariantRegistryEntry.java index f70d189203d5..a45e852a96e1 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/ChickenVariantRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/ChickenVariantRegistryEntry.java @@ -31,21 +31,21 @@ enum Model { /** * Provides the client texture asset of the chicken variant, which represents the texture to use. * - * @return the client texture asset. + * @return the client texture asset */ ClientTextureAsset clientTextureAsset(); /** * Provides the client texture asset of the baby chicken variant, which represents the texture to use. * - * @return the baby client texture asset. + * @return the baby client texture asset */ ClientTextureAsset babyClientTextureAsset(); /** * Provides the model of the chicken variant. * - * @return the model. + * @return the model */ Model model(); @@ -66,8 +66,8 @@ interface Builder extends ChickenVariantRegistryEntry, RegistryBuilder /** * Sets the client texture asset of the cow variant, which is the location of the texture to use. * - * @param clientTextureAsset the client texture asset. - * @return this builder instance. + * @param clientTextureAsset the client texture asset + * @return this builder instance * @see CowVariantRegistryEntry#clientTextureAsset() */ @Contract(value = "_ -> this", mutates = "this") @@ -81,8 +81,8 @@ interface Builder extends CowVariantRegistryEntry, RegistryBuilder /** * Sets the client texture asset of the baby cow variant, which is the location of the texture to use. * - * @param babyClientTextureAsset the baby client texture asset. - * @return this builder instance. + * @param babyClientTextureAsset the baby client texture asset + * @return this builder instance * @see CowVariantRegistryEntry#babyClientTextureAsset() */ @Contract(value = "_ -> this", mutates = "this") @@ -91,8 +91,8 @@ interface Builder extends CowVariantRegistryEntry, RegistryBuilder /** * Sets the model to use for this cow variant. * - * @param model the model. - * @return this builder instance. + * @param model the model + * @return this builder instance * @see CowVariantRegistryEntry#model() */ @Contract(value = "_ -> this", mutates = "this") diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/DamageTypeRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/DamageTypeRegistryEntry.java index 50136f1d6a2b..fae3c3debd4a 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/DamageTypeRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/DamageTypeRegistryEntry.java @@ -70,7 +70,7 @@ interface Builder extends DamageTypeRegistryEntry, RegistryBuilder { /** * Sets part of the death message translation key. * - * @return this builder instance. + * @return this builder instance * @see DamageTypeRegistryEntry#messageId() * @see DamageType#getTranslationKey() */ @@ -80,7 +80,7 @@ interface Builder extends DamageTypeRegistryEntry, RegistryBuilder { /** * Sets the amount of hunger exhaustion caused by this damage type. * - * @return this builder instance. + * @return this builder instance * @see DamageTypeRegistryEntry#exhaustion() * @see DamageType#getExhaustion() */ @@ -90,7 +90,7 @@ interface Builder extends DamageTypeRegistryEntry, RegistryBuilder { /** * Sets the {@link DamageScaling} for this damage type. * - * @return this builder instance. + * @return this builder instance * @see DamageTypeRegistryEntry#damageScaling() * @see DamageType#getDamageScaling() */ @@ -100,7 +100,7 @@ interface Builder extends DamageTypeRegistryEntry, RegistryBuilder { /** * Sets the {@link DamageEffect} for this damage type. * - * @return this builder instance. + * @return this builder instance * @see DamageTypeRegistryEntry#damageEffect() * @see DamageType#getDamageEffect() */ @@ -110,7 +110,7 @@ interface Builder extends DamageTypeRegistryEntry, RegistryBuilder { /** * Sets the {@link DeathMessageType} for this damage type. * - * @return this builder instance. + * @return this builder instance * @see DamageTypeRegistryEntry#deathMessageType() * @see DamageType#getDeathMessageType() */ diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java index 4b3a21406017..262c2565e0ca 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java @@ -30,14 +30,14 @@ public interface EnchantmentRegistryEntry { * Provides the description of this enchantment entry as displayed to the client, e.g. "Sharpness" for the sharpness * enchantment. * - * @return the description component. + * @return the description component */ Component description(); /** * Provides the registry key set referencing the items this enchantment is supported on. * - * @return the registry key set. + * @return the registry key set */ RegistryKeySet supportedItems(); @@ -49,22 +49,22 @@ public interface EnchantmentRegistryEntry { * Additionally, the tag {@link io.papermc.paper.registry.keys.tags.EnchantmentTagKeys#IN_ENCHANTING_TABLE} defines * which enchantments can even show up in an enchantment table. * - * @return the registry key set. + * @return the registry key set */ @Nullable RegistryKeySet primaryItems(); /** * Provides the weight of this enchantment used by the weighted random when selecting enchantments. * - * @return the weight value. - * @see https://minecraft.wiki/w/Enchanting for examplary weights. + * @return the weight value + * @see https://minecraft.wiki/w/Enchanting for exemplary weights */ @Range(from = 1, to = 1024) int weight(); /** * Provides the maximum level this enchantment can have when applied. * - * @return the maximum level. + * @return the maximum level */ @Range(from = 1, to = 255) int maxLevel(); @@ -73,9 +73,9 @@ public interface EnchantmentRegistryEntry { *

* Note that a cost is not directly related to the consumed xp. * - * @return the enchantment cost. + * @return the enchantment cost * @see https://minecraft.wiki/w/Enchanting/Levels for - * examplary costs. + * exemplary costs */ EnchantmentCost minimumCost(); @@ -86,7 +86,7 @@ public interface EnchantmentRegistryEntry { * * @return the enchantment cost. * @see https://minecraft.wiki/w/Enchanting/Levels for - * examplary costs. + * exemplary costs */ EnchantmentCost maximumCost(); @@ -108,7 +108,7 @@ public interface EnchantmentRegistryEntry { * If the item enchanted with this enchantment is equipped in a slot not covered by the returned list and its * groups, the enchantment's effects, like attribute modifiers, will not activate. * - * @return a list of equipment slot groups. + * @return a list of equipment slot groups * @see Enchantment#getActiveSlotGroups() */ @Unmodifiable List activeSlots(); @@ -119,7 +119,7 @@ public interface EnchantmentRegistryEntry { * Exclusive enchantments prohibit the application of this enchantment to an item if they are already present on * said item. * - * @return a registry set of enchantments exclusive to this one. + * @return a registry set of enchantments exclusive to this one */ RegistryKeySet exclusiveWith(); @@ -146,8 +146,8 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder * Configures the description of this enchantment entry as displayed to the client, e.g. "Sharpness" for the * sharpness enchantment. * - * @param description the description component. - * @return this builder instance. + * @param description the description component + * @return this builder instance */ @Contract(value = "_ -> this", mutates = "this") Builder description(Component description); @@ -160,8 +160,8 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_ARMOR} and * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_MELEE_WEAPON}. * - * @param supportedItems the registry key set representing the supported items. - * @return this builder instance. + * @param supportedItems the registry key set representing the supported items + * @return this builder instance * @see RegistrySet#keySet(RegistryKey, TypedKey[]) * @see RegistryComposeEvent#getOrCreateTag(TagKey) */ @@ -192,9 +192,9 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder /** * Configures the weight of this enchantment used by the weighted random when selecting enchantments. * - * @param weight the weight value. - * @return this builder instance. - * @see https://minecraft.wiki/w/Enchanting for examplary weights. + * @param weight the weight value + * @return this builder instance + * @see https://minecraft.wiki/w/Enchanting for exemplary weights */ @Contract(value = "_ -> this", mutates = "this") Builder weight(@Range(from = 1, to = 1024) int weight); @@ -213,10 +213,10 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder *

* Note that a cost is not directly related to the consumed xp. * - * @param minimumCost the enchantment cost. - * @return this builder instance. + * @param minimumCost the enchantment cost + * @return this builder instance * @see https://minecraft.wiki/w/Enchanting/Levels for - * examplary costs. + * exemplary costs */ @Contract(value = "_ -> this", mutates = "this") Builder minimumCost(EnchantmentCost minimumCost); @@ -226,10 +226,10 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder *

* Note that a cost is not directly related to the consumed xp. * - * @param maximumCost the enchantment cost. - * @return this builder instance. + * @param maximumCost the enchantment cost + * @return this builder instance * @see https://minecraft.wiki/w/Enchanting/Levels for - * examplary costs. + * exemplary costs */ @Contract(value = "_ -> this", mutates = "this") Builder maximumCost(EnchantmentCost maximumCost); @@ -242,7 +242,7 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder *

* * @param anvilCost the anvil cost of this enchantment - * @return this builder instance. + * @return this builder instance * @see Enchantment#getAnvilCost() */ @Contract(value = "_ -> this", mutates = "this") @@ -254,8 +254,8 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder * If the item enchanted with this enchantment is equipped in a slot not covered by the returned list and its * groups, the enchantment's effects, like attribute modifiers, will not activate. * - * @param activeSlots a list of equipment slot groups. - * @return this builder instance. + * @param activeSlots a list of equipment slot groups + * @return this builder instance * @see Enchantment#getActiveSlotGroups() */ @Contract(value = "_ -> this", mutates = "this") @@ -269,8 +269,8 @@ default Builder activeSlots(final EquipmentSlotGroup... activeSlots) { * If the item enchanted with this enchantment is equipped in a slot not covered by the returned list and its * groups, the enchantment's effects, like attribute modifiers, will not activate. * - * @param activeSlots a list of equipment slot groups. - * @return this builder instance. + * @param activeSlots a list of equipment slot groups + * @return this builder instance * @see Enchantment#getActiveSlotGroups() */ @Contract(value = "_ -> this", mutates = "this") @@ -284,8 +284,8 @@ default Builder activeSlots(final EquipmentSlotGroup... activeSlots) { *

* Defaults to an empty set allowing this enchantment to be applied regardless of other enchantments. * - * @param exclusiveWith a registry set of enchantments exclusive to this one. - * @return this builder instance. + * @param exclusiveWith a registry set of enchantments exclusive to this one + * @return this builder instance * @see RegistrySet#keySet(RegistryKey, TypedKey[]) * @see RegistryComposeEvent#getOrCreateTag(TagKey) */ @@ -296,12 +296,14 @@ default Builder activeSlots(final EquipmentSlotGroup... activeSlots) { /** * The enchantment cost interface represents the cost of applying an enchantment, split up into its different components. */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable interface EnchantmentCost { /** * Returns the base cost of this enchantment cost, no matter what level the enchantment has. * - * @return the cost in levels. + * @return the cost in levels */ int baseCost(); @@ -309,18 +311,18 @@ interface EnchantmentCost { * Returns the additional cost added per level of the enchantment to be applied. * This cost is applied per level above the first. * - * @return the cost added to the {@link #baseCost()} for each level above the first. + * @return the cost added to the {@link #baseCost()} for each level above the first */ int additionalPerLevelCost(); /** * Creates a new enchantment cost instance based on the passed values. * - * @param baseCost the base cost of the enchantment cost as returned by {@link #baseCost()} + * @param baseCost the base cost of the enchantment cost, as returned by {@link #baseCost()} * @param additionalPerLevelCost the additional cost per level, as returned by {@link #additionalPerLevelCost()} - * @return the created instance. + * @return the created instance */ - @Contract(value = "_,_ -> new", pure = true) + @Contract(value = "_, _ -> new", pure = true) static EnchantmentCost of(final int baseCost, final int additionalPerLevelCost) { record Impl(int baseCost, int additionalPerLevelCost) implements EnchantmentCost { } diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/FrogVariantRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/FrogVariantRegistryEntry.java index 7f9c5e87602f..56fd67f5ab8c 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/FrogVariantRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/FrogVariantRegistryEntry.java @@ -16,7 +16,7 @@ public interface FrogVariantRegistryEntry { /** * Provides the client texture asset of the frog variant, which represents the texture to use. * - * @return the client texture asset. + * @return the client texture asset */ ClientTextureAsset clientTextureAsset(); @@ -35,8 +35,8 @@ interface Builder extends FrogVariantRegistryEntry, RegistryBuilder { /** * Sets the range in which this game event should notify its listeners. * - * @param range the range of blocks. - * @return this builder instance. + * @param range the range of blocks + * @return this builder instance * @see GameEventRegistryEntry#range() * @see GameEvent#getRange() */ diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/InstrumentRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/InstrumentRegistryEntry.java index 3ae55ffe6af9..9ef7195c381b 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/InstrumentRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/InstrumentRegistryEntry.java @@ -22,7 +22,7 @@ public interface InstrumentRegistryEntry { /** * Provides the sound event of the instrument. * - * @return the sound event. + * @return the sound event * @see MusicInstrument#getSound() */ @Contract(pure = true) @@ -31,7 +31,7 @@ public interface InstrumentRegistryEntry { /** * Provides the duration of the instrument, which is time to use. * - * @return the duration. + * @return the duration * @see MusicInstrument#getDuration() */ @Contract(pure = true) @@ -40,7 +40,7 @@ public interface InstrumentRegistryEntry { /** * Provides the range of the instrument, which is range of the sound. * - * @return the range. + * @return the range * @see MusicInstrument#getRange() */ @Contract(pure = true) @@ -49,7 +49,7 @@ public interface InstrumentRegistryEntry { /** * Provides the description of the instrument, which is used in the item tooltip. * - * @return the description. + * @return the description * @see MusicInstrument#description() */ @Contract(pure = true) diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/JukeboxSongRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/JukeboxSongRegistryEntry.java index 5779281e5c0b..7c1c7f605fd7 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/JukeboxSongRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/JukeboxSongRegistryEntry.java @@ -101,7 +101,7 @@ interface Builder extends JukeboxSongRegistryEntry, RegistryBuilder * @see #soundEvent(TypedKey) * @see #soundEvent(Consumer) */ - @Contract( value = "_ -> this", mutates = "this") + @Contract(value = "_ -> this", mutates = "this") Builder soundEvent(RegistryHolder soundEvent); /** diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java index a42dd7cd8700..a8ae0f06c3f9 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/PaintingVariantRegistryEntry.java @@ -19,7 +19,7 @@ public interface PaintingVariantRegistryEntry { /** * Provides the width of this painting in blocks. * - * @return the width. + * @return the width * @see Art#getBlockWidth() */ @Range(from = 1, to = 16) int width(); @@ -27,7 +27,7 @@ public interface PaintingVariantRegistryEntry { /** * Provides the height of this painting in blocks. * - * @return the height. + * @return the height * @see Art#getBlockHeight() */ @Range(from = 1, to = 16) int height(); @@ -35,7 +35,7 @@ public interface PaintingVariantRegistryEntry { /** * Provides the title of the painting visible in the creative inventory. * - * @return the title. + * @return the title * @see Art#title() */ @Nullable Component title(); @@ -43,7 +43,7 @@ public interface PaintingVariantRegistryEntry { /** * Provides the author of the painting visible in the creative inventory. * - * @return the author. + * @return the author * @see Art#author() */ @Nullable Component author(); @@ -51,7 +51,7 @@ public interface PaintingVariantRegistryEntry { /** * Provides the asset id of the painting, which is the location of the sprite to use. * - * @return the asset id. + * @return the asset id * @see Art#assetId() */ Key assetId(); @@ -73,8 +73,8 @@ interface Builder extends PaintingVariantRegistryEntry, RegistryBuilder { /** * Sets the width of the painting in blocks. * - * @param width the width in blocks. - * @return this builder instance. + * @param width the width in blocks + * @return this builder instance * @see PaintingVariantRegistryEntry#width() * @see Art#getBlockWidth() */ @@ -84,8 +84,8 @@ interface Builder extends PaintingVariantRegistryEntry, RegistryBuilder { /** * Sets the height of the painting in blocks. * - * @param height the height in blocks. - * @return this builder instance. + * @param height the height in blocks + * @return this builder instance * @see PaintingVariantRegistryEntry#height() * @see Art#getBlockHeight() */ @@ -95,8 +95,8 @@ interface Builder extends PaintingVariantRegistryEntry, RegistryBuilder { /** * Sets the title of the painting. * - * @param title the title. - * @return this builder instance. + * @param title the title + * @return this builder instance * @see PaintingVariantRegistryEntry#title() * @see Art#title() */ @@ -106,8 +106,8 @@ interface Builder extends PaintingVariantRegistryEntry, RegistryBuilder { /** * Sets the author of the painting. * - * @param author the author. - * @return this builder instance. + * @param author the author + * @return this builder instance * @see PaintingVariantRegistryEntry#author() * @see Art#author() */ @@ -117,8 +117,8 @@ interface Builder extends PaintingVariantRegistryEntry, RegistryBuilder { /** * Sets the asset id of the painting, which is the location of the sprite to use. * - * @param assetId the asset id. - * @return this builder instance. + * @param assetId the asset id + * @return this builder instance * @see PaintingVariantRegistryEntry#assetId() * @see Art#assetId() */ diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/PigVariantRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/PigVariantRegistryEntry.java index 0b482be5990f..e32b208c66d2 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/PigVariantRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/PigVariantRegistryEntry.java @@ -31,21 +31,21 @@ enum Model { /** * Provides the client texture asset of the pig variant, which represents the texture to use. * - * @return the client texture asset. + * @return the client texture asset */ ClientTextureAsset clientTextureAsset(); /** * Provides the client texture asset of the baby pig variant, which represents the texture to use. * - * @return the baby client texture asset. + * @return the baby client texture asset */ ClientTextureAsset babyClientTextureAsset(); /** * Provides the model of the pig variant. * - * @return the model. + * @return the model */ Model model(); @@ -66,8 +66,8 @@ interface Builder extends PigVariantRegistryEntry, RegistryBuilder /** * Sets the client texture asset of the pig variant, which is the location of the texture to use. * - * @param clientTextureAsset the client texture asset. - * @return this builder instance. + * @param clientTextureAsset the client texture asset + * @return this builder instance * @see PigVariantRegistryEntry#clientTextureAsset() */ @Contract(value = "_ -> this", mutates = "this") @@ -76,8 +76,8 @@ interface Builder extends PigVariantRegistryEntry, RegistryBuilder /** * Sets the client texture asset of the baby pig variant, which is the location of the texture to use. * - * @param babyClientTextureAsset the baby client texture asset. - * @return this builder instance. + * @param babyClientTextureAsset the baby client texture asset + * @return this builder instance * @see PigVariantRegistryEntry#babyClientTextureAsset() */ @Contract(value = "_ -> this", mutates = "this") @@ -86,8 +86,8 @@ interface Builder extends PigVariantRegistryEntry, RegistryBuilder /** * Sets the model to use for this pig variant. * - * @param model the model. - * @return this builder instance. + * @param model the model + * @return this builder instance * @see PigVariantRegistryEntry#model() */ @Contract(value = "_ -> this", mutates = "this") diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/SulfurCubeArchetypeRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/SulfurCubeArchetypeRegistryEntry.java new file mode 100644 index 000000000000..5523943bf728 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/SulfurCubeArchetypeRegistryEntry.java @@ -0,0 +1,375 @@ +package io.papermc.paper.registry.data; + +import io.papermc.paper.registry.RegistryBuilder; +import io.papermc.paper.registry.TypedKey; +import io.papermc.paper.registry.set.RegistryKeySet; +import java.util.List; +import org.bukkit.Sound; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeModifier; +import org.bukkit.damage.DamageType; +import org.bukkit.entity.SulfurCube; +import org.bukkit.inventory.ItemType; +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.index.qual.Positive; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.Nullable; + +import static io.papermc.paper.util.BoundChecker.requireNonNegative; +import static io.papermc.paper.util.BoundChecker.requirePositive; + +/** + * A data-centric version-specific registry entry for the {@link SulfurCube.Archetype} type. + */ +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface SulfurCubeArchetypeRegistryEntry { + + /** + * An attribute entry to apply to a sulfur cube of this archetype. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface AttributeEntry { + + /** + * {@return the attribute to modify} + */ + TypedKey attribute(); + + /** + * {@return the modifier of the given attribute} + */ + AttributeModifier modifier(); + + /** + * Creates a new attribute entry instance based on the passed values. + * + * @param attribute the attribute to modify, as returned by {@link #attribute()} + * @param modifier the modifier of the given attribute, as returned by {@link #modifier()} + * @return the created instance + */ + @Contract(value = "_, _ -> new", pure = true) + static AttributeEntry of(final TypedKey attribute, final AttributeModifier modifier) { + record Impl(TypedKey attribute, AttributeModifier modifier) implements AttributeEntry { + } + + return new Impl(attribute, modifier); + } + } + + /** + * The contact damage a sulfur cube of this archetype will deal when pushed + * by another entity. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface ContactDamage { + + /** + * {@return the damage type of the damage dealt} + */ + TypedKey damageType(); + + /** + * {@return the damage amount of the damage dealt} + * @apiNote for non-constant damage this will return one possible sample + * instead of the exact amount + */ + @NonNegative float amount(); // todo expose FloatProvider/IntProvider in a consistent way (should match Machine's PR for dimension type) + + /** + * {@return whether the sulfur cube of this damage should be recorded in the + * damage source} + */ + boolean attributeToSource(); + + /** + * Creates a new contact damage instance based on the passed values. + * + * @param damageType the damage type of the damage dealt, as returned by {@link #damageType()} + * @param amount the damage amount of the damage dealt, as returned by {@link #amount()} + * @param attributeToSource whether the sulfur cube of this damage should be recorded, as returned by {@link #attributeToSource()} + * @return the created instance + */ + @Contract(value = "_, _, _ -> new", pure = true) + static ContactDamage of(final TypedKey damageType, final @NonNegative float amount, final boolean attributeToSource) { + record Impl(TypedKey damageType, @NonNegative float amount, boolean attributeToSource) implements ContactDamage { + } + + return new Impl(damageType, requireNonNegative(amount, "amount"), attributeToSource); + } + } + + /** + * The explosion settings of a sulfur cube of this archetype. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface ExplosionSettings { + + /** + * {@return the radius of the explosion} + */ + @NonNegative int power(); + + /** + * {@return whether the explosion will produce fire on the ground} + */ + boolean incendiary(); + + /** + * {@return the amount of ticks needed once the sulfur cube + * is ignited before exploding} + */ + @Positive int fuseTicks(); + + /** + * Creates a new explosion settings instance based on the passed values. + * + * @param power the radius of the explosion, as returned by {@link #power()} + * @param incendiary whether the explosion will produce fire, as returned by {@link #incendiary()} + * @param fuseTicks the amount of ticks needed once the sulfur cube + * is ignited before exploding, as returned by {@link #fuseTicks()} + * @return the created instance + */ + @Contract(value = "_, _, _ -> new", pure = true) + static ExplosionSettings of(final @NonNegative int power, final boolean incendiary, final @Positive int fuseTicks) { + record Impl(@NonNegative int power, boolean incendiary, @Positive int fuseTicks) implements ExplosionSettings { + } + + return new Impl(requireNonNegative(power, "power"), incendiary, requirePositive(fuseTicks, "fuseTicks")); + } + } + + /** + * The knockback modifiers a sulfur cube of this archetype will receive + * when knocked by another entity. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface KnockbackModifiers { + + /** + * {@return the horizontal base power of the knockback to receive before all other environmental/contextual changes} + */ + float horizontalPower(); + + /** + * {@return the vertical base power of the knockback to receive before all other environmental/contextual changes} + */ + float verticalPower(); + + /** + * Creates a new knockback modifiers instance based on the passed values. + * + * @param horizontalPower the horizontal base power of the knockback, as returned by {@link #horizontalPower()} + * @param verticalPower the vertical base power of the knockback, as returned by {@link #verticalPower()} + * @return the created instance + */ + @Contract(value = "_, _ -> new", pure = true) + static KnockbackModifiers of(final float horizontalPower, final float verticalPower) { + record Impl(float horizontalPower, float verticalPower) implements KnockbackModifiers { + } + + return new Impl(horizontalPower, verticalPower); + } + } + + /** + * The sound settings of a sulfur cube of this archetype. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface SoundSettings { + + /** + * {@return the sound played once the sulfur cube is knocked} + */ + TypedKey hitSound(); // todo should take a RegistryHolder but need more thoughts on the create method + + /** + * {@return the sound played once the sulfur cube is pushed} + */ + TypedKey pushSound(); + + /** + * {@return the smallest impulse required to play the push sound} + */ + float pushSoundImpulseThreshold(); + + /** + * {@return the amount of seconds before the push sound can be played again} + */ + float pushSoundCooldown(); + + /** + * Creates a new sound settings instance based on the passed values. + * + * @param hitSound the sound played once the sulfur cube is knocked, as returned by {@link #hitSound()} + * @param pushSound the sound played once the sulfur cube is pushed, as returned by {@link #pushSound()} + * @param pushSoundImpulseThreshold the smallest impulse required to play the push sound, as returned by {@link #pushSoundImpulseThreshold()} + * @param pushSoundCooldown the amount of seconds before the push sound can be played again, as returned by {@link #pushSoundCooldown()} + * @return the created instance + */ + @Contract(value = "_, _, _, _ -> new", pure = true) + static SoundSettings of(final TypedKey hitSound, final TypedKey pushSound, final float pushSoundImpulseThreshold, final float pushSoundCooldown) { + record Impl(TypedKey hitSound, TypedKey pushSound, float pushSoundImpulseThreshold, float pushSoundCooldown) implements SoundSettings { + } + + return new Impl(hitSound, pushSound, pushSoundImpulseThreshold, pushSoundCooldown); + } + } + + /** + * Provides the items a sulfur cube of this archetype can absorb. + * + * @return the items absorbable + */ + RegistryKeySet items(); + + /** + * Provides the attribute modifiers to apply to a sulfur cube of this archetype. + * + * @return the attribute modifiers to apply + */ + List attributeModifiers(); + + /** + * Checks if a sulfur cube of this archetype can float in liquid. + * + * @return the ability of the sulfur cube to float + */ + boolean buoyant(); + + /** + * Provides the explosion settings of a sulfur cube of this archetype. + * If defined the sulfur cube can be ignited like a tnt. + * + * @return the explosion settings + */ + @Nullable ExplosionSettings explosion(); + + /** + * Provides the damage a sulfur cube of this archetype can deal + * when in contact of another entity. + * + * @return the contact damage + */ + @Nullable ContactDamage contactDamage(); + + /** + * Provides the knockback modifiers a sulfur cube of this archetype will receive + * when knocked by another entity. + * + * @return the knockback modifiers + */ + KnockbackModifiers knockbackModifiers(); + + /** + * Provides the sound settings of a sulfur cube of this archetype. + * + * @return the sound settings + */ + SoundSettings soundSettings(); + + /** + * A mutable builder for the {@link SulfurCubeArchetypeRegistryEntry} plugins may change in applicable registry events. + *

+ * The following values are required for each builder: + *

    + *
  • {@link #items(RegistryKeySet)}
  • + *
  • {@link #knockbackModifiers(KnockbackModifiers)}
  • + *
  • {@link #soundSettings(SoundSettings)}
  • + *
+ */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends SulfurCubeArchetypeRegistryEntry, RegistryBuilder { + + /** + * Sets the items a sulfur cube of this archetype can absorb. + * + * @param items the items absorbable + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#items() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder items(RegistryKeySet items); + + /** + * Sets the attribute modifiers to apply to a sulfur cube of this archetype. + * + * @param entries the attribute modifiers to apply + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#attributeModifiers() + */ + @Contract(value = "_ -> this", mutates = "this") + default Builder attributeModifiers(final AttributeEntry... entries) { + return this.attributeModifiers(List.of(entries)); + } + + /** + * Sets the attribute modifiers to apply to a sulfur cube of this archetype. + * + * @param entries the attribute modifiers to apply + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#attributeModifiers() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder attributeModifiers(Iterable entries); + + /** + * Sets the ability of the sulfur cube to float. + * + * @param buoyant the ability of the sulfur cube to float + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#buoyant() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder buoyant(boolean buoyant); + + /** + * Sets the explosion settings of a sulfur cube of this archetype. + * + * @param settings the explosion settings + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#explosion() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder explosion(@Nullable ExplosionSettings settings); + + /** + * Sets the damage a sulfur cube of this archetype can deal + * when in contact of another entity. + * + * @param damage the contact damage + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#contactDamage() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder contactDamage(@Nullable ContactDamage damage); + + /** + * Sets the knockback modifiers a sulfur cube of this archetype will receive + * when knocked by another entity. + * + * @param modifiers the knockback modifiers + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#knockbackModifiers() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder knockbackModifiers(KnockbackModifiers modifiers); + + /** + * Sets the sound settings of a sulfur cube of this archetype. + * + * @param settings the sound settings + * @return this builder instance + * @see SulfurCubeArchetypeRegistryEntry#soundSettings() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder soundSettings(SoundSettings settings); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/WolfVariantRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/WolfVariantRegistryEntry.java index 921c533dd226..464a15cb77b8 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/data/WolfVariantRegistryEntry.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/WolfVariantRegistryEntry.java @@ -16,42 +16,42 @@ public interface WolfVariantRegistryEntry { /** * Provides the client texture asset of the wolf variant for when it is angry, which is the location of the texture to use. * - * @return the client texture asset. + * @return the client texture asset */ ClientTextureAsset angryClientTextureAsset(); /** * Provides the client texture asset of the wolf variant for when it is wild, which is the location of the texture to use. * - * @return the client texture asset. + * @return the client texture asset */ ClientTextureAsset wildClientTextureAsset(); /** * Provides the client texture asset of the wolf variant for when it is tame, which is the location of the texture to use. * - * @return the client texture asset. + * @return the client texture asset */ ClientTextureAsset tameClientTextureAsset(); /** * Provides the client texture asset of the wolf variant for when it is an angry baby. * - * @return the baby angry client texture asset. + * @return the baby angry client texture asset */ ClientTextureAsset babyAngryClientTextureAsset(); /** * Provides the client texture asset of the wolf variant for when it is a wild baby. * - * @return the baby wild client texture asset. + * @return the baby wild client texture asset */ ClientTextureAsset babyWildClientTextureAsset(); /** * Provides the client texture asset of the wolf variant for when it is a tame baby. * - * @return the baby tame client texture asset. + * @return the baby tame client texture asset */ ClientTextureAsset babyTameClientTextureAsset(); @@ -75,8 +75,8 @@ interface Builder extends WolfVariantRegistryEntry, RegistryBuilder new") - static ClientTextureAsset clientTextureAsset(final @KeyPattern String identifier) { + static ClientTextureAsset clientTextureAsset(@KeyPattern final String identifier) { return clientTextureAsset(Key.key(identifier)); } } diff --git a/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java b/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java index 6ae47dac3496..a140ed834dab 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java @@ -14,6 +14,7 @@ import io.papermc.paper.registry.data.JukeboxSongRegistryEntry; import io.papermc.paper.registry.data.PaintingVariantRegistryEntry; import io.papermc.paper.registry.data.PigVariantRegistryEntry; +import io.papermc.paper.registry.data.SulfurCubeArchetypeRegistryEntry; import io.papermc.paper.registry.data.WolfVariantRegistryEntry; import io.papermc.paper.registry.data.ZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.DialogRegistryEntry; @@ -29,6 +30,7 @@ import org.bukkit.entity.Cow; import org.bukkit.entity.Frog; import org.bukkit.entity.Pig; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.Wolf; import org.bukkit.entity.ZombieNautilus; @@ -55,6 +57,7 @@ public final class RegistryEvents { public static final RegistryEventProvider COW_VARIANT = create(RegistryKey.COW_VARIANT); public static final RegistryEventProvider PIG_VARIANT = create(RegistryKey.PIG_VARIANT); public static final RegistryEventProvider ZOMBIE_NAUTILUS_VARIANT = create(RegistryKey.ZOMBIE_NAUTILUS_VARIANT); + public static final RegistryEventProvider SULFUR_CUBE_ARCHETYPE = create(RegistryKey.SULFUR_CUBE_ARCHETYPE); public static final RegistryEventProvider DIALOG = create(RegistryKey.DIALOG); // End generate - RegistryEvents diff --git a/paper-api/src/main/java/io/papermc/paper/registry/holder/RegistryHolder.java b/paper-api/src/main/java/io/papermc/paper/registry/holder/RegistryHolder.java index 06ea3436f342..10e031d33852 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/holder/RegistryHolder.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/holder/RegistryHolder.java @@ -7,6 +7,7 @@ * During the registry loading phase, some values can be references to values to-be-loaded * in the future, or inlined, anonymous values that already exist. This type (and subtypes) represent * that structure. + * * @param the registry's type * @param the type of the registry entry (for inlined values) */ diff --git a/paper-api/src/main/java/io/papermc/paper/tag/EntityTags.java b/paper-api/src/main/java/io/papermc/paper/tag/EntityTags.java index 5f67e2dba644..4d5901947898 100644 --- a/paper-api/src/main/java/io/papermc/paper/tag/EntityTags.java +++ b/paper-api/src/main/java/io/papermc/paper/tag/EntityTags.java @@ -52,7 +52,7 @@ private static EntitySetTag replacedBy(Tag vanillaTag, String legacy * Covers mobs that split into smaller mobs */ public static final EntitySetTag SPLITTING_MOBS = new EntitySetTag(keyFor("splitting_mobs")) - .add(EntityType.SLIME, EntityType.MAGMA_CUBE).lock(); + .add(EntityType.SLIME, EntityType.MAGMA_CUBE, EntityType.SULFUR_CUBE).lock(); /** * Covers all water based mobs diff --git a/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java b/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java index 934d1d3ca490..cfa9fd3700c6 100644 --- a/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java +++ b/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java @@ -1,5 +1,6 @@ package io.papermc.paper.text; +import io.papermc.paper.InternalAPIBridge; import java.io.IOException; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.flattener.ComponentFlattener; @@ -80,9 +81,8 @@ public static Component resolveWithContext(final Component input, final @Nullabl * @return the resolved component * @throws IOException if a syntax error tripped during resolving */ - @SuppressWarnings("deprecation") // using unsafe as a bridge public static Component resolveWithContext(final Component input, final @Nullable CommandSender context, final @Nullable Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { - return Bukkit.getUnsafe().resolveWithContext(input, context, scoreboardSubject, bypassPermissions); + return InternalAPIBridge.get().resolveWithContext(input, context, scoreboardSubject, bypassPermissions); } /** @@ -90,9 +90,8 @@ public static Component resolveWithContext(final Component input, final @Nullabl * * @return a component flattener */ - @SuppressWarnings("deprecation") // using unsafe as a bridge public static ComponentFlattener flattener() { - return Bukkit.getUnsafe().componentFlattener(); + return InternalAPIBridge.get().componentFlattener(); } /** @@ -122,7 +121,7 @@ public static PlainComponentSerializer plainSerializer() { */ @Deprecated(forRemoval = true, since = "1.18.2") public static PlainTextComponentSerializer plainTextSerializer() { - return Bukkit.getUnsafe().plainTextSerializer(); + return PlainTextComponentSerializer.plainText(); } /** @@ -138,7 +137,7 @@ public static PlainTextComponentSerializer plainTextSerializer() { */ @Deprecated(forRemoval = true, since = "1.18.2") public static GsonComponentSerializer gsonSerializer() { - return Bukkit.getUnsafe().gsonComponentSerializer(); + return GsonComponentSerializer.gson(); } /** @@ -155,7 +154,7 @@ public static GsonComponentSerializer gsonSerializer() { */ @Deprecated(forRemoval = true, since = "1.18.2") public static GsonComponentSerializer colorDownsamplingGsonSerializer() { - return Bukkit.getUnsafe().colorDownsamplingGsonComponentSerializer(); + return GsonComponentSerializer.colorDownsamplingGson(); } /** @@ -175,6 +174,6 @@ public static GsonComponentSerializer colorDownsamplingGsonSerializer() { */ @Deprecated(forRemoval = true, since = "1.18.2") public static LegacyComponentSerializer legacySectionSerializer() { - return Bukkit.getUnsafe().legacyComponentSerializer(); + return LegacyComponentSerializer.legacySection(); } } diff --git a/paper-server/src/main/java/io/papermc/paper/util/BoundChecker.java b/paper-api/src/main/java/io/papermc/paper/util/BoundChecker.java similarity index 93% rename from paper-server/src/main/java/io/papermc/paper/util/BoundChecker.java rename to paper-api/src/main/java/io/papermc/paper/util/BoundChecker.java index 86609549d314..5d65576f750d 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/BoundChecker.java +++ b/paper-api/src/main/java/io/papermc/paper/util/BoundChecker.java @@ -1,8 +1,13 @@ package io.papermc.paper.util; +import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; +/** + * @hidden + */ @NullMarked +@ApiStatus.Internal public final class BoundChecker { public static int requireRange(final int value, final String field, final int min, final int max) { @@ -30,7 +35,7 @@ public static float requireRange(final float value, final String field, final fl if (Float.compare(value, min) >= 0 && Float.compare(value, max) <= 0) { return value; } - throw new IllegalArgumentException("argument " + field + " must be in [" + min + "," + max +"]: " + value); + throw new IllegalArgumentException("argument " + field + " must be in [" + min + "," + max + "]: " + value); } public static float requireNonNegative(final float value, final String field) { diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index de21023e1e0e..6dc049664394 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -265,7 +265,7 @@ public static String getIp() { /** * Get world type (level-type setting) for default world. * - * @return the value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1) + * @return the value of level-type (e.g. minecraft:normal, minecraft:flat, minecraft:large_biomes, minecraft:amplified) */ @NotNull public static String getWorldType() { @@ -805,7 +805,7 @@ public static List getWorlds() { * * @return true if the worlds are being ticked, false otherwise. */ - public static boolean isTickingWorlds(){ + public static boolean isTickingWorlds() { return server.isTickingWorlds(); } // Paper end diff --git a/paper-api/src/main/java/org/bukkit/Effect.java b/paper-api/src/main/java/org/bukkit/Effect.java index d2952c7750af..5e3e33ccbbcb 100644 --- a/paper-api/src/main/java/org/bukkit/Effect.java +++ b/paper-api/src/main/java/org/bukkit/Effect.java @@ -442,6 +442,8 @@ public enum Effect { TRIAL_SPAWNER_SPAWN_ITEM(3021, Type.VISUAL, Boolean.class), SOUND_WITH_CHARGE_SHOT(1051, Type.SOUND), + + SOUND_SULFUR_SPIKE_LAND(1052, Type.SOUND) ; // Paper end diff --git a/paper-api/src/main/java/org/bukkit/EntityEffect.java b/paper-api/src/main/java/org/bukkit/EntityEffect.java index 84d2a21a68c7..b85705aff303 100644 --- a/paper-api/src/main/java/org/bukkit/EntityEffect.java +++ b/paper-api/src/main/java/org/bukkit/EntityEffect.java @@ -201,7 +201,7 @@ public enum EntityEffect { *

* This will cause client-glitches! */ - TNT_MINECART_IGNITE(10, ExplosiveMinecart.class), + TNT_MINECART_IGNITE(70, ExplosiveMinecart.class), /** * When an Iron Golem gives a rose. */ diff --git a/paper-api/src/main/java/org/bukkit/GameEvent.java b/paper-api/src/main/java/org/bukkit/GameEvent.java index 9627a90843db..5ec417a75e3d 100644 --- a/paper-api/src/main/java/org/bukkit/GameEvent.java +++ b/paper-api/src/main/java/org/bukkit/GameEvent.java @@ -30,6 +30,8 @@ public abstract class GameEvent implements Keyed { public static final GameEvent BLOCK_PLACE = getEvent("block_place"); + public static final GameEvent BOUNCE = getEvent("bounce"); + public static final GameEvent CONTAINER_CLOSE = getEvent("container_close"); public static final GameEvent CONTAINER_OPEN = getEvent("container_open"); diff --git a/paper-api/src/main/java/org/bukkit/JukeboxSong.java b/paper-api/src/main/java/org/bukkit/JukeboxSong.java index 3dd6d79abccb..67bf2ae75e42 100644 --- a/paper-api/src/main/java/org/bukkit/JukeboxSong.java +++ b/paper-api/src/main/java/org/bukkit/JukeboxSong.java @@ -22,6 +22,8 @@ public interface JukeboxSong extends Keyed, Translatable { JukeboxSong BLOCKS = get("blocks"); + JukeboxSong BOUNCE = get("bounce"); + JukeboxSong CAT = get("cat"); JukeboxSong CHIRP = get("chirp"); diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 8ead81efe82f..16c5ab03ad07 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -90,11 +90,10 @@ import org.bukkit.block.data.type.MossyCarpet; import org.bukkit.block.data.type.NoteBlock; import org.bukkit.block.data.type.Observer; -import org.bukkit.block.data.type.PinkPetals; import org.bukkit.block.data.type.Piston; import org.bukkit.block.data.type.PistonHead; import org.bukkit.block.data.type.PitcherCrop; -import org.bukkit.block.data.type.PointedDripstone; +import org.bukkit.block.data.type.PotentSulfur; import org.bukkit.block.data.type.RedstoneRail; import org.bukkit.block.data.type.RedstoneWallTorch; import org.bukkit.block.data.type.RedstoneWire; @@ -114,6 +113,7 @@ import org.bukkit.block.data.type.Slab; import org.bukkit.block.data.type.SmallDripleaf; import org.bukkit.block.data.type.Snow; +import org.bukkit.block.data.type.Speleothem; import org.bukkit.block.data.type.Stairs; import org.bukkit.block.data.type.StructureBlock; import org.bukkit.block.data.type.Switch; @@ -435,6 +435,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla MUSIC_DISC_11(-1), MUSIC_DISC_13(-1), MUSIC_DISC_BLOCKS(-1), + MUSIC_DISC_BOUNCE(-1), MUSIC_DISC_CAT(-1), MUSIC_DISC_CHIRP(-1), MUSIC_DISC_CREATOR(-1), @@ -584,6 +585,8 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla STRIDER_SPAWN_EGG(-1), STRING(-1), SUGAR(-1), + SULFUR_CUBE_BUCKET(-1), + SULFUR_CUBE_SPAWN_EGG(-1), SUSPICIOUS_STEW(-1), SWEET_BERRIES(-1), TADPOLE_BUCKET(-1), @@ -830,6 +833,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla CHEST(-1, Chest.class), CHIPPED_ANVIL(-1, Directional.class), CHISELED_BOOKSHELF(-1, ChiseledBookshelf.class), + CHISELED_CINNABAR(-1), CHISELED_COPPER(-1), CHISELED_DEEPSLATE(-1), CHISELED_NETHER_BRICKS(-1), @@ -839,10 +843,19 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla CHISELED_RESIN_BRICKS(-1), CHISELED_SANDSTONE(-1), CHISELED_STONE_BRICKS(-1), + CHISELED_SULFUR(-1), CHISELED_TUFF(-1), CHISELED_TUFF_BRICKS(-1), CHORUS_FLOWER(-1, Ageable.class), CHORUS_PLANT(-1, MultipleFacing.class), + CINNABAR(-1), + CINNABAR_BRICK_SLAB(-1, Slab.class), + CINNABAR_BRICK_STAIRS(-1, Stairs.class), + CINNABAR_BRICK_WALL(-1, Wall.class), + CINNABAR_BRICKS(-1), + CINNABAR_SLAB(-1, Slab.class), + CINNABAR_STAIRS(-1, Stairs.class), + CINNABAR_WALL(-1, Wall.class), CLAY(-1), CLOSED_EYEBLOSSOM(-1), COAL_BLOCK(-1), @@ -1376,7 +1389,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla PLAYER_HEAD(-1, Skull.class), PLAYER_WALL_HEAD(-1, WallSkull.class), PODZOL(-1, Snowable.class), - POINTED_DRIPSTONE(-1, PointedDripstone.class), + POINTED_DRIPSTONE(-1, Speleothem.class), POLISHED_ANDESITE(-1), POLISHED_ANDESITE_SLAB(-1, Slab.class), POLISHED_ANDESITE_STAIRS(-1, Stairs.class), @@ -1391,6 +1404,10 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla POLISHED_BLACKSTONE_SLAB(-1, Slab.class), POLISHED_BLACKSTONE_STAIRS(-1, Stairs.class), POLISHED_BLACKSTONE_WALL(-1, Wall.class), + POLISHED_CINNABAR(-1), + POLISHED_CINNABAR_SLAB(-1, Slab.class), + POLISHED_CINNABAR_STAIRS(-1, Stairs.class), + POLISHED_CINNABAR_WALL(-1, Wall.class), POLISHED_DEEPSLATE(-1), POLISHED_DEEPSLATE_SLAB(-1, Slab.class), POLISHED_DEEPSLATE_STAIRS(-1, Stairs.class), @@ -1401,12 +1418,17 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla POLISHED_GRANITE(-1), POLISHED_GRANITE_SLAB(-1, Slab.class), POLISHED_GRANITE_STAIRS(-1, Stairs.class), + POLISHED_SULFUR(-1), + POLISHED_SULFUR_SLAB(-1, Slab.class), + POLISHED_SULFUR_STAIRS(-1, Stairs.class), + POLISHED_SULFUR_WALL(-1, Wall.class), POLISHED_TUFF(-1), POLISHED_TUFF_SLAB(-1, Slab.class), POLISHED_TUFF_STAIRS(-1, Stairs.class), POLISHED_TUFF_WALL(-1, Wall.class), POPPY(-1), POTATOES(-1, Ageable.class), + POTENT_SULFUR(-1, PotentSulfur.class), POTTED_ACACIA_SAPLING(-1), POTTED_ALLIUM(-1), POTTED_AZALEA_BUSH(-1), @@ -1633,6 +1655,15 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla STRUCTURE_BLOCK(-1, StructureBlock.class), STRUCTURE_VOID(-1), SUGAR_CANE(-1, Ageable.class), + SULFUR(-1), + SULFUR_BRICK_SLAB(-1, Slab.class), + SULFUR_BRICK_STAIRS(-1, Stairs.class), + SULFUR_BRICK_WALL(-1, Wall.class), + SULFUR_BRICKS(-1), + SULFUR_SLAB(-1, Slab.class), + SULFUR_SPIKE(-1, Speleothem.class), + SULFUR_STAIRS(-1, Stairs.class), + SULFUR_WALL(-1, Wall.class), SUNFLOWER(-1, Bisected.class), SUSPICIOUS_GRAVEL(-1, Brushable.class), SUSPICIOUS_SAND(-1, Brushable.class), diff --git a/paper-api/src/main/java/org/bukkit/MusicInstrument.java b/paper-api/src/main/java/org/bukkit/MusicInstrument.java index 7f7b1d606d84..a382646256d1 100644 --- a/paper-api/src/main/java/org/bukkit/MusicInstrument.java +++ b/paper-api/src/main/java/org/bukkit/MusicInstrument.java @@ -46,7 +46,7 @@ public static MusicInstrument create(final Consumer 1, "waterBlocks must be positive"); + this.waterBlocks = waterBlocks; + } + + /** + * The number of water blocks below the geyser + * which scale the particle size and its burst impulse. + * + * @return the number of water blocks + */ + public int getWaterBlocks() { + return waterBlocks; + } + } } diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index dd8ad5976eb4..62341f72e845 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -213,7 +213,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi /** * Get world type (level-type setting) for default world. * - * @return the value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1) + * @return the value of level-type (e.g. minecraft:normal, minecraft:flat, minecraft:large_biomes, minecraft:amplified) */ @NotNull public String getWorldType(); @@ -1380,7 +1380,6 @@ default int broadcast(net.kyori.adventure.text.@NotNull Component message) { * @return an offline player * @see #getOfflinePlayer(java.util.UUID) */ - // @Deprecated(since = "1.7.5") // Paper @NotNull public OfflinePlayer getOfflinePlayer(@NotNull String name); @@ -2410,9 +2409,8 @@ public org.bukkit.configuration.file.YamlConfiguration getConfig() { // Paper start @Deprecated(since = "1.21.4", forRemoval = true) @NotNull - public org.bukkit.configuration.file.YamlConfiguration getBukkitConfig() - { - throw new UnsupportedOperationException( "Not supported yet." ); + public org.bukkit.configuration.file.YamlConfiguration getBukkitConfig() { + throw new UnsupportedOperationException("Not supported yet."); } /** @@ -2424,8 +2422,7 @@ public org.bukkit.configuration.file.YamlConfiguration getBukkitConfig() */ @Deprecated(since = "1.21.4", forRemoval = true) @NotNull - public org.bukkit.configuration.file.YamlConfiguration getSpigotConfig() - { + public org.bukkit.configuration.file.YamlConfiguration getSpigotConfig() { throw new UnsupportedOperationException("Not supported yet."); } @@ -2438,8 +2435,7 @@ public org.bukkit.configuration.file.YamlConfiguration getSpigotConfig() */ @Deprecated(since = "1.21.4", forRemoval = true) @NotNull - public org.bukkit.configuration.file.YamlConfiguration getPaperConfig() - { + public org.bukkit.configuration.file.YamlConfiguration getPaperConfig() { throw new UnsupportedOperationException("Not supported yet."); } // Paper end diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index 6c3c6cecb75f..d49582493850 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -410,6 +410,16 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound BLOCK_CHORUS_FLOWER_GROW = getSound("block.chorus_flower.grow"); + Sound BLOCK_CINNABAR_BREAK = getSound("block.cinnabar.break"); + + Sound BLOCK_CINNABAR_FALL = getSound("block.cinnabar.fall"); + + Sound BLOCK_CINNABAR_HIT = getSound("block.cinnabar.hit"); + + Sound BLOCK_CINNABAR_PLACE = getSound("block.cinnabar.place"); + + Sound BLOCK_CINNABAR_STEP = getSound("block.cinnabar.step"); + Sound BLOCK_COBWEB_BREAK = getSound("block.cobweb.break"); Sound BLOCK_COBWEB_FALL = getSound("block.cobweb.fall"); @@ -1168,6 +1178,26 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound BLOCK_PORTAL_TRIGGER = getSound("block.portal.trigger"); + Sound BLOCK_POTENT_SULFUR_BREAK = getSound("block.potent_sulfur.break"); + + Sound BLOCK_POTENT_SULFUR_FALL = getSound("block.potent_sulfur.fall"); + + Sound BLOCK_POTENT_SULFUR_GEYSER_CONTINUOUS_ERUPTION = getSound("block.potent_sulfur.geyser_continuous_eruption"); + + Sound BLOCK_POTENT_SULFUR_GEYSER_CONTINUOUS_ERUPTION_ACTIVE = getSound("block.potent_sulfur.geyser_continuous_eruption_active"); + + Sound BLOCK_POTENT_SULFUR_GEYSER_ERUPTION = getSound("block.potent_sulfur.geyser_eruption"); + + Sound BLOCK_POTENT_SULFUR_GEYSER_ERUPTION_ACTIVE = getSound("block.potent_sulfur.geyser_eruption_active"); + + Sound BLOCK_POTENT_SULFUR_HIT = getSound("block.potent_sulfur.hit"); + + Sound BLOCK_POTENT_SULFUR_NOXIOUS_GAS = getSound("block.potent_sulfur.noxious_gas"); + + Sound BLOCK_POTENT_SULFUR_PLACE = getSound("block.potent_sulfur.place"); + + Sound BLOCK_POTENT_SULFUR_STEP = getSound("block.potent_sulfur.step"); + Sound BLOCK_POWDER_SNOW_BREAK = getSound("block.powder_snow.break"); Sound BLOCK_POWDER_SNOW_FALL = getSound("block.powder_snow.fall"); @@ -1474,6 +1504,28 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound BLOCK_STONE_PRESSURE_PLATE_CLICK_ON = getSound("block.stone_pressure_plate.click_on"); + Sound BLOCK_SULFUR_BREAK = getSound("block.sulfur.break"); + + Sound BLOCK_SULFUR_FALL = getSound("block.sulfur.fall"); + + Sound BLOCK_SULFUR_HIT = getSound("block.sulfur.hit"); + + Sound BLOCK_SULFUR_PLACE = getSound("block.sulfur.place"); + + Sound BLOCK_SULFUR_STEP = getSound("block.sulfur.step"); + + Sound BLOCK_SULFUR_SPIKE_BREAK = getSound("block.sulfur_spike.break"); + + Sound BLOCK_SULFUR_SPIKE_FALL = getSound("block.sulfur_spike.fall"); + + Sound BLOCK_SULFUR_SPIKE_HIT = getSound("block.sulfur_spike.hit"); + + Sound BLOCK_SULFUR_SPIKE_LAND = getSound("block.sulfur_spike.land"); + + Sound BLOCK_SULFUR_SPIKE_PLACE = getSound("block.sulfur_spike.place"); + + Sound BLOCK_SULFUR_SPIKE_STEP = getSound("block.sulfur_spike.step"); + Sound BLOCK_SUSPICIOUS_GRAVEL_BREAK = getSound("block.suspicious_gravel.break"); Sound BLOCK_SUSPICIOUS_GRAVEL_FALL = getSound("block.suspicious_gravel.fall"); @@ -3006,6 +3058,16 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_SLIME_SQUISH_SMALL = getSound("entity.slime.squish_small"); + Sound ENTITY_SMALL_SULFUR_CUBE_DEATH = getSound("entity.small_sulfur_cube.death"); + + Sound ENTITY_SMALL_SULFUR_CUBE_EAT = getSound("entity.small_sulfur_cube.eat"); + + Sound ENTITY_SMALL_SULFUR_CUBE_HURT = getSound("entity.small_sulfur_cube.hurt"); + + Sound ENTITY_SMALL_SULFUR_CUBE_JUMP = getSound("entity.small_sulfur_cube.jump"); + + Sound ENTITY_SMALL_SULFUR_CUBE_SQUISH = getSound("entity.small_sulfur_cube.squish"); + Sound ENTITY_SNIFFER_DEATH = getSound("entity.sniffer.death"); Sound ENTITY_SNIFFER_DIGGING = getSound("entity.sniffer.digging"); @@ -3088,6 +3150,68 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_STRIDER_STEP_LAVA = getSound("entity.strider.step_lava"); + Sound ENTITY_SULFUR_CUBE_ABSORB = getSound("entity.sulfur_cube.absorb"); + + Sound ENTITY_SULFUR_CUBE_BOUNCE = getSound("entity.sulfur_cube.bounce"); + + Sound ENTITY_SULFUR_CUBE_BOUNCY_HIT = getSound("entity.sulfur_cube.bouncy.hit"); + + Sound ENTITY_SULFUR_CUBE_BOUNCY_PUSH = getSound("entity.sulfur_cube.bouncy.push"); + + Sound ENTITY_SULFUR_CUBE_DEATH = getSound("entity.sulfur_cube.death"); + + Sound ENTITY_SULFUR_CUBE_EJECT = getSound("entity.sulfur_cube.eject"); + + Sound ENTITY_SULFUR_CUBE_EXPLOSIVE_HIT = getSound("entity.sulfur_cube.explosive.hit"); + + Sound ENTITY_SULFUR_CUBE_EXPLOSIVE_PUSH = getSound("entity.sulfur_cube.explosive.push"); + + Sound ENTITY_SULFUR_CUBE_FAST_FLAT_HIT = getSound("entity.sulfur_cube.fast_flat.hit"); + + Sound ENTITY_SULFUR_CUBE_FAST_FLAT_PUSH = getSound("entity.sulfur_cube.fast_flat.push"); + + Sound ENTITY_SULFUR_CUBE_FAST_SLIDING_HIT = getSound("entity.sulfur_cube.fast_sliding.hit"); + + Sound ENTITY_SULFUR_CUBE_FAST_SLIDING_PUSH = getSound("entity.sulfur_cube.fast_sliding.push"); + + Sound ENTITY_SULFUR_CUBE_HIGH_RESISTANCE_HIT = getSound("entity.sulfur_cube.high_resistance.hit"); + + Sound ENTITY_SULFUR_CUBE_HIGH_RESISTANCE_PUSH = getSound("entity.sulfur_cube.high_resistance.push"); + + Sound ENTITY_SULFUR_CUBE_HOT_HIT = getSound("entity.sulfur_cube.hot.hit"); + + Sound ENTITY_SULFUR_CUBE_HOT_PUSH = getSound("entity.sulfur_cube.hot.push"); + + Sound ENTITY_SULFUR_CUBE_HURT = getSound("entity.sulfur_cube.hurt"); + + Sound ENTITY_SULFUR_CUBE_JUMP = getSound("entity.sulfur_cube.jump"); + + Sound ENTITY_SULFUR_CUBE_LIGHT_HIT = getSound("entity.sulfur_cube.light.hit"); + + Sound ENTITY_SULFUR_CUBE_LIGHT_PUSH = getSound("entity.sulfur_cube.light.push"); + + Sound ENTITY_SULFUR_CUBE_REGULAR_HIT = getSound("entity.sulfur_cube.regular.hit"); + + Sound ENTITY_SULFUR_CUBE_REGULAR_PUSH = getSound("entity.sulfur_cube.regular.push"); + + Sound ENTITY_SULFUR_CUBE_SLOW_BOUNCY_HIT = getSound("entity.sulfur_cube.slow_bouncy.hit"); + + Sound ENTITY_SULFUR_CUBE_SLOW_BOUNCY_PUSH = getSound("entity.sulfur_cube.slow_bouncy.push"); + + Sound ENTITY_SULFUR_CUBE_SLOW_FLAT_HIT = getSound("entity.sulfur_cube.slow_flat.hit"); + + Sound ENTITY_SULFUR_CUBE_SLOW_FLAT_PUSH = getSound("entity.sulfur_cube.slow_flat.push"); + + Sound ENTITY_SULFUR_CUBE_SLOW_SLIDING_HIT = getSound("entity.sulfur_cube.slow_sliding.hit"); + + Sound ENTITY_SULFUR_CUBE_SLOW_SLIDING_PUSH = getSound("entity.sulfur_cube.slow_sliding.push"); + + Sound ENTITY_SULFUR_CUBE_SQUISH = getSound("entity.sulfur_cube.squish"); + + Sound ENTITY_SULFUR_CUBE_STICKY_HIT = getSound("entity.sulfur_cube.sticky.hit"); + + Sound ENTITY_SULFUR_CUBE_STICKY_PUSH = getSound("entity.sulfur_cube.sticky.push"); + Sound ENTITY_TADPOLE_DEATH = getSound("entity.tadpole.death"); Sound ENTITY_TADPOLE_FLOP = getSound("entity.tadpole.flop"); @@ -3532,6 +3656,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_BUCKET_EMPTY_POWDER_SNOW = getSound("item.bucket.empty_powder_snow"); + Sound ITEM_BUCKET_EMPTY_SULFUR_CUBE = getSound("item.bucket.empty_sulfur_cube"); + Sound ITEM_BUCKET_EMPTY_TADPOLE = getSound("item.bucket.empty_tadpole"); Sound ITEM_BUCKET_FILL = getSound("item.bucket.fill"); @@ -3544,6 +3670,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_BUCKET_FILL_POWDER_SNOW = getSound("item.bucket.fill_powder_snow"); + Sound ITEM_BUCKET_FILL_SULFUR_CUBE = getSound("item.bucket.fill_sulfur_cube"); + Sound ITEM_BUCKET_FILL_TADPOLE = getSound("item.bucket.fill_tadpole"); Sound ITEM_BUNDLE_DROP_CONTENTS = getSound("item.bundle.drop_contents"); @@ -3754,6 +3882,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound MUSIC_OVERWORLD_STONY_PEAKS = getSound("music.overworld.stony_peaks"); + Sound MUSIC_OVERWORLD_SULFUR_CAVES = getSound("music.overworld.sulfur_caves"); + Sound MUSIC_OVERWORLD_SWAMP = getSound("music.overworld.swamp"); Sound MUSIC_UNDER_WATER = getSound("music.under_water"); @@ -3766,6 +3896,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound MUSIC_DISC_BLOCKS = getSound("music_disc.blocks"); + Sound MUSIC_DISC_BOUNCE = getSound("music_disc.bounce"); + Sound MUSIC_DISC_CAT = getSound("music_disc.cat"); Sound MUSIC_DISC_CHIRP = getSound("music_disc.chirp"); diff --git a/paper-api/src/main/java/org/bukkit/Tag.java b/paper-api/src/main/java/org/bukkit/Tag.java index 7e2f386ce22f..349e2ddc04fc 100644 --- a/paper-api/src/main/java/org/bukkit/Tag.java +++ b/paper-api/src/main/java/org/bukkit/Tag.java @@ -100,6 +100,10 @@ public interface Tag extends Keyed { Tag CAULDRONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cauldrons"), Material.class); + Tag CAUSES_CONTINUOUS_GEYSER_ERUPTIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("causes_continuous_geyser_eruptions"), Material.class); + + Tag CAUSES_PERIODIC_GEYSER_ERUPTIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("causes_periodic_geyser_eruptions"), Material.class); + Tag CAVE_VINES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cave_vines"), Material.class); Tag CEILING_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ceiling_hanging_signs"), Material.class); @@ -116,7 +120,9 @@ public interface Tag extends Keyed { Tag COMPLETES_FIND_TREE_TUTORIAL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("completes_find_tree_tutorial"), Material.class); - Tag CONCRETE_POWDER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("concrete_powder"), Material.class); + Tag CONCRETE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("concrete"), Material.class); + + Tag CONCRETE_POWDERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("concrete_powders"), Material.class); Tag CONVERTABLE_TO_MUD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("convertable_to_mud"), Material.class); @@ -146,6 +152,8 @@ public interface Tag extends Keyed { Tag DEEPSLATE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("deepslate_ore_replaceables"), Material.class); + Tag DEFAULT_IMMUNE_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("default_immune_to"), Material.class); + Tag DIAMOND_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("diamond_ores"), Material.class); Tag DIRT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt"), Material.class); @@ -190,6 +198,8 @@ public interface Tag extends Keyed { Tag FOREST_ROCK_CAN_PLACE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("forest_rock_can_place_on"), Material.class); + Tag FOX_IMMUNE_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fox_immune_to"), Material.class); + Tag FOXES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("foxes_spawnable_on"), Material.class); Tag FROG_PREFER_JUMP_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("frog_prefer_jump_to"), Material.class); @@ -198,6 +208,8 @@ public interface Tag extends Keyed { Tag GEODE_INVALID_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("geode_invalid_blocks"), Material.class); + Tag GLAZED_TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("glazed_terracotta"), Material.class); + Tag GOATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("goats_spawnable_on"), Material.class); Tag GOLD_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("gold_ores"), Material.class); @@ -320,6 +332,8 @@ public interface Tag extends Keyed { Tag PLANKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("planks"), Material.class); + Tag POLAR_BEAR_IMMUNE_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("polar_bear_immune_to"), Material.class); + Tag POLAR_BEARS_SPAWNABLE_ON_ALTERNATE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("polar_bears_spawnable_on_alternate"), Material.class); Tag PORTALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("portals"), Material.class); @@ -350,6 +364,12 @@ public interface Tag extends Keyed { Tag SCULK_REPLACEABLE_WORLD_GEN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sculk_replaceable_world_gen"), Material.class); + Tag SHEARS_EXTREME_BREAKING_SPEED = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("shears_extreme_breaking_speed"), Material.class); + + Tag SHEARS_MAJOR_BREAKING_SPEED = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("shears_major_breaking_speed"), Material.class); + + Tag SHEARS_MINOR_BREAKING_SPEED = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("shears_minor_breaking_speed"), Material.class); + Tag SHULKER_BOXES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("shulker_boxes"), Material.class); Tag SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("signs"), Material.class); @@ -368,10 +388,14 @@ public interface Tag extends Keyed { Tag SNOW = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow"), Material.class); + Tag SNOW_GOLEM_IMMUNE_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow_golem_immune_to"), Material.class); + Tag SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class); Tag SOUL_SPEED_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_speed_blocks"), Material.class); + Tag SPELEOTHEMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("speleothems"), Material.class); + Tag SPRUCE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("spruce_logs"), Material.class); Tag STAIRS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stairs"), Material.class); @@ -386,10 +410,14 @@ public interface Tag extends Keyed { Tag STONE_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_pressure_plates"), Material.class); + Tag STRAY_IMMUNE_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stray_immune_to"), Material.class); + Tag STRIDER_WARM_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("strider_warm_blocks"), Material.class); Tag SUBSTRATE_OVERWORLD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("substrate_overworld"), Material.class); + Tag SULFUR_SPIKE_REPLACEABLE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sulfur_spike_replaceable_blocks"), Material.class); + Tag SUPPORT_OVERRIDE_CACTUS_FLOWER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("support_override_cactus_flower"), Material.class); Tag SUPPORT_OVERRIDE_SNOW_LAYER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("support_override_snow_layer"), Material.class); @@ -454,6 +482,8 @@ public interface Tag extends Keyed { Tag SUPPORTS_WITHER_ROSE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("supports_wither_rose"), Material.class); + Tag SUPPRESSES_BOUNCE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("suppresses_bounce"), Material.class); + Tag SWORD_EFFICIENT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sword_efficient"), Material.class); Tag SWORD_INSTANTLY_MINES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sword_instantly_mines"), Material.class); @@ -494,6 +524,10 @@ public interface Tag extends Keyed { Tag WITHER_IMMUNE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_immune"), Material.class); + Tag WITHER_IMMUNE_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_immune_to"), Material.class); + + Tag WITHER_SKELETON_IMMUNE_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_skeleton_immune_to"), Material.class); + Tag WITHER_SUMMON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_summon_base_blocks"), Material.class); Tag WOLVES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wolves_spawnable_on"), Material.class); @@ -592,6 +626,10 @@ public interface Tag extends Keyed { Tag ITEMS_COMPLETES_FIND_TREE_TUTORIAL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("completes_find_tree_tutorial"), Material.class); + Tag ITEMS_CONCRETE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("concrete"), Material.class); + + Tag ITEMS_CONCRETE_POWDERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("concrete_powders"), Material.class); + Tag ITEMS_COPPER = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("copper"), Material.class); Tag ITEMS_COPPER_CHESTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("copper_chests"), Material.class); @@ -698,6 +736,8 @@ public interface Tag extends Keyed { Tag ITEMS_GAZE_DISGUISE_EQUIPMENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gaze_disguise_equipment"), Material.class); + Tag ITEMS_GLAZED_TERRACOTTA = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("glazed_terracotta"), Material.class); + Tag ITEMS_GOAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("goat_food"), Material.class); Tag ITEMS_GOLD_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gold_ores"), Material.class); @@ -882,6 +922,34 @@ public interface Tag extends Keyed { Tag ITEMS_STRIDER_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("strider_tempt_items"), Material.class); + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_BOUNCY = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/bouncy"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_EXPLOSIVE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/explosive"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_FAST_FLAT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/fast_flat"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_FAST_SLIDING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/fast_sliding"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_HIGH_RESISTANCE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/high_resistance"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_HOT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/hot"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_LIGHT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/light"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_REGULAR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/regular"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_SLOW_BOUNCY = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/slow_bouncy"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_SLOW_FLAT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/slow_flat"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_SLOW_SLIDING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/slow_sliding"), Material.class); + + Tag ITEMS_SULFUR_CUBE_ARCHETYPE_STICKY = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_archetype/sticky"), Material.class); + + Tag ITEMS_SULFUR_CUBE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_food"), Material.class); + + Tag ITEMS_SULFUR_CUBE_SWALLOWABLE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sulfur_cube_swallowable"), Material.class); + Tag ITEMS_SWORDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("swords"), Material.class); Tag ITEMS_TERRACOTTA = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("terracotta"), Material.class); @@ -1022,6 +1090,8 @@ public interface Tag extends Keyed { Tag ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class); + Tag ENTITY_TYPES_NOT_AFFECTED_BY_GEYSERS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("not_affected_by_geysers"), EntityType.class); + Tag ENTITY_TYPES_NOT_SCARY_FOR_PUFFERFISH = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("not_scary_for_pufferfish"), EntityType.class); Tag ENTITY_TYPES_POWDER_SNOW_WALKABLE_MOBS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("powder_snow_walkable_mobs"), EntityType.class); @@ -1117,6 +1187,11 @@ public interface Tag extends Keyed { */ @Deprecated(since = "1.21.4", forRemoval = true) Tag DRIPSTONE_REPLACEABLE = DRIPSTONE_REPLACEABLE_BLOCKS; + /** + * @deprecated replaced by {@link #CONCRETE_POWDERS} + */ + @Deprecated(since = "26.2", forRemoval = true) + Tag CONCRETE_POWDER = CONCRETE_POWDERS; /** * Vanilla item tag representing all piglin food. * diff --git a/paper-api/src/main/java/org/bukkit/Translatable.java b/paper-api/src/main/java/org/bukkit/Translatable.java index fd1629c2d202..3e968f56ac78 100644 --- a/paper-api/src/main/java/org/bukkit/Translatable.java +++ b/paper-api/src/main/java/org/bukkit/Translatable.java @@ -5,6 +5,7 @@ /** * Represents an object with a text representation that can be translated by the * Minecraft client. + * * @deprecated use {@link net.kyori.adventure.translation.Translatable} */ @Deprecated(forRemoval = true) // Paper diff --git a/paper-api/src/main/java/org/bukkit/UnsafeValues.java b/paper-api/src/main/java/org/bukkit/UnsafeValues.java index cff5d4681e6e..b3574dd72345 100644 --- a/paper-api/src/main/java/org/bukkit/UnsafeValues.java +++ b/paper-api/src/main/java/org/bukkit/UnsafeValues.java @@ -1,20 +1,13 @@ package org.bukkit; -import com.google.common.collect.Multimap; import io.papermc.paper.entity.EntitySerializationFlag; import io.papermc.paper.registry.RegistryKey; +import java.util.Map; import net.kyori.adventure.text.event.HoverEvent; import org.bukkit.advancement.Advancement; -import org.bukkit.attribute.Attribute; -import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.data.BlockData; -import org.bukkit.damage.DamageSource; -import org.bukkit.damage.DamageType; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.inventory.CreativeCategory; -import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.plugin.InvalidPluginException; @@ -23,7 +16,6 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; /** * This interface provides value conversions that may be specific to a @@ -35,15 +27,6 @@ */ @Deprecated(since = "1.7.2") public interface UnsafeValues { - // Paper start - net.kyori.adventure.text.flattener.ComponentFlattener componentFlattener(); - @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer(); - @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer(); - @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer(); - @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer(); - @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer(); - net.kyori.adventure.text.Component resolveWithContext(net.kyori.adventure.text.Component component, org.bukkit.command.CommandSender context, org.bukkit.entity.Entity scoreboardSubject, boolean bypassPermissions) throws java.io.IOException; - // Paper end Material toLegacy(Material material); @@ -96,27 +79,6 @@ public interface UnsafeValues { */ boolean removeAdvancement(NamespacedKey key); - @Deprecated(since = "1.21", forRemoval = true) - Multimap getDefaultAttributeModifiers(Material material, EquipmentSlot slot); - - @Deprecated(since = "1.21", forRemoval = true) - CreativeCategory getCreativeCategory(Material material); - - @Deprecated(since = "1.21", forRemoval = true) - String getBlockTranslationKey(Material material); - - @Deprecated(since = "1.21", forRemoval = true) - String getItemTranslationKey(Material material); - - String getTranslationKey(EntityType entityType); - - String getTranslationKey(ItemStack itemStack); - - @Deprecated(since = "1.21.3", forRemoval = true) - String getTranslationKey(Attribute attribute); - - // Paper - replace with better system - /** * Do not use, method will get removed, and the plugin won't run * @@ -127,18 +89,8 @@ public interface UnsafeValues { @Deprecated(since = "1.20.2", forRemoval = true) PotionType.InternalPotionData getInternalPotionData(NamespacedKey key); - /** - * Create a new {@link DamageSource.Builder}. - * - * @param damageType the {@link DamageType} to use - * @return a {@link DamageSource.Builder} - */ - @ApiStatus.Internal - @NotNull - DamageSource.Builder createDamageSourceBuilder(@NotNull DamageType damageType); - @ApiStatus.Internal - String get(Class aClass, String value); + String get(Class elementClass, String value); @ApiStatus.Internal @Nullable B get(RegistryKey registry, NamespacedKey key); @@ -154,17 +106,6 @@ static boolean isLegacyPlugin(org.bukkit.plugin.Plugin plugin) { // Paper end // Paper start - /** - * Called once by the version command on first use, then cached. - */ - default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { - return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher(); - } - - byte[] serializeItem(ItemStack item); - - ItemStack deserializeItem(byte[] data); - /** * Serializes this itemstack to json format. * It is safe for data migrations as it will use the built-in data converter instead of bukkit's @@ -276,7 +217,7 @@ default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { *

* Use this when sending custom packets, so that there are no collisions on the client or server. */ - public int nextEntityId(); + int nextEntityId(final World world); /** * Just don't use it. @@ -289,100 +230,8 @@ default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { * @return the server's protocol version */ int getProtocolVersion(); - - /** - * Checks if an itemstack can be repaired with another itemstack. - * Returns false if either argument's type is not an item ({@link Material#isItem()}). - * - * @param itemToBeRepaired the itemstack to be repaired - * @param repairMaterial the repair material - * @return true if valid repair, false if not - */ - public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial); - - /** - * Checks if the entity represented by the namespaced key has default attributes. - * - * @param entityKey the entity's key - * @return true if it has default attributes - */ - boolean hasDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey); - - /** - * Gets the default attributes for the entity represented by the namespaced key. - * - * @param entityKey the entity's key - * @return an unmodifiable instance of Attributable for reading default attributes. - * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first) - */ - @org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey); // Paper end - // Paper start - namespaced key biome methods - /** - * Gets the {@link NamespacedKey} for the biome at the given location. - * - * @param accessor The {@link RegionAccessor} of the provided coordinates - * @param x X-coordinate of the block - * @param y Y-coordinate of the block - * @param z Z-coordinate of the block - * @deprecated custom biomes are properly supported in API now - * @return the biome's {@link NamespacedKey} - */ - @org.jetbrains.annotations.NotNull - @Deprecated(since = "1.21.3", forRemoval = true) - NamespacedKey getBiomeKey(RegionAccessor accessor, int x, int y, int z); - - /** - * Sets the biome at the given location to a biome registered - * to the given {@link NamespacedKey}. If no biome by the given - * {@link NamespacedKey} exists, an {@link IllegalStateException} - * will be thrown. - * - * @param accessor The {@link RegionAccessor} of the provided coordinates - * @param x X-coordinate of the block - * @param y Y-coordinate of the block - * @param z Z-coordinate of the block - * @param biomeKey Biome key - * @deprecated custom biomes are properly supported in API now - * @throws IllegalStateException if no biome by the given key is registered. - */ - @Deprecated(since = "1.21.3", forRemoval = true) - void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey); - // Paper end - namespaced key biome methods - - String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); // Paper - fix custom stats criteria creation - - // Paper start - spawn egg color visibility - /** - * Obtains the underlying color informating for a spawn egg of a given - * entity type, or {@code null} if the entity passed does not have a spawn egg. - * Spawn eggs have two colors - the background layer (0), and the - * foreground layer (1) - * - * @param entityType the entity type to get the color for - * @param layer the texture layer to get a color for - * @return the color of the layer for the entity's spawn egg - * @deprecated the color is no longer available to the server - */ - @Deprecated(since = "1.21.4") - @Nullable Color getSpawnEggLayerColor(EntityType entityType, int layer); - // Paper end - spawn egg color visibility - - // Paper start - lifecycle event API - /** - * @hidden - */ - @org.jetbrains.annotations.ApiStatus.Internal - io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager createPluginLifecycleEventManager(final org.bukkit.plugin.java.JavaPlugin plugin, final java.util.function.BooleanSupplier registrationCheck); - // Paper end - lifecycle event API - - @NotNull java.util.List computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines - - ItemStack createEmptyStack(); // Paper - proxy ItemStack - - @NotNull Map serializeStack(ItemStack itemStack); - @NotNull ItemStack deserializeStack(@NotNull Map args); /** @@ -392,4 +241,6 @@ default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { * @return the deserialized {@code ItemStack} */ @NotNull ItemStack deserializeItemHover(HoverEvent.@NotNull ShowItem itemHover); + + @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer(); } diff --git a/paper-api/src/main/java/org/bukkit/WorldType.java b/paper-api/src/main/java/org/bukkit/WorldType.java index 652b75bb6523..67d06c9da856 100644 --- a/paper-api/src/main/java/org/bukkit/WorldType.java +++ b/paper-api/src/main/java/org/bukkit/WorldType.java @@ -13,7 +13,9 @@ public enum WorldType { NORMAL("DEFAULT"), FLAT("FLAT"), LARGE_BIOMES("LARGEBIOMES"), - AMPLIFIED("AMPLIFIED"); + AMPLIFIED("AMPLIFIED"), + SINGLE_BIOME_SURFACE("SINGLE_BIOME_SURFACE"), + DEBUG_ALL_BLOCK_STATES("DEBUG"); private static final Map BY_NAME = Maps.newHashMap(); private final String name; diff --git a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java index c5d5afbcd25a..dc19e5f57a12 100644 --- a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java +++ b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java @@ -159,6 +159,26 @@ public interface Attribute extends OldEnum, Keyed, Translatable, net. * Attribute controlling the range an entity receives other waypoints from. */ Attribute WAYPOINT_RECEIVE_RANGE = getAttribute("waypoint_receive_range"); + /** + * The air friction an entity receives when moving. + */ + Attribute AIR_DRAG_MODIFIER = getAttribute("air_drag_modifier"); + /** + * The ground friction an entity receives when moving. + */ + Attribute FRICTION_MODIFIER = getAttribute("friction_modifier"); + /** + * The received motion when landing on the ground. + */ + Attribute BOUNCINESS = getAttribute("bounciness"); + /** + * The minimum distance the scoreboard objective in the below_name display slot become visible for others. + */ + Attribute BELOW_NAME_DISTANCE = getAttribute("below_name_distance"); + /** + * The minimum distance the display name become visible for others. + */ + Attribute NAME_TAG_DISTANCE = getAttribute("name_tag_distance"); @NotNull private static Attribute getAttribute(@NotNull @KeyPattern.Value String key) { diff --git a/paper-api/src/main/java/org/bukkit/block/Bed.java b/paper-api/src/main/java/org/bukkit/block/Bed.java index 46778452893d..5249d72854f6 100644 --- a/paper-api/src/main/java/org/bukkit/block/Bed.java +++ b/paper-api/src/main/java/org/bukkit/block/Bed.java @@ -4,9 +4,10 @@ /** * Represents a captured state of a bed. + * + * @deprecated bed block entity no longer exists */ -// Paper start -// @Deprecated(since = "1.13") +@Deprecated(forRemoval = true, since = "26.2") public interface Bed extends TileState, Colorable { @Override @@ -21,5 +22,4 @@ public interface Bed extends TileState, Colorable { @org.jetbrains.annotations.Contract("_ -> fail") @Deprecated(forRemoval = true) void setColor(@org.bukkit.UndefinedNullability("not supported") org.bukkit.DyeColor color); -// Paper end } diff --git a/paper-api/src/main/java/org/bukkit/block/Biome.java b/paper-api/src/main/java/org/bukkit/block/Biome.java index 8c4fd26c7782..bbaf6bfcdb18 100644 --- a/paper-api/src/main/java/org/bukkit/block/Biome.java +++ b/paper-api/src/main/java/org/bukkit/block/Biome.java @@ -132,6 +132,8 @@ public interface Biome extends OldEnum, Keyed, net.kyori.adventure.transl Biome STONY_SHORE = getBiome("stony_shore"); + Biome SULFUR_CAVES = getBiome("sulfur_caves"); + Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains"); Biome SWAMP = getBiome("swamp"); diff --git a/paper-api/src/main/java/org/bukkit/block/BlockType.java b/paper-api/src/main/java/org/bukkit/block/BlockType.java index 0e42965a729f..6045210bdd9a 100644 --- a/paper-api/src/main/java/org/bukkit/block/BlockType.java +++ b/paper-api/src/main/java/org/bukkit/block/BlockType.java @@ -87,7 +87,7 @@ import org.bukkit.block.data.type.Piston; import org.bukkit.block.data.type.PistonHead; import org.bukkit.block.data.type.PitcherCrop; -import org.bukkit.block.data.type.PointedDripstone; +import org.bukkit.block.data.type.PotentSulfur; import org.bukkit.block.data.type.RedstoneRail; import org.bukkit.block.data.type.RedstoneWallTorch; import org.bukkit.block.data.type.RedstoneWire; @@ -107,6 +107,7 @@ import org.bukkit.block.data.type.Slab; import org.bukkit.block.data.type.SmallDripleaf; import org.bukkit.block.data.type.Snow; +import org.bukkit.block.data.type.Speleothem; import org.bukkit.block.data.type.Stairs; import org.bukkit.block.data.type.StructureBlock; import org.bukkit.block.data.type.Switch; @@ -570,6 +571,8 @@ interface Typed extends BlockType { BlockType.Typed CHISELED_BOOKSHELF = getBlockType("chiseled_bookshelf"); + BlockType.Typed CHISELED_CINNABAR = getBlockType("chiseled_cinnabar"); + BlockType.Typed CHISELED_COPPER = getBlockType("chiseled_copper"); BlockType.Typed CHISELED_DEEPSLATE = getBlockType("chiseled_deepslate"); @@ -588,6 +591,8 @@ interface Typed extends BlockType { BlockType.Typed CHISELED_STONE_BRICKS = getBlockType("chiseled_stone_bricks"); + BlockType.Typed CHISELED_SULFUR = getBlockType("chiseled_sulfur"); + BlockType.Typed CHISELED_TUFF = getBlockType("chiseled_tuff"); BlockType.Typed CHISELED_TUFF_BRICKS = getBlockType("chiseled_tuff_bricks"); @@ -596,6 +601,22 @@ interface Typed extends BlockType { BlockType.Typed CHORUS_PLANT = getBlockType("chorus_plant"); + BlockType.Typed CINNABAR = getBlockType("cinnabar"); + + BlockType.Typed CINNABAR_BRICK_SLAB = getBlockType("cinnabar_brick_slab"); + + BlockType.Typed CINNABAR_BRICK_STAIRS = getBlockType("cinnabar_brick_stairs"); + + BlockType.Typed CINNABAR_BRICK_WALL = getBlockType("cinnabar_brick_wall"); + + BlockType.Typed CINNABAR_BRICKS = getBlockType("cinnabar_bricks"); + + BlockType.Typed CINNABAR_SLAB = getBlockType("cinnabar_slab"); + + BlockType.Typed CINNABAR_STAIRS = getBlockType("cinnabar_stairs"); + + BlockType.Typed CINNABAR_WALL = getBlockType("cinnabar_wall"); + BlockType.Typed CLAY = getBlockType("clay"); BlockType.Typed CLOSED_EYEBLOSSOM = getBlockType("closed_eyeblossom"); @@ -1662,7 +1683,7 @@ interface Typed extends BlockType { BlockType.Typed PODZOL = getBlockType("podzol"); - BlockType.Typed POINTED_DRIPSTONE = getBlockType("pointed_dripstone"); + BlockType.Typed POINTED_DRIPSTONE = getBlockType("pointed_dripstone"); BlockType.Typed POLISHED_ANDESITE = getBlockType("polished_andesite"); @@ -1692,6 +1713,14 @@ interface Typed extends BlockType { BlockType.Typed POLISHED_BLACKSTONE_WALL = getBlockType("polished_blackstone_wall"); + BlockType.Typed POLISHED_CINNABAR = getBlockType("polished_cinnabar"); + + BlockType.Typed POLISHED_CINNABAR_SLAB = getBlockType("polished_cinnabar_slab"); + + BlockType.Typed POLISHED_CINNABAR_STAIRS = getBlockType("polished_cinnabar_stairs"); + + BlockType.Typed POLISHED_CINNABAR_WALL = getBlockType("polished_cinnabar_wall"); + BlockType.Typed POLISHED_DEEPSLATE = getBlockType("polished_deepslate"); BlockType.Typed POLISHED_DEEPSLATE_SLAB = getBlockType("polished_deepslate_slab"); @@ -1712,6 +1741,14 @@ interface Typed extends BlockType { BlockType.Typed POLISHED_GRANITE_STAIRS = getBlockType("polished_granite_stairs"); + BlockType.Typed POLISHED_SULFUR = getBlockType("polished_sulfur"); + + BlockType.Typed POLISHED_SULFUR_SLAB = getBlockType("polished_sulfur_slab"); + + BlockType.Typed POLISHED_SULFUR_STAIRS = getBlockType("polished_sulfur_stairs"); + + BlockType.Typed POLISHED_SULFUR_WALL = getBlockType("polished_sulfur_wall"); + BlockType.Typed POLISHED_TUFF = getBlockType("polished_tuff"); BlockType.Typed POLISHED_TUFF_SLAB = getBlockType("polished_tuff_slab"); @@ -1724,6 +1761,8 @@ interface Typed extends BlockType { BlockType.Typed POTATOES = getBlockType("potatoes"); + BlockType.Typed POTENT_SULFUR = getBlockType("potent_sulfur"); + BlockType.Typed POTTED_ACACIA_SAPLING = getBlockType("potted_acacia_sapling"); BlockType.Typed POTTED_ALLIUM = getBlockType("potted_allium"); @@ -2176,6 +2215,24 @@ interface Typed extends BlockType { BlockType.Typed SUGAR_CANE = getBlockType("sugar_cane"); + BlockType.Typed SULFUR = getBlockType("sulfur"); + + BlockType.Typed SULFUR_BRICK_SLAB = getBlockType("sulfur_brick_slab"); + + BlockType.Typed SULFUR_BRICK_STAIRS = getBlockType("sulfur_brick_stairs"); + + BlockType.Typed SULFUR_BRICK_WALL = getBlockType("sulfur_brick_wall"); + + BlockType.Typed SULFUR_BRICKS = getBlockType("sulfur_bricks"); + + BlockType.Typed SULFUR_SLAB = getBlockType("sulfur_slab"); + + BlockType.Typed SULFUR_SPIKE = getBlockType("sulfur_spike"); + + BlockType.Typed SULFUR_STAIRS = getBlockType("sulfur_stairs"); + + BlockType.Typed SULFUR_WALL = getBlockType("sulfur_wall"); + BlockType.Typed SUNFLOWER = getBlockType("sunflower"); BlockType.Typed SUSPICIOUS_GRAVEL = getBlockType("suspicious_gravel"); diff --git a/paper-api/src/main/java/org/bukkit/block/PotentSulfur.java b/paper-api/src/main/java/org/bukkit/block/PotentSulfur.java new file mode 100644 index 000000000000..301399939f1b --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/PotentSulfur.java @@ -0,0 +1,7 @@ +package org.bukkit.block; + +/** + * Represents a captured state of a potent sulfur block. + */ +public interface PotentSulfur extends TileState { +} diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/PointedDripstone.java b/paper-api/src/main/java/org/bukkit/block/data/type/PointedDripstone.java index ae604692f7de..1adc571709ca 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/PointedDripstone.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/PointedDripstone.java @@ -1,83 +1,16 @@ package org.bukkit.block.data.type; -import java.util.Set; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.Waterlogged; -import org.jetbrains.annotations.NotNull; - /** - * 'thickness' represents the dripstone thickness. + * 'thickness' represents the speleothem thickness. *
- * 'vertical_direction' represents the dripstone orientation. + * 'vertical_direction' represents the speleothem orientation. *
* Some blocks may not be able to face in all directions, use * {@link #getVerticalDirections()} to get all possible directions for this * block. + * + * @deprecated incorrect name as multiple type of speleothem exists now. Use {@link Speleothem} */ -public interface PointedDripstone extends Waterlogged { - - /** - * Gets the value of the 'vertical_direction' property. - * - * @return the 'vertical_direction' value - */ - @NotNull - BlockFace getVerticalDirection(); - - /** - * Sets the value of the 'vertical_direction' property. - * - * @param direction the new 'vertical_direction' value - */ - void setVerticalDirection(@NotNull BlockFace direction); - - /** - * Gets the faces which are applicable to this block. - * - * @return the allowed 'vertical_direction' values - */ - @NotNull - Set getVerticalDirections(); - - /** - * Gets the value of the 'thickness' property. - * - * @return the 'thickness' value - */ - @NotNull - Thickness getThickness(); - - /** - * Sets the value of the 'thickness' property. - * - * @param thickness the new 'thickness' value - */ - void setThickness(@NotNull Thickness thickness); - - /** - * Represents the thickness of the dripstone, corresponding to its position - * within a multi-block dripstone formation. - */ - public enum Thickness { - /** - * Extended tip. - */ - TIP_MERGE, - /** - * Just the tip. - */ - TIP, - /** - * Top section. - */ - FRUSTUM, - /** - * Middle section. - */ - MIDDLE, - /** - * Base. - */ - BASE; - } +@Deprecated(forRemoval = true, since = "26.2") +public interface PointedDripstone extends Speleothem { } diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/PotentSulfur.java b/paper-api/src/main/java/org/bukkit/block/data/type/PotentSulfur.java new file mode 100644 index 000000000000..55663bfc2c21 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/data/type/PotentSulfur.java @@ -0,0 +1,36 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.BlockData; +import org.jspecify.annotations.NullMarked; + +/** + * 'potent_sulfur_state' represents the environmental state of the block and whether it can form a geyser. + */ +@NullMarked +public interface PotentSulfur extends BlockData { + + /** + * Gets the value of the 'potent_sulfur_state' property. + * + * @return the 'potent_sulfur_state' value + */ + State getPotentSulfurState(); + + /** + * Sets the value of the 'potent_sulfur_state' property. + * + * @param state the new 'potent_sulfur_state' value + */ + void setPotentSulfurState(State state); + + /** + * The environmental state of the potent sulfur. + */ + enum State { + DRY, + WET, + DORMANT, + ERUPTING, + CONTINUOUS; + } +} diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Speleothem.java b/paper-api/src/main/java/org/bukkit/block/data/type/Speleothem.java new file mode 100644 index 000000000000..e27e721b5857 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/data/type/Speleothem.java @@ -0,0 +1,81 @@ +package org.bukkit.block.data.type; + +import java.util.Set; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Waterlogged; +import org.jspecify.annotations.NullMarked; + +/** + * 'thickness' represents the speleothem thickness. + *
+ * 'vertical_direction' represents the speleothem orientation. + *
+ * Some blocks may not be able to face in all directions, use + * {@link #getVerticalDirections()} to get all possible directions for this + * block. + */ +@NullMarked +public interface Speleothem extends Waterlogged { + + /** + * Gets the value of the 'vertical_direction' property. + * + * @return the 'vertical_direction' value + */ + BlockFace getVerticalDirection(); + + /** + * Sets the value of the 'vertical_direction' property. + * + * @param direction the new 'vertical_direction' value + */ + void setVerticalDirection(BlockFace direction); + + /** + * Gets the faces which are applicable to this block. + * + * @return the allowed 'vertical_direction' values + */ + Set getVerticalDirections(); + + /** + * Gets the value of the 'thickness' property. + * + * @return the 'thickness' value + */ + Thickness getThickness(); + + /** + * Sets the value of the 'thickness' property. + * + * @param thickness the new 'thickness' value + */ + void setThickness(Thickness thickness); + + /** + * Represents the thickness of the speleothem, corresponding to its position + * within a multi-block speleothem formation. + */ + enum Thickness { + /** + * Extended tip. + */ + TIP_MERGE, + /** + * Just the tip. + */ + TIP, + /** + * Top section. + */ + FRUSTUM, + /** + * Middle section. + */ + MIDDLE, + /** + * Base. + */ + BASE; + } +} diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java index 29756f4ea6c6..f4dd936d7999 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java @@ -1,11 +1,13 @@ package org.bukkit.command.defaults; +import com.destroystokyo.paper.util.VersionFetcher; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; +import io.papermc.paper.InternalAPIBridge; import java.io.BufferedReader; import java.io.IOException; import java.net.URL; @@ -18,6 +20,11 @@ import java.util.Locale; import java.util.Set; import java.util.concurrent.locks.ReentrantLock; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -25,19 +32,13 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.util.StringUtil; import org.jetbrains.annotations.NotNull; -import com.destroystokyo.paper.util.VersionFetcher; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.event.ClickEvent; -import net.kyori.adventure.text.format.TextDecoration; -import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; @Deprecated(forRemoval = true) public class VersionCommand extends BukkitCommand { private VersionFetcher versionFetcher; // Paper - version command 2.0 private VersionFetcher getVersionFetcher() { // lazy load because unsafe isn't available at command registration if (versionFetcher == null) { - versionFetcher = Bukkit.getUnsafe().getVersionFetcher(); + versionFetcher = InternalAPIBridge.get().getVersionFetcher(); } return versionFetcher; diff --git a/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java b/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java index 43f15c38a173..0db085183bcb 100644 --- a/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java +++ b/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java @@ -1,6 +1,5 @@ package org.bukkit.damage; -import com.google.common.base.Preconditions; import io.papermc.paper.InternalAPIBridge; import org.bukkit.Sound; import org.jetbrains.annotations.NotNull; @@ -38,7 +37,7 @@ public interface DamageEffect { @NotNull private static DamageEffect getDamageEffect(@NotNull String key) { - return Preconditions.checkNotNull(InternalAPIBridge.get().getDamageEffect(key), "No DamageEffect found for %s. This is a bug.", key); + return InternalAPIBridge.get().getDamageEffect(key); } /** diff --git a/paper-api/src/main/java/org/bukkit/damage/DamageSource.java b/paper-api/src/main/java/org/bukkit/damage/DamageSource.java index 2a1a2a50e789..5ee92a1886f8 100644 --- a/paper-api/src/main/java/org/bukkit/damage/DamageSource.java +++ b/paper-api/src/main/java/org/bukkit/damage/DamageSource.java @@ -1,6 +1,6 @@ package org.bukkit.damage; -import org.bukkit.Bukkit; +import io.papermc.paper.InternalAPIBridge; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.jetbrains.annotations.NotNull; @@ -104,9 +104,8 @@ public interface DamageSource { * @return a {@link DamageSource.Builder} */ @NotNull - @SuppressWarnings("deprecation") public static Builder builder(@NotNull DamageType damageType) { - return Bukkit.getUnsafe().createDamageSourceBuilder(damageType); + return InternalAPIBridge.get().createDamageSourceBuilder(damageType); } /** diff --git a/paper-api/src/main/java/org/bukkit/damage/DamageType.java b/paper-api/src/main/java/org/bukkit/damage/DamageType.java index f43147f81f45..64b65a88ee0b 100644 --- a/paper-api/src/main/java/org/bukkit/damage/DamageType.java +++ b/paper-api/src/main/java/org/bukkit/damage/DamageType.java @@ -104,6 +104,8 @@ public interface DamageType extends Keyed, Translatable { DamageType STING = getDamageType("sting"); + DamageType SULFUR_CUBE_HOT = getDamageType("sulfur_cube_hot"); + DamageType SWEET_BERRY_BUSH = getDamageType("sweet_berry_bush"); DamageType THORNS = getDamageType("thorns"); diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java b/paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java new file mode 100644 index 000000000000..0f0c32b34f80 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java @@ -0,0 +1,41 @@ +package org.bukkit.entity; + +/** + * Represents an abstract cube mob. + */ +public interface AbstractCubeMob extends Creature { + + /** + * @return the size of the slime + */ + int getSize(); + + /** + * Setting the size of the slime (regardless of previous size) + * will set the following attributes: + *

    + *
  • {@link org.bukkit.attribute.Attribute#MAX_HEALTH}
  • + *
  • {@link org.bukkit.attribute.Attribute#MOVEMENT_SPEED}
  • + *
  • {@link org.bukkit.attribute.Attribute#ATTACK_DAMAGE}
  • + *
+ * to their per-size defaults and heal the + * slime to its max health (assuming it's alive). + * + * @param size the new size of the slime. + */ + void setSize(int size); + + /** + * Get whether this slime can randomly wander/jump around on its own + * + * @return {@code true} if can wander + */ + boolean canWander(); + + /** + * Set whether this slime can randomly wander/jump around on its own + * + * @param canWander {@code true} if can wander + */ + void setWander(boolean canWander); +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Cat.java b/paper-api/src/main/java/org/bukkit/entity/Cat.java index e7efc09cd3f6..72cdef500c8e 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Cat.java +++ b/paper-api/src/main/java/org/bukkit/entity/Cat.java @@ -95,7 +95,7 @@ interface Type extends OldEnum, Keyed { // End generate - CatType @NotNull - private static Type getType(@NotNull @KeyPattern.Value String key) { + private static Type getType(@NotNull @KeyPattern.Value final String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } @@ -136,7 +136,7 @@ interface SoundVariant extends Keyed { // End generate - CatSoundVariant @NotNull - private static SoundVariant getSoundVariant(final @NotNull @KeyPattern.Value String key) { + private static SoundVariant getSoundVariant(@KeyPattern.Value final @NotNull String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_SOUND_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Chicken.java b/paper-api/src/main/java/org/bukkit/entity/Chicken.java index 79d7eff05a88..29511b7600be 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Chicken.java +++ b/paper-api/src/main/java/org/bukkit/entity/Chicken.java @@ -82,7 +82,7 @@ interface Variant extends Keyed { Variant WARM = getVariant("warm"); // End generate - ChickenVariant - private static Variant getVariant(@KeyPattern.Value String key) { + private static Variant getVariant(@KeyPattern.Value final String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.CHICKEN_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } @@ -98,7 +98,7 @@ interface SoundVariant extends Keyed { SoundVariant PICKY = getSoundVariant("picky"); // End generate - ChickenSoundVariant - private static SoundVariant getSoundVariant(final @KeyPattern.Value String key) { + private static SoundVariant getSoundVariant(@KeyPattern.Value final String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.CHICKEN_SOUND_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Cow.java b/paper-api/src/main/java/org/bukkit/entity/Cow.java index 8b37664f88b1..e257860c4e99 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Cow.java +++ b/paper-api/src/main/java/org/bukkit/entity/Cow.java @@ -54,7 +54,7 @@ interface Variant extends Keyed { Variant WARM = getVariant("warm"); // End generate - CowVariant - private static Variant getVariant(@KeyPattern.Value String key) { + private static Variant getVariant(@KeyPattern.Value final String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.COW_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } @@ -70,7 +70,7 @@ interface SoundVariant extends Keyed { SoundVariant MOODY = getSoundVariant("moody"); // End generate - CowSoundVariant - private static SoundVariant getSoundVariant(final @KeyPattern.Value String key) { + private static SoundVariant getSoundVariant(@KeyPattern.Value final String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.COW_SOUND_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } diff --git a/paper-api/src/main/java/org/bukkit/entity/EntityType.java b/paper-api/src/main/java/org/bukkit/entity/EntityType.java index 5cbd14263618..1583067fe6fa 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -1,10 +1,10 @@ package org.bukkit.entity; import com.google.common.base.Preconditions; +import io.papermc.paper.InternalAPIBridge; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.Keyed; import org.bukkit.Location; import org.bukkit.NamespacedKey; @@ -176,6 +176,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans SQUID("squid", Squid.class, 94), STRAY("stray", Stray.class, 6), STRIDER("strider", Strider.class, -1), + SULFUR_CUBE("sulfur_cube", SulfurCube.class, -1), TADPOLE("tadpole", Tadpole.class, -1), TEXT_DISPLAY("text_display", TextDisplay.class, -1), TNT("tnt", TNTPrimed.class, 20), @@ -329,7 +330,7 @@ public boolean isAlive() { @NotNull @Deprecated(forRemoval = true) // Paper public String getTranslationKey() { - return Bukkit.getUnsafe().getTranslationKey(this); + return this.translationKey(); } // Paper start @@ -339,7 +340,7 @@ public String getTranslationKey() { @Override public @NotNull String translationKey() { Preconditions.checkArgument(this != UNKNOWN, "UNKNOWN entities do not have translation keys"); - return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this); + return InternalAPIBridge.get().getTranslationKey(this); } /** @@ -348,7 +349,10 @@ public String getTranslationKey() { * @return true if it has default attributes */ public boolean hasDefaultAttributes() { - return org.bukkit.Bukkit.getUnsafe().hasDefaultEntityAttributes(this.key); + if (this == UNKNOWN) { + return false; + } + return InternalAPIBridge.get().hasDefaultEntityAttributes(this.key); } /** @@ -358,7 +362,8 @@ public boolean hasDefaultAttributes() { * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultAttributes()} first) */ public @NotNull org.bukkit.attribute.Attributable getDefaultAttributes() { - return org.bukkit.Bukkit.getUnsafe().getDefaultEntityAttributes(this.key); + Preconditions.checkArgument(this.hasDefaultAttributes(), this.key + " doesn't have default attributes"); + return InternalAPIBridge.get().getDefaultEntityAttributes(this.key); } // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java b/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java index 714b4426da6a..f35c47ff34dd 100644 --- a/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java +++ b/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java @@ -3,5 +3,5 @@ /** * Represents a MagmaCube. */ -public interface MagmaCube extends Slime { +public interface MagmaCube extends AbstractCubeMob, Enemy { } diff --git a/paper-api/src/main/java/org/bukkit/entity/Pig.java b/paper-api/src/main/java/org/bukkit/entity/Pig.java index 275742466a07..83a5432e1f92 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Pig.java +++ b/paper-api/src/main/java/org/bukkit/entity/Pig.java @@ -54,7 +54,7 @@ interface Variant extends Keyed { Variant WARM = getVariant("warm"); // End generate - PigVariant - private static Variant getVariant(@KeyPattern.Value String key) { + private static Variant getVariant(@KeyPattern.Value final String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.PIG_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } @@ -72,7 +72,7 @@ interface SoundVariant extends Keyed { SoundVariant MINI = getSoundVariant("mini"); // End generate - PigSoundVariant - private static SoundVariant getSoundVariant(final @KeyPattern.Value String key) { + private static SoundVariant getSoundVariant(@KeyPattern.Value final String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.PIG_SOUND_VARIANT).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index fe3f4b7552e1..5c3eb7d3cfab 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -3771,7 +3771,7 @@ public void sendMessage(net.md_5.bungee.api.ChatMessageType position, java.util. */ @Deprecated public int getPing() { - throw new UnsupportedOperationException( "Not supported yet." ); + throw new UnsupportedOperationException("Not supported yet."); } // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/Slime.java b/paper-api/src/main/java/org/bukkit/entity/Slime.java index d200b7e9248a..bbcd9b7d9a19 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Slime.java +++ b/paper-api/src/main/java/org/bukkit/entity/Slime.java @@ -3,39 +3,5 @@ /** * Represents a Slime. */ -public interface Slime extends Mob, Enemy { - - /** - * @return The size of the slime - */ - public int getSize(); - - /** - * Setting the size of the slime (regardless of previous size) - * will set the following attributes: - *
    - *
  • {@link org.bukkit.attribute.Attribute#MAX_HEALTH}
  • - *
  • {@link org.bukkit.attribute.Attribute#MOVEMENT_SPEED}
  • - *
  • {@link org.bukkit.attribute.Attribute#ATTACK_DAMAGE}
  • - *
- * to their per-size defaults and heal the - * slime to its max health (assuming it's alive). - * - * @param sz The new size of the slime. - */ - public void setSize(int sz); - - /** - * Get whether this slime can randomly wander/jump around on its own - * - * @return true if can wander - */ - public boolean canWander(); - - /** - * Set whether this slime can randomly wander/jump around on its own - * - * @param canWander true if can wander - */ - public void setWander(boolean canWander); +public interface Slime extends AbstractCubeMob, Enemy { } diff --git a/paper-api/src/main/java/org/bukkit/entity/SulfurCube.java b/paper-api/src/main/java/org/bukkit/entity/SulfurCube.java new file mode 100644 index 000000000000..cc7cbf395665 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/SulfurCube.java @@ -0,0 +1,113 @@ +package org.bukkit.entity; + +import io.papermc.paper.entity.Bucketable; +import io.papermc.paper.entity.Shearable; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.key.KeyPattern; +import org.bukkit.Keyed; +import org.jspecify.annotations.NullMarked; + +/** + * Represents a Sulfur Cube. + */ +@NullMarked +public interface SulfurCube extends AbstractCubeMob, Shearable, Bucketable, Ageable { + + /** + * Gets the amount of ticks until this sulfur cube explode. + * + * @return the fuse ticks or -1 if not exploding + */ + int getFuseTicks(); + + /** + * Sets the amount of ticks until this sulfur cube explode. + * + * @param ticks the new fuse ticks + */ + void setFuseTicks(int ticks); + + /** + * Determines whether this sulfur cube is capable of exploding. + * + * @return {@code true} if the sulfur cube can explode, {@code false} otherwise + */ + boolean canExplode(); + + /** + * Ignites this sulfur cube, beginning its fuse if {@link #canExplode()} is {@code true}. + *

+ * The amount of time the sulfur cube takes to explode is defined in the {@link Archetype} + * of the entity and further controlled by the {@code imminent} parameter. + *

+ * This action can be cancelled using {@link io.papermc.paper.event.entity.EntityIgniteEvent}. + * The resulting explosion can also be cancelled by an + * {@link org.bukkit.event.entity.ExplosionPrimeEvent} and obeys the mob + * griefing gamerule. + * + * @param imminent if {@code true} the fuse time is shortened but still depends on the {@link Archetype} + * @return whether the sulfur cube got ignited + * @see #canExplode() + * @see #ignite() + */ + boolean ignite(boolean imminent); + + /** + * Ignites this sulfur cube, beginning its fuse if {@link #canExplode()} is {@code true}. + *

+ * The amount of time the sulfur cube takes to explode is defined in the {@link Archetype} + * of the entity. + *

+ * This action can be cancelled using {@link io.papermc.paper.event.entity.EntityIgniteEvent}. + * The resulting explosion can also be cancelled by an + * {@link org.bukkit.event.entity.ExplosionPrimeEvent} and obeys the mob + * griefing gamerule. + * + * @return whether the sulfur cube got ignited + * @see #canExplode() + * @see #ignite(boolean) + */ + default boolean ignite() { + return this.ignite(false); + } + + /** + * Represents the archetype of a sulfur cube + * which define a lot of possible behavior and interaction + * throughout its lifetime. + */ + interface Archetype extends Keyed { + + // Start generate - SulfurCubeArchetype + Archetype BOUNCY = getArchetype("bouncy"); + + Archetype EXPLOSIVE = getArchetype("explosive"); + + Archetype FAST_FLAT = getArchetype("fast_flat"); + + Archetype FAST_SLIDING = getArchetype("fast_sliding"); + + Archetype HIGH_RESISTANCE = getArchetype("high_resistance"); + + Archetype HOT = getArchetype("hot"); + + Archetype LIGHT = getArchetype("light"); + + Archetype REGULAR = getArchetype("regular"); + + Archetype SLOW_BOUNCY = getArchetype("slow_bouncy"); + + Archetype SLOW_FLAT = getArchetype("slow_flat"); + + Archetype SLOW_SLIDING = getArchetype("slow_sliding"); + + Archetype STICKY = getArchetype("sticky"); + // End generate - SulfurCubeArchetype + + private static Archetype getArchetype(@KeyPattern.Value final String key) { + return RegistryAccess.registryAccess().getRegistry(RegistryKey.SULFUR_CUBE_ARCHETYPE).getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); + } + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java index 423630e7778d..72682887eb3e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java @@ -30,6 +30,7 @@ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final En } @ApiStatus.Internal + @Deprecated(forRemoval = true) public EntityDamageByBlockEvent(@Nullable final Block damager, @Nullable final BlockState damagerState, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { super(damagee, cause, damageSource, damage); this.damager = damager; diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index 456ca29c92b6..01d020c88484 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -42,6 +42,7 @@ public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCau } @ApiStatus.Internal + @Deprecated(forRemoval = true) public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { this(damagee, cause, damageSource, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap>(ImmutableMap.of(DamageModifier.BASE, ZERO))); } @@ -309,8 +310,8 @@ public enum DamageCause { */ WORLD_BORDER, /** - * Damage caused when an entity contacts a block such as a Cactus, - * Dripstone (Stalagmite) or Berry Bush. + * Damage caused when an entity contacts another entity (sulfur cube) or block (cactus, dripstone stalagmite, + * berry bush, campfire, magma block). *

* Damage: variable */ @@ -454,7 +455,7 @@ public enum DamageCause { * @deprecated never used without help of commands or plugins, * {@link #ENTITY_ATTACK} will be used instead */ - @Deprecated + @Deprecated(since = "1.21.5") DRAGON_BREATH, /** * Damage caused when an entity runs into a wall. @@ -466,13 +467,19 @@ public enum DamageCause { * Damage caused when an entity steps on {@link Material#MAGMA_BLOCK}. *

* Damage: 1 + * + * @deprecated use {@link #CONTACT}, the block will be exposed in the event */ + @Deprecated(since = "26.2") HOT_FLOOR, /** * Damage caused when an entity steps on {@link Material#CAMPFIRE} or {@link Material#SOUL_CAMPFIRE}. *

* Damage: 1 or 2 (for soul fire) + * + * @deprecated use {@link #CONTACT}, the block will be exposed in the event */ + @Deprecated(since = "26.2") CAMPFIRE, /** * Damage caused when an entity is colliding with too many entities due diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java index 739794558f78..881c3828703e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java @@ -4,25 +4,20 @@ import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Pig; import org.bukkit.entity.PigZombie; -import org.bukkit.event.Cancellable; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Stores data for pigs being zapped + * + * @deprecated use {@link EntityZapEvent} */ -public class PigZapEvent extends EntityZapEvent implements Cancellable { // todo redundant with parent? - - private final PigZombie zombifiedPiglin; - private final LightningStrike bolt; - - private boolean cancelled; +@Deprecated(since = "26.2") +public class PigZapEvent extends EntityZapEvent { @ApiStatus.Internal public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie zombifiedPiglin) { super(pig, bolt, zombifiedPiglin); - this.bolt = bolt; - this.zombifiedPiglin = zombifiedPiglin; } @NotNull @@ -35,10 +30,12 @@ public Pig getEntity() { * Gets the bolt which is striking the pig. * * @return lightning entity + * @deprecated use {@link EntityZapEvent#getBolt()} */ @NotNull + @Deprecated(since = "26.2") public LightningStrike getLightning() { - return this.bolt; + return super.getBolt(); } /** @@ -46,21 +43,21 @@ public LightningStrike getLightning() { * not cancelled first. * * @return resulting entity - * @deprecated use {@link EntityTransformEvent#getTransformedEntity()} + * @deprecated use {@link EntityZapEvent#getReplacementEntity()} */ @NotNull @Deprecated(since = "1.13.2") public PigZombie getPigZombie() { - return this.zombifiedPiglin; + return (PigZombie) super.getReplacementEntity(); } @Override public boolean isCancelled() { - return this.cancelled; + return super.isCancelled(); } @Override public void setCancelled(boolean cancel) { - this.cancelled = cancel; + super.setCancelled(cancel); } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java index f71e62c8e8bf..17ad9c6d3bfd 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java @@ -1,6 +1,6 @@ package org.bukkit.event.entity; -import org.bukkit.entity.Slime; +import org.bukkit.entity.AbstractCubeMob; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; @@ -17,15 +17,15 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { private boolean cancelled; @ApiStatus.Internal - public SlimeSplitEvent(@NotNull final Slime slime, final int count) { - super(slime); + public SlimeSplitEvent(@NotNull final AbstractCubeMob cubeMob, final int count) { + super(cubeMob); this.count = count; } @NotNull @Override - public Slime getEntity() { - return (Slime) this.entity; + public AbstractCubeMob getEntity() { + return (AbstractCubeMob) this.entity; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java index d685e7e15e91..8b0d473a1505 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java @@ -8,7 +8,6 @@ /** * Represents a player animation event - *
Use {@link io.papermc.paper.event.player.PlayerArmSwingEvent} for determining which arm was swung. */ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java index 77a113229860..b8fee3b41c00 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java @@ -44,7 +44,7 @@ public PlayerGameModeChangeEvent(@NotNull final Player player, @NotNull final Ga /** * Gets the GameMode the player is switched to. * - * @return player's new GameMode + * @return player's new GameMode */ @NotNull public GameMode getNewGameMode() { diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java index d1a01b4f9d2f..3596c1bf733a 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java @@ -29,7 +29,7 @@ public PlayerKickEvent(final Player playerKicked, final String kickReason, final super(playerKicked); this.kickReason = LegacyComponentSerializer.legacySection().deserialize(kickReason); this.leaveMessage = LegacyComponentSerializer.legacySection().deserialize(leaveMessage); - this.cause = Cause.UNKNOWN; + this.cause = Cause.UNKNOWN; } @ApiStatus.Internal diff --git a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java index 297ae0047857..0ae0a10ecc93 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java +++ b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java @@ -13,7 +13,7 @@ public enum EquipmentSlot { CHEST(() -> EquipmentSlotGroup.CHEST), HEAD(() -> EquipmentSlotGroup.HEAD), /** - * Only for certain entities such as horses, wolves, happy ghasts and nautiluses. + * Only for certain entities such as horses, wolves, happy ghasts, nautiluses and sulfur cubes. */ BODY(() -> EquipmentSlotGroup.BODY), /** diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java index f20f072b0978..433525ea022a 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java @@ -1,15 +1,14 @@ package org.bukkit.inventory; import com.google.common.base.Preconditions; +import io.papermc.paper.InternalAPIBridge; import io.papermc.paper.datacomponent.DataComponentHolder; import io.papermc.paper.registry.RegistryKey; -import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import java.util.function.Consumer; import java.util.function.Predicate; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.event.HoverEvent; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -497,7 +496,7 @@ public void removeEnchantments() { @NotNull @Utility public Map serialize() { - return Bukkit.getUnsafe().serializeStack(this); + return this.craftDelegate.serialize(); } /** @@ -668,7 +667,7 @@ public boolean setItemMeta(@Nullable ItemMeta itemMeta) { @NotNull @Deprecated(forRemoval = true) // Paper public String getTranslationKey() { - return Bukkit.getUnsafe().getTranslationKey(this); + return this.craftDelegate.getTranslationKey(); } // Paper start @@ -757,7 +756,7 @@ public ItemStack ensureServerConversions() { /** * Deserializes this itemstack from raw NBT bytes. NBT is safer for data migrations as it will - * use the built in data converter instead of bukkits dangerous serialization system. + * use the built-in data converter instead of bukkits dangerous serialization system. * * This expects that the DataVersion was stored on the root of the Compound, as saved from * the {@link #serializeAsBytes()} API returned. @@ -765,16 +764,20 @@ public ItemStack ensureServerConversions() { * @return ItemStack migrated to this version of Minecraft if needed. */ public static @NotNull ItemStack deserializeBytes(final byte @NotNull [] bytes) { - return org.bukkit.Bukkit.getUnsafe().deserializeItem(bytes); + Preconditions.checkArgument(bytes != null, "null cannot be deserialized"); + Preconditions.checkArgument(bytes.length > 0, "cannot deserialize nothing"); + + return InternalAPIBridge.get().deserializeItem(bytes); } /** * Serializes this itemstack to raw bytes in NBT. NBT is safer for data migrations as it will - * use the built in data converter instead of bukkits dangerous serialization system. + * use the built-in data converter instead of bukkits dangerous serialization system. + * * @return bytes representing this item in NBT. */ public byte @NotNull [] serializeAsBytes() { - return org.bukkit.Bukkit.getUnsafe().serializeItem(this); + return this.craftDelegate.serializeAsBytes(); } /** @@ -884,7 +887,7 @@ public String getI18NDisplayName() { */ @Deprecated(forRemoval = true) public int getMaxItemUseDuration() { - return getMaxItemUseDuration(null); + return this.getMaxItemUseDuration(null); } public int getMaxItemUseDuration(@NotNull final org.bukkit.entity.LivingEntity entity) { @@ -1079,7 +1082,7 @@ public boolean hasItemFlag(@NotNull ItemFlag flag) { */ @Override public @NotNull String translationKey() { - return Bukkit.getUnsafe().getTranslationKey(this); + return this.craftDelegate.translationKey(); } /** @@ -1102,7 +1105,7 @@ public io.papermc.paper.inventory.ItemRarity getRarity() { * @return true if it is repairable by, false if not */ public boolean isRepairableBy(@NotNull ItemStack repairMaterial) { - return Bukkit.getUnsafe().isValidRepairItemStack(this, repairMaterial); + return this.craftDelegate.isRepairableBy(repairMaterial); } /** @@ -1113,7 +1116,7 @@ public boolean isRepairableBy(@NotNull ItemStack repairMaterial) { * @return true if it can repair, false if not */ public boolean canRepair(@NotNull ItemStack toBeRepaired) { - return Bukkit.getUnsafe().isValidRepairItemStack(toBeRepaired, this); + return toBeRepaired.isRepairableBy(this); } /** @@ -1138,8 +1141,7 @@ public boolean canRepair(@NotNull ItemStack toBeRepaired) { */ @NotNull public static ItemStack empty() { - //noinspection deprecation - return Bukkit.getUnsafe().createEmptyStack(); // Paper - proxy ItemStack + return InternalAPIBridge.get().createEmptyStack(); // Paper - proxy ItemStack } /** @@ -1162,9 +1164,8 @@ public boolean isEmpty() { * @param player a player for player-specific tooltip lines * @return an immutable list of components (can be empty) */ - @SuppressWarnings("deprecation") // abusing unsafe as a bridge - public java.util.@NotNull @org.jetbrains.annotations.Unmodifiable List computeTooltipLines(final @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, final @Nullable org.bukkit.entity.Player player) { - return Bukkit.getUnsafe().computeTooltipLines(this, tooltipContext, player); + public java.util.@NotNull @org.jetbrains.annotations.Unmodifiable List computeTooltipLines(final @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, final org.bukkit.entity.@Nullable Player player) { + return this.craftDelegate.computeTooltipLines(tooltipContext, player); } // Paper end - expose itemstack tooltip lines diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemType.java b/paper-api/src/main/java/org/bukkit/inventory/ItemType.java index ed64c9193855..97cecbb60c86 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemType.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemType.java @@ -290,7 +290,7 @@ interface Typed extends ItemType { ItemType.Typed BLACK_BANNER = getItemType("black_banner"); - ItemType.Typed BLACK_BED = getItemType("black_bed"); + ItemType.Typed BLACK_BED = getItemType("black_bed"); ItemType.Typed BLACK_BUNDLE = getItemType("black_bundle"); @@ -338,7 +338,7 @@ interface Typed extends ItemType { ItemType.Typed BLUE_BANNER = getItemType("blue_banner"); - ItemType.Typed BLUE_BED = getItemType("blue_bed"); + ItemType.Typed BLUE_BED = getItemType("blue_bed"); ItemType.Typed BLUE_BUNDLE = getItemType("blue_bundle"); @@ -420,7 +420,7 @@ interface Typed extends ItemType { ItemType.Typed BROWN_BANNER = getItemType("brown_banner"); - ItemType.Typed BROWN_BED = getItemType("brown_bed"); + ItemType.Typed BROWN_BED = getItemType("brown_bed"); ItemType.Typed BROWN_BUNDLE = getItemType("brown_bundle"); @@ -564,6 +564,8 @@ interface Typed extends ItemType { ItemType.Typed CHISELED_BOOKSHELF = getItemType("chiseled_bookshelf"); + ItemType.Typed CHISELED_CINNABAR = getItemType("chiseled_cinnabar"); + ItemType.Typed CHISELED_COPPER = getItemType("chiseled_copper"); ItemType.Typed CHISELED_DEEPSLATE = getItemType("chiseled_deepslate"); @@ -582,6 +584,8 @@ interface Typed extends ItemType { ItemType.Typed CHISELED_STONE_BRICKS = getItemType("chiseled_stone_bricks"); + ItemType.Typed CHISELED_SULFUR = getItemType("chiseled_sulfur"); + ItemType.Typed CHISELED_TUFF = getItemType("chiseled_tuff"); ItemType.Typed CHISELED_TUFF_BRICKS = getItemType("chiseled_tuff_bricks"); @@ -592,6 +596,22 @@ interface Typed extends ItemType { ItemType.Typed CHORUS_PLANT = getItemType("chorus_plant"); + ItemType.Typed CINNABAR = getItemType("cinnabar"); + + ItemType.Typed CINNABAR_BRICK_SLAB = getItemType("cinnabar_brick_slab"); + + ItemType.Typed CINNABAR_BRICK_STAIRS = getItemType("cinnabar_brick_stairs"); + + ItemType.Typed CINNABAR_BRICK_WALL = getItemType("cinnabar_brick_wall"); + + ItemType.Typed CINNABAR_BRICKS = getItemType("cinnabar_bricks"); + + ItemType.Typed CINNABAR_SLAB = getItemType("cinnabar_slab"); + + ItemType.Typed CINNABAR_STAIRS = getItemType("cinnabar_stairs"); + + ItemType.Typed CINNABAR_WALL = getItemType("cinnabar_wall"); + ItemType.Typed CLAY = getItemType("clay"); ItemType.Typed CLAY_BALL = getItemType("clay_ball"); @@ -800,7 +820,7 @@ interface Typed extends ItemType { ItemType.Typed CYAN_BANNER = getItemType("cyan_banner"); - ItemType.Typed CYAN_BED = getItemType("cyan_bed"); + ItemType.Typed CYAN_BED = getItemType("cyan_bed"); ItemType.Typed CYAN_BUNDLE = getItemType("cyan_bundle"); @@ -1252,7 +1272,7 @@ interface Typed extends ItemType { ItemType.Typed GRAY_BANNER = getItemType("gray_banner"); - ItemType.Typed GRAY_BED = getItemType("gray_bed"); + ItemType.Typed GRAY_BED = getItemType("gray_bed"); ItemType.Typed GRAY_BUNDLE = getItemType("gray_bundle"); @@ -1282,7 +1302,7 @@ interface Typed extends ItemType { ItemType.Typed GREEN_BANNER = getItemType("green_banner"); - ItemType.Typed GREEN_BED = getItemType("green_bed"); + ItemType.Typed GREEN_BED = getItemType("green_bed"); ItemType.Typed GREEN_BUNDLE = getItemType("green_bundle"); @@ -1512,7 +1532,7 @@ interface Typed extends ItemType { ItemType.Typed LIGHT_BLUE_BANNER = getItemType("light_blue_banner"); - ItemType.Typed LIGHT_BLUE_BED = getItemType("light_blue_bed"); + ItemType.Typed LIGHT_BLUE_BED = getItemType("light_blue_bed"); ItemType.Typed LIGHT_BLUE_BUNDLE = getItemType("light_blue_bundle"); @@ -1542,7 +1562,7 @@ interface Typed extends ItemType { ItemType.Typed LIGHT_GRAY_BANNER = getItemType("light_gray_banner"); - ItemType.Typed LIGHT_GRAY_BED = getItemType("light_gray_bed"); + ItemType.Typed LIGHT_GRAY_BED = getItemType("light_gray_bed"); ItemType.Typed LIGHT_GRAY_BUNDLE = getItemType("light_gray_bundle"); @@ -1582,7 +1602,7 @@ interface Typed extends ItemType { ItemType.Typed LIME_BANNER = getItemType("lime_banner"); - ItemType.Typed LIME_BED = getItemType("lime_bed"); + ItemType.Typed LIME_BED = getItemType("lime_bed"); ItemType.Typed LIME_BUNDLE = getItemType("lime_bundle"); @@ -1622,7 +1642,7 @@ interface Typed extends ItemType { ItemType.Typed MAGENTA_BANNER = getItemType("magenta_banner"); - ItemType.Typed MAGENTA_BED = getItemType("magenta_bed"); + ItemType.Typed MAGENTA_BED = getItemType("magenta_bed"); ItemType.Typed MAGENTA_BUNDLE = getItemType("magenta_bundle"); @@ -1762,6 +1782,8 @@ interface Typed extends ItemType { ItemType.Typed MUSIC_DISC_BLOCKS = getItemType("music_disc_blocks"); + ItemType.Typed MUSIC_DISC_BOUNCE = getItemType("music_disc_bounce"); + ItemType.Typed MUSIC_DISC_CAT = getItemType("music_disc_cat"); ItemType.Typed MUSIC_DISC_CHIRP = getItemType("music_disc_chirp"); @@ -1918,7 +1940,7 @@ interface Typed extends ItemType { ItemType.Typed ORANGE_BANNER = getItemType("orange_banner"); - ItemType.Typed ORANGE_BED = getItemType("orange_bed"); + ItemType.Typed ORANGE_BED = getItemType("orange_bed"); ItemType.Typed ORANGE_BUNDLE = getItemType("orange_bundle"); @@ -2060,7 +2082,7 @@ interface Typed extends ItemType { ItemType.Typed PINK_BANNER = getItemType("pink_banner"); - ItemType.Typed PINK_BED = getItemType("pink_bed"); + ItemType.Typed PINK_BED = getItemType("pink_bed"); ItemType.Typed PINK_BUNDLE = getItemType("pink_bundle"); @@ -2138,6 +2160,14 @@ interface Typed extends ItemType { ItemType.Typed POLISHED_BLACKSTONE_WALL = getItemType("polished_blackstone_wall"); + ItemType.Typed POLISHED_CINNABAR = getItemType("polished_cinnabar"); + + ItemType.Typed POLISHED_CINNABAR_SLAB = getItemType("polished_cinnabar_slab"); + + ItemType.Typed POLISHED_CINNABAR_STAIRS = getItemType("polished_cinnabar_stairs"); + + ItemType.Typed POLISHED_CINNABAR_WALL = getItemType("polished_cinnabar_wall"); + ItemType.Typed POLISHED_DEEPSLATE = getItemType("polished_deepslate"); ItemType.Typed POLISHED_DEEPSLATE_SLAB = getItemType("polished_deepslate_slab"); @@ -2158,6 +2188,14 @@ interface Typed extends ItemType { ItemType.Typed POLISHED_GRANITE_STAIRS = getItemType("polished_granite_stairs"); + ItemType.Typed POLISHED_SULFUR = getItemType("polished_sulfur"); + + ItemType.Typed POLISHED_SULFUR_SLAB = getItemType("polished_sulfur_slab"); + + ItemType.Typed POLISHED_SULFUR_STAIRS = getItemType("polished_sulfur_stairs"); + + ItemType.Typed POLISHED_SULFUR_WALL = getItemType("polished_sulfur_wall"); + ItemType.Typed POLISHED_TUFF = getItemType("polished_tuff"); ItemType.Typed POLISHED_TUFF_SLAB = getItemType("polished_tuff_slab"); @@ -2174,6 +2212,8 @@ interface Typed extends ItemType { ItemType.Typed POTATO = getItemType("potato"); + ItemType.Typed POTENT_SULFUR = getItemType("potent_sulfur"); + ItemType.Typed POTION = getItemType("potion"); ItemType.Typed POWDER_SNOW_BUCKET = getItemType("powder_snow_bucket"); @@ -2214,7 +2254,7 @@ interface Typed extends ItemType { ItemType.Typed PURPLE_BANNER = getItemType("purple_banner"); - ItemType.Typed PURPLE_BED = getItemType("purple_bed"); + ItemType.Typed PURPLE_BED = getItemType("purple_bed"); ItemType.Typed PURPLE_BUNDLE = getItemType("purple_bundle"); @@ -2294,7 +2334,7 @@ interface Typed extends ItemType { ItemType.Typed RED_BANNER = getItemType("red_banner"); - ItemType.Typed RED_BED = getItemType("red_bed"); + ItemType.Typed RED_BED = getItemType("red_bed"); ItemType.Typed RED_BUNDLE = getItemType("red_bundle"); @@ -2680,6 +2720,28 @@ interface Typed extends ItemType { ItemType.Typed SUGAR_CANE = getItemType("sugar_cane"); + ItemType.Typed SULFUR = getItemType("sulfur"); + + ItemType.Typed SULFUR_BRICK_SLAB = getItemType("sulfur_brick_slab"); + + ItemType.Typed SULFUR_BRICK_STAIRS = getItemType("sulfur_brick_stairs"); + + ItemType.Typed SULFUR_BRICK_WALL = getItemType("sulfur_brick_wall"); + + ItemType.Typed SULFUR_BRICKS = getItemType("sulfur_bricks"); + + ItemType.Typed SULFUR_CUBE_BUCKET = getItemType("sulfur_cube_bucket"); + + ItemType.Typed SULFUR_CUBE_SPAWN_EGG = getItemType("sulfur_cube_spawn_egg"); + + ItemType.Typed SULFUR_SLAB = getItemType("sulfur_slab"); + + ItemType.Typed SULFUR_SPIKE = getItemType("sulfur_spike"); + + ItemType.Typed SULFUR_STAIRS = getItemType("sulfur_stairs"); + + ItemType.Typed SULFUR_WALL = getItemType("sulfur_wall"); + ItemType.Typed SUNFLOWER = getItemType("sunflower"); ItemType.Typed SUSPICIOUS_GRAVEL = getItemType("suspicious_gravel"); @@ -2996,7 +3058,7 @@ interface Typed extends ItemType { ItemType.Typed WHITE_BANNER = getItemType("white_banner"); - ItemType.Typed WHITE_BED = getItemType("white_bed"); + ItemType.Typed WHITE_BED = getItemType("white_bed"); ItemType.Typed WHITE_BUNDLE = getItemType("white_bundle"); @@ -3064,7 +3126,7 @@ interface Typed extends ItemType { ItemType.Typed YELLOW_BANNER = getItemType("yellow_banner"); - ItemType.Typed YELLOW_BED = getItemType("yellow_bed"); + ItemType.Typed YELLOW_BED = getItemType("yellow_bed"); ItemType.Typed YELLOW_BUNDLE = getItemType("yellow_bundle"); diff --git a/paper-api/src/main/java/org/bukkit/inventory/MenuType.java b/paper-api/src/main/java/org/bukkit/inventory/MenuType.java index 349422376cba..6827e85bcef9 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/MenuType.java +++ b/paper-api/src/main/java/org/bukkit/inventory/MenuType.java @@ -236,7 +236,7 @@ default V create(HumanEntity player) { Class getInventoryViewClass(); @SuppressWarnings("unchecked") - private static T get(final @KeyPattern.Value String key) { + private static T get(@KeyPattern.Value final String key) { return (T) Registry.MENU.getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key)); } } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index d4ca244f3855..b4c19bd04c8b 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java @@ -985,7 +985,7 @@ default void displayName(final net.kyori.adventure.text.@Nullable Component disp * This will return false if nothing was removed. * * @param attribute attribute to remove - * @return true if all modifiers were removed from a given + * @return true if all modifiers were removed from a given * Attribute. Returns false if no attributes were * removed. * @throws NullPointerException if Attribute is null diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index 1b010fecadcc..0f3d3b757fbb 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -1,6 +1,7 @@ package org.bukkit.plugin.java; import com.google.common.base.Preconditions; +import io.papermc.paper.InternalAPIBridge; import io.papermc.paper.command.brigadier.BasicCommand; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import java.io.File; @@ -52,8 +53,7 @@ public abstract class JavaPlugin extends PluginBase { private FileConfiguration newConfig = null; private File configFile = null; private Logger logger = null; - @SuppressWarnings("deprecation") - private final io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager lifecycleEventManager = org.bukkit.Bukkit.getUnsafe().createPluginLifecycleEventManager(this, () -> this.allowsLifecycleRegistration); + private final io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager lifecycleEventManager = InternalAPIBridge.get().createPluginLifecycleEventManager(this, () -> this.allowsLifecycleRegistration); private boolean allowsLifecycleRegistration = true; private boolean isBeingEnabled = false; @@ -288,7 +288,7 @@ public final void setEnabled(final boolean enabled) { } private static class DummyPluginLoaderImplHolder { - private static final PluginLoader INSTANCE = net.kyori.adventure.util.Services.service(PluginLoader.class) + private static final PluginLoader INSTANCE = net.kyori.adventure.util.Services.service(PluginLoader.class) .orElseThrow(); } public final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) { diff --git a/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java b/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java index d0820d43fd8d..891d1f8e2adc 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java +++ b/paper-api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java @@ -62,7 +62,7 @@ private void removeFromOutgoing(@NotNull Plugin plugin, @NotNull String channel) channels.remove(channel); if (channels.isEmpty()) { - outgoingByChannel.remove(channel); + outgoingByPlugin.remove(plugin); } } } @@ -75,7 +75,7 @@ private void removeFromOutgoing(@NotNull Plugin plugin) { if (channels != null) { String[] toRemove = channels.toArray(new String[channels.size()]); - outgoingByPlugin.remove(plugin); + outgoingByPlugin.remove(plugin); // todo test for (String channel : toRemove) { removeFromOutgoing(plugin, channel); diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/Criteria.java b/paper-api/src/main/java/org/bukkit/scoreboard/Criteria.java index 3bc3abaf093d..bba5d1617502 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/Criteria.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/Criteria.java @@ -1,6 +1,7 @@ package org.bukkit.scoreboard; import com.google.common.base.Preconditions; +import io.papermc.paper.InternalAPIBridge; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Statistic; @@ -335,7 +336,7 @@ public static Criteria statistic(@NotNull Statistic statistic, @NotNull EntityTy @NotNull public static Criteria statistic(@NotNull Statistic statistic) { Preconditions.checkArgument(statistic != null, "statistic must not be null"); - return Bukkit.getScoreboardCriteria(org.bukkit.Bukkit.getUnsafe().getStatisticCriteriaKey(statistic)); // Paper + return Bukkit.getScoreboardCriteria(InternalAPIBridge.get().getStatisticCriteriaKey(statistic)); // Paper } /** diff --git a/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java b/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java index d4dd27540579..d88c6be9e00e 100644 --- a/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java +++ b/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java @@ -76,6 +76,8 @@ public final class DamageTypeTags { public static final Tag PANIC_ENVIRONMENTAL_CAUSES = getTag("panic_environmental_causes"); + public static final Tag SULFUR_CUBE_WITH_BLOCK_IMMUNE_TO = getTag("sulfur_cube_with_block_immune_to"); + public static final Tag WITCH_RESISTANT_TO = getTag("witch_resistant_to"); public static final Tag WITHER_IMMUNE_TO = getTag("wither_immune_to"); diff --git a/paper-api/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java b/paper-api/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java index 9e8ad3d74828..5977c4a21d02 100644 --- a/paper-api/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java +++ b/paper-api/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java @@ -138,6 +138,23 @@ public void testUnregisterIncomingPluginChannel_Plugin_String() { assertTrue(listener2.hasReceived()); } + @Test + public void testUnregisterOutgoingPluginChannel_SharedChannel() { + Messenger messenger = getMessenger(); + BukkitTestPlugin plugin1 = getPlugin(); + BukkitTestPlugin plugin2 = getPlugin(); + + messenger.registerOutgoingPluginChannel(plugin1, "test:foo"); + messenger.registerOutgoingPluginChannel(plugin2, "test:foo"); + + messenger.unregisterOutgoingPluginChannel(plugin1, "test:foo"); + + assertTrue(messenger.getOutgoingChannels().contains("test:foo"), "Channel should still be present because plugin2 is still registered"); + + assertTrue(messenger.isOutgoingChannelRegistered(plugin2, "test:foo"), "Second plugin should still be registered"); + assertFalse(messenger.isOutgoingChannelRegistered(plugin1, "test:foo"), "First plugin should no longer be registered"); + } + @Test public void testUnregisterIncomingPluginChannel_Plugin() { Messenger messenger = getMessenger(); diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java index b597f12a4b51..1e98011fac71 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -26,8 +26,8 @@ import io.papermc.paper.datacomponent.item.SwingAnimation; import io.papermc.paper.datacomponent.item.consumable.ItemUseAnimation; import io.papermc.paper.dialog.Dialog; -import io.papermc.paper.item.MapPostProcessing; import io.papermc.paper.entity.poi.PoiTypes; +import io.papermc.paper.item.MapPostProcessing; import io.papermc.paper.world.WeatheringCopperState; import io.papermc.typewriter.preset.EnumCloneRewriter; import io.papermc.typewriter.preset.model.EnumValue; @@ -77,6 +77,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Salmon; import org.bukkit.entity.Sniffer; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.TropicalFish; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; @@ -231,10 +232,11 @@ protected String rewriteFieldType(Holder.Reference(Registries.PIG_VARIANT, "getVariant")) .register("PigSoundVariant", Pig.SoundVariant.class, new RegistryFieldRewriter<>(Registries.PIG_SOUND_VARIANT, "getSoundVariant")) .register("ZombieNautilusVariant", ZombieNautilus.Variant.class, new RegistryFieldRewriter<>(Registries.ZOMBIE_NAUTILUS_VARIANT, "getVariant")) + .register("SulfurCubeArchetype", SulfurCube.Archetype.class, new RegistryFieldRewriter<>(Registries.SULFUR_CUBE_ARCHETYPE, "getArchetype")) .register("Dialog", Dialog.class, new RegistryFieldRewriter<>(Registries.DIALOG, "getDialog")) .register("PoiTypes", PoiTypes.class, new RegistryFieldRewriter<>(Registries.POINT_OF_INTEREST_TYPE, "get")) .register("MemoryKey", MemoryKey.class, new MemoryKeyRewriter()) - // .register("ItemType", org.bukkit.inventory.ItemType.class, new io.papermc.generator.rewriter.types.simple.ItemTypeRewriter()) - disable for now, lynx want the generic type + // .register("ItemType", org.bukkit.inventory.ItemType.class, new io.papermc.generator.rewriter.types.simple.ItemTypeRewriter()) // - disable for now, lynx want the generic type .register("BlockType", BlockType.class, new BlockTypeRewriter()) .register("FeatureFlag", FeatureFlag.class, new FeatureFlagRewriter()) .register("Tag", Tag.class, new TagRewriter()) diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java index 7f83d85aa7f0..0bd9978a2a10 100644 --- a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -18,6 +18,7 @@ import io.papermc.paper.registry.data.PaintingVariantRegistryEntry; import io.papermc.paper.registry.data.PigVariantRegistryEntry; import io.papermc.paper.registry.data.SoundEventRegistryEntry; +import io.papermc.paper.registry.data.SulfurCubeArchetypeRegistryEntry; import io.papermc.paper.registry.data.WolfVariantRegistryEntry; import io.papermc.paper.registry.data.ZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.DialogRegistryEntry; @@ -42,6 +43,7 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.SulfurCubeArchetypes; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.animal.chicken.ChickenSoundVariants; @@ -94,6 +96,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Frog; import org.bukkit.entity.Pig; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; import org.bukkit.entity.ZombieNautilus; @@ -203,11 +206,12 @@ private static RegistryEntry inconsistentEntry(ResourceKey> API_ONLY = List.of( - entry(Registries.ENTITY_TYPE, net.minecraft.world.entity.EntityType.class, EntityType.class), + entry(Registries.ENTITY_TYPE, net.minecraft.world.entity.EntityTypes.class, EntityType.class), entry(Registries.PARTICLE_TYPE, ParticleTypes.class, Particle.class), entry(Registries.POTION, Potions.class, PotionType.class), entry(Registries.MEMORY_MODULE_TYPE, MemoryModuleType.class, MemoryKey.class) diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java index 4b3f2abf9b4e..81c2e547809d 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java @@ -4,7 +4,7 @@ import io.papermc.generator.utils.Formatting; import io.papermc.typewriter.replace.SearchMetadata; import io.papermc.typewriter.replace.SearchReplaceRewriter; -import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.BlockEntityTypes; public class CraftBlockEntityStateMapping extends SearchReplaceRewriter { @@ -13,7 +13,7 @@ protected void insert(SearchMetadata metadata, StringBuilder builder) { BlockEntityMapping.MAPPING.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().identifier().getPath())).forEach(entry -> { builder.append(metadata.indent()); builder.append("register(%s.%s, %s.class, %s::new);".formatted( - BlockEntityType.class.getSimpleName(), Formatting.formatKeyAsField(entry.getKey().identifier().getPath()), + BlockEntityTypes.class.getSimpleName(), Formatting.formatKeyAsField(entry.getKey().identifier().getPath()), entry.getValue(), entry.getValue())); builder.append('\n'); }); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java index d1cd5ee841df..79ab00152224 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java @@ -21,6 +21,7 @@ import net.minecraft.util.Util; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.Mob; import static io.papermc.generator.utils.Formatting.quoted; @@ -54,93 +55,93 @@ public class EntityTypeRewriter extends EnumRegistryRewriter> { @Deprecated private static final Object2IntMap> LEGACY_ID = Util.make(new Object2IntOpenHashMap<>(), map -> { - map.put(EntityType.ITEM, 1); - map.put(EntityType.EXPERIENCE_ORB, 2); - map.put(EntityType.AREA_EFFECT_CLOUD, 3); - map.put(EntityType.ELDER_GUARDIAN, 4); - map.put(EntityType.WITHER_SKELETON, 5); - map.put(EntityType.STRAY, 6); - map.put(EntityType.EGG, 7); - map.put(EntityType.LEASH_KNOT, 8); - map.put(EntityType.PAINTING, 9); - map.put(EntityType.ARROW, 10); - map.put(EntityType.SNOWBALL, 11); - map.put(EntityType.FIREBALL, 12); - map.put(EntityType.SMALL_FIREBALL, 13); - map.put(EntityType.ENDER_PEARL, 14); - map.put(EntityType.EYE_OF_ENDER, 15); - map.put(EntityType.SPLASH_POTION, 16); - map.put(EntityType.EXPERIENCE_BOTTLE, 17); - map.put(EntityType.ITEM_FRAME, 18); - map.put(EntityType.WITHER_SKULL, 19); - map.put(EntityType.TNT, 20); - map.put(EntityType.FALLING_BLOCK, 21); - map.put(EntityType.FIREWORK_ROCKET, 22); - map.put(EntityType.HUSK, 23); - map.put(EntityType.SPECTRAL_ARROW, 24); - map.put(EntityType.SHULKER_BULLET, 25); - map.put(EntityType.DRAGON_FIREBALL, 26); - map.put(EntityType.ZOMBIE_VILLAGER, 27); - map.put(EntityType.SKELETON_HORSE, 28); - map.put(EntityType.ZOMBIE_HORSE, 29); - map.put(EntityType.ARMOR_STAND, 30); - map.put(EntityType.DONKEY, 31); - map.put(EntityType.MULE, 32); - map.put(EntityType.EVOKER_FANGS, 33); - map.put(EntityType.EVOKER, 34); - map.put(EntityType.VEX, 35); - map.put(EntityType.VINDICATOR, 36); - map.put(EntityType.ILLUSIONER, 37); - - map.put(EntityType.COMMAND_BLOCK_MINECART, 40); - map.put(EntityType.MINECART, 42); - map.put(EntityType.CHEST_MINECART, 43); - map.put(EntityType.FURNACE_MINECART, 44); - map.put(EntityType.TNT_MINECART, 45); - map.put(EntityType.HOPPER_MINECART, 46); - map.put(EntityType.SPAWNER_MINECART, 47); - - map.put(EntityType.CREEPER, 50); - map.put(EntityType.SKELETON, 51); - map.put(EntityType.SPIDER, 52); - map.put(EntityType.GIANT, 53); - map.put(EntityType.ZOMBIE, 54); - map.put(EntityType.SLIME, 55); - map.put(EntityType.GHAST, 56); - map.put(EntityType.ZOMBIFIED_PIGLIN, 57); - map.put(EntityType.ENDERMAN, 58); - map.put(EntityType.CAVE_SPIDER, 59); - map.put(EntityType.SILVERFISH, 60); - map.put(EntityType.BLAZE, 61); - map.put(EntityType.MAGMA_CUBE, 62); - map.put(EntityType.ENDER_DRAGON, 63); - map.put(EntityType.WITHER, 64); - map.put(EntityType.BAT, 65); - map.put(EntityType.WITCH, 66); - map.put(EntityType.ENDERMITE, 67); - map.put(EntityType.GUARDIAN, 68); - map.put(EntityType.SHULKER, 69); - - map.put(EntityType.PIG, 90); - map.put(EntityType.SHEEP, 91); - map.put(EntityType.COW, 92); - map.put(EntityType.CHICKEN, 93); - map.put(EntityType.SQUID, 94); - map.put(EntityType.WOLF, 95); - map.put(EntityType.MOOSHROOM, 96); - map.put(EntityType.SNOW_GOLEM, 97); - map.put(EntityType.OCELOT, 98); - map.put(EntityType.IRON_GOLEM, 99); - map.put(EntityType.HORSE, 100); - map.put(EntityType.RABBIT, 101); - map.put(EntityType.POLAR_BEAR, 102); - map.put(EntityType.LLAMA, 103); - map.put(EntityType.LLAMA_SPIT, 104); - map.put(EntityType.PARROT, 105); - - map.put(EntityType.VILLAGER, 120); - - map.put(EntityType.END_CRYSTAL, 200); + map.put(EntityTypes.ITEM, 1); + map.put(EntityTypes.EXPERIENCE_ORB, 2); + map.put(EntityTypes.AREA_EFFECT_CLOUD, 3); + map.put(EntityTypes.ELDER_GUARDIAN, 4); + map.put(EntityTypes.WITHER_SKELETON, 5); + map.put(EntityTypes.STRAY, 6); + map.put(EntityTypes.EGG, 7); + map.put(EntityTypes.LEASH_KNOT, 8); + map.put(EntityTypes.PAINTING, 9); + map.put(EntityTypes.ARROW, 10); + map.put(EntityTypes.SNOWBALL, 11); + map.put(EntityTypes.FIREBALL, 12); + map.put(EntityTypes.SMALL_FIREBALL, 13); + map.put(EntityTypes.ENDER_PEARL, 14); + map.put(EntityTypes.EYE_OF_ENDER, 15); + map.put(EntityTypes.SPLASH_POTION, 16); + map.put(EntityTypes.EXPERIENCE_BOTTLE, 17); + map.put(EntityTypes.ITEM_FRAME, 18); + map.put(EntityTypes.WITHER_SKULL, 19); + map.put(EntityTypes.TNT, 20); + map.put(EntityTypes.FALLING_BLOCK, 21); + map.put(EntityTypes.FIREWORK_ROCKET, 22); + map.put(EntityTypes.HUSK, 23); + map.put(EntityTypes.SPECTRAL_ARROW, 24); + map.put(EntityTypes.SHULKER_BULLET, 25); + map.put(EntityTypes.DRAGON_FIREBALL, 26); + map.put(EntityTypes.ZOMBIE_VILLAGER, 27); + map.put(EntityTypes.SKELETON_HORSE, 28); + map.put(EntityTypes.ZOMBIE_HORSE, 29); + map.put(EntityTypes.ARMOR_STAND, 30); + map.put(EntityTypes.DONKEY, 31); + map.put(EntityTypes.MULE, 32); + map.put(EntityTypes.EVOKER_FANGS, 33); + map.put(EntityTypes.EVOKER, 34); + map.put(EntityTypes.VEX, 35); + map.put(EntityTypes.VINDICATOR, 36); + map.put(EntityTypes.ILLUSIONER, 37); + + map.put(EntityTypes.COMMAND_BLOCK_MINECART, 40); + map.put(EntityTypes.MINECART, 42); + map.put(EntityTypes.CHEST_MINECART, 43); + map.put(EntityTypes.FURNACE_MINECART, 44); + map.put(EntityTypes.TNT_MINECART, 45); + map.put(EntityTypes.HOPPER_MINECART, 46); + map.put(EntityTypes.SPAWNER_MINECART, 47); + + map.put(EntityTypes.CREEPER, 50); + map.put(EntityTypes.SKELETON, 51); + map.put(EntityTypes.SPIDER, 52); + map.put(EntityTypes.GIANT, 53); + map.put(EntityTypes.ZOMBIE, 54); + map.put(EntityTypes.SLIME, 55); + map.put(EntityTypes.GHAST, 56); + map.put(EntityTypes.ZOMBIFIED_PIGLIN, 57); + map.put(EntityTypes.ENDERMAN, 58); + map.put(EntityTypes.CAVE_SPIDER, 59); + map.put(EntityTypes.SILVERFISH, 60); + map.put(EntityTypes.BLAZE, 61); + map.put(EntityTypes.MAGMA_CUBE, 62); + map.put(EntityTypes.ENDER_DRAGON, 63); + map.put(EntityTypes.WITHER, 64); + map.put(EntityTypes.BAT, 65); + map.put(EntityTypes.WITCH, 66); + map.put(EntityTypes.ENDERMITE, 67); + map.put(EntityTypes.GUARDIAN, 68); + map.put(EntityTypes.SHULKER, 69); + + map.put(EntityTypes.PIG, 90); + map.put(EntityTypes.SHEEP, 91); + map.put(EntityTypes.COW, 92); + map.put(EntityTypes.CHICKEN, 93); + map.put(EntityTypes.SQUID, 94); + map.put(EntityTypes.WOLF, 95); + map.put(EntityTypes.MOOSHROOM, 96); + map.put(EntityTypes.SNOW_GOLEM, 97); + map.put(EntityTypes.OCELOT, 98); + map.put(EntityTypes.IRON_GOLEM, 99); + map.put(EntityTypes.HORSE, 100); + map.put(EntityTypes.RABBIT, 101); + map.put(EntityTypes.POLAR_BEAR, 102); + map.put(EntityTypes.LLAMA, 103); + map.put(EntityTypes.LLAMA_SPIT, 104); + map.put(EntityTypes.PARROT, 105); + + map.put(EntityTypes.VILLAGER, 120); + + map.put(EntityTypes.END_CRYSTAL, 200); }); private static final ClassResolver runtime = new ClassResolver(EntityTypeRewriter.class.getClassLoader()); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/PoseRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/PoseRewriter.java index 2288a15627ea..3f4b330cdd4e 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/PoseRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/PoseRewriter.java @@ -9,10 +9,8 @@ import io.papermc.typewriter.preset.EnumCloneRewriter; import io.papermc.typewriter.preset.model.EnumValue; import io.papermc.typewriter.replace.SearchMetadata; -import java.util.EnumSet; import java.util.HashMap; import java.util.Map; -import java.util.Set; import net.minecraft.world.entity.Pose; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -22,16 +20,6 @@ public PoseRewriter() { super(Pose.class); } - private static final Set FORMAT_TOKENS = EnumSet.of( - TokenType.COMMENT, - TokenType.SINGLE_COMMENT - ); - - private static final Set END_VALUE_MARKERS = EnumSet.of( - TokenType.CO, - TokenType.SECO - ); - private @MonotonicNonNull Map javadocsPerConstant; private Map parseConstantJavadocs(String content) { @@ -39,11 +27,11 @@ private Map parseConstantJavadocs(String content Lexer lex = new Lexer(content.toCharArray()); lex.checkMarkdownDocComments = !this.sourcesMetadata.canSkipMarkdownDocComments(); - SequenceTokens.wrap(lex, FORMAT_TOKENS) + SequenceTokens.wrap(lex, TokenTypeSets.COMMENT_TOKENS) .group(action -> { ProtoConstant constant = new ProtoConstant(); action - .map(TokenType.JAVADOC, token -> { // /** */ + .map(TokenTypeSets.JAVADOC_TOKENS::contains, token -> { // /** */ constant.javadocs(((CharSequenceBlockToken) token)); }, TokenTaskBuilder::asOptional) .map(TokenType.IDENTIFIER, token -> { // @@ -51,7 +39,7 @@ private Map parseConstantJavadocs(String content }) .skipClosure(TokenType.LPAREN, TokenType.RPAREN, true, TokenTaskBuilder::asOptional) // (*)? .skipClosure(TokenType.LSCOPE, TokenType.RSCOPE, true, TokenTaskBuilder::asOptional) // {*}? - .map(END_VALUE_MARKERS::contains, _ -> { // ;|, + .map(TokenTypeSets.ENUM_END_MARKER_TOKENS::contains, _ -> { // ;|, // this part will fail for the last entry for enum without end (,;) if (constant.isComplete()) { map.put(constant.name(), constant.javadocs()); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/TokenTypeSets.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/TokenTypeSets.java new file mode 100644 index 000000000000..b50a51b59600 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/TokenTypeSets.java @@ -0,0 +1,30 @@ +package io.papermc.generator.rewriter.types.simple.trial; + +import com.google.common.collect.Sets; +import io.papermc.typewriter.parser.token.TokenType; +import java.util.Set; + +public final class TokenTypeSets { + + static final Set COMMENT_TOKENS = of( + TokenType.COMMENT, + TokenType.SINGLE_COMMENT + ); + + static final Set JAVADOC_TOKENS = of( + TokenType.JAVADOC, + TokenType.MARKDOWN_JAVADOC + ); + + static final Set ENUM_END_MARKER_TOKENS = of( + TokenType.CO, + TokenType.SECO + ); + + private static Set of(TokenType first, TokenType... rest) { + return Sets.immutableEnumSet(first, rest); + } + + private TokenTypeSets() { + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java index 5425b0d21325..b6450ce10dd0 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java @@ -8,10 +8,8 @@ import io.papermc.typewriter.parser.token.CharSequenceToken; import io.papermc.typewriter.parser.token.TokenType; import io.papermc.typewriter.replace.SearchMetadata; -import java.util.EnumSet; import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.function.Predicate; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; @@ -24,11 +22,6 @@ public VillagerProfessionRewriter() { super(Registries.VILLAGER_PROFESSION, "getProfession"); } - private static final Set FORMAT_TOKENS = EnumSet.of( - TokenType.COMMENT, - TokenType.SINGLE_COMMENT - ); - private @MonotonicNonNull Map javadocsPerConstant; private Map parseConstantJavadocs(String content) { @@ -36,11 +29,11 @@ private Map parseConstantJavadocs(String content Lexer lex = new Lexer(content.toCharArray()); lex.checkMarkdownDocComments = !this.sourcesMetadata.canSkipMarkdownDocComments(); - SequenceTokens.wrap(lex, FORMAT_TOKENS) + SequenceTokens.wrap(lex, TokenTypeSets.COMMENT_TOKENS) .group(action -> { ProtoConstant constant = new ProtoConstant(); action - .map(TokenType.JAVADOC, token -> { + .map(TokenTypeSets.JAVADOC_TOKENS::contains, token -> { constant.javadocs(((CharSequenceBlockToken) token)); }, TokenTaskBuilder::asOptional) .skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC)) diff --git a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java index 77f75a900573..0db4f367e3ca 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java @@ -71,7 +71,7 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.animal.golem.IronGolem.class, IronGolem.class); map.put(net.minecraft.world.entity.animal.equine.Llama.class, Llama.class); map.put(net.minecraft.world.entity.animal.equine.TraderLlama.class, TraderLlama.class); - map.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class); + map.put(net.minecraft.world.entity.monster.cubemob.MagmaCube.class, MagmaCube.class); map.put(net.minecraft.world.entity.monster.Monster.class, Monster.class); map.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); // close enough map.put(net.minecraft.world.entity.animal.cow.MushroomCow.class, MushroomCow.class); @@ -96,7 +96,7 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.monster.skeleton.AbstractSkeleton.class, AbstractSkeleton.class); map.put(net.minecraft.world.entity.monster.skeleton.Stray.class, Stray.class); map.put(net.minecraft.world.entity.monster.skeleton.WitherSkeleton.class, WitherSkeleton.class); - map.put(net.minecraft.world.entity.monster.Slime.class, Slime.class); + map.put(net.minecraft.world.entity.monster.cubemob.Slime.class, Slime.class); map.put(net.minecraft.world.entity.animal.golem.SnowGolem.class, Snowman.class); map.put(net.minecraft.world.entity.monster.spider.Spider.class, Spider.class); map.put(net.minecraft.world.entity.animal.squid.Squid.class, Squid.class); @@ -142,6 +142,8 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, org.bukkit.entity.ZombieNautilus.class); map.put(net.minecraft.world.entity.animal.camel.CamelHusk.class, org.bukkit.entity.CamelHusk.class); map.put(net.minecraft.world.entity.monster.skeleton.Parched.class, org.bukkit.entity.Parched.class); + map.put(net.minecraft.world.entity.monster.cubemob.SulfurCube.class, SulfurCube.class); + map.put(net.minecraft.world.entity.monster.cubemob.AbstractCubeMob.class, AbstractCubeMob.class); // }); @@ -161,7 +163,8 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s RangedEntity.class, Tameable.class, Monster.class, - PufferFish.class // weird case + PufferFish.class, // weird case + AbstractCubeMob.class ); private static String getPathName(Class type, Class holderClass, String name) { diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java b/paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java index 65f77112b593..33bab489e9cd 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java @@ -47,16 +47,17 @@ import net.minecraft.world.level.block.state.properties.CreakingHeartState; import net.minecraft.world.level.block.state.properties.DoorHingeSide; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; -import net.minecraft.world.level.block.state.properties.DripstoneThickness; import net.minecraft.world.level.block.state.properties.Half; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.world.level.block.state.properties.PotentSulfurState; import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.RailShape; import net.minecraft.world.level.block.state.properties.RedstoneSide; import net.minecraft.world.level.block.state.properties.SculkSensorPhase; import net.minecraft.world.level.block.state.properties.SideChainPart; import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.level.block.state.properties.SpeleothemThickness; import net.minecraft.world.level.block.state.properties.StairsShape; import net.minecraft.world.level.block.state.properties.StructureMode; import net.minecraft.world.level.block.state.properties.TestBlockMode; @@ -98,12 +99,13 @@ import org.bukkit.block.data.type.Dripleaf; import org.bukkit.block.data.type.Fence; import org.bukkit.block.data.type.Furnace; -import org.bukkit.block.data.type.PointedDripstone; +import org.bukkit.block.data.type.PotentSulfur; import org.bukkit.block.data.type.RedstoneRail; import org.bukkit.block.data.type.RedstoneWire; import org.bukkit.block.data.type.ResinClump; import org.bukkit.block.data.type.SculkSensor; import org.bukkit.block.data.type.Slab; +import org.bukkit.block.data.type.Speleothem; import org.bukkit.block.data.type.Stairs; import org.bukkit.block.data.type.Switch; import org.bukkit.block.data.type.TechnicalPiston; @@ -233,6 +235,10 @@ public record BlockData(String implName, @Nullable Class, Class> MAIN_PROPERTY_TO_DATA = Map.of( @@ -278,7 +285,7 @@ public record BlockData(String implName, @Nullable Class getBestSuitedApiClass(Class block) { diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 8c3039f56e0c..cd251009c842 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:26.1.2+build.3") + mache("io.papermc:mache:26.2-pre-5+build.1") paperclip("io.papermc:paperclip:3.0.4") } @@ -23,7 +23,7 @@ paperweight { gitFilePatches = false updatingMinecraft { - // oldPaperCommit = "711c5de2b05df39b72c44ff54e9f9381f8d153cb" + oldPaperCommit = "d4fe85375af18bfa88f44d7c1e6a61904ae550cc" } } diff --git a/paper-server/patches/features/0003-Optimize-Connection-and-add-advanced-packet-support.patch b/paper-server/patches/features/0001-Optimize-Connection-and-add-advanced-packet-support.patch similarity index 94% rename from paper-server/patches/features/0003-Optimize-Connection-and-add-advanced-packet-support.patch rename to paper-server/patches/features/0001-Optimize-Connection-and-add-advanced-packet-support.patch index 224216985f3e..cc10c73f1835 100644 --- a/paper-server/patches/features/0003-Optimize-Connection-and-add-advanced-packet-support.patch +++ b/paper-server/patches/features/0001-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 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e7e150804 100644 +index 25de26a3fae61b4e3f33f395a5653e729cc33627..a01698455cc5650899e2dc8732154cc9b04b1bb0 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -64,7 +64,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -65,7 +65,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 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e public Channel channel; public SocketAddress address; // Spigot start -@@ -123,6 +123,10 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -124,6 +124,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 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e public Connection(final PacketFlow receiving) { this.receiving = receiving; -@@ -392,11 +396,38 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -393,11 +397,38 @@ public class Connection extends SimpleChannelInboundHandler> { } public void send(final Packet packet, final @Nullable ChannelFutureListener listener, final boolean flush) { @@ -93,7 +93,7 @@ index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e } } -@@ -405,7 +436,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -406,7 +437,7 @@ public class Connection extends SimpleChannelInboundHandler> { this.flushQueue(); action.accept(this); } else { @@ -102,7 +102,7 @@ index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e } } -@@ -419,21 +450,42 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -420,21 +451,42 @@ public class Connection extends SimpleChannelInboundHandler> { } private void doSendPacket(final Packet packet, final @Nullable ChannelFutureListener listener, final boolean flush) { @@ -149,7 +149,7 @@ index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e } } -@@ -445,16 +497,57 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -446,16 +498,57 @@ public class Connection extends SimpleChannelInboundHandler> { } } @@ -212,7 +212,7 @@ index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e 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 -@@ -524,6 +617,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -525,6 +618,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void disconnect(final DisconnectionDetails details) { this.preparing = false; // Spigot @@ -220,7 +220,7 @@ index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e if (this.channel == null) { this.delayedDisconnect = details; } -@@ -705,7 +799,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -714,7 +808,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void handleDisconnection() { if (this.channel != null && !this.channel.isOpen()) { if (this.disconnectionHandled) { @@ -229,7 +229,7 @@ index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e } else { this.disconnectionHandled = true; PacketListener packetListener = this.getPacketListener(); -@@ -716,7 +810,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -725,7 +819,7 @@ public class Connection extends SimpleChannelInboundHandler> { ); disconnectListener.onDisconnect(details); } @@ -238,9 +238,9 @@ index 13faa13a9d3120cdeaca63d6eb3a0feb8019fb3a..d14aea970ce98edfe3dc3692e707334e // Paper start - Add PlayerConnectionCloseEvent if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) { /* Player was logged in, either game listener or configuration listener */ -@@ -751,4 +845,96 @@ public class Connection extends SimpleChannelInboundHandler> { - public void setBandwidthLogger(final LocalSampleLogger bandwidthLogger) { - this.bandwidthDebugMonitor = new BandwidthDebugMonitor(bandwidthLogger); +@@ -768,4 +862,96 @@ public class Connection extends SimpleChannelInboundHandler> { + public @Nullable UUID getIntendedProfileId() { + return this.intendedProfileId; } + + // Paper start - Optimize network @@ -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 77e1c02b74c1f6597fbb5a457bf463fe52de019e..6d506004583b2415ab356e34e2f8d6ac0e39cca2 100644 +index ffa34134e3b4b6fdeafc0922e4eb49be12c6fbb7..c5e029444adb05c129d51b51f63fcf63a8c70ce8 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -51,11 +51,13 @@ public class ServerConnectionListener { +@@ -55,11 +55,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 77e1c02b74c1f6597fbb5a457bf463fe52de019e..6d506004583b2415ab356e34e2f8d6ac } } // Paper end - prevent blocking on adding a new connection while the server is ticking -@@ -87,6 +89,7 @@ public class ServerConnectionListener { +@@ -91,6 +93,7 @@ public class ServerConnectionListener { } catch (ChannelException var5) { } diff --git a/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0002-Entity-Activation-Range-2.0.patch similarity index 93% rename from paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch rename to paper-server/patches/features/0002-Entity-Activation-Range-2.0.patch index 565f83bbc7d2..61b48cd006e4 100644 --- a/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0002-Entity-Activation-Range-2.0.patch @@ -15,16 +15,17 @@ Adds villagers as separate config diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java new file mode 100644 -index 0000000000000000000000000000000000000000..ce6b57eeeeb1bd652f4bb53c19dcfbc05126c7e9 +index 0000000000000000000000000000000000000000..fe05c3bd9adeddc2dd740af3546f835c1c2de311 --- /dev/null +++ b/io/papermc/paper/entity/activation/ActivationRange.java -@@ -0,0 +1,334 @@ +@@ -0,0 +1,335 @@ +package io.papermc.paper.entity.activation; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EntityTypes; +import net.minecraft.world.entity.ExperienceOrb; +import net.minecraft.world.entity.LightningBolt; +import net.minecraft.world.entity.LivingEntity; @@ -344,9 +345,9 @@ index 0000000000000000000000000000000000000000..ce6b57eeeeb1bd652f4bb53c19dcfbc0 + } + + private static Set> ENTITIES_THAT_FLY = Set.of( -+ EntityType.GHAST, -+ EntityType.HAPPY_GHAST, -+ EntityType.PHANTOM ++ EntityTypes.GHAST, ++ EntityTypes.HAPPY_GHAST, ++ EntityTypes.PHANTOM + ); + + private static boolean isEntityThatFlies(final Entity entity) { @@ -354,10 +355,10 @@ index 0000000000000000000000000000000000000000..ce6b57eeeeb1bd652f4bb53c19dcfbc0 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 89da20b0682708ba8bfc0d10381eb9784d80c395..b5d63d7b848c11ed322d512adeee102886cbb6fd 100644 +index 594d22edfaeee1097304478d09f33a3d5e0dd51d..dc12dc263ae235a5ccf1fb54e418dae9deae25e2 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 +@@ -619,6 +619,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet profiler.pop(); } @@ -365,7 +366,7 @@ index 89da20b0682708ba8bfc0d10381eb9784d80c395..b5d63d7b848c11ed322d512adeee1028 this.entityTickList .forEach( entity -> { -@@ -1383,12 +1384,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1094,12 +1095,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet entity.totalEntityAge++; // Paper - age-like counter for all entities profiler.push(entity.typeHolder()::getRegisteredName); profiler.incrementCounter("tickNonPassenger"); @@ -382,7 +383,7 @@ index 89da20b0682708ba8bfc0d10381eb9784d80c395..b5d63d7b848c11ed322d512adeee1028 } // Paper start - log detailed entity tick information } finally { -@@ -1399,7 +1403,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1110,7 +1114,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet // Paper end - log detailed entity tick information } @@ -391,7 +392,7 @@ index 89da20b0682708ba8bfc0d10381eb9784d80c395..b5d63d7b848c11ed322d512adeee1028 if (entity.isRemoved() || entity.getVehicle() != vehicle) { entity.stopRiding(); } else if (entity instanceof Player || this.entityTickList.contains(entity)) { -@@ -1409,12 +1413,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1120,12 +1124,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet ProfilerFiller profiler = Profiler.get(); profiler.push(entity.typeHolder()::getRegisteredName); profiler.incrementCounter("tickPassenger"); @@ -415,10 +416,10 @@ index 89da20b0682708ba8bfc0d10381eb9784d80c395..b5d63d7b848c11ed322d512adeee1028 } } diff --git a/net/minecraft/world/entity/AgeableMob.java b/net/minecraft/world/entity/AgeableMob.java -index 1cca5523edf4052bd3048496d38acd44f19a7c63..9f77fcd1cebf675a90adb55c6ffd34e9c5bc0aa7 100644 +index dad587ec02f434c0ce91244d9668664a9681f354..3cf4c6af77a315b7a6d05571192b1249efbc128c 100644 --- a/net/minecraft/world/entity/AgeableMob.java +++ b/net/minecraft/world/entity/AgeableMob.java -@@ -189,6 +189,21 @@ public abstract class AgeableMob extends PathfinderMob { +@@ -197,6 +197,21 @@ public abstract class AgeableMob extends PathfinderMob { super.onSyncedDataUpdated(accessor); } @@ -441,7 +442,7 @@ index 1cca5523edf4052bd3048496d38acd44f19a7c63..9f77fcd1cebf675a90adb55c6ffd34e9 public void aiStep() { super.aiStep(); diff --git a/net/minecraft/world/entity/AreaEffectCloud.java b/net/minecraft/world/entity/AreaEffectCloud.java -index 0df8332933203a904bd9ef9efb3c9bce21e65441..1a502cbd8acea9420fa6dd8d716018b5ede4ba6a 100644 +index 8948755478b9d8bcf49593be695daca45a4e65ad..76ad0a8c9161e5c8602f015deb9003b8ee095c23 100644 --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java @@ -140,6 +140,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { @@ -462,10 +463,10 @@ 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 593265d78564b60bacbb4899f18a6e74bf56601d..84c664711658eb83b5ff9d4c8470fd8ec54a5473 100644 +index 943264d99c6dd879dfa363638c072ad1fca0159b..4837708576725decc0fad19cf92e52341fffe034 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -382,6 +382,15 @@ public abstract class Entity +@@ -426,6 +426,15 @@ public abstract class Entity private final int despawnTime; // Paper - entity despawn time limit public int totalEntityAge; // Paper - age-like counter for all entities public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges @@ -481,7 +482,7 @@ index 593265d78564b60bacbb4899f18a6e74bf56601d..84c664711658eb83b5ff9d4c8470fd8e // CraftBukkit end // Paper start -@@ -547,6 +556,13 @@ public abstract class Entity +@@ -442,6 +451,13 @@ public abstract class Entity this.position = Vec3.ZERO; this.blockPosition = BlockPos.ZERO; this.chunkPosition = ChunkPos.ZERO; @@ -495,7 +496,7 @@ index 593265d78564b60bacbb4899f18a6e74bf56601d..84c664711658eb83b5ff9d4c8470fd8e SynchedEntityData.Builder entityDataBuilder = new SynchedEntityData.Builder(this); entityDataBuilder.define(DATA_SHARED_FLAGS_ID, (byte)0); entityDataBuilder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply()); -@@ -1135,6 +1151,10 @@ public abstract class Entity +@@ -1034,6 +1050,10 @@ public abstract class Entity } else { if (moverType == MoverType.PISTON) { delta = this.limitPistonMovement(delta); @@ -506,7 +507,7 @@ index 593265d78564b60bacbb4899f18a6e74bf56601d..84c664711658eb83b5ff9d4c8470fd8e if (delta.equals(Vec3.ZERO)) { return; } -@@ -1150,6 +1170,13 @@ public abstract class Entity +@@ -1049,6 +1069,13 @@ public abstract class Entity this.stuckSpeedMultiplier = Vec3.ZERO; this.setDeltaMovement(Vec3.ZERO); } @@ -521,10 +522,10 @@ index 593265d78564b60bacbb4899f18a6e74bf56601d..84c664711658eb83b5ff9d4c8470fd8e 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 f62e535b62d249dd3be19d7c1b02fae8dad31c10..6eb95b979ffe37d78fd68eb57ebe71891beb0d28 100644 +index 3f7ca2206ec29e77613c85129ad06f642b53a213..98a9aa825dd7dd17af1b3c269d48d758352328c8 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3380,6 +3380,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3404,6 +3404,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin protected void playAttackSound() { } @@ -540,10 +541,10 @@ index f62e535b62d249dd3be19d7c1b02fae8dad31c10..6eb95b979ffe37d78fd68eb57ebe7189 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index e63ac861b785cf3dccac25404454289c44b7ec9d..8b036640be655c65852e0862e30962e443d3024d 100644 +index c68f122ddc161ce9b4be6d826187c14a0e830a58..282ae01e8d83b866fae10354dc93a4266b0696c0 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 +@@ -216,6 +216,20 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs return this.lookControl; } @@ -578,7 +579,7 @@ index a19d8d4c0075340e8d187d5f8b6ce989567d3163..c661311dfdc1e21e3d6ec65e1e8b9536 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 c918154444a05917a3622947d0ddbc29bdb9bead..b13bdc2852504903fa054c42f89299a5d33dfbd3 100644 +index 706a7ce383afef9d80197afafcb6e6dab138ae29..66839736d997f5c911dfd9cf251b0d4406172782 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 { @@ -589,7 +590,7 @@ index c918154444a05917a3622947d0ddbc29bdb9bead..b13bdc2852504903fa054c42f89299a5 public void addGoal(final int prio, final Goal goal) { this.availableGoals.add(new WrappedGoal(prio, goal)); -@@ -33,6 +34,22 @@ public class GoalSelector { +@@ -39,6 +40,22 @@ public class GoalSelector { this.availableGoals.removeIf(goal -> predicate.test(goal.getGoal())); } @@ -610,8 +611,8 @@ index c918154444a05917a3622947d0ddbc29bdb9bead..b13bdc2852504903fa054c42f89299a5 + // Paper end - EAR 2 + public void removeGoal(final Goal toRemove) { - for (WrappedGoal availableGoal : this.availableGoals) { - if (availableGoal.getGoal() == toRemove && availableGoal.isRunning()) { + this.removeAllGoals(goal -> goal == toRemove); + } diff --git a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java index d46e0e3a4a7fc3bb3f1dd695d4cc563778b99db0..c6e9b155c2341c13d569f28f54f0c1d2d7313676 100644 --- a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java @@ -640,10 +641,10 @@ index d46e0e3a4a7fc3bb3f1dd695d4cc563778b99db0..c6e9b155c2341c13d569f28f54f0c1d2 } } diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index ca0b7ce4ab535d7112b315a7de1dc5130797ea2d..974d1d7b283aace71f0ea8ef07ba68a17b75af8a 100644 +index fd25032b8a68bec2951fdc626fd95946fea5deb4..c800c894a921ae77ed1757794ddf8d737b05681e 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 { +@@ -125,6 +125,29 @@ public class ItemEntity extends Entity implements TraceableEntity { return 0.04; } @@ -674,10 +675,10 @@ index ca0b7ce4ab535d7112b315a7de1dc5130797ea2d..974d1d7b283aace71f0ea8ef07ba68a1 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 084a4a945d4fc6a76878da00e5015c79fc88b47f..e4ba6e200e85f4e226d6a3e68db734f277b89226 100644 +index e1cac3972e8ec33ee269061e2f4dee83c04dbeb7..4f8439afa4ea602b662e68e6b86e9d927fb6a481 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 +@@ -235,11 +235,35 @@ public class Villager extends AbstractVillager implements VillagerDataHolder, Re return this.assignProfessionWhenSpawned; } @@ -714,7 +715,7 @@ index 084a4a945d4fc6a76878da00e5015c79fc88b47f..e4ba6e200e85f4e226d6a3e68db734f2 profiler.pop(); if (this.assignProfessionWhenSpawned) { this.assignProfessionWhenSpawned = false; -@@ -272,7 +296,7 @@ public class Villager extends AbstractVillager implements VillagerDataHolder, Re +@@ -263,7 +287,7 @@ public class Villager extends AbstractVillager implements VillagerDataHolder, Re this.lastTradedPlayer = null; } @@ -723,7 +724,7 @@ index 084a4a945d4fc6a76878da00e5015c79fc88b47f..e4ba6e200e85f4e226d6a3e68db734f2 Raid raid = level.getRaidAt(this.blockPosition()); if (raid != null && raid.isActive() && !raid.isOver()) { level.broadcastEntityEvent(this, EntityEvent.VILLAGER_SWEAT); -@@ -283,6 +307,7 @@ public class Villager extends AbstractVillager implements VillagerDataHolder, Re +@@ -274,6 +298,7 @@ public class Villager extends AbstractVillager implements VillagerDataHolder, Re this.stopTrading(); } @@ -732,10 +733,10 @@ index 084a4a945d4fc6a76878da00e5015c79fc88b47f..e4ba6e200e85f4e226d6a3e68db734f2 } diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index c457a6b0935fa4dce20f93db79c27070ce147705..c9f7e68abccbc6b894a66b675952c973e22af8e6 100644 +index eac6a80bc21280f9872344583ad825df40e03640..325bdcd8c7dd4e03aa6f649c8f76b031529d5fd8 100644 --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -111,6 +111,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -112,6 +112,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { return super.shouldRender(camX, camY, camZ) && !this.isAttachedToEntity(); } @@ -758,10 +759,10 @@ index c457a6b0935fa4dce20f93db79c27070ce147705..c9f7e68abccbc6b894a66b675952c973 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/projectile/arrow/Arrow.java b/net/minecraft/world/entity/projectile/arrow/Arrow.java -index f3861c936855a0d9c9170585f4da4ce1cd77b854..3b4cbbc4c8ca1cd3110d1d6ba9e3531283b53c08 100644 +index 3bdfe511c6df6188ea8a4ecd38864b268f42b5c6..546503142ad5330fdf8ed2acbe9ac18e6b9e3e80 100644 --- a/net/minecraft/world/entity/projectile/arrow/Arrow.java +++ b/net/minecraft/world/entity/projectile/arrow/Arrow.java -@@ -70,6 +70,16 @@ public class Arrow extends AbstractArrow { +@@ -71,6 +71,16 @@ public class Arrow extends AbstractArrow { entityData.define(ID_EFFECT_COLOR, -1); } @@ -818,10 +819,10 @@ index f46cca0467bb4da5511bc953ce5b43fa606bf978..445c5cafad71028171c1f26193966177 + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index cc492445307ddc08446484d272866f01646cf7b3..a5d46832d4f8a13b0bf67b523c21d5c3b44209a9 100644 +index bfb65ccca995366261e857aec69cae0fcf0dbf07..2f8f8e1fbc5f01b09d70a6ea5b4ed69664249c86 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 +@@ -155,6 +155,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Nullable public List captureDrops; public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); @@ -835,7 +836,7 @@ index cc492445307ddc08446484d272866f01646cf7b3..a5d46832d4f8a13b0bf67b523c21d5c3 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 ef78f286ca14512c3dfccdb8fb06ebe9affa1589..c5c0b01c41055a82e49c1546d4525da0acce13a4 100644 +index 089401dbd221cdf865eea04e5529024d53c6e963..3fcb1a45a547681740d6ec8946b274539448cf95 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/0003-Optimize-Voxel-Shape-Merging.patch similarity index 96% rename from paper-server/patches/features/0006-Optimize-Voxel-Shape-Merging.patch rename to paper-server/patches/features/0003-Optimize-Voxel-Shape-Merging.patch index c927369ad44c..4f604c5e916e 100644 --- a/paper-server/patches/features/0006-Optimize-Voxel-Shape-Merging.patch +++ b/paper-server/patches/features/0003-Optimize-Voxel-Shape-Merging.patch @@ -67,14 +67,14 @@ index 6c637af546a411d5790ceba9936aa9128d05d97e..e18f24a3941e1102648bac841851a874 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 ccdaf6043f667b6983e4492cf570947ed5179df1..5c552f618d09fa9456195bbfa643ce4a1a03bd84 100644 +index f3235d10461382573053d890ab00c62bf17d3553..5a3852b669df2a842be5c9f41e645145e72554f9 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 { +@@ -293,11 +293,26 @@ public final class Shapes { } @VisibleForTesting -- protected static IndexMerger createIndexMerger( +- static IndexMerger createIndexMerger( + private static IndexMerger createIndexMerger( // Paper - private final int cost, final DoubleList first, final DoubleList second, final boolean firstOnlyMatters, final boolean secondOnlyMatters ) { @@ -98,7 +98,7 @@ index ccdaf6043f667b6983e4492cf570947ed5179df1..5c552f618d09fa9456195bbfa643ce4a if (first instanceof CubePointRange && second instanceof CubePointRange) { long size = lcm(firstSize, secondSize); if (cost * size <= 256L) { -@@ -355,14 +370,21 @@ public final class Shapes { +@@ -305,14 +320,21 @@ public final class Shapes { } } diff --git a/paper-server/patches/features/0007-optimize-dirt-and-snow-spreading.patch b/paper-server/patches/features/0004-optimize-dirt-and-snow-spreading.patch similarity index 98% rename from paper-server/patches/features/0007-optimize-dirt-and-snow-spreading.patch rename to paper-server/patches/features/0004-optimize-dirt-and-snow-spreading.patch index 8605b4256514..95615fbbd07b 100644 --- a/paper-server/patches/features/0007-optimize-dirt-and-snow-spreading.patch +++ b/paper-server/patches/features/0004-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 85666946f8cb23255360bca8efde2ce13abcbc0a..839bfdda7f54e6aabe401db6da1856544b032bf8 100644 +index 24b0ace935f3eab31163f0dff772b5def82b8ae0..513e23b693aa0f47bcf91e9087159a75471efd36 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 { diff --git a/paper-server/patches/features/0008-Use-Velocity-compression-and-cipher-natives.patch b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch similarity index 95% rename from paper-server/patches/features/0008-Use-Velocity-compression-and-cipher-natives.patch rename to paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch index fdb6b9a8c8d8..5b9e51de3726 100644 --- a/paper-server/patches/features/0008-Use-Velocity-compression-and-cipher-natives.patch +++ b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch @@ -267,18 +267,19 @@ index 595db570b0ade9cad7de77d2ab7b10d9e68699df..ac095f59d9f17d8239d6493d1c1e3942 + // Paper end - Use Velocity cipher } diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index d14aea970ce98edfe3dc3692e707334e7e150804..0f06d509125e72ec11d263d0d5c2179d65f6d8dd 100644 +index a01698455cc5650899e2dc8732154cc9b04b1bb0..99751e03a4b5389682140bbade93e5a64feff87e 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -730,11 +730,22 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -744,10 +744,24 @@ public class Connection extends SimpleChannelInboundHandler> { return connection; } - public void setEncryptionKey(final Cipher decryptCipher, final Cipher encryptCipher) { -- this.encrypted = true; - this.channel.pipeline().addBefore(HandlerNames.SPLITTER, HandlerNames.DECRYPT, new CipherDecoder(decryptCipher)); - this.channel.pipeline().addBefore(HandlerNames.PREPENDER, HandlerNames.ENCRYPT, new CipherEncoder(encryptCipher)); + // Paper start - Use Velocity cipher ++ private boolean encrypted; ++ + public void setEncryptionKey(final javax.crypto.SecretKey key) throws net.minecraft.util.CryptException { + if (!this.encrypted) { + try { @@ -295,9 +296,9 @@ index d14aea970ce98edfe3dc3692e707334e7e150804..0f06d509125e72ec11d263d0d5c2179d } + // Paper end - Use Velocity cipher - public boolean isEncrypted() { - return this.encrypted; -@@ -772,16 +783,17 @@ public class Connection extends SimpleChannelInboundHandler> { + public boolean isConnected() { + return this.channel != null && this.channel.isOpen(); +@@ -781,16 +795,17 @@ public class Connection extends SimpleChannelInboundHandler> { public void setupCompression(final int threshold, final boolean validateDecompressed) { if (threshold >= 0) { @@ -319,10 +320,10 @@ index d14aea970ce98edfe3dc3692e707334e7e150804..0f06d509125e72ec11d263d0d5c2179d 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 6d506004583b2415ab356e34e2f8d6ac0e39cca2..474b7f06223514d95bad3d91356dfaa5435b77f5 100644 +index c5e029444adb05c129d51b51f63fcf63a8c70ce8..4552ebad6154c0178f928a4e9a5fe061f6fbde52 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -76,6 +76,10 @@ public class ServerConnectionListener { +@@ -80,6 +80,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. @@ -334,17 +335,15 @@ index 6d506004583b2415ab356e34e2f8d6ac0e39cca2..474b7f06223514d95bad3d91356dfaa5 .add( new ServerBootstrap() diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 50e4f4037702875fe7755b169947abd800b06e7b..722c832ce18fd930d9fdb4f718dc13bfc962e5dd 100644 +index 04d027b9a044d197c15fd8de95e475b94ba3ad7c..7a83935dd71fcf69c655259209c4af5983980b50 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -251,11 +251,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - } - +@@ -255,9 +255,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, SecretKey secretKey = packet.getSecretKey(serverPrivateKey); -- Cipher decryptCipher = Crypt.getCipher(2, secretKey); -- Cipher encryptCipher = Crypt.getCipher(1, secretKey); digest = new BigInteger(Crypt.digestData("", this.server.getKeyPair().getPublic(), secretKey)).toString(16); this.state = ServerLoginPacketListenerImpl.State.AUTHENTICATING; +- Cipher decryptCipher = Crypt.getCipher(Cipher.DECRYPT_MODE, secretKey); +- Cipher encryptCipher = Crypt.getCipher(Cipher.ENCRYPT_MODE, secretKey); - this.connection.setEncryptionKey(decryptCipher, encryptCipher); + this.connection.setEncryptionKey(secretKey); // Paper - Use Velocity cipher } catch (CryptException e) { diff --git a/paper-server/patches/features/0010-Handle-Oversized-block-entities-in-chunks.patch b/paper-server/patches/features/0006-Handle-Oversized-block-entities-in-chunks.patch similarity index 97% rename from paper-server/patches/features/0010-Handle-Oversized-block-entities-in-chunks.patch rename to paper-server/patches/features/0006-Handle-Oversized-block-entities-in-chunks.patch index 6550f27bbb22..b0070deb697a 100644 --- a/paper-server/patches/features/0010-Handle-Oversized-block-entities-in-chunks.patch +++ b/paper-server/patches/features/0006-Handle-Oversized-block-entities-in-chunks.patch @@ -9,7 +9,7 @@ creating too large of a packet to sed. Co-authored-by: Spottedleaf diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 6ecda939755534ce0f35680be16a04c0a0e0a312..488d5654f5414c9950f19e86a791507366366e01 100644 +index ab0653c49aabf520a186e2df217aebbb91d2a06c..d7a1dde0452632d46fe594afa158cace71698de8 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -32,6 +32,14 @@ public class ClientboundLevelChunkPacketData { diff --git a/paper-server/patches/features/0011-Optimize-Bit-Operations-by-inlining.patch b/paper-server/patches/features/0007-Optimize-Bit-Operations-by-inlining.patch similarity index 92% rename from paper-server/patches/features/0011-Optimize-Bit-Operations-by-inlining.patch rename to paper-server/patches/features/0007-Optimize-Bit-Operations-by-inlining.patch index f4b1300a9e1c..8999774906e3 100644 --- a/paper-server/patches/features/0011-Optimize-Bit-Operations-by-inlining.patch +++ b/paper-server/patches/features/0007-Optimize-Bit-Operations-by-inlining.patch @@ -7,10 +7,10 @@ Inline bit operations and reduce instruction count to make these hot operations faster diff --git a/net/minecraft/core/BlockPos.java b/net/minecraft/core/BlockPos.java -index 1359d55f32160d74b5dd7cd1a575ad1a87d5d70c..b94e57a7776b211d509c873edbd6bc9128cc4d35 100644 +index 63203d7e3dba6d24f642700b8d724ab45d7153c3..f4c9543cca33c3730b18cedb47127d702818acb1 100644 --- a/net/minecraft/core/BlockPos.java +++ b/net/minecraft/core/BlockPos.java -@@ -48,15 +48,17 @@ public class BlockPos extends Vec3i { +@@ -47,15 +47,17 @@ public class BlockPos extends Vec3i { } }; public static final BlockPos ZERO = new BlockPos(0, 0, 0); @@ -36,7 +36,7 @@ index 1359d55f32160d74b5dd7cd1a575ad1a87d5d70c..b94e57a7776b211d509c873edbd6bc91 public BlockPos(final int x, final int y, final int z) { super(x, y, z); -@@ -66,28 +68,29 @@ public class BlockPos extends Vec3i { +@@ -65,28 +67,29 @@ public class BlockPos extends Vec3i { this(vec3i.getX(), vec3i.getY(), vec3i.getZ()); } @@ -71,7 +71,7 @@ index 1359d55f32160d74b5dd7cd1a575ad1a87d5d70c..b94e57a7776b211d509c873edbd6bc91 } public static BlockPos containing(final double x, final double y, final double z) { -@@ -111,10 +114,7 @@ public class BlockPos extends Vec3i { +@@ -110,10 +113,7 @@ public class BlockPos extends Vec3i { } public static long asLong(final int x, final int y, final int z) { @@ -84,10 +84,10 @@ index 1359d55f32160d74b5dd7cd1a575ad1a87d5d70c..b94e57a7776b211d509c873edbd6bc91 public static long getFlatIndex(final long neighborBlockNode) { diff --git a/net/minecraft/core/SectionPos.java b/net/minecraft/core/SectionPos.java -index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec1e28d582 100644 +index e8d925affa2c4b6bd34345fc42e2477c682bd64c..17e7308e0903ecddac6a75b6a7132e0e0c591cdf 100644 --- a/net/minecraft/core/SectionPos.java +++ b/net/minecraft/core/SectionPos.java -@@ -42,7 +42,7 @@ public class SectionPos extends Vec3i { +@@ -43,7 +43,7 @@ public class SectionPos extends Vec3i { } public static SectionPos of(final BlockPos pos) { @@ -96,7 +96,7 @@ index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec } public static SectionPos of(final ChunkPos pos, final int sectionY) { -@@ -58,7 +58,7 @@ public class SectionPos extends Vec3i { +@@ -59,7 +59,7 @@ public class SectionPos extends Vec3i { } public static SectionPos of(final long sectionNode) { @@ -105,7 +105,7 @@ index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec } public static SectionPos bottomOf(final ChunkAccess chunk) { -@@ -69,8 +69,16 @@ public class SectionPos extends Vec3i { +@@ -70,8 +70,16 @@ public class SectionPos extends Vec3i { return offset(sectionNode, offset.getStepX(), offset.getStepY(), offset.getStepZ()); } @@ -123,7 +123,7 @@ index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec } public static int posToSectionCoord(final double pos) { -@@ -90,10 +98,7 @@ public class SectionPos extends Vec3i { +@@ -91,10 +99,7 @@ public class SectionPos extends Vec3i { } public static short sectionRelativePos(final BlockPos pos) { @@ -135,7 +135,7 @@ index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec } public static int sectionRelativeX(final short relative) { -@@ -156,16 +161,16 @@ public class SectionPos extends Vec3i { +@@ -157,16 +162,16 @@ public class SectionPos extends Vec3i { return this.getZ(); } @@ -158,7 +158,7 @@ index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec } public int maxBlockX() { -@@ -181,9 +186,7 @@ public class SectionPos extends Vec3i { +@@ -182,9 +187,7 @@ public class SectionPos extends Vec3i { } public static long blockToSection(final long blockNode) { @@ -169,7 +169,7 @@ index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec } public static long getZeroNode(final int x, final int z) { -@@ -215,15 +218,17 @@ public class SectionPos extends Vec3i { +@@ -216,15 +219,17 @@ public class SectionPos extends Vec3i { return asLong(blockToSectionCoord(pos.getX()), blockToSectionCoord(pos.getY()), blockToSectionCoord(pos.getZ())); } @@ -192,7 +192,7 @@ index e6595167980d93772088f63ba6dd0423489d90c4..96439461ea272b9f5101365a094f8eec } @Override -@@ -236,10 +241,7 @@ public class SectionPos extends Vec3i { +@@ -237,10 +242,7 @@ public class SectionPos extends Vec3i { } public static Stream cube(final SectionPos center, final int radius) { diff --git a/paper-server/patches/features/0012-Remove-streams-from-hot-code.patch b/paper-server/patches/features/0008-Remove-streams-from-hot-code.patch similarity index 100% rename from paper-server/patches/features/0012-Remove-streams-from-hot-code.patch rename to paper-server/patches/features/0008-Remove-streams-from-hot-code.patch diff --git a/paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/paper-server/patches/features/0009-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch similarity index 100% rename from paper-server/patches/features/0013-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch rename to paper-server/patches/features/0009-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch diff --git a/paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch b/paper-server/patches/features/0010-Eigencraft-redstone-implementation.patch similarity index 99% rename from paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch rename to paper-server/patches/features/0010-Eigencraft-redstone-implementation.patch index 5ee7ca55c5fe..bd4e89f4c741 100644 --- a/paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch +++ b/paper-server/patches/features/0010-Eigencraft-redstone-implementation.patch @@ -973,7 +973,7 @@ index 0000000000000000000000000000000000000000..8e03419df1469c6fecfaa82fcb319a58 + } +} diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 0ee7bc3a10896a4f59fa94df158bce741aea0464..a00002774755eb90a0b772fe742b30a5e09452cf 100644 +index 30353df7dbd986bd49bee466ed28814684dd3f76..b75d36c519d94d666752b7bfb3c8b62a09563eb6 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -269,6 +269,56 @@ public class RedStoneWireBlock extends Block { @@ -1061,7 +1061,7 @@ index 0ee7bc3a10896a4f59fa94df158bce741aea0464..a00002774755eb90a0b772fe742b30a5 dropResources(state, level, pos); level.removeBlock(pos, false); diff --git a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java -index 45c3586a653f4ec22b9fb859b2869503d0b6c5b3..81b7b625dbfe69f2a9d74dac000a0e60a75db839 100644 +index e01604a7913601e9d84d39509c24210c810dcefd..2540a39f40827ff864a9b3e8bec5cb7b43dbcebd 100644 --- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java @@ -44,7 +44,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator { diff --git a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0011-Add-Alternate-Current-redstone-implementation.patch similarity index 99% rename from paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch rename to paper-server/patches/features/0011-Add-Alternate-Current-redstone-implementation.patch index e9123d2691af..7574a44d54c0 100644 --- a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0011-Add-Alternate-Current-redstone-implementation.patch @@ -2194,7 +2194,7 @@ index 0000000000000000000000000000000000000000..259b301b2c8b64cb7974a235afb260e0 +} diff --git a/alternate/current/wire/WireNode.java b/alternate/current/wire/WireNode.java new file mode 100644 -index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9f5689bdb +index 0000000000000000000000000000000000000000..33cd90c30c22200a4e1ae64f40a0bf7864546b33 --- /dev/null +++ b/alternate/current/wire/WireNode.java @@ -0,0 +1,122 @@ @@ -2314,17 +2314,17 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9 + return true; + } + -+ currentPower = LevelHelper.doRedstoneEvent(level, pos, currentPower, Mth.clamp(virtualPower, Redstone.SIGNAL_MIN, Redstone.SIGNAL_MAX));; ++ currentPower = LevelHelper.doRedstoneEvent(level, pos, currentPower, Mth.clamp(virtualPower, Redstone.SIGNAL_MIN, Redstone.SIGNAL_MAX)); + state = state.setValue(RedStoneWireBlock.POWER, currentPower); + + return LevelHelper.setWireState(level, pos, state, added); + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 9fc39230f52f4cf6b44edd34aa9542b9d500538e..965d9f515d0410df3395d07c6cf5e6349c75c923 100644 +index dc12dc263ae235a5ccf1fb54e418dae9deae25e2..283c293de7e1997933604983fbf86fe6848d1c6d 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 +@@ -234,6 +234,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet private @Nullable ServerClockManager clockManager; public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent @@ -2332,7 +2332,7 @@ index 9fc39230f52f4cf6b44edd34aa9542b9d500538e..965d9f515d0410df3395d07c6cf5e634 @Override public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { -@@ -2775,6 +2776,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2447,6 +2448,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet return this.debugSynchronizers; } @@ -2347,10 +2347,10 @@ index 9fc39230f52f4cf6b44edd34aa9542b9d500538e..965d9f515d0410df3395d07c6cf5e634 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 8d1d7582730e05bf605db31e13ee24242592074e..3d20ef3bc4e891e3e6e5f9f6f5efc6c0367369ea 100644 +index 2f8f8e1fbc5f01b09d70a6ea5b4ed69664249c86..017f76d0bbca6a3b32be7f36137439365aa69f7e 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -2156,6 +2156,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1458,6 +1458,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return this.palettedContainerFactory; } @@ -2369,7 +2369,7 @@ index 8d1d7582730e05bf605db31e13ee24242592074e..3d20ef3bc4e891e3e6e5f9f6f5efc6c0 NONE("none"), BLOCK("block"), diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 5bdeaa9ae20de9f42e760d2207219d5f22d95e9b..0e285f38d282b29f625c5578ee1871a6c2b8585d 100644 +index b75d36c519d94d666752b7bfb3c8b62a09563eb6..35e49078d8d36ae4683de26988435d971c7f0e89 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/0020-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0012-Incremental-chunk-and-player-saving.patch similarity index 86% rename from paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch rename to paper-server/patches/features/0012-Incremental-chunk-and-player-saving.patch index 25138bee13b5..e3c53ef9bd37 100644 --- a/paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0012-Incremental-chunk-and-player-saving.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 49be7709026cd75cfcb31715550387f0ba954a16..f9da26656b18327e3bcc1537a5f51e84b32cc43a 100644 +index 7b2a078c11cc5e7b9770ee3811e2b04479d20b37..0f41295186f7dbcdf3c496c97b70b9732ce1ca23 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -961,7 +961,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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 bab8c73be9537a1d531871b1b72bed87d2e0956e..02d19fc610e738f5ed12c23ab92bbdcbabaeced3 100644 +index e50ffa3c66026fae9b6be3b28a8536cd5c22f1b2..45f5a1846f857a7526edf280202fccd94858d05b 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -330,7 +330,7 @@ public abstract class PlayerList { +@@ -331,7 +331,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,10 +209,10 @@ index bab8c73be9537a1d531871b1b72bed87d2e0956e..02d19fc610e738f5ed12c23ab92bbdcb } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 5a5f7cbc0217ab7aa034698802f634d149662da1..f4302e835fa9684d0fc7d6b65075ec3ec40f8f9f 100644 +index 017f76d0bbca6a3b32be7f36137439365aa69f7e..8812d33fad6f54b07544605749bcd35e9551a807 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 +@@ -145,6 +145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { private long subTickCount; // CraftBukkit start @@ -220,7 +220,7 @@ index 5a5f7cbc0217ab7aa034698802f634d149662da1..f4302e835fa9684d0fc7d6b65075ec3e private final CraftWorld world; public org.bukkit.generator.@Nullable ChunkGenerator generator; -@@ -836,7 +837,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -213,7 +214,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { org.bukkit.generator.@Nullable BiomeProvider biomeProvider, // Paper org.bukkit.World.Environment environment, // Paper java.util.function.Function paperWorldConfigCreator, // Paper - create paper world config + java.util.concurrent.Executor executor // Paper - Anti-Xray ) { - // Paper start - getblock optimisations - cache world height/sections - final DimensionType dimType = dimensionTypeRegistration.value(); -@@ -871,6 +873,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + final org.bukkit.NamespacedKey worldKey = CraftNamespacedKey.fromMinecraft(dimension.identifier()); // Paper + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, worldKey); // Spigot +@@ -238,6 +240,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + this.registryAccess = registryAccess; this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); - this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system + this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new io.papermc.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : io.papermc.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray } - // Paper start - Cancel hit for vanished players -@@ -1088,6 +1091,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + public int getNextEntityId() { +@@ -459,6 +462,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } // CraftBukkit end - capture blockstates BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); @@ -247,20 +247,15 @@ index 5a5f7cbc0217ab7aa034698802f634d149662da1..f4302e835fa9684d0fc7d6b65075ec3e // 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 +index de6c4c7518a48c237df4b7a1ca6ef5e6e0aa99e3..c1738500a2e5a7244087351081c71d7633b1c7f9 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -161,7 +161,7 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM +@@ -110,13 +110,13 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM } } - replaceMissingSections(containerFactory, this.sections); + this.replaceMissingSections(containerFactory, this.sections); // Paper - Anti-Xray - make it a non-static method - // Paper start - rewrite chunk system - if (!((Object)this instanceof ImposterProtoChunk)) { - this.starlight$setBlockNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(levelHeightAccessor)); -@@ -174,10 +174,10 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM - // Paper end - get block chunk optimisation } - private static void replaceMissingSections(final PalettedContainerFactory containerFactory, final LevelChunkSection[] sections) { @@ -273,10 +268,10 @@ index c974b1c276d29610cb59566afaad19f5bcf0c602..c73b9871faa87493e081cb54e1bf1dce } } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 536c24ec46bdf571637376728aee06755a6256ef..b381c4d5a8b981f34852d029bbe46374d24f7879 100644 +index f5d4733e0f1654aa1495b72ff83489acdbb8f5c6..eb88266d43fa31b54fea433c6d47dc0e6e3a0d33 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -151,7 +151,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -118,7 +118,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { final LevelChunk.@Nullable PostLoadProcessor postLoad, final @Nullable BlendingData blendingData ) { @@ -286,10 +281,10 @@ index 536c24ec46bdf571637376728aee06755a6256ef..b381c4d5a8b981f34852d029bbe46374 this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index 0e7bb7db9e46b2cade771fa5e94469023d8b47b0..0f807317cc7fa113ee57ab31f91bb6b8df7c4ae0 100644 +index d1bf15ab369af57d022ff133b8d37afc98f9eb8c..6276b471b3cdd49c25a2323d7a08c8892dce53e4 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -60,8 +60,14 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -33,8 +33,14 @@ public class LevelChunkSection { this.recalcBlockCounts(); } @@ -305,7 +300,7 @@ index 0e7bb7db9e46b2cade771fa5e94469023d8b47b0..0f807317cc7fa113ee57ab31f91bb6b8 this.biomes = containerFactory.createForBiomes(); } -@@ -283,11 +289,17 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -176,11 +182,17 @@ public class LevelChunkSection { this.biomes = biomes; } @@ -326,12 +321,12 @@ index 0e7bb7db9e46b2cade771fa5e94469023d8b47b0..0f807317cc7fa113ee57ab31f91bb6b8 public int getSerializedSize() { diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8ef640028 100644 +index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e9933fc5bd4 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 private static final int MIN_PALETTE_BITS = 0; - public volatile PalettedContainer.Data data; // Paper - optimise collisions - public + private volatile PalettedContainer.Data data; private final Strategy strategy; + private final T @Nullable [] presetValues; // Paper - Anti-Xray - Add preset values //private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused @@ -360,9 +355,9 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 return codec(elementCodec, strategy, defaultValue, unpacker); } -@@ -91,19 +99,57 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -64,17 +72,55 @@ public class PalettedContainer implements PaletteResize, PalettedContainer + ); } - // Paper end - optimise palette reads - private PalettedContainer(final Strategy strategy, final Configuration dataConfiguration, final BitStorage storage, final Palette palette) { + // Paper start - Anti-Xray - Add preset values @@ -398,7 +393,6 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 + } + } + // Paper end - Anti-Xray - this.updateData(this.data); // Paper - optimise palette reads } - private PalettedContainer(final PalettedContainer source) { @@ -406,7 +400,6 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 + this.presetValues = presetValues; // Paper - Anti-Xray - Add preset values this.strategy = source.strategy; this.data = source.data.copy(); - this.updateData(this.data); // Paper - optimise palette reads } + @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Anti-Xray @@ -420,7 +413,7 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 this.strategy = strategy; this.data = this.createOrReuseData(null, 0); this.data.palette.idFor(initialValue, this); -@@ -123,15 +169,39 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -93,14 +139,38 @@ public class PalettedContainer implements PaletteResize, PalettedContainer return new PalettedContainer.Data<>(dataConfiguration, storage, palette); } @@ -451,7 +444,6 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 PalettedContainer.Data newData = this.createOrReuseData(oldData, bits); newData.copyFrom(oldData.palette, oldData.storage); this.data = newData; - this.updateData(this.data); // Paper - optimise palette reads - return newData.palette.idFor(lastAddedValue, PaletteResize.noResizeExpected()); + // Paper start - Anti-Xray + this.addPresetValues(); @@ -462,15 +454,14 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 public synchronized T getAndSet(final int x, final int y, final int z, final T value) { // Paper - synchronize this.acquire(); -@@ -200,6 +270,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -164,24 +234,38 @@ public class PalettedContainer implements PaletteResize, PalettedContainer newData.palette.read(buffer, this.strategy.globalMap()); buffer.readFixedSizeLongArray(newData.storage.getRaw()); this.data = newData; + this.addPresetValues(); // Paper - Anti-Xray - Add preset values (inefficient, but this isn't used by the server) - this.updateData(this.data); // Paper - optimise palette reads } finally { this.release(); -@@ -207,18 +278,31 @@ public class PalettedContainer implements PaletteResize, PalettedContainer + } } @Override @@ -504,7 +495,7 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 List paletteEntries = discData.paletteEntries(); int entryCount = strategy.entryCount(); Configuration storedConfiguration = strategy.getConfigurationForPaletteSize(paletteEntries.size()); -@@ -257,7 +341,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -220,7 +304,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer } } @@ -513,7 +504,7 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 } @Override -@@ -323,12 +407,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -293,12 +377,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @Override public PalettedContainer copy() { @@ -528,7 +519,7 @@ index 4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb..66a05adab494f8674f0636f8b34533f8 } @Override -@@ -398,9 +482,16 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -331,9 +415,16 @@ public class PalettedContainer implements PaletteResize, PalettedContainer return 1 + this.palette.getSerializedSize(globalMap) + this.storage.getRaw().length * 8; } @@ -587,7 +578,7 @@ index 9977331d182cbc592f00006aabce23f0f69d2393..cd20a791b101548367ed53080f78e78b } } diff --git a/net/minecraft/world/level/chunk/PalettedContainerRO.java b/net/minecraft/world/level/chunk/PalettedContainerRO.java -index 4607d2d7591a35d09d748d1ecf7582947bb86f39..f5f40aa2fd1b478045cb9a28b5ae11bc19f337f0 100644 +index 8ce60c968bf8c9be2d6f21cc16762627cbc23219..45e95faebdb81485dc9b3823601f4506d8e85f25 100644 --- a/net/minecraft/world/level/chunk/PalettedContainerRO.java +++ b/net/minecraft/world/level/chunk/PalettedContainerRO.java @@ -14,7 +14,11 @@ public interface PalettedContainerRO { @@ -616,10 +607,10 @@ index 5c518b6ec7da546460884c37e9af682b6ab9fc22..958be147cd940ac430576ca5b4ada70f 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 98fb7a282a33f4391de124ed9be9bcf069178516..7d29fdc6548324d97ec34d476b5b48ec0bdba0d2 100644 +index 760eda9e45a3f31a68a3b2b2dc13479c7db0d3cc..8f55e7a12541e2281e607da2b6a4d4b4c2811562 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( +@@ -129,6 +129,7 @@ public record SerializableChunkData( public static SerializableChunkData parse( final LevelHeightAccessor levelHeight, final PalettedContainerFactory containerFactory, final CompoundTag chunkData ) { @@ -627,7 +618,7 @@ index 98fb7a282a33f4391de124ed9be9bcf069178516..7d29fdc6548324d97ec34d476b5b48ec if (chunkData.getString("Status").isEmpty()) { return null; } -@@ -202,9 +203,11 @@ public record SerializableChunkData( +@@ -190,9 +191,11 @@ public record SerializableChunkData( int y = sectionTag.getByteOr("Y", (byte)0); LevelChunkSection section; if (y >= levelHeight.getMinSectionY() && y <= levelHeight.getMaxSectionY()) { diff --git a/paper-server/patches/features/0031-Delay-open-close-callbacks-for-chests.patch b/paper-server/patches/features/0017-Delay-open-close-callbacks-for-chests.patch similarity index 94% rename from paper-server/patches/features/0031-Delay-open-close-callbacks-for-chests.patch rename to paper-server/patches/features/0017-Delay-open-close-callbacks-for-chests.patch index f04ea538cc0f..d377c6cee53d 100644 --- a/paper-server/patches/features/0031-Delay-open-close-callbacks-for-chests.patch +++ b/paper-server/patches/features/0017-Delay-open-close-callbacks-for-chests.patch @@ -10,7 +10,7 @@ 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 b39b8176d6b1a1d3f7058387518bcbb71a3631bb..5ba46020b47edfc886ecd5c33483ebb0fa57e5dc 100644 +index dd407db2db01b5ff49b7a3cdba92688c484a4928..5bfd25f22808794f5e24d5425ea32e8c1b927182 100644 --- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java @@ -61,6 +61,13 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { @@ -28,7 +28,7 @@ index b39b8176d6b1a1d3f7058387518bcbb71a3631bb..5ba46020b47edfc886ecd5c33483ebb0 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 3635bd9e9b6292ff4389984eae1ae89ebca4be51..324f19786c4e298e706184045aea3e8ab98aaf46 100644 +index 06878204e0df42fc35cfa380413986a045ee229d..a9273aebb5c8efe78e88158f11e1ee2af0dff3f1 100644 --- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java @@ -30,6 +30,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement @@ -100,10 +100,10 @@ index baa8b5aba0500981a191626553d66650c7304b88..52737172ccfa0c7c977e4f2fe1db242e } } diff --git a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -index 592d253921d8adb168840edcc1b24b64969e80f2..551149b8888d78fc17b153a59532ed08e7f5724b 100644 +index a469bef4b2e9c7d57391a5700277066cc5872ae9..6109d8da984b398bb1eb6cd6ab9a55f0511a615c 100644 --- a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -@@ -13,6 +13,13 @@ import net.minecraft.world.level.block.state.BlockState; +@@ -14,6 +14,13 @@ 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() { diff --git a/paper-server/patches/features/0032-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features/0018-Improve-exact-choice-recipe-ingredients.patch similarity index 99% rename from paper-server/patches/features/0032-Improve-exact-choice-recipe-ingredients.patch rename to paper-server/patches/features/0018-Improve-exact-choice-recipe-ingredients.patch index ef902bd3347f..1a1e21477ed2 100644 --- a/paper-server/patches/features/0032-Improve-exact-choice-recipe-ingredients.patch +++ b/paper-server/patches/features/0018-Improve-exact-choice-recipe-ingredients.patch @@ -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 653fb104bb51fb738aa3ad22093c24f196f33df2..d4601c6a77f89d89ac9f042ee7b8c25461409523 100644 +index 1a6870fd5dd02022d6b0df88e8f55f8ba9cf07c9..4f3697573fbfec3865751037de00a562ad81cddb 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; @@ -415,7 +415,7 @@ index 653fb104bb51fb738aa3ad22093c24f196f33df2..d4601c6a77f89d89ac9f042ee7b8c254 } @Override -@@ -120,6 +125,11 @@ public final class Ingredient implements Predicate, StackedContents.I +@@ -125,6 +130,11 @@ public final class Ingredient implements Predicate, StackedContents.I } public SlotDisplay display() { diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features_unapplied/0001-Moonrise-optimisation-patches.patch similarity index 100% rename from paper-server/patches/features/0001-Moonrise-optimisation-patches.patch rename to paper-server/patches/features_unapplied/0001-Moonrise-optimisation-patches.patch diff --git a/paper-server/patches/features/0002-Rewrite-dataconverter-system.patch b/paper-server/patches/features_unapplied/0002-Rewrite-dataconverter-system.patch similarity index 100% rename from paper-server/patches/features/0002-Rewrite-dataconverter-system.patch rename to paper-server/patches/features_unapplied/0002-Rewrite-dataconverter-system.patch diff --git a/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features_unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch similarity index 100% rename from paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch rename to paper-server/patches/features_unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch diff --git a/paper-server/patches/features/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/paper-server/patches/features_unapplied/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch similarity index 100% rename from paper-server/patches/features/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch rename to paper-server/patches/features_unapplied/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch diff --git a/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features_unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch similarity index 100% rename from paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch rename to paper-server/patches/features_unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch diff --git a/paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features_unapplied/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch similarity index 100% rename from paper-server/patches/features/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch rename to paper-server/patches/features_unapplied/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch diff --git a/paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features_unapplied/0018-Entity-load-save-limit-per-chunk.patch similarity index 100% rename from paper-server/patches/features/0018-Entity-load-save-limit-per-chunk.patch rename to paper-server/patches/features_unapplied/0018-Entity-load-save-limit-per-chunk.patch diff --git a/paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features_unapplied/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 100% rename from paper-server/patches/features/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to paper-server/patches/features_unapplied/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch diff --git a/paper-server/patches/features/0021-Flush-regionfiles-on-save-configuration-option.patch b/paper-server/patches/features_unapplied/0021-Flush-regionfiles-on-save-configuration-option.patch similarity index 100% rename from paper-server/patches/features/0021-Flush-regionfiles-on-save-configuration-option.patch rename to paper-server/patches/features_unapplied/0021-Flush-regionfiles-on-save-configuration-option.patch diff --git a/paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features_unapplied/0022-Optimise-collision-checking-in-player-move-packet-ha.patch similarity index 100% rename from paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch rename to paper-server/patches/features_unapplied/0022-Optimise-collision-checking-in-player-move-packet-ha.patch diff --git a/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch b/paper-server/patches/features_unapplied/0026-DataConverter-Moonrise-co-fixes.patch similarity index 100% rename from paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch rename to paper-server/patches/features_unapplied/0026-DataConverter-Moonrise-co-fixes.patch diff --git a/paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch b/paper-server/patches/features_unapplied/0027-Optional-per-player-mob-spawns.patch similarity index 100% rename from paper-server/patches/features/0027-Optional-per-player-mob-spawns.patch rename to paper-server/patches/features_unapplied/0027-Optional-per-player-mob-spawns.patch diff --git a/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/paper-server/patches/features_unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch similarity index 100% rename from paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch rename to paper-server/patches/features_unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch diff --git a/paper-server/patches/features/0029-Optimize-Hoppers.patch b/paper-server/patches/features_unapplied/0029-Optimize-Hoppers.patch similarity index 100% rename from paper-server/patches/features/0029-Optimize-Hoppers.patch rename to paper-server/patches/features_unapplied/0029-Optimize-Hoppers.patch diff --git a/paper-server/patches/resources/data/minecraft/loot_table/chests/trial_chambers/intersection_barrel.json.patch b/paper-server/patches/resources/data/minecraft/loot_table/chests/trial_chambers/intersection_barrel.json.patch index 7eb4e3632ca6..f0bf85ceda04 100644 --- a/paper-server/patches/resources/data/minecraft/loot_table/chests/trial_chambers/intersection_barrel.json.patch +++ b/paper-server/patches/resources/data/minecraft/loot_table/chests/trial_chambers/intersection_barrel.json.patch @@ -1,12 +1,11 @@ --- a/data/minecraft/loot_table/chests/trial_chambers/intersection_barrel.json +++ b/data/minecraft/loot_table/chests/trial_chambers/intersection_barrel.json -@@ -70,15 +_,6 @@ - "add": false, +@@ -63,14 +_,6 @@ + { "count": 1.0, "function": "minecraft:set_count" - }, - { -- "add": false, - "damage": { - "type": "minecraft:uniform", - "max": 0.8, diff --git a/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/amplified.json.patch b/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/amplified.json.patch index 65b8e5ca426a..c35828f7aa3d 100644 --- a/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/amplified.json.patch +++ b/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/amplified.json.patch @@ -1,6 +1,6 @@ --- a/data/minecraft/worldgen/noise_settings/amplified.json +++ b/data/minecraft/worldgen/noise_settings/amplified.json -@@ -446,7 +_,8 @@ +@@ -455,7 +_,8 @@ { "type": "minecraft:condition", "if_true": { diff --git a/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/large_biomes.json.patch b/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/large_biomes.json.patch index 2a08836c5a7b..ed1ebfa0cb37 100644 --- a/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/large_biomes.json.patch +++ b/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/large_biomes.json.patch @@ -1,6 +1,6 @@ --- a/data/minecraft/worldgen/noise_settings/large_biomes.json +++ b/data/minecraft/worldgen/noise_settings/large_biomes.json -@@ -446,7 +_,8 @@ +@@ -455,7 +_,8 @@ { "type": "minecraft:condition", "if_true": { diff --git a/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/overworld.json.patch b/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/overworld.json.patch index 917a60365560..9d6941f5803e 100644 --- a/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/overworld.json.patch +++ b/paper-server/patches/resources/data/minecraft/worldgen/noise_settings/overworld.json.patch @@ -1,6 +1,6 @@ --- a/data/minecraft/worldgen/noise_settings/overworld.json +++ b/data/minecraft/worldgen/noise_settings/overworld.json -@@ -446,7 +_,8 @@ +@@ -455,7 +_,8 @@ { "type": "minecraft:condition", "if_true": { diff --git a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch b/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch deleted file mode 100644 index 5a2523953d3a..000000000000 --- a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/ChatFormatting.java -+++ b/net/minecraft/ChatFormatting.java -@@ -112,6 +_,19 @@ - return name == null ? null : FORMATTING_BY_NAME.get(cleanName(name)); - } - -+ // Paper start - add method to get by hex value -+ @Nullable -+ public static ChatFormatting getByHexValue(int color) { -+ for (ChatFormatting value : values()) { -+ if (value.getColor() != null && value.getColor() == color) { -+ return value; -+ } -+ } -+ -+ return null; -+ } -+ // Paper end - add method to get by hex value -+ - public static @Nullable ChatFormatting getById(final int id) { - if (id < 0) { - return RESET; diff --git a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch index cd847e191d32..71690fa84e1d 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() { -@@ -214,7 +_,7 @@ +@@ -235,7 +_,7 @@ } public static void preload() { diff --git a/paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch b/paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch deleted file mode 100644 index a1e2ae309c8c..000000000000 --- a/paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- a/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java -+++ b/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java -@@ -17,41 +_,41 @@ - import net.minecraft.world.level.storage.loot.ValidationContextSource; - - public abstract class SimpleCriterionTrigger implements CriterionTrigger { -- private final Map>> players = Maps.newIdentityHashMap(); -+ // private final Map>> players = Maps.newIdentityHashMap(); // Paper - fix PlayerAdvancements leak; moved into PlayerAdvancements to fix memory leak - - @Override - public final void addPlayerListener(final PlayerAdvancements player, final CriterionTrigger.Listener listener) { -- this.players.computeIfAbsent(player, k -> Sets.newHashSet()).add(listener); -+ player.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(listener); // Paper - fix PlayerAdvancements leak - } - - @Override - public final void removePlayerListener(final PlayerAdvancements player, final CriterionTrigger.Listener listener) { -- Set> listeners = this.players.get(player); -+ Set> listeners = (Set) player.criterionData.get(this); // Paper - fix PlayerAdvancements leak - if (listeners != null) { - listeners.remove(listener); - if (listeners.isEmpty()) { -- this.players.remove(player); -+ player.criterionData.remove(this); // Paper - fix PlayerAdvancements leak - } - } - } - - @Override - public final void removePlayerListeners(final PlayerAdvancements player) { -- this.players.remove(player); -+ player.criterionData.remove(this); // Paper - fix PlayerAdvancements leak - } - - protected void trigger(final ServerPlayer player, final Predicate matcher) { - PlayerAdvancements advancements = player.getAdvancements(); -- Set> allListeners = this.players.get(advancements); -+ Set> allListeners = (Set) advancements.criterionData.get(this); // Paper - fix PlayerAdvancements leak - if (allListeners != null && !allListeners.isEmpty()) { -- LootContext playerContext = EntityPredicate.createContext(player, player); -+ LootContext playerContext = null; // EntityPredicate.createContext(player, player); // Paper - Perf: lazily create LootContext for criterions - List> listeners = null; - - for (CriterionTrigger.Listener listener : allListeners) { - T triggerInstance = listener.trigger(); - if (matcher.test(triggerInstance)) { - Optional predicate = triggerInstance.player(); -- if (predicate.isEmpty() || predicate.get().matches(playerContext)) { -+ if (predicate.isEmpty() || predicate.get().matches(playerContext = (playerContext == null ? EntityPredicate.createContext(player, player) : playerContext))) { // Paper - Perf: lazily create LootContext for criterions - if (listeners == null) { - listeners = Lists.newArrayList(); - } diff --git a/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch b/paper-server/patches/sources/net/minecraft/advancements/predicates/LocationPredicate.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/predicates/LocationPredicate.java.patch index 17c5ea52bfc2..2b43b3de8164 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/predicates/LocationPredicate.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/advancements/criterion/LocationPredicate.java -+++ b/net/minecraft/advancements/criterion/LocationPredicate.java +--- a/net/minecraft/advancements/predicates/LocationPredicate.java ++++ b/net/minecraft/advancements/predicates/LocationPredicate.java @@ -46,7 +_,7 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/advancements/triggers/SimpleCriterionTrigger.java.patch b/paper-server/patches/sources/net/minecraft/advancements/triggers/SimpleCriterionTrigger.java.patch new file mode 100644 index 000000000000..5e4628730ff0 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/advancements/triggers/SimpleCriterionTrigger.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/advancements/triggers/SimpleCriterionTrigger.java ++++ b/net/minecraft/advancements/triggers/SimpleCriterionTrigger.java +@@ -20,14 +_,14 @@ + PlayerAdvancements advancements = player.getAdvancements(); + Map listenersForType = advancements.getTriggerMapForType(this); + if (listenersForType != null && !listenersForType.isEmpty()) { +- LootContext playerContext = EntityPredicate.createContext(player, player); ++ LootContext playerContext = null; // EntityPredicate.createContext(player, player); // Paper - Perf: lazily create LootContext for criterions + List matchedConditions = null; + + for (Entry entry : listenersForType.entrySet()) { + T value = entry.getValue(); + if (matcher.test(value)) { + Optional predicate = value.player(); +- if (!predicate.isPresent() || predicate.get().matches(playerContext)) { ++ if (!predicate.isPresent() || predicate.get().matches(playerContext = (playerContext == null ? EntityPredicate.createContext(player, player) : playerContext))) { // Paper - Perf: lazily create LootContext for criterions + if (matchedConditions == null) { + matchedConditions = new ArrayList<>(); + } 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 bd76d801d6ee..f235a2b3a084 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -156,6 +_,7 @@ +@@ -157,6 +_,7 @@ import org.slf4j.Logger; public class Commands { @@ -8,7 +8,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(); -@@ -180,6 +_,7 @@ +@@ -181,6 +_,7 @@ @Override public boolean isRestricted(final CommandNode node) { @@ -16,7 +16,7 @@ Predicate requirement = node.getRequirement(); return !requirement.test(this.noPermissionSource); } -@@ -187,6 +_,11 @@ +@@ -188,6 +_,11 @@ private final CommandDispatcher dispatcher = new CommandDispatcher<>(); public Commands(final Commands.CommandSelection commandSelection, final CommandBuildContext context) { @@ -28,8 +28,8 @@ AdvancementCommands.register(this.dispatcher); AttributeCommand.register(this.dispatcher, context); ExecuteCommand.register(this.dispatcher, context); -@@ -298,6 +_,42 @@ - PublishCommand.register(this.dispatcher); +@@ -300,6 +_,42 @@ + UnpublishCommand.register(this.dispatcher); } + // Paper start - Vanilla command permission fixes @@ -71,7 +71,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -317,6 +_,13 @@ +@@ -319,6 +_,13 @@ } public void performCommand(final ParseResults command, final String commandString) { @@ -85,7 +85,7 @@ CommandSourceStack sender = command.getContext().getSource(); Profiler.get().push(() -> "/" + commandString); ContextChain commandChain = finishParsing(command, commandString, sender); -@@ -330,10 +_,12 @@ +@@ -332,10 +_,12 @@ ) ); } @@ -101,7 +101,7 @@ StackTraceElement[] stackTrace = e.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -364,7 +_,11 @@ +@@ -366,7 +_,11 @@ return ContextChain.tryFlatten(command.getContext().build(commandString)) .orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(command.getReader())); } catch (CommandSyntaxException e) { @@ -114,7 +114,7 @@ if (e.getInput() != null && e.getCursor() >= 0) { int cursor = Math.min(e.getInput().length(), e.getCursor()); MutableComponent context = Component.empty() -@@ -381,7 +_,17 @@ +@@ -383,7 +_,17 @@ } context.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); @@ -133,7 +133,7 @@ } return null; -@@ -409,19 +_,112 @@ +@@ -411,19 +_,112 @@ } public void sendCommands(final ServerPlayer player) { @@ -249,7 +249,7 @@ if (builder.getRedirect() != null) { builder.redirect(converted.get(builder.getRedirect())); } -@@ -430,7 +_,7 @@ +@@ -432,7 +_,7 @@ converted.put(child, node); target.addChild(node); if (!child.getChildren().isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch b/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch index 120188986cf4..7241ccc4e647 100644 --- a/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/BlockPos.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/BlockPos.java +++ b/net/minecraft/core/BlockPos.java -@@ -155,67 +_,84 @@ +@@ -146,67 +_,84 @@ @Override public BlockPos above() { @@ -98,7 +98,7 @@ } @Override -@@ -662,9 +_,9 @@ +@@ -682,9 +_,9 @@ } public BlockPos.MutableBlockPos set(final int x, final int y, final int z) { @@ -111,7 +111,7 @@ return this; } -@@ -722,19 +_,19 @@ +@@ -742,19 +_,19 @@ @Override public BlockPos.MutableBlockPos setX(final int x) { diff --git a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch index 0a1d9fb63129..e371ca3cb79a 100644 --- a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteractions.java.patch @@ -82,8 +82,8 @@ 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); +@@ -118,14 +_,14 @@ + Items.DYED_SHULKER_BOX.forEach(dyedShulkerBox -> WATER.put(dyedShulkerBox, CauldronInteractions::shulkerBoxInteraction)); LAVA.put( Items.BUCKET, - (state, level, pos, player, hand, itemInHand) -> fillBucket( @@ -100,7 +100,7 @@ state, level, pos, -@@ -164,7 +_,7 @@ +@@ -134,7 +_,7 @@ itemInHand, new ItemStack(Items.POWDER_SNOW_BUCKET), s -> s.getValue(LayeredCauldronBlock.LEVEL) == 3, @@ -109,7 +109,7 @@ ) ); addDefaultInteractions(POWDER_SNOW); -@@ -187,16 +_,47 @@ +@@ -157,16 +_,47 @@ final Predicate canFill, final SoundEvent soundEvent ) { @@ -158,7 +158,7 @@ level.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PICKUP, pos); } -@@ -213,12 +_,42 @@ +@@ -183,12 +_,42 @@ final BlockState newState, final SoundEvent soundEvent ) { @@ -203,7 +203,7 @@ level.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PLACE, pos); } -@@ -227,23 +_,23 @@ +@@ -197,23 +_,23 @@ } private static InteractionResult fillWaterInteraction( @@ -232,7 +232,7 @@ ) { return isUnderWater(level, pos) ? InteractionResult.CONSUME -@@ -254,12 +_,12 @@ +@@ -224,12 +_,12 @@ hand, itemInHand, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), @@ -247,7 +247,7 @@ ) { Block block = Block.byItem(itemInHand.getItem()); if (!(block instanceof ShulkerBoxBlock)) { -@@ -267,17 +_,22 @@ +@@ -237,17 +_,22 @@ } if (!level.isClientSide()) { @@ -272,7 +272,7 @@ ) { BannerPatternLayers patterns = itemInHand.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY); if (patterns.layers().isEmpty()) { -@@ -285,27 +_,37 @@ +@@ -255,27 +_,37 @@ } if (!level.isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch index 35439836aeff..e6a7bc20ffe3 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/component/DataComponents.java +++ b/net/minecraft/core/component/DataComponents.java -@@ -231,10 +_,10 @@ +@@ -232,10 +_,10 @@ "map_post_processing", b -> b.networkSynchronized(MapPostProcessing.STREAM_CODEC) ); public static final DataComponentType CHARGED_PROJECTILES = register( @@ -13,7 +13,7 @@ ); public static final DataComponentType POTION_CONTENTS = register( "potion_contents", b -> b.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding() -@@ -314,7 +_,7 @@ +@@ -315,7 +_,7 @@ "pot_decorations", b -> b.persistent(PotDecorations.CODEC).networkSynchronized(PotDecorations.STREAM_CODEC).cacheEncoding() ); public static final DataComponentType CONTAINER = register( diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index 5fe9b0cd7828..575d440b82c6 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -32,7 +32,7 @@ if (boat != null) { - boat.setInitialPos(spawnX, spawnY + yOffset, spawnZ); + boat.setInitialPos(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); // CraftBukkit - EntityType.createDefaultStackConfig(level, dispensed, null).accept(boat); + EntityType.createDefaultStackConfig(level, dispensed, null).apply(boat); boat.setYRot(direction.toYRot()); - level.addFreshEntity(boat); - dispensed.shrink(1); diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index 0d7e83b21326..f403aa041850 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -87,12 +_,38 @@ +@@ -81,12 +_,38 @@ Direction direction = source.state().getValue(DispenserBlock.FACING); BlockPos pos = source.pos().relative(direction); ServerLevel serverLevel = source.level(); @@ -30,18 +30,18 @@ + // CraftBukkit end + + final ItemStack newStack = org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getItem()); // Paper - use event itemstack (unwrap is fine here because the stack won't be modified) - Consumer postSpawnConfig = EntityType.appendDefaultStackConfig( + PostSpawnProcessor postSpawnConfig = EntityType.appendDefaultStackConfig( - armorStandx -> armorStandx.setYRot(direction.toYRot()), serverLevel, dispensed, null + armorStandx -> armorStandx.setYRot(direction.toYRot()), serverLevel, newStack, null // Paper - track changed items in the dispense event ); - ArmorStand armorStand = EntityType.ARMOR_STAND.spawn(serverLevel, postSpawnConfig, pos, EntitySpawnReason.DISPENSER, false, false); + ArmorStand armorStand = EntityTypes.ARMOR_STAND.spawn(serverLevel, postSpawnConfig, pos, EntitySpawnReason.DISPENSER, false, false); if (armorStand != null) { - dispensed.shrink(1); + if (shrink) dispensed.shrink(1); // Paper } return dispensed; -@@ -110,8 +_,33 @@ +@@ -104,8 +_,33 @@ .getEntitiesOfClass(AbstractChestedHorse.class, new AABB(pos), entity -> entity.isAlive() && !entity.hasChest())) { if (abstractChestedHorse.isTamed()) { SlotAccess slot = abstractChestedHorse.getSlot(AbstractHorse.CHEST_SLOT_OFFSET); @@ -77,7 +77,7 @@ this.setSuccess(true); return dispensed; } -@@ -150,8 +_,45 @@ +@@ -144,8 +_,45 @@ DispensibleContainerItem bucket = (DispensibleContainerItem)dispensed.getItem(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); Level level = source.level(); @@ -124,7 +124,7 @@ return this.consumeWithRemainder(source, dispensed, new ItemStack(Items.BUCKET)); } else { return this.defaultDispenseItemBehavior.dispense(source, dispensed); -@@ -174,13 +_,20 @@ +@@ -169,13 +_,20 @@ BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); BlockState blockState = level.getBlockState(target); if (blockState.getBlock() instanceof BucketPickup bucket) { @@ -146,35 +146,7 @@ return this.consumeWithRemainder(source, dispensed, new ItemStack(targetType)); } else { return super.execute(source, dispensed); -@@ -194,15 +_,26 @@ - this.setSuccess(true); - Direction facing = source.state().getValue(DispenserBlock.FACING); - BlockPos targetPos = source.pos().relative(facing); -+ // Paper start - Call BlockDispenseEvent -+ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, targetPos, dispensed, this); -+ if (result != null) { -+ this.setSuccess(false); -+ return result; -+ } -+ // Paper end - Call BlockDispenseEvent - BlockState target = level.getBlockState(targetPos); - if (BaseFireBlock.canBePlacedAt(level, targetPos, facing)) { -+ // CraftBukkit start - Ignition by dispensing flint and steel -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, targetPos, source.pos()).isCancelled()) { - level.setBlockAndUpdate(targetPos, BaseFireBlock.getState(level, targetPos)); - level.gameEvent(null, GameEvent.BLOCK_PLACE, targetPos); -+ } -+ // CraftBukkit end - } else if (CampfireBlock.canLight(target) || CandleBlock.canLight(target) || CandleCakeBlock.canLight(target)) { - level.setBlockAndUpdate(targetPos, target.setValue(BlockStateProperties.LIT, true)); - level.gameEvent(null, GameEvent.BLOCK_CHANGE, targetPos); - } else if (target.getBlock() instanceof TntBlock) { -- if (TntBlock.prime(level, targetPos)) { -+ if (TntBlock.prime(level, targetPos, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, targetPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, source.pos()))) { // CraftBukkit - TNTPrimeEvent - level.removeBlock(targetPos, false); - } else { - this.setSuccess(false); -@@ -224,11 +_,46 @@ +@@ -189,11 +_,54 @@ this.setSuccess(true); Level level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); @@ -185,35 +157,43 @@ + return result; + } + // Paper end - Call BlockDispenseEvent ++ List capturedBlockStates; // Paper ++ org.bukkit.TreeType treeType; // Paper + level.captureTreeGeneration = true; // CraftBukkit ++ try { // Paper if (!BoneMealItem.growCrop(dispensed, level, target) && !BoneMealItem.growWaterPlant(dispensed, level, target, null)) { this.setSuccess(false); } else if (!level.isClientSide()) { level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, target, 15); } -+ // CraftBukkit start -+ level.captureTreeGeneration = false; -+ if (!level.capturedBlockStates.isEmpty()) { -+ org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType; ++ // Paper start ++ } finally { ++ level.captureTreeGeneration = false; ++ ++ capturedBlockStates = new java.util.ArrayList<>(level.capturedBlockStates.values()); ++ level.capturedBlockStates.clear(); ++ ++ treeType = net.minecraft.world.level.block.SaplingBlock.treeType; + net.minecraft.world.level.block.SaplingBlock.treeType = null; ++ } ++ // Paper end ++ // CraftBukkit start ++ if (!capturedBlockStates.isEmpty()) { + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(target, level); -+ List states = 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, false, null, states); ++ structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, false, null, (List) (List) capturedBlockStates); + org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); + } + -+ org.bukkit.event.block.BlockFertilizeEvent fertilizeEvent = new org.bukkit.event.block.BlockFertilizeEvent(location.getBlock(), null, states); ++ org.bukkit.event.block.BlockFertilizeEvent fertilizeEvent = new org.bukkit.event.block.BlockFertilizeEvent(location.getBlock(), null, (List) (List) capturedBlockStates); + fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled()); + org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent); + + if (!fertilizeEvent.isCancelled()) { -+ for (org.bukkit.block.BlockState state : states) { -+ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) state; -+ craftBlockState.place(craftBlockState.getFlags()); -+ source.level().checkCapturedTreeStateForObserverNotify(target, craftBlockState); // Paper - notify observers even if grow failed ++ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : capturedBlockStates) { ++ snapshot.place(snapshot.getFlags()); ++ source.level().checkCapturedTreeStateForObserverNotify(target, snapshot); // Paper - notify observers even if grow failed + } + } + } @@ -221,47 +201,56 @@ return dispensed; } -@@ -242,11 +_,36 @@ - return dispensed; - } else { - BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); -- PrimedTnt tnt = new PrimedTnt(level, target.getX() + 0.5, target.getY(), target.getZ() + 0.5, null); -+ // CraftBukkit start -+ ItemStack singleItemStack = dispensed.copyWithCount(1); // Paper - shrink at end and single item in event -+ 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(singleItemStack); +@@ -208,15 +_,41 @@ + } + + BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); +- if (SulfurCubeBlockDispenseItemBehavior.dispenseBlock(level, target, dispensed)) { +- return dispensed; +- } +- +- PrimedTnt tnt = new PrimedTnt(level, target.getX() + 0.5, target.getY(), target.getZ() + 0.5, null); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) target.getX() + 0.5D, (double) target.getY(), (double) target.getZ() + 0.5D)); -+ level.getCraftServer().getPluginManager().callEvent(event); ++ if (SulfurCubeBlockDispenseItemBehavior.dispenseBlock(level, target, dispensed, source, this)) { // Paper ++ return dispensed; ++ } + -+ if (event.isCancelled()) { -+ return dispensed; -+ } ++ // CraftBukkit start ++ ItemStack singleItemStack = dispensed.copyWithCount(1); // Paper - shrink at end and single item in event ++ 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(singleItemStack); + -+ 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 dispenseBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(source, eventStack); -+ return dispensed; -+ } ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) target.getX() + 0.5D, (double) target.getY(), (double) target.getZ() + 0.5D)); ++ level.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return dispensed; ++ } ++ ++ 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 dispenseBehavior = DispenserBlock.getDispenseBehavior(source, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { ++ dispenseBehavior.dispense(source, eventStack); ++ return dispensed; + } ++ } ++ // CraftBukkit end + -+ PrimedTnt tnt = new PrimedTnt(level, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), null); -+ // CraftBukkit end - level.addFreshEntity(tnt); - level.playSound(null, tnt.getX(), tnt.getY(), tnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); -- level.gameEvent(null, GameEvent.ENTITY_PLACE, target); -- dispensed.shrink(1); -+ level.gameEvent(null, GameEvent.ENTITY_PLACE, org.bukkit.craftbukkit.util.CraftVector.toBlockPos(event.getVelocity())); // Paper - update game event position -+ if (shrink) dispensed.shrink(1); // Paper - this.setSuccess(true); - return dispensed; - } -@@ -260,6 +_,13 @@ ++ PrimedTnt tnt = new PrimedTnt(level, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), null); // CraftBukkit + level.addFreshEntity(tnt); + level.playSound(null, tnt.getX(), tnt.getY(), tnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); +- level.gameEvent(null, GameEvent.ENTITY_PLACE, target); +- dispensed.shrink(1); ++ level.gameEvent(null, GameEvent.ENTITY_PLACE, org.bukkit.craftbukkit.util.CraftVector.toBlockPos(event.getVelocity())); // Paper - update game event position ++ if (shrink) dispensed.shrink(1); // Paper + this.setSuccess(true); + return dispensed; + } +@@ -229,6 +_,13 @@ Level level = source.level(); Direction direction = source.state().getValue(DispenserBlock.FACING); BlockPos target = source.pos().relative(direction); @@ -275,7 +264,7 @@ if (level.isEmptyBlock(target) && WitherSkullBlock.canSpawnMob(level, target, dispensed)) { level.setBlock( target, -@@ -275,7 +_,7 @@ +@@ -243,7 +_,7 @@ dispensed.shrink(1); this.setSuccess(true); } else { @@ -284,7 +273,7 @@ } return dispensed; -@@ -288,6 +_,13 @@ +@@ -256,6 +_,13 @@ Level level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); CarvedPumpkinBlock pumpkinBlock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; @@ -298,7 +287,7 @@ if (level.isEmptyBlock(target) && pumpkinBlock.canSpawnGolem(level, target)) { if (!level.isClientSide()) { level.setBlock(target, pumpkinBlock.defaultBlockState(), Block.UPDATE_ALL); -@@ -297,7 +_,7 @@ +@@ -265,7 +_,7 @@ dispensed.shrink(1); this.setSuccess(true); } else { @@ -307,7 +296,7 @@ } return dispensed; -@@ -335,6 +_,12 @@ +@@ -288,6 +_,12 @@ ServerLevel level = source.level(); BlockPos target = source.pos().relative(source.state().getValue(DispenserBlock.FACING)); BlockState state = level.getBlockState(target); @@ -320,7 +309,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 @@ +@@ -313,6 +_,13 @@ this.setSuccess(true); if (blockState.is(Blocks.RESPAWN_ANCHOR)) { if (blockState.getValue(RespawnAnchorBlock.CHARGE) != 4) { @@ -334,7 +323,7 @@ RespawnAnchorBlock.charge(null, level, pos, blockState); dispensed.shrink(1); } else { -@@ -384,6 +_,28 @@ +@@ -337,6 +_,28 @@ return dispensed; } @@ -363,7 +352,7 @@ for (Armadillo armadillo : armadillos) { if (armadillo.brushOffScute(null, dispensed)) { dispensed.hurtAndBreak(16, level, null, item -> {}); -@@ -403,6 +_,13 @@ +@@ -356,6 +_,13 @@ BlockState blockState = level.getBlockState(pos); Optional maybeWaxed = HoneycombItem.getWaxed(blockState); if (maybeWaxed.isPresent()) { @@ -377,7 +366,7 @@ level.setBlockAndUpdate(pos, maybeWaxed.get()); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_WAX_ON, pos, 0); dispensed.shrink(1); -@@ -432,6 +_,12 @@ +@@ -385,6 +_,12 @@ return this.defaultDispenseItemBehavior.dispense(source, dispensed); } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/FlintAndSteelDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/FlintAndSteelDispenseItemBehavior.java.patch new file mode 100644 index 000000000000..868af11f1868 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/FlintAndSteelDispenseItemBehavior.java.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/core/dispenser/FlintAndSteelDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/FlintAndSteelDispenseItemBehavior.java +@@ -24,16 +_,27 @@ + this.setSuccess(true); + Direction facing = source.state().getValue(DispenserBlock.FACING); + BlockPos targetPos = source.pos().relative(facing); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, targetPos, dispensed, this); ++ if (result != null) { ++ this.setSuccess(false); ++ return result; ++ } ++ // Paper end - Call BlockDispenseEvent + BlockState target = level.getBlockState(targetPos); + if (!tryIgniteExplosiveEntities(level, targetPos)) { + if (BaseFireBlock.canBePlacedAt(level, targetPos, facing)) { ++ // CraftBukkit start - Ignition by dispensing flint and steel ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, targetPos, source.pos()).isCancelled()) { + level.setBlockAndUpdate(targetPos, BaseFireBlock.getState(level, targetPos)); + level.gameEvent(null, GameEvent.BLOCK_PLACE, targetPos); ++ } ++ // CraftBukkit end + } else if (CampfireBlock.canLight(target) || CandleBlock.canLight(target) || CandleCakeBlock.canLight(target)) { + level.setBlockAndUpdate(targetPos, target.setValue(BlockStateProperties.LIT, true)); + level.gameEvent(null, GameEvent.BLOCK_CHANGE, targetPos); + } else if (target.getBlock() instanceof TntBlock) { +- if (TntBlock.prime(level, targetPos)) { ++ if (TntBlock.prime(level, targetPos, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, targetPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, source.pos()))) { // CraftBukkit - TNTPrimeEvent + level.removeBlock(targetPos, false); + } else { + this.setSuccess(false); diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch index e33af392147a..1fc8b2ef0c77 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch @@ -43,7 +43,7 @@ return true; } - if (entity instanceof Shearable shearable && shearable.readyForShearing()) { + if (entity.isAlive() && entity instanceof Shearable shearable && shearable.readyForShearing()) { - shearable.shear(level, SoundSource.BLOCKS, tool); + // CraftBukkit start + // Paper start - Add drops to shear events diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch index 633393b05579..86b56e72f390 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +++ b/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java -@@ -22,10 +_,36 @@ +@@ -20,8 +_,34 @@ BlockPos relativePos = source.pos().relative(facing); Direction clickedFace = source.level().isEmptyBlock(relativePos.below()) ? facing : Direction.UP; @@ -26,11 +26,9 @@ + } + // CraftBukkit end try { +- this.setSuccess(blockItem.place(new DirectionalPlaceContext(source.level(), relativePos, facing, dispensed, clickedFace)).consumesAction()); + // Paper start - track changed items in the dispense event - this.setSuccess( -- ((BlockItem)item).place(new DirectionalPlaceContext(source.level(), relativePos, facing, dispensed, clickedFace)).consumesAction() -+ ((BlockItem)item).place(new DirectionalPlaceContext(source.level(), relativePos, facing, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()), clickedFace)).consumesAction() - ); ++ this.setSuccess(blockItem.place(new DirectionalPlaceContext(source.level(), relativePos, facing, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()), clickedFace)).consumesAction()); + if (this.isSuccess()) { + dispensed.shrink(1); // vanilla shrink is in the place function above, manually handle it here + } 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 index 99e409f5b601..11152e3e2415 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/SpawnEggItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/SpawnEggItemBehavior.java +++ b/net/minecraft/core/dispenser/SpawnEggItemBehavior.java -@@ -19,14 +_,37 @@ +@@ -20,9 +_,32 @@ return dispensed; } @@ -28,10 +28,13 @@ + } + // 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); + Entity spawned = type.spawn( +- source.level(), dispensed, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false ++ source.level(), singleDispensed, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false // Paper - block dispense event - update used item stack + ); + if (spawned == null) { + return dispensed; +@@ -32,7 +_,7 @@ return ItemStack.EMPTY; } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/SulfurCubeBlockDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/SulfurCubeBlockDispenseItemBehavior.java.patch new file mode 100644 index 000000000000..1d8957d7b7ce --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/SulfurCubeBlockDispenseItemBehavior.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/core/dispenser/SulfurCubeBlockDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/SulfurCubeBlockDispenseItemBehavior.java +@@ -12,12 +_,19 @@ + + @Override + protected ItemStack execute(final BlockSource source, final ItemStack dispensed) { +- return dispenseBlock(source.level(), source.pos().relative(source.state().getValue(DispenserBlock.FACING)), dispensed) ++ return dispenseBlock(source.level(), source.pos().relative(source.state().getValue(DispenserBlock.FACING)), dispensed, source, this) // Paper - Call BlockDispenseEvent + ? dispensed + : super.execute(source, dispensed); + } + +- public static boolean dispenseBlock(final ServerLevel level, final BlockPos pos, final ItemStack dispensed) { ++ // Paper start - Call BlockDispenseEvent ++ public static boolean dispenseBlock(final ServerLevel level, final BlockPos pos, final ItemStack dispensed, final BlockSource source, final @org.jspecify.annotations.Nullable DispenseItemBehavior currentBehavior) { ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, pos, dispensed, currentBehavior); ++ if (result != null) { // todo - snapshot - setItem should probably override the equipped item + possible event in the for loop ++ return false; ++ } ++ // Paper end - Call BlockDispenseEvent ++ + for (SulfurCube entity : level.getEntitiesOfClass(SulfurCube.class, new AABB(pos))) { + if (entity.equipItem(dispensed)) { + dispensed.shrink(1); diff --git a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch index a1540c1aa6c5..74f31401e0a1 100644 --- a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -361,6 +_,11 @@ +@@ -365,6 +_,11 @@ public static final Registry> SLOT_SOURCE_TYPE = registerSimple(Registries.SLOT_SOURCE_TYPE, SlotSources::bootstrap); public static final Registry> TEST_FUNCTION = registerSimple(Registries.TEST_FUNCTION, BuiltinTestFunctions::bootstrap); public static final Registry> REGISTRY = WRITABLE_REGISTRY; @@ -12,7 +12,7 @@ private static Registry registerSimple(final ResourceKey> name, final BuiltInRegistries.RegistryBootstrap loader) { return internalRegister(name, new MappedRegistry<>(name, Lifecycle.stable(), false), loader); -@@ -388,6 +_,7 @@ +@@ -392,6 +_,7 @@ final ResourceKey> name, final R registry, final BuiltInRegistries.RegistryBootstrap loader ) { Bootstrap.checkBootstrapCalled(() -> "registry " + name.identifier()); @@ -20,7 +20,7 @@ Identifier key = name.identifier(); LOADERS.put(key, () -> loader.run(registry)); WRITABLE_REGISTRY.register((ResourceKey)name, registry, RegistrationInfo.BUILT_IN); -@@ -395,16 +_,34 @@ +@@ -399,16 +_,34 @@ } public static void bootStrap() { @@ -55,7 +55,7 @@ }); } -@@ -413,6 +_,7 @@ +@@ -417,6 +_,7 @@ for (Registry registry : REGISTRY) { bindBootstrappedTagsToEmpty(registry); diff --git a/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch b/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch index 511748b2a25e..0889845ab7e2 100644 --- a/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch +++ b/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/packs/VanillaChestLoot.java +++ b/net/minecraft/data/loot/packs/VanillaChestLoot.java -@@ -1047,7 +_,6 @@ +@@ -1067,7 +_,6 @@ .add( LootItem.lootTableItem(Items.COMPASS) .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F))) diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch index d4acbfb1c257..2889b13bb315 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -154,6 +_,8 @@ +@@ -156,6 +_,8 @@ final int repeatCount ) { super( @@ -9,7 +9,7 @@ serverThread, levelStorageSource, packRepository, -@@ -172,9 +_,17 @@ +@@ -175,9 +_,17 @@ @Override protected boolean initServer() { @@ -29,7 +29,7 @@ ServerLevel level = this.overworld(); this.testBatches = this.evaluateTestsToRun(level); LOGGER.info("Started game test server"); -@@ -380,6 +_,13 @@ +@@ -393,6 +_,13 @@ return false; } @@ -43,7 +43,7 @@ @Override public boolean isSingleplayerOwner(final NameAndId nameAndId) { return false; -@@ -427,5 +_,16 @@ +@@ -440,5 +_,16 @@ @Override public void save() { } diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch index 60705bfeefa0..deaf3c80777a 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/StructureUtils.java +++ b/net/minecraft/gametest/framework/StructureUtils.java -@@ -85,7 +_,7 @@ +@@ -75,7 +_,7 @@ level.clearBlockEvents(structureBoundingBox); AABB bounds = AABB.of(structureBoundingBox); List livingEntities = level.getEntitiesOfClass(Entity.class, bounds, mob -> !(mob instanceof Player)); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch index 54b94a7b7ced..b5abddb460c2 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch @@ -1,6 +1,22 @@ --- a/net/minecraft/gametest/framework/TestEnvironmentDefinition.java +++ b/net/minecraft/gametest/framework/TestEnvironmentDefinition.java -@@ -184,7 +_,7 @@ +@@ -184,13 +_,13 @@ + @Override + public Difficulty setup(final ServerLevel level) { + Difficulty oldDifficulty = level.getDifficulty(); +- level.getServer().setDifficulty(this.difficulty, true); ++ level.getServer().setDifficulty(level, this.difficulty, null, true); // Paper + return oldDifficulty; + } + + @Override + public void teardown(final ServerLevel level, final Difficulty saveData) { +- level.getServer().setDifficulty(saveData, true); ++ level.getServer().setDifficulty(level, saveData, null, true); // Paper + } + + @Override +@@ -210,7 +_,7 @@ GameRuleMap originalState = GameRuleMap.of(); GameRules gameRules = level.getGameRules(); this.gameRulesMap.keySet().forEach(rule -> setFromActive(originalState, (GameRule)rule, gameRules)); @@ -9,7 +25,7 @@ return originalState; } -@@ -194,7 +_,7 @@ +@@ -220,7 +_,7 @@ @Override public void teardown(final ServerLevel level, final GameRuleMap saveData) { @@ -18,10 +34,10 @@ } @Override -@@ -286,7 +_,7 @@ +@@ -312,7 +_,7 @@ } - void apply(final ServerLevel level) { + public void apply(final ServerLevel level) { - level.getServer().setWeatherParameters(this.clearTime, this.rainTime, this.raining, this.thundering); + level.getServer().setWeatherParameters(level, this.clearTime, this.rainTime, this.raining, this.thundering); // Paper - per-level WeatherData } 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 153bf5a8bd81..45a642aabe13 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch @@ -10,7 +10,7 @@ + if (input instanceof io.netty.buffer.ByteBufInputStream byteBufInputStream) { + input = new DataInputStream(new org.spigotmc.LimitStream(byteBufInputStream, accounter)); + } -+ // Spigot end - Tag tag = readUnnamedTag(input, accounter); - if (tag instanceof CompoundTag) { - return (CompoundTag)tag; ++ // Spigot end + if (readUnnamedTag(input, accounter) instanceof CompoundTag compoundTag) { + return compoundTag; + } else { diff --git a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch index dfb10ac330e0..82eaa02d7561 100644 --- a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -67,6 +_,11 @@ +@@ -68,6 +_,11 @@ private final Queue> pendingActions = Queues.newConcurrentLinkedQueue(); public Channel channel; public SocketAddress address; @@ -12,10 +12,10 @@ private volatile @Nullable PacketListener disconnectListener; private volatile @Nullable PacketListener packetListener; private @Nullable DisconnectionDetails disconnectionDetails; -@@ -80,6 +_,44 @@ - private boolean handlingFault; +@@ -81,6 +_,44 @@ private volatile @Nullable DisconnectionDetails delayedDisconnect; private @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; + private @Nullable UUID intendedProfileId; + public String hostname = ""; // CraftBukkit - add field + public boolean handleConnectionDisconnectOnNextTick = false; // Paper - Force kill connection ticking + // Paper start - NetworkClient implementation @@ -57,7 +57,7 @@ public Connection(final PacketFlow receiving) { this.receiving = receiving; -@@ -90,6 +_,7 @@ +@@ -91,6 +_,7 @@ super.channelActive(ctx); this.channel = ctx.channel(); this.address = this.channel.remoteAddress(); @@ -65,7 +65,7 @@ if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } -@@ -101,15 +_,32 @@ +@@ -102,15 +_,32 @@ } @Override @@ -99,7 +99,7 @@ this.disconnect(Component.translatable("disconnect.timeout")); } else { Component reason = Component.translatable("disconnect.genericReason", "Internal Exception: " + cause); -@@ -121,9 +_,11 @@ +@@ -122,9 +_,11 @@ details = new DisconnectionDetails(reason); } @@ -112,7 +112,7 @@ Packet packet = this.sendLoginDisconnect ? new ClientboundLoginDisconnectPacket(reason) : new ClientboundDisconnectPacket(reason); -@@ -140,6 +_,7 @@ +@@ -141,6 +_,7 @@ } } } @@ -120,7 +120,7 @@ } @Override -@@ -149,11 +_,60 @@ +@@ -150,11 +_,60 @@ if (packetListener == null) { throw new IllegalStateException("Received a packet before the packet listener was initialized"); } @@ -182,7 +182,7 @@ } catch (RejectedExecutionException ignored) { this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); } catch (ClassCastException exception) { -@@ -343,10 +_,30 @@ +@@ -344,10 +_,30 @@ } } @@ -213,7 +213,7 @@ } if (!this.isConnected() && !this.disconnectionHandled) { -@@ -354,7 +_,7 @@ +@@ -355,7 +_,7 @@ } if (this.channel != null) { @@ -222,7 +222,7 @@ } if (this.tickCount++ % 20 == 0) { -@@ -390,6 +_,7 @@ +@@ -391,6 +_,7 @@ } public void disconnect(final DisconnectionDetails details) { @@ -230,7 +230,7 @@ if (this.channel == null) { this.delayedDisconnect = details; } -@@ -534,6 +_,14 @@ +@@ -543,6 +_,14 @@ } } @@ -245,7 +245,7 @@ public void setupCompression(final int threshold, final boolean validateDecompressed) { if (threshold >= 0) { if (this.channel.pipeline().get(HandlerNames.DECOMPRESS) instanceof CompressionDecoder compressionDecoder) { -@@ -547,6 +_,7 @@ +@@ -556,6 +_,7 @@ } else { this.channel.pipeline().addAfter(HandlerNames.PREPENDER, HandlerNames.COMPRESS, new CompressionEncoder(threshold)); } @@ -253,7 +253,7 @@ } else { if (this.channel.pipeline().get(HandlerNames.DECOMPRESS) instanceof CompressionDecoder) { this.channel.pipeline().remove(HandlerNames.DECOMPRESS); -@@ -555,6 +_,7 @@ +@@ -564,6 +_,7 @@ if (this.channel.pipeline().get(HandlerNames.COMPRESS) instanceof CompressionEncoder) { this.channel.pipeline().remove(HandlerNames.COMPRESS); } @@ -261,7 +261,7 @@ } } -@@ -572,6 +_,26 @@ +@@ -581,6 +_,26 @@ ); disconnectListener.onDisconnect(details); } diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch index 22053517b89e..3793d0aca6b6 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch @@ -8,11 +8,31 @@ public static Optional resolve(final ResolutionContext context, final Optional component, final int recursionDepth) throws CommandSyntaxException { return component.isPresent() ? Optional.of(resolve(context, component.get(), recursionDepth)) : Optional.empty(); } -@@ -55,13 +_,40 @@ +@@ -55,13 +_,18 @@ return resolve(context, component, 0); } - public static MutableComponent resolve(final ResolutionContext context, final Component component, final int recursionDepth) throws CommandSyntaxException { ++ public static MutableComponent resolve(final ResolutionContext context, Component component, final int recursionDepth) throws CommandSyntaxException { // Paper - adventure; pass actual vanilla component + if (recursionDepth > context.depthLimit()) { + return switch (context.depthLimitBehavior()) { + case DISCARD_REMAINING -> CommonComponents.ELLIPSIS.copy(); + case STOP_PROCESSING_AND_COPY_REMAINING -> component.copy(); + }; + } else { ++ // Paper start - adventure; pass actual vanilla component ++ if (component instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { ++ component = adventureComponent.deepConverted(); ++ } ++ // Paper end - adventure; pass actual vanilla component + MutableComponent result = component.getContents().resolve(context, recursionDepth + 1); + + for (Component sibling : component.getSiblings()) { +@@ -71,6 +_,28 @@ + return result.withStyle(resolveStyle(context, component.getStyle(), recursionDepth)); + } + } ++ + // Paper start - validate separator + public static Optional resolveSeparator(final ResolutionContext context, final Optional text, final int recursionDepth) throws CommandSyntaxException { + if (text.isEmpty() || !isValidSelector(text.get())) return Optional.empty(); @@ -34,19 +54,6 @@ + return true; + } + // Paper end - validate separator -+ -+ public static MutableComponent resolve(final ResolutionContext context, Component component, final int recursionDepth) throws CommandSyntaxException { // Paper - adventure; pass actual vanilla component - if (recursionDepth > context.depthLimit()) { - return switch (context.depthLimitBehavior()) { - case DISCARD_REMAINING -> CommonComponents.ELLIPSIS.copy(); - case STOP_PROCESSING_AND_COPY_REMAINING -> component.copy(); - }; - } else { -+ // Paper start - adventure; pass actual vanilla component -+ if (component instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { -+ component = adventureComponent.deepConverted(); -+ } -+ // Paper end - adventure; pass actual vanilla component - MutableComponent result = component.getContents().resolve(context, recursionDepth + 1); - for (Component sibling : component.getSiblings()) { + private static Style resolveStyle(final ResolutionContext context, final Style style, final int recursionDepth) throws CommandSyntaxException { + if (style.getHoverEvent() instanceof HoverEvent.ShowText(Component text)) { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch index 71e7db277d02..6353b5868d4c 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/MutableComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/MutableComponent.java +++ b/net/minecraft/network/chat/MutableComponent.java -@@ -97,6 +_,11 @@ +@@ -102,6 +_,11 @@ @Override public boolean equals(final Object o) { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch deleted file mode 100644 index aa4e4213f486..000000000000 --- a/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/network/chat/TextColor.java -+++ b/net/minecraft/network/chat/TextColor.java -@@ -17,22 +_,28 @@ - public static final Codec CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize); - private static final Map LEGACY_FORMAT_TO_COLOR = Stream.of(ChatFormatting.values()) - .filter(ChatFormatting::isColor) -- .collect(ImmutableMap.toImmutableMap(Function.identity(), f -> new TextColor(f.getColor(), f.getName()))); -+ .collect(ImmutableMap.toImmutableMap(Function.identity(), f -> new TextColor(f.getColor(), f.getName(), f))); // CraftBukkit - private static final Map NAMED_COLORS = LEGACY_FORMAT_TO_COLOR.values() - .stream() - .collect(ImmutableMap.toImmutableMap(e -> e.name, Function.identity())); - private final int value; - public final @Nullable String name; -+ // CraftBukkit start -+ @Nullable -+ public final ChatFormatting format; - -- private TextColor(final int value, final String name) { -+ private TextColor(final int value, final String name, ChatFormatting format) { - this.value = value & 16777215; - this.name = name; -+ this.format = format; - } - - private TextColor(final int value) { - this.value = value & 16777215; - this.name = null; -+ this.format = null; - } -+ // CraftBukkit end - - public int getValue() { - return this.value; diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch index 09c75d241518..6f5f8ae0ab4a 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch @@ -12,7 +12,7 @@ + + @Override + public boolean packetTooLarge(net.minecraft.network.Connection manager) { -+ for (int i = 0 ; i < this.items.size() ; i++) { ++ for (int i = 0; i < this.items.size(); i++) { + manager.send(new ClientboundContainerSetSlotPacket(this.containerId, this.stateId, i, this.items.get(i))); + } + return true; diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch index 7e1cfcafd6e5..38f7a3185e6a 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java -@@ -61,6 +_,12 @@ +@@ -60,6 +_,12 @@ ); } @@ -13,12 +13,16 @@ private ClientboundSetPlayerTeamPacket(final RegistryFriendlyByteBuf input) { this.name = input.readUtf(); this.method = input.readByte(); -@@ -201,7 +_,7 @@ - ComponentSerialization.TRUSTED_STREAM_CODEC.encode(output, this.displayName); - output.writeByte(this.options); - Team.Visibility.STREAM_CODEC.encode(output, this.nametagVisibility); -- Team.CollisionRule.STREAM_CODEC.encode(output, this.collisionRule); -+ Team.CollisionRule.STREAM_CODEC.encode(output, !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? PlayerTeam.CollisionRule.NEVER : this.collisionRule); // Paper - Configurable player collision - output.writeEnum(this.color); - ComponentSerialization.TRUSTED_STREAM_CODEC.encode(output, this.playerPrefix); - ComponentSerialization.TRUSTED_STREAM_CODEC.encode(output, this.playerSuffix); +@@ -178,5 +_,12 @@ + team.packOptions() + ); + } ++ ++ // Paper start ++ @Override ++ public Team.CollisionRule collisionRule() { ++ return !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? PlayerTeam.CollisionRule.NEVER : this.collisionRule; // Paper - Configurable player collision ++ } ++ // Paper end + } + } diff --git a/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch index 0313fcd319a9..9a96367299ad 100644 --- a/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/Identifier.java +++ b/net/minecraft/resources/Identifier.java -@@ -22,12 +_,20 @@ +@@ -23,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_.-]"; @@ -21,7 +21,7 @@ this.namespace = namespace; this.path = path; } -@@ -240,7 +_,7 @@ +@@ -250,7 +_,7 @@ private static String assertValidNamespace(final String namespace, final String path) { if (!isValidNamespace(namespace)) { @@ -30,7 +30,7 @@ } else { return namespace; } -@@ -256,7 +_,7 @@ +@@ -266,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/RegistryDataLoader.java.patch b/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch index 91fa2b5938bb..f2bcb902a430 100644 --- a/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -243,11 +_,21 @@ +@@ -246,11 +_,21 @@ final Map>, RegistryOps.RegistryInfo> result = new HashMap<>(); contextRegistries.forEach(e -> result.put(e.key(), createInfoForContextRegistry((HolderLookup.RegistryLookup)e))); newRegistriesAndLoaders.forEach(e -> result.put(e.registryKey(), e.createRegistryInfo())); diff --git a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch index 3ca47e862d0e..5aebec6c43eb 100644 --- a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java -@@ -43,6 +_,7 @@ +@@ -44,6 +_,7 @@ if (!isBootstrapped) { isBootstrapped = true; Instant start = Instant.now(); @@ -8,7 +8,7 @@ if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { throw new IllegalStateException("Unable to load registries"); } -@@ -56,10 +_,84 @@ +@@ -57,10 +_,84 @@ EntitySelectorOptions.bootStrap(); DispenseItemBehavior.bootStrap(); CauldronInteractions.bootStrap(); diff --git a/paper-server/patches/sources/net/minecraft/server/Main.java.patch b/paper-server/patches/sources/net/minecraft/server/Main.java.patch index 31e6c418b7de..ba009b9893e4 100644 --- a/paper-server/patches/sources/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -63,8 +_,10 @@ +@@ -66,8 +_,10 @@ private static final Logger LOGGER = LogUtils.getLogger(); @SuppressForbidden(reason = "System.out needed before bootstrap") @@ -12,7 +12,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 @@ +@@ -92,41 +_,97 @@ parser.printHelpOn(System.err); return; } @@ -86,7 +86,6 @@ - File universePath = new File(options.valueOf(universe)); - Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), universePath); -- String levelName = Optional.ofNullable(options.valueOf(worldName)).orElse(settings.getProperties().levelName); + // Paper start - Detect headless JRE + String awtException = io.papermc.paper.util.ServerEnvironment.awtDependencyCheck(); + if (awtException != null) { @@ -112,11 +111,14 @@ + } + // Paper end - fix SPIGOT-5824 + Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), universePath, userCacheFile, options); // Paper - pass OptionSet to load paper config files; override authentication service; fix world-container + NotificationManager notificationManager = new NotificationManager(); + ManagementServer jsonRpcServer = JsonRpc.create(settings, notificationManager); +- String levelName = Optional.ofNullable(options.valueOf(worldName)).orElse(settings.getProperties().levelName); + String levelName = Optional.ofNullable((String) options.valueOf("world")).orElse(settings.getProperties().levelName); // CraftBukkit LevelStorageSource levelStorageSource = LevelStorageSource.createDefault(universePath.toPath()); LevelStorageSource.LevelStorageAccess access = levelStorageSource.validateAndCreateAccess(levelName); Dynamic levelDataTag; -@@ -149,13 +_,38 @@ +@@ -154,13 +_,38 @@ } else { levelDataTag = null; } @@ -156,7 +158,7 @@ WorldStem worldStem; try { -@@ -164,17 +_,31 @@ +@@ -169,17 +_,31 @@ executor -> WorldLoader.load( worldLoadConfig, context -> { @@ -170,7 +172,7 @@ + context.datapackWorldgen(), + levelName, + LevelStem.OVERWORLD, -+ io.papermc.paper.world.PaperWorldLoader.dimensionKey(LevelStem.OVERWORLD) ++ Registries.levelStemToLevel(LevelStem.OVERWORLD) + ); + } catch (final IOException ex) { + throw new UncheckedIOException("Failed to migrate world storage for " + LevelStem.OVERWORLD.identifier(), ex); @@ -190,7 +192,7 @@ } }, WorldStem::new, -@@ -190,6 +_,7 @@ +@@ -195,6 +_,7 @@ return; } @@ -198,7 +200,7 @@ RegistryAccess.Frozen registryHolder = worldStem.registries().compositeAccess(); WorldData data = worldStem.worldDataAndGenSettings().data(); boolean recreateRegionFilesValue = options.has(recreateRegionFiles); -@@ -198,22 +_,51 @@ +@@ -203,9 +_,12 @@ } access.saveDataTag(data); @@ -206,19 +208,15 @@ final DedicatedServer dedicatedServer = MinecraftServer.spin( thread -> { DedicatedServer server = new DedicatedServer( -- thread, access, packRepository, worldStem, Optional.empty(), settings, DataFixers.getDataFixer(), services -+ // CraftBukkit start -+ options, -+ worldLoader.get(), -+ thread, -+ access, -+ packRepository, -+ worldStem, -+ Optional.empty(), -+ settings, -+ DataFixers.getDataFixer(), -+ services ++ options, // CraftBukkit ++ worldLoader.get(), // CraftBukkit + thread, + access, + packRepository, +@@ -218,17 +_,35 @@ + notificationManager ); + notificationManager.setServer(server); + /* server.setPort(options.valueOf(port)); - server.setDemo(options.has(demo)); @@ -253,7 +251,7 @@ Thread shutdownThread = new Thread("Server Shutdown Thread") { @Override public void run() { -@@ -222,12 +_,13 @@ +@@ -237,12 +_,13 @@ }; shutdownThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); Runtime.getRuntime().addShutdownHook(shutdownThread); @@ -268,7 +266,7 @@ final DedicatedServerSettings settings, final WorldLoader.DataLoadContext context, final Registry datapackDimensions, -@@ -298,7 +_,11 @@ +@@ -313,7 +_,11 @@ final RegistryAccess registryAccess, final boolean recreateRegionFiles ) { @@ -281,7 +279,7 @@ try (WorldUpgrader upgrader = new WorldUpgrader(storageSource, fixerUpper, registryAccess, eraseCache, recreateRegionFiles)) { Component lastStatus = null; -@@ -326,5 +_,6 @@ +@@ -341,5 +_,6 @@ } } } 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 287219cd7f3b..acdc44780519 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -192,11 +_,13 @@ +@@ -190,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements CommandSource, ServerInfo, ChunkIOErrorReporter { @@ -15,7 +15,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 @@ +@@ -218,7 +_,7 @@ public final PlayerDataStorage playerDataStorage; private final SavedDataStorage savedDataStorage; private final List tickables = Lists.newArrayList(); @@ -24,7 +24,7 @@ private MetricsRecorder metricsRecorder = InactiveMetricsRecorder.INSTANCE; private Consumer onMetricsRecordingStopped = results -> this.stopRecordingMetrics(); private Consumer onMetricsRecordingFinished = ignored -> {}; -@@ -227,7 +_,7 @@ +@@ -226,7 +_,7 @@ private MinecraftServer.@Nullable TimeProfiler debugCommandProfiler; private boolean debugCommandProfilerDelayStart; private ServerConnectionListener connection; @@ -33,7 +33,7 @@ private @Nullable ServerStatus status; private ServerStatus.@Nullable Favicon statusIcon; private final RandomSource random = RandomSource.create(); -@@ -238,13 +_,14 @@ +@@ -237,13 +_,14 @@ private Map, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -49,7 +49,7 @@ private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -272,7 +_,7 @@ +@@ -271,7 +_,7 @@ private @Nullable CommandStorage commandStorage; private final CustomBossEvents customBossEvents; private final RandomSequences randomSequences; @@ -58,7 +58,7 @@ private final ServerFunctionManager functionManager; private boolean enforceWhitelist; private boolean usingWhitelist; -@@ -292,13 +_,14 @@ +@@ -291,13 +_,14 @@ private final SuppressedExceptionCollector suppressedExceptions = new SuppressedExceptionCollector(); private final DiscontinuousFrame tickFrame; private final PacketProcessor packetProcessor; @@ -75,7 +75,7 @@ if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } -@@ -309,7 +_,124 @@ +@@ -308,7 +_,124 @@ return server; } @@ -201,7 +201,7 @@ final LevelStorageSource.LevelStorageAccess storageSource, final PackRepository packRepository, @@ -322,28 +_,28 @@ - final boolean propagatesCrashes + final NotificationManager notificationManager ) { super("Server", propagatesCrashes); + SERVER = this; // Paper - better singleton @@ -1278,7 +1278,7 @@ this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); } -@@ -1372,10 +_,20 @@ +@@ -1376,10 +_,20 @@ @Override public String getMotd() { @@ -1300,7 +1300,7 @@ this.motd = motd; } -@@ -1405,16 +_,20 @@ +@@ -1409,16 +_,20 @@ int count = 0; for (ServerPlayer player : this.getPlayerList().getPlayers()) { @@ -1324,7 +1324,7 @@ } public boolean isReady() { -@@ -1477,7 +_,7 @@ +@@ -1485,7 +_,7 @@ @Override public void executeIfPossible(final Runnable command) { if (this.isStopped()) { @@ -1333,7 +1333,7 @@ } super.executeIfPossible(command); -@@ -1512,7 +_,16 @@ +@@ -1520,7 +_,16 @@ return this.functionManager; } @@ -1350,7 +1350,7 @@ CompletableFuture result = CompletableFuture.supplyAsync( () -> packsToEnable.stream() .map(this.packRepository::getPack) -@@ -1524,7 +_,7 @@ +@@ -1532,7 +_,7 @@ .thenCompose( packsToLoad -> { CloseableResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, packsToLoad); @@ -1359,7 +1359,7 @@ return ReloadableServerResources.loadResources( resources, this.registries, -@@ -1544,18 +_,37 @@ +@@ -1552,18 +_,37 @@ } ) .thenAcceptAsync(newResources -> { @@ -1399,7 +1399,7 @@ }, this); if (this.isSameThread()) { this.managedBlock(result::isDone); -@@ -1570,7 +_,7 @@ +@@ -1578,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet forcedFeatures = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet allowedFeatures = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1408,7 +1408,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), forcedFeatures, false); } -@@ -1625,7 +_,7 @@ +@@ -1633,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( final PackRepository packRepository, final Collection selected, final FeatureFlagSet forcedFeatures, final boolean disableInactive ) { @@ -1417,7 +1417,7 @@ enableForcedFeaturePacks(packRepository, forcedFeatures); DataPackConfig packConfig = getSelectedPacks(packRepository, disableInactive); FeatureFlagSet packRequestedFeatures = packRepository.getRequestedFeatureFlags().join(forcedFeatures); -@@ -1657,7 +_,7 @@ +@@ -1665,7 +_,7 @@ } } @@ -1426,7 +1426,7 @@ } } -@@ -1674,8 +_,8 @@ +@@ -1682,8 +_,8 @@ UserWhiteList whiteList = playerList.getWhiteList(); for (ServerPlayer player : Lists.newArrayList(playerList.getPlayers())) { @@ -1437,7 +1437,7 @@ } } } -@@ -1705,12 +_,12 @@ +@@ -1713,12 +_,12 @@ } public ServerLevel findRespawnDimension() { @@ -1452,7 +1452,7 @@ public void setRespawnData(final LevelData.RespawnData respawnData) { ServerLevelData levelData = this.worldData.overworldData(); LevelData.RespawnData oldRespawnData = levelData.getRespawnData(); -@@ -1778,17 +_,20 @@ +@@ -1786,17 +_,20 @@ return this.randomSequences; } @@ -1478,7 +1478,7 @@ } public boolean isEnforceWhitelist() { -@@ -1879,7 +_,7 @@ +@@ -1887,7 +_,7 @@ private void dumpGameRules(final Path path) throws IOException { try (Writer output = Files.newBufferedWriter(path)) { final List entries = Lists.newArrayList(); @@ -1487,7 +1487,7 @@ gameRules.visitGameRuleTypes(new GameRuleTypeVisitor() { @Override public void visit(final GameRule gameRule) { -@@ -1937,6 +_,17 @@ +@@ -1944,6 +_,17 @@ } } @@ -1505,7 +1505,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2057,16 +_,22 @@ +@@ -2064,16 +_,22 @@ } public void logChatMessage(final Component message, final ChatType.Bound chatType, final @Nullable String tag) { @@ -1532,7 +1532,7 @@ } public boolean logIPs() { -@@ -2077,8 +_,9 @@ +@@ -2084,8 +_,9 @@ LOGGER.debug("Received custom click action {} with payload {}", id, payload.orElse(null)); } @@ -1543,7 +1543,7 @@ } public boolean setAutoSave(final boolean enable) { -@@ -2104,12 +_,14 @@ +@@ -2111,12 +_,14 @@ return false; } @@ -1561,7 +1561,7 @@ player.connection.send(new ClientboundEntityEventPacket(player, event)); } } else if (rule == GameRules.LIMITED_CRAFTING || rule == GameRules.IMMEDIATE_RESPAWN) { -@@ -2117,20 +_,21 @@ +@@ -2124,20 +_,21 @@ ? ClientboundGameEventPacket.LIMITED_CRAFTING : ClientboundGameEventPacket.IMMEDIATE_RESPAWN; ClientboundGameEventPacket packet = new ClientboundGameEventPacket(eventType, (Boolean)value ? 1.0F : 0.0F); @@ -1588,7 +1588,7 @@ } } -@@ -2143,12 +_,14 @@ +@@ -2150,12 +_,14 @@ return this.savedDataStorage; } @@ -1605,7 +1605,7 @@ } public boolean acceptsTransfers() { -@@ -2294,4 +_,53 @@ +@@ -2322,4 +_,53 @@ }; } } diff --git a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch index f8391f805185..f3ef38ec840e 100644 --- a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch @@ -9,15 +9,7 @@ private final PlayerList playerList; private final Path playerSavePath; private AdvancementTree tree; -@@ -59,6 +_,7 @@ - private @Nullable AdvancementHolder lastSelectedTab; - private boolean isFirstPacket = true; - private final Codec codec; -+ public final Map, Set>> criterionData = new java.util.IdentityHashMap<>(); // Paper - fix advancement data player leakage - - public PlayerAdvancements( - final DataFixer dataFixer, final PlayerList playerList, final ServerAdvancementManager manager, final Path playerSavePath, final ServerPlayer player -@@ -128,6 +_,7 @@ +@@ -127,6 +_,7 @@ } public void save() { @@ -25,7 +17,7 @@ JsonElement json = this.codec.encodeStart(JsonOps.INSTANCE, this.asData()).getOrThrow(); try { -@@ -145,6 +_,7 @@ +@@ -144,6 +_,7 @@ data.forEach((id, progress) -> { AdvancementHolder advancement = manager.get(id); if (advancement == null) { @@ -33,7 +25,7 @@ LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", id, this.playerSavePath); } else { this.startProgress(advancement, progress); -@@ -169,14 +_,31 @@ +@@ -168,14 +_,31 @@ AdvancementProgress progress = this.getOrStartProgress(holder); boolean wasDone = progress.isDone(); if (progress.grantProgress(criterion)) { @@ -67,7 +59,7 @@ } }); } -@@ -247,7 +_,7 @@ +@@ -238,7 +_,7 @@ public void flushDirty(final ServerPlayer player, final boolean showAdvancements) { if (this.isFirstPacket || !this.rootsToUpdate.isEmpty() || !this.progressChanged.isEmpty()) { Map progress = new HashMap<>(); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/DeOpCommands.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/DeOpCommands.java.patch deleted file mode 100644 index 1918257ef32a..000000000000 --- a/paper-server/patches/sources/net/minecraft/server/commands/DeOpCommands.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/commands/DeOpCommands.java -+++ b/net/minecraft/server/commands/DeOpCommands.java -@@ -35,7 +_,7 @@ - if (list.isOp(player)) { - list.deop(player); - count++; -- source.sendSuccess(() -> Component.translatable("commands.deop.success", players.iterator().next().name()), true); -+ source.sendSuccess(() -> Component.translatable("commands.deop.success", player.name()), true); // Paper - fixes MC-307513 - } - } - 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 index fb0f2487c318..fd6cb2439e6f 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/DifficultyCommand.java.patch @@ -6,7 +6,7 @@ MinecraftServer server = source.getServer(); - if (server.getWorldData().getDifficulty() == difficulty) { + if (source.getLevel().getDifficulty() == difficulty) { // CraftBukkit - throw ERROR_ALREADY_SAME_DIFFICULTY.create(difficulty.getSerializedName()); + throw ERROR_ALREADY_SAME_DIFFICULTY.create(difficulty.getDisplayName()); } - server.setDifficulty(difficulty, true); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/EffectCommands.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/EffectCommands.java.patch index e82fad73ce0e..c84911e4ba58 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/EffectCommands.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/EffectCommands.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/commands/EffectCommands.java @@ -178,7 +_,7 @@ for (Entity entity : entities) { - if (entity instanceof LivingEntity) { + if (entity instanceof LivingEntity livingEntity) { MobEffectInstance instance = new MobEffectInstance(effectHolder, duration, amplifier, false, particles); -- if (((LivingEntity)entity).addEffect(instance, source.getEntity())) { -+ if (((LivingEntity)entity).addEffect(instance, source.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit +- if (livingEntity.addEffect(instance, source.getEntity())) { ++ if (livingEntity.addEffect(instance, source.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit count++; } } @@ -13,8 +13,8 @@ int count = 0; for (Entity entity : entities) { -- if (entity instanceof LivingEntity && ((LivingEntity)entity).removeAllEffects()) { -+ if (entity instanceof LivingEntity && ((LivingEntity)entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit +- if (entity instanceof LivingEntity livingEntity && livingEntity.removeAllEffects()) { ++ if (entity instanceof LivingEntity livingEntity && livingEntity.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit count++; } } @@ -22,8 +22,8 @@ int count = 0; for (Entity entity : entities) { -- if (entity instanceof LivingEntity && ((LivingEntity)entity).removeEffect(effectHolder)) { -+ if (entity instanceof LivingEntity && ((LivingEntity)entity).removeEffect(effectHolder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit +- if (entity instanceof LivingEntity livingEntity && livingEntity.removeEffect(effectHolder)) { ++ if (entity instanceof LivingEntity livingEntity && livingEntity.removeEffect(effectHolder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit count++; } } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GameModeCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GameModeCommand.java.patch index 0af763405329..cffb62622f6e 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GameModeCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/GameModeCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/GameModeCommand.java +++ b/net/minecraft/server/commands/GameModeCommand.java -@@ -63,9 +_,21 @@ +@@ -69,7 +_,14 @@ } private static boolean setGameMode(final CommandSourceStack source, final ServerPlayer player, final GameType type) { @@ -13,6 +13,11 @@ + org.bukkit.event.player.PlayerGameModeChangeEvent event = player.setGameMode(type, cause, null); + if (event != null && !event.isCancelled()) { + // Paper end - Expand PlayerGameModeChangeEvent + MinecraftServer server = source.getServer(); + if (server.isSingleplayerOwner(player.nameAndId())) { + server.setDefaultGameType(type); +@@ -77,6 +_,11 @@ + logGamemodeChange(source, player, type); return true; + // Paper start - Expand PlayerGameModeChangeEvent 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 index dfbc359450bc..2b7c123881af 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/PlaceCommand.java +++ b/net/minecraft/server/commands/PlaceCommand.java -@@ -299,6 +_,7 @@ +@@ -300,6 +_,7 @@ throw ERROR_STRUCTURE_FAILED.create(); } 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 index f68ef1494ca4..ad9add6db7d0 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/RideCommand.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/RideCommand.java +++ b/net/minecraft/server/commands/RideCommand.java -@@ -56,7 +_,7 @@ +@@ -57,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 +- if (vehicle.is(EntityTypes.PLAYER)) { ++ if (vehicle.is(EntityTypes.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/SummonCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch index 864b687049c4..0622e5aa8067 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/SummonCommand.java +++ b/net/minecraft/server/commands/SummonCommand.java -@@ -80,7 +_,7 @@ +@@ -82,7 +_,7 @@ throw INVALID_POSITION.create(); } @@ -9,15 +9,15 @@ throw ERROR_FAILED_PEACEFUL.create(); } -@@ -89,6 +_,7 @@ +@@ -91,6 +_,7 @@ ServerLevel level = source.getLevel(); - Entity entity = EntityType.loadEntityRecursive(entityTag, level, EntitySpawnReason.COMMAND, e -> { + Entity entity = EntityType.loadEntityRecursive(entityTag, level, new EntitySpawnRequest(EntitySpawnReason.COMMAND, false), 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 @@ +@@ -101,7 +_,7 @@ mob.finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, null); } 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 12632227b8c6..e01ddb157046 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/TimeCommand.java +++ b/net/minecraft/server/commands/TimeCommand.java -@@ -119,7 +_,7 @@ +@@ -120,7 +_,7 @@ final CommandSourceStack source, final SuggestionsBuilder builder, final Holder clock ) { return SharedSuggestionProvider.suggestResource( @@ -9,7 +9,7 @@ ); } -@@ -141,7 +_,7 @@ +@@ -142,7 +_,7 @@ } private static int queryTime(final CommandSourceStack source, final Holder clock) { @@ -18,7 +18,7 @@ long totalTicks = clockManager.getTotalTicks(clock); source.sendSuccess(() -> Component.translatable("commands.time.query.absolute", clock.getRegisteredName(), totalTicks), false); return wrapTime(totalTicks); -@@ -152,7 +_,7 @@ +@@ -153,7 +_,7 @@ throw ERROR_WRONG_TIMELINE_FOR_CLOCK.create(clock.getRegisteredName(), timeline.getRegisteredName()); } @@ -27,7 +27,7 @@ long currentTicks = timeline.value().getCurrentTicks(clockManager); source.sendSuccess(() -> Component.translatable("commands.time.query.timeline", timeline.getRegisteredName(), currentTicks), false); return wrapTime(currentTicks); -@@ -163,45 +_,67 @@ +@@ -164,45 +_,67 @@ throw ERROR_WRONG_TIMELINE_FOR_CLOCK.create(clock.getRegisteredName(), timeline.getRegisteredName()); } @@ -97,12 +97,12 @@ - source.getServer().clockManager().setPaused(clock, paused); + source.getLevel().clockManager().setPaused(clock, paused); // Paper - per-world time source.sendSuccess(() -> Component.translatable(paused ? "commands.time.pause" : "commands.time.resume", clock.getRegisteredName()), true); - return 1; + return Command.SINGLE_SUCCESS; } private static int setRate(final CommandSourceStack source, final Holder clock, final float rate) { - source.getServer().clockManager().setRate(clock, rate); + source.getLevel().clockManager().setRate(clock, rate); // Paper - per-world time source.sendSuccess(() -> Component.translatable("commands.time.rate", clock.getRegisteredName(), rate), true); - return 1; + return Command.SINGLE_SUCCESS; } 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 65d885fc3451..777fef675dac 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/WaypointCommand.java +++ b/net/minecraft/server/commands/WaypointCommand.java -@@ -164,7 +_,7 @@ +@@ -166,7 +_,7 @@ } private static void mutateIcon(final CommandSourceStack source, final WaypointTransmitter waypoint, final Consumer iconConsumer) { 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 7e43d28d3f0c..6bbb58927356 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -83,9 +_,9 @@ +@@ -76,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; @@ -12,33 +12,33 @@ private @Nullable RconThread rconThread; public DedicatedServerSettings settings; private @Nullable MinecraftServerGui gui; -@@ -98,6 +_,7 @@ - private long lastHeartbeat; +@@ -90,6 +_,7 @@ + private final @Nullable ManagementServer jsonRpcServer; public DedicatedServer( + joptsimple.OptionSet options, net.minecraft.server.WorldLoader.DataLoadContext worldLoader, // CraftBukkit - Signature changed final Thread serverThread, final LevelStorageSource.LevelStorageAccess levelStorageSource, final PackRepository packRepository, -@@ -108,6 +_,7 @@ - final Services services +@@ -102,6 +_,7 @@ + final NotificationManager notificationManager ) { super( + options, worldLoader, // CraftBukkit - Signature changed serverThread, levelStorageSource, packRepository, -@@ -120,7 +_,8 @@ - true +@@ -115,7 +_,8 @@ + notificationManager ); this.settings = settings; - this.rconConsoleSource = new RconConsoleSource(this); + this.setMotd(settings.getProperties().motd.get()); // Paper - set field from initial properties + //this.rconConsoleSource = new RconConsoleSource(this); // CraftBukkit - remove field this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); + this.jsonRpcServer = jsonRpcServer; this.serverLinks = createServerLinks(settings); - if (settings.getProperties().codeOfConduct) { -@@ -206,6 +_,10 @@ +@@ -167,6 +_,10 @@ Thread consoleThread = new Thread("Server console handler") { @Override public void run() { @@ -49,7 +49,7 @@ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String line; -@@ -216,16 +_,41 @@ +@@ -177,16 +_,41 @@ } catch (IOException e) { DedicatedServer.LOGGER.error("Exception handling console input", e); } @@ -92,7 +92,7 @@ LOGGER.info("Loading properties"); DedicatedServerProperties properties = this.settings.getProperties(); if (this.isSingleplayer()) { -@@ -236,8 +_,45 @@ +@@ -197,8 +_,45 @@ this.setLocalIp(properties.serverIp); } @@ -139,7 +139,7 @@ InetAddress localAddress = null; if (!this.getLocalIp().isEmpty()) { localAddress = InetAddress.getByName(this.getLocalIp()); -@@ -246,47 +_,73 @@ +@@ -207,47 +_,73 @@ if (this.getPort() < 0) { this.setPort(properties.serverPort); } @@ -221,16 +221,16 @@ } if (properties.enableQuery) { -@@ -299,7 +_,7 @@ +@@ -260,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)); + Thread watchdog = new Thread(new ServerWatchdog(this), "Server Watchdog"); watchdog.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); - watchdog.setName("Server Watchdog"); -@@ -317,6 +_,12 @@ + watchdog.setDaemon(true); +@@ -277,6 +_,12 @@ return true; } @@ -243,7 +243,7 @@ @Override public boolean isEnforceWhitelist() { return this.settings.getProperties().enforceWhitelist.get(); -@@ -334,6 +_,7 @@ +@@ -294,6 +_,7 @@ @Override public void setUsingWhitelist(final boolean usingWhitelist) { @@ -251,7 +251,7 @@ this.settings.update(p -> p.whiteList.update(this.registryAccess(), usingWhitelist)); } -@@ -395,7 +_,7 @@ +@@ -345,7 +_,7 @@ @Override protected void forceDifficulty() { @@ -260,7 +260,7 @@ } public int viewDistance() { -@@ -451,11 +_,11 @@ +@@ -403,11 +_,11 @@ } if (this.rconThread != null) { @@ -274,7 +274,7 @@ } if (this.jsonRpcServer != null) { -@@ -465,6 +_,9 @@ +@@ -417,6 +_,9 @@ LOGGER.error("Interrupted while stopping the management server", e); } } @@ -284,7 +284,7 @@ } @Override -@@ -474,12 +_,20 @@ +@@ -426,12 +_,20 @@ } public void handleConsoleInput(final String msg, final CommandSourceStack source) { @@ -308,7 +308,7 @@ this.getCommands().performPrefixedCommand(input.source, input.msg); } } -@@ -625,12 +_,15 @@ +@@ -592,12 +_,15 @@ @Override public String getMotd() { @@ -326,7 +326,7 @@ } @Override -@@ -656,7 +_,11 @@ +@@ -623,7 +_,11 @@ @Override public boolean enforceSecureProfile() { DedicatedServerProperties properties = this.getProperties(); @@ -339,7 +339,7 @@ } @Override -@@ -741,21 +_,60 @@ +@@ -708,21 +_,60 @@ @Override public String getPluginNames() { @@ -405,7 +405,7 @@ } @Override -@@ -883,4 +_,15 @@ +@@ -850,4 +_,15 @@ public Map getCodeOfConducts() { return this.codeOfConductTexts; } diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index 098f8b33594e..6cb19c477e5d 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -8,7 +8,7 @@ public static final String MANAGEMENT_SERVER_TLS_ENABLED_KEY = "management-server-tls-enabled"; public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_KEY = "management-server-tls-keystore"; public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_PASSWORD_KEY = "management-server-tls-keystore-password"; -@@ -106,7 +_,7 @@ +@@ -108,7 +_,7 @@ public final boolean broadcastRconToOps = this.get("broadcast-rcon-to-ops", true); public final boolean broadcastConsoleToOps = this.get("broadcast-console-to-ops", true); public final int maxWorldSize = this.get("max-world-size", v -> Mth.clamp(v, 1, 29999984), 29999984); @@ -17,7 +17,7 @@ public final String regionFileComression = this.get("region-file-compression", "deflate"); public final boolean enableJmxMonitoring = this.get("enable-jmx-monitoring", false); public final Settings.MutableValue enableStatus = this.getMutable("enable-status", true); -@@ -123,13 +_,16 @@ +@@ -125,13 +_,16 @@ public final Settings.MutableValue whiteList = this.getMutable("white-list", false); public final boolean enforceSecureProfile = this.get("enforce-secure-profile", true); public final boolean logIPs = this.get("log-ips", true); @@ -37,7 +37,7 @@ String levelSeed = this.get("level-seed", ""); boolean generateStructures = this.get("generate-structures", true); long seed = WorldOptions.parseSeed(levelSeed).orElse(WorldOptions.randomSeed()); -@@ -150,15 +_,23 @@ +@@ -152,15 +_,23 @@ this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())) ); 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 6979890a62db..88a18bfdbbfd 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 -@@ -48,7 +_,7 @@ +@@ -51,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/gui/MinecraftServerGui.java.patch b/paper-server/patches/sources/net/minecraft/server/gui/MinecraftServerGui.java.patch index 7d1652db9cb0..5db76fe53efe 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 -@@ -53,6 +_,13 @@ +@@ -55,6 +_,13 @@ frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); @@ -14,7 +14,7 @@ frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent event) { -@@ -74,6 +_,7 @@ +@@ -76,6 +_,7 @@ this.setLayout(new BorderLayout()); try { @@ -22,7 +22,7 @@ this.add(this.buildChatPanel(), "Center"); this.add(this.buildInfoPanel(), "West"); } catch (Exception e) { -@@ -87,7 +_,7 @@ +@@ -89,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"); -@@ -150,6 +_,7 @@ +@@ -152,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)); -@@ -162,7 +_,7 @@ +@@ -164,7 +_,7 @@ } try { @@ -48,7 +48,7 @@ } catch (BadLocationException var8) { } -@@ -171,4 +_,37 @@ +@@ -173,4 +_,37 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch b/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch index 5e806ee764fb..9ea017876dad 100644 --- a/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/gui/StatsComponent.java.patch @@ -29,7 +29,7 @@ + + // Paper start - Improve ServerGUI + private static String format(double tps) { -+ return (( tps > 21.0 ) ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, 20.0); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise ++ return ((tps > 21.0) ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, 20.0); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise + } + // Paper end - Improve ServerGUI } diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch index 7d8ae2961a80..0407a3d02f9d 100644 --- a/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java.patch @@ -1,51 +1,53 @@ --- a/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java +++ b/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java -@@ -10,21 +_,30 @@ - +@@ -14,11 +_,22 @@ public class MinecraftGameRuleServiceImpl implements MinecraftGameRuleService { - private final DedicatedServer server; -- private GameRules gameRules; -+ private @org.jspecify.annotations.Nullable GameRules gameRules; // Paper - per-world game rules + private final NotificationManager notificationManager; private final JsonRpcLogger jsonrpcLogger; ++ private @org.jspecify.annotations.Nullable GameRules gameRules; // Paper - per-world game rules - public MinecraftGameRuleServiceImpl(final DedicatedServer server, final JsonRpcLogger jsonrpcLogger) { - this.server = server; -- this.gameRules = server.getGameRules(); -+ this.gameRules = null; // Paper - per-world game rules - cannot get game rules until server is started + public MinecraftGameRuleServiceImpl(final NotificationManager notificationManager, final JsonRpcLogger jsonrpcLogger) { + this.notificationManager = notificationManager; this.jsonrpcLogger = jsonrpcLogger; - } - +- } ++ this.gameRules = null; // Paper - per-world game rules - cannot get game rules until server is started ++ } ++ + // Paper start - per-world game rules + public GameRules getGameRules() { + if (this.gameRules == null) { -+ this.gameRules = this.server.overworld().getGameRules(); ++ this.gameRules = this.server().overworld().getGameRules(); + } + return this.gameRules; + } + // Paper end -+ - @Override + + private DedicatedServer server() { + return Objects.requireNonNull(this.notificationManager.server()); +@@ -28,10 +_,10 @@ public GameRulesService.GameRuleUpdate updateGameRule(final GameRulesService.GameRuleUpdate update, final ClientInfo clientInfo) { GameRule gameRule = update.gameRule(); -- T oldValue = this.gameRules.get(gameRule); -+ T oldValue = this.getGameRules().get(gameRule); // Paper - per-world game rules + MinecraftServer server = this.server(); +- GameRules gameRules = server.getGameRules(); ++ GameRules gameRules = this.getGameRules(); // Paper - per-world game rules + T oldValue = gameRules.get(gameRule); T newValue = update.value(); -- this.gameRules.set(gameRule, newValue, this.server); -+ this.getGameRules().set(gameRule, newValue, this.server.overworld()); // Paper - per-world game rules - use overworld for vanilla protocol +- gameRules.set(gameRule, newValue, server); ++ gameRules.set(gameRule, newValue, this.server().overworld()); // Paper - per-world game rules - use overworld for vanilla protocol this.jsonrpcLogger .log(clientInfo, "Game rule '{}' updated from '{}' to '{}'", gameRule.id(), gameRule.serialize(oldValue), gameRule.serialize(newValue)); return update; -@@ -37,11 +_,11 @@ +@@ -44,11 +_,11 @@ @Override public Stream> getAvailableGameRules() { -- return this.gameRules.availableRules(); +- return this.server().getGameRules().availableRules(); + return this.getGameRules().availableRules(); // Paper - per-world game rules } @Override public T getRuleValue(final GameRule gameRule) { -- return this.gameRules.get(gameRule); +- return this.server().getGameRules().get(gameRule); + return this.getGameRules().get(gameRule); // Paper - per-world game rules } } 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 c2584b6efe61..4e018ac9d134 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 @@ -141,7 +141,7 @@ } }, this.unloadQueue::add).whenComplete((ignored, throwable) -> { if (throwable != null) { -@@ -843,7 +_,7 @@ +@@ -840,7 +_,7 @@ } public int size() { @@ -150,7 +150,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -870,10 +_,10 @@ +@@ -867,10 +_,10 @@ .addColumn("fluid_ticks") .build(output); @@ -164,8 +164,8 @@ + ChunkHolder holder = entry; // Paper - Moonrise Optional chunk = Optional.ofNullable(holder.getLatestChunk()); Optional fullChunk = chunk.flatMap( - chunkAccess -> chunkAccess instanceof LevelChunk ? Optional.of((LevelChunk)chunkAccess) : Optional.empty() -@@ -922,14 +_,14 @@ + chunkAccess -> chunkAccess instanceof LevelChunk levelChunk ? Optional.of(levelChunk) : Optional.empty() +@@ -919,14 +_,14 @@ return this.upgradeChunkTag( tag, -1, @@ -183,7 +183,7 @@ generatorIdentifier.ifPresent(identifier -> contextTag.putString("generator", identifier.toString())); return contextTag; } -@@ -941,7 +_,7 @@ +@@ -938,7 +_,7 @@ ChunkHolder holder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (holder != null) { LevelChunk chunk = holder.getTickingChunk(); @@ -192,7 +192,7 @@ output.add(chunk); } } -@@ -961,8 +_,14 @@ +@@ -958,8 +_,14 @@ } public boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos) { @@ -207,8 +207,8 @@ + // Spigot end } - boolean anyPlayerCloseEnoughTo(final BlockPos pos, final int maxDistance) { -@@ -978,8 +_,24 @@ + public boolean anyPlayerCloseEnoughTo(final BlockPos pos, final int maxDistance) { +@@ -975,8 +_,24 @@ } private boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos) { @@ -234,7 +234,7 @@ return true; } } -@@ -996,7 +_,7 @@ +@@ -993,7 +_,7 @@ Builder builder = ImmutableList.builder(); for (ServerPlayer player : this.playerMap.getAllPlayers()) { @@ -243,7 +243,7 @@ builder.add(player); } } -@@ -1004,13 +_,13 @@ +@@ -1001,13 +_,13 @@ return builder.build(); } @@ -259,7 +259,7 @@ } private boolean playerIsCloseEnoughTo(final ServerPlayer player, final Vec3 pos, final int maxDistance) { -@@ -1138,9 +_,19 @@ +@@ -1139,9 +_,19 @@ } public void addEntity(final Entity entity) { @@ -279,7 +279,7 @@ if (range != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1164,6 +_,7 @@ +@@ -1165,6 +_,7 @@ } protected void removeEntity(final Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch b/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch index b9e3d08db459..b8808e6c3333 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/PlayerSpawnFinder.java.patch @@ -4,8 +4,8 @@ } public static CompletableFuture findSpawn(final ServerLevel level, final BlockPos spawnSuggestion) { -- if (level.dimensionType().hasSkyLight() && level.getServer().getWorldData().getGameType() != GameType.ADVENTURE) { -+ if (level.dimensionType().hasSkyLight() && level.serverLevelData.getGameType() != GameType.ADVENTURE) { // CraftBukkit - int radius = Math.max(0, level.getGameRules().get(GameRules.RESPAWN_RADIUS)); - int distToBorder = Mth.floor(level.getWorldBorder().getDistanceToBorder(spawnSuggestion.getX(), spawnSuggestion.getZ())); - if (distToBorder < radius) { +- if (level.getServer().getWorldData().getGameType() == GameType.ADVENTURE) { ++ if (level.serverLevelData.getGameType() == GameType.ADVENTURE) { // CraftBukkit + return CompletableFuture.completedFuture(fixupSpawnHeight(level, spawnSuggestion)); + } + diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch index 86c6ee5d84a2..28f9e1ad51be 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch @@ -113,7 +113,7 @@ return chunkAccess; } } -@@ -236,7 +_,15 @@ +@@ -235,7 +_,15 @@ long key = pos.pack(); int targetTicketLevel = ChunkLevel.byStatus(targetStatus); ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(key); @@ -130,7 +130,7 @@ this.addTicket(new Ticket(TicketType.UNKNOWN, targetTicketLevel), pos); if (this.chunkAbsent(chunkHolder, targetTicketLevel)) { ProfilerFiller profiler = Profiler.get(); -@@ -256,7 +_,7 @@ +@@ -255,7 +_,7 @@ } private boolean chunkAbsent(final @Nullable ChunkHolder chunkHolder, final int targetTicketLevel) { @@ -139,7 +139,7 @@ } @Override -@@ -310,17 +_,39 @@ +@@ -309,17 +_,39 @@ @Override public void close() throws IOException { @@ -181,7 +181,7 @@ this.ticketStorage.purgeStaleTickets(this.chunkMap); } -@@ -344,7 +_,7 @@ +@@ -343,7 +_,7 @@ if (!this.level.isDebug()) { ProfilerFiller profiler = Profiler.get(); profiler.push("pollingChunks"); @@ -190,7 +190,7 @@ profiler.push("tickingChunks"); this.tickChunks(profiler, timeDiff); profiler.pop(); -@@ -376,12 +_,20 @@ +@@ -375,12 +_,20 @@ chunkCount, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap) ); this.lastSpawnState = spawnCookie; @@ -200,7 +200,7 @@ List spawningCategories; - if (doMobSpawning) { - boolean spawnPersistent = this.level.getGameTime() % 400L == 0L; -- spawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnCookie, true, this.spawnEnemies, spawnPersistent); +- spawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnCookie, this.spawnEnemies, spawnPersistent); + if (doMobSpawning && (this.spawnEnemies || this.spawnFriendlies)) { // Paper + // Paper start - PlayerNaturallySpawnCreaturesEvent + for (ServerPlayer player : this.level.players()) { @@ -211,11 +211,11 @@ + } + // Paper end - PlayerNaturallySpawnCreaturesEvent + boolean spawnPersistent = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit -+ spawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnCookie, this.spawnFriendlies, this.spawnEnemies, spawnPersistent, this.level); // CraftBukkit ++ spawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnCookie, this.spawnFriendlies, this.spawnEnemies, spawnPersistent, this.level); // CraftBukkit // todo snapshot - method lost its spawnFriendlies parameter as mojang is moving away further. We can do what we did prior and reintroduce or re-evaluate. // re-added it for now but let's still re-evaluate later } else { spawningCategories = List.of(); } -@@ -558,7 +_,13 @@ +@@ -561,7 +_,13 @@ @Override public void setSpawnSettings(final boolean spawnEnemies) { @@ -229,7 +229,7 @@ } public String getChunkDebugData(final ChunkPos pos) { -@@ -625,12 +_,18 @@ +@@ -628,12 +_,18 @@ @Override protected boolean pollTask() { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch index 437e3937161b..242c94deec0a 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch @@ -46,7 +46,7 @@ data.tickCarriedBy(player, itemStack, frame); Packet packet = data.getUpdatePacket(id, player); if (packet != null) { -@@ -136,7 +_,13 @@ +@@ -141,7 +_,13 @@ } else { this.teleportDelay++; Vec3 currentPosition = this.entity.trackingPosition(); @@ -61,7 +61,7 @@ Packet packet = null; boolean pos = positionChanged || this.tickCount % 60 == 0; boolean sentPosition = false; -@@ -218,6 +_,25 @@ +@@ -223,6 +_,25 @@ this.tickCount++; if (this.entity.hurtMarked) { @@ -87,7 +87,7 @@ this.entity.hurtMarked = false; this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityMotionPacket(this.entity)); } -@@ -269,7 +_,10 @@ +@@ -274,7 +_,10 @@ public void sendPairingData(final ServerPlayer player, final Consumer> broadcast) { this.entity.updateDataBeforeSync(); if (this.entity.isRemoved()) { @@ -99,7 +99,7 @@ } Packet packet = this.entity.getAddEntityPacket(this); -@@ -280,6 +_,11 @@ +@@ -285,6 +_,11 @@ if (this.entity instanceof LivingEntity livingEntity) { Collection attributes = livingEntity.getAttributes().getSyncableAttributes(); @@ -111,7 +111,7 @@ if (!attributes.isEmpty()) { broadcast.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), attributes)); } -@@ -296,8 +_,9 @@ +@@ -301,8 +_,9 @@ } if (!slots.isEmpty()) { @@ -122,9 +122,9 @@ } if (!this.entity.getPassengers().isEmpty()) { -@@ -344,6 +_,11 @@ - if (this.entity instanceof LivingEntity) { - Set attributes = ((LivingEntity)this.entity).getAttributes().getAttributesToSync(); +@@ -349,6 +_,11 @@ + if (this.entity instanceof LivingEntity livingEntity) { + Set attributes = livingEntity.getAttributes().getAttributesToSync(); if (!attributes.isEmpty()) { + // CraftBukkit start - Send scaled max health + if (this.entity instanceof ServerPlayer serverPlayer) { 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 c71e11b9d093..db7fa776b4a3 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -194,7 +_,7 @@ +@@ -195,7 +_,7 @@ private final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; @@ -9,7 +9,7 @@ private final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; private EnvironmentAttributeSystem environmentAttributes; -@@ -221,24 +_,199 @@ +@@ -222,24 +_,199 @@ private final boolean tickTime; private final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -211,7 +211,7 @@ boolean syncWrites = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityStorage = new EntityStorage( -@@ -260,16 +_,17 @@ +@@ -261,16 +_,17 @@ server.getStructureManager(), executor, generator, @@ -232,7 +232,7 @@ } this.raids = this.getDataStorage().computeIfAbsent(Raids.TYPE); -@@ -277,14 +_,13 @@ +@@ -278,14 +_,13 @@ levelData.setGameType(server.getDefaultGameType()); } @@ -248,7 +248,7 @@ generator, this.chunkSource.randomState(), this, -@@ -300,10 +_,18 @@ +@@ -301,10 +_,18 @@ this.sleepStatus = new SleepStatus(); this.gameEventDispatcher = new GameEventDispatcher(this); @@ -267,9 +267,9 @@ + } + // Paper end - @Deprecated - @VisibleForTesting -@@ -322,7 +_,7 @@ + @Override + public int getNextEntityId() { +@@ -334,7 +_,7 @@ @Override public ServerClockManager clockManager() { @@ -278,7 +278,7 @@ } @Override -@@ -354,11 +_,24 @@ +@@ -367,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(); @@ -305,7 +305,7 @@ if (this.getGameRules().get(GameRules.ADVANCE_WEATHER) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -373,9 +_,9 @@ +@@ -386,9 +_,9 @@ if (!this.isDebug() && runs) { long tick = this.getGameTime(); profiler.push("blockTicks"); @@ -317,7 +317,7 @@ profiler.pop(); } -@@ -393,7 +_,7 @@ +@@ -406,7 +_,7 @@ this.handlingTick = false; profiler.pop(); @@ -326,7 +326,7 @@ if (isActive) { this.resetEmptyTime(); } -@@ -437,9 +_,12 @@ +@@ -450,9 +_,12 @@ } } ); @@ -339,7 +339,7 @@ } profiler.push("entityManagement"); -@@ -468,7 +_,7 @@ +@@ -480,7 +_,7 @@ long time = this.levelData.getGameTime() + 1L; this.serverLevelData.setGameTime(time); Profiler.get().push("scheduledFunctions"); @@ -348,7 +348,7 @@ Profiler.get().pop(); } } -@@ -491,11 +_,13 @@ +@@ -503,11 +_,13 @@ ProfilerFiller profiler = Profiler.get(); profiler.push("iceandsnow"); @@ -362,7 +362,7 @@ profiler.popPush("tickBlocks"); if (tickSpeed > 0) { -@@ -536,12 +_,12 @@ +@@ -548,12 +_,12 @@ int minZ = chunkPos.getMinBlockZ(); ProfilerFiller profiler = Profiler.get(); profiler.push("thunder"); @@ -376,8 +376,8 @@ + && this.random.nextDouble() < difficulty.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01) // Paper - Configurable spawn chances for skeleton horses && !this.getBlockState(pos.below()).is(BlockTags.LIGHTNING_RODS); if (isTrap) { - SkeletonHorse horse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -549,7 +_,7 @@ + SkeletonHorse horse = EntityTypes.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); +@@ -561,7 +_,7 @@ horse.setTrap(true); horse.setAge(0); horse.setPos(pos.getX(), pos.getY(), pos.getZ()); @@ -386,7 +386,7 @@ } } -@@ -557,7 +_,7 @@ +@@ -569,7 +_,7 @@ if (bolt != null) { bolt.snapTo(Vec3.atBottomCenterOf(pos)); bolt.setVisualOnly(isTrap); @@ -395,7 +395,7 @@ } } } -@@ -571,7 +_,7 @@ +@@ -583,7 +_,7 @@ BlockPos belowPos = topPos.below(); Biome biome = this.getBiome(topPos).value(); if (biome.shouldFreeze(this, belowPos)) { @@ -404,7 +404,7 @@ } if (this.isRaining()) { -@@ -583,10 +_,10 @@ +@@ -595,10 +_,10 @@ if (currentLayers < Math.min(maxHeight, 8)) { BlockState newState = state.setValue(SnowLayerBlock.LAYERS, currentLayers + 1); Block.pushEntitiesUp(state, newState, this, topPos); @@ -417,7 +417,7 @@ } } -@@ -611,6 +_,13 @@ +@@ -623,6 +_,13 @@ } protected BlockPos findLightningTargetAround(final BlockPos pos) { @@ -431,7 +431,7 @@ BlockPos center = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional lightningRodTarget = this.findLightningRod(center); if (lightningRodTarget.isPresent()) { -@@ -618,11 +_,12 @@ +@@ -630,11 +_,12 @@ } AABB search = AABB.encapsulatingFullBlocks(center, center.atY(this.getMaxY() + 1)).inflate(3.0); @@ -445,7 +445,7 @@ if (center.getY() == this.getMinY() - 1) { center = center.above(2); } -@@ -739,8 +_,8 @@ +@@ -751,8 +_,8 @@ weatherData.setThunderTime(thunderTime); weatherData.setRainTime(rainTime); weatherData.setClearWeatherTime(clearWeatherTime); @@ -456,7 +456,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -761,6 +_,7 @@ +@@ -773,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -464,7 +464,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -783,15 +_,48 @@ +@@ -795,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)); } @@ -517,7 +517,7 @@ } public void resetEmptyTime() { -@@ -813,18 +_,46 @@ +@@ -825,18 +_,46 @@ } } @@ -564,7 +564,7 @@ } private void tickPassenger(final Entity vehicle, final Entity entity) { -@@ -833,10 +_,12 @@ +@@ -845,10 +_,12 @@ } else if (entity instanceof Player || this.entityTickList.contains(entity)) { entity.setOldPosAndRot(); entity.tickCount++; @@ -577,7 +577,7 @@ profiler.pop(); for (Entity passenger : entity.getPassengers()) { -@@ -867,6 +_,7 @@ +@@ -879,6 +_,7 @@ public void save(final @Nullable ProgressListener progressListener, final boolean flush, final boolean noSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!noSave) { @@ -585,7 +585,7 @@ if (progressListener != null) { progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -887,6 +_,7 @@ +@@ -899,6 +_,7 @@ private void saveLevelData(final boolean sync) { SavedDataStorage savedDataStorage = this.getChunkSource().getDataStorage(); @@ -593,7 +593,7 @@ if (sync) { savedDataStorage.saveAndJoin(); } else { -@@ -949,18 +_,40 @@ +@@ -961,18 +_,40 @@ @Override public boolean addFreshEntity(final Entity entity) { @@ -637,7 +637,7 @@ } } -@@ -983,42 +_,121 @@ +@@ -995,42 +_,121 @@ this.entityManager.addNewEntity(player); } @@ -764,7 +764,7 @@ player.connection.send(new ClientboundBlockDestructionPacket(id, blockPos, progress)); } } -@@ -1106,7 +_,7 @@ +@@ -1118,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -773,7 +773,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1118,6 +_,11 @@ +@@ -1130,6 +_,11 @@ @Override public void gameEvent(final Holder gameEvent, final Vec3 position, final GameEvent.Context context) { @@ -785,7 +785,7 @@ this.gameEventDispatcher.post(gameEvent, position, context); } -@@ -1130,17 +_,28 @@ +@@ -1142,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -814,7 +814,7 @@ try { this.isUpdatingNavigations = true; -@@ -1152,15 +_,23 @@ +@@ -1164,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -838,7 +838,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, null, orientation); } -@@ -1214,6 +_,44 @@ +@@ -1226,6 +_,44 @@ final WeightedList blockParticles, final Holder explosionSound ) { @@ -883,7 +883,7 @@ Explosion.BlockInteraction blockInteraction = switch (interactionType) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); -@@ -1222,10 +_,17 @@ +@@ -1234,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -901,7 +901,7 @@ ParticleOptions explosionParticle = explosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer player : this.players) { -@@ -1234,6 +_,8 @@ +@@ -1246,6 +_,8 @@ player.connection.send(new ClientboundExplodePacket(center, r, blockCount, playerKnockback, explosionParticle, explosionSound, blockParticles)); } } @@ -910,7 +910,7 @@ } private Explosion.BlockInteraction getDestroyType(final GameRule gameRule) { -@@ -1311,7 +_,7 @@ +@@ -1323,7 +_,7 @@ final double zDist, final double speed ) { @@ -919,7 +919,7 @@ } public int sendParticles( -@@ -1327,13 +_,49 @@ +@@ -1339,13 +_,49 @@ final double zDist, final double speed ) { @@ -971,16 +971,7 @@ if (this.sendParticles(player, overrideLimiter, x, y, z, packet)) { result++; } -@@ -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; - } - -@@ -1479,10 +_,36 @@ +@@ -1487,10 +_,36 @@ @Override public @Nullable MapItemSavedData getMapData(final MapId id) { @@ -1018,7 +1009,7 @@ this.getServer().getDataStorage().set(MapItemSavedData.type(id), data); } -@@ -1492,7 +_,20 @@ +@@ -1500,7 +_,20 @@ @Override public void setRespawnData(final LevelData.RespawnData respawnData) { @@ -1040,19 +1031,19 @@ } @Override -@@ -1529,6 +_,11 @@ +@@ -1537,6 +_,11 @@ this.debugSynchronizers.dropPoi(immutable); })); newType.ifPresent(poiType -> this.getServer().execute(() -> { + // Paper start - Remove stale POIs -+ if (oldType.isEmpty() && this.getPoiManager().exists(pos, _ -> true)) { -+ this.getPoiManager().remove(pos); ++ if (oldType.isEmpty() && this.getPoiManager().exists(immutable, _ -> true)) { ++ this.getPoiManager().remove(immutable); + } + // Paper end - Remove stale POIs PoiRecord record = this.getPoiManager().add(immutable, (Holder)poiType); if (record != null) { this.debugSynchronizers.registerPoi(record); -@@ -1677,12 +_,12 @@ +@@ -1685,12 +_,12 @@ } public boolean isFlat() { @@ -1067,7 +1058,7 @@ } public @Nullable EnderDragonFight getDragonFight() { -@@ -1690,7 +_,7 @@ +@@ -1698,7 +_,7 @@ } public WeatherData getWeatherData() { @@ -1076,7 +1067,7 @@ } @Override -@@ -1737,6 +_,7 @@ +@@ -1745,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1084,7 +1075,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1841,8 +_,30 @@ +@@ -1847,8 +_,30 @@ } public GameRules getGameRules() { @@ -1117,7 +1108,7 @@ @Override public CrashReportCategory fillReportDetails(final CrashReport report) { -@@ -1900,6 +_,7 @@ +@@ -1906,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypoint && waypoint.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypoint); } @@ -1125,7 +1116,7 @@ } @Override -@@ -1913,17 +_,24 @@ +@@ -1919,17 +_,24 @@ @Override public void onTickingStart(final Entity entity) { @@ -1151,7 +1142,7 @@ if (entity instanceof ServerPlayer player) { ServerLevel.this.players.add(player); if (player.isReceivingWaypoints()) { -@@ -1938,7 +_,7 @@ +@@ -1944,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1160,7 +1151,7 @@ String message = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1955,10 +_,52 @@ +@@ -1961,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1213,7 +1204,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer player) { ServerLevel.this.players.remove(player); -@@ -1967,7 +_,7 @@ +@@ -1973,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1222,7 +1213,7 @@ String message = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1985,6 +_,15 @@ +@@ -1991,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1238,7 +1229,7 @@ } @Override -@@ -1992,4 +_,24 @@ +@@ -1998,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } 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 36e80c0dc5b1..68042aa2e57d 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -252,7 +_,8 @@ +@@ -256,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +10,7 @@ private @Nullable Vec3 startingToFallPosition; private @Nullable Vec3 enteredNetherPosition; private @Nullable Vec3 enteredLavaOnVehiclePosition; -@@ -297,6 +_,13 @@ +@@ -303,6 +_,13 @@ } } @@ -24,7 +24,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)); -@@ -332,6 +_,32 @@ +@@ -338,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(final AbstractContainerMenu container, final int id, final int value) { } -@@ -358,10 +_,43 @@ +@@ -364,10 +_,43 @@ public void sendSystemMessage(final Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -101,7 +101,7 @@ public ServerPlayer(final MinecraftServer server, final ServerLevel level, final GameProfile gameProfile, final ClientInformation clientInformation) { super(level, gameProfile); -@@ -372,8 +_,14 @@ +@@ -378,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); @@ -117,7 +117,7 @@ } @Override -@@ -391,6 +_,7 @@ +@@ -398,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())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -398,6 +_,19 @@ +@@ -405,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); @@ -145,7 +145,7 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); -@@ -425,12 +_,24 @@ +@@ -433,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput vehicleWrapper = playerOutput.child("RootVehicle"); vehicleWrapper.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(vehicleWrapper.child("Entity")); -@@ -442,7 +_,7 @@ +@@ -450,7 +_,7 @@ if (!rootTag.isEmpty()) { ServerLevel serverLevel = this.level(); Entity vehicle = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (vehicle != null) { UUID attachTo = rootTag.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -459,10 +_,10 @@ +@@ -467,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -474,6 +_,7 @@ +@@ -482,6 +_,7 @@ ValueOutput.ValueOutputList pearlsOutput = playerOutput.childrenList("ender_pearls"); for (ThrownEnderpearl enderPearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (enderPearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -508,6 +_,16 @@ +@@ -516,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(final int amount) { float limit = this.getXpNeededForNextLevel(); float max = (limit - 1.0F) / limit; -@@ -572,6 +_,11 @@ +@@ -580,6 +_,11 @@ @Override public void tick() { @@ -230,7 +230,7 @@ this.connection.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -579,9 +_,18 @@ +@@ -587,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -640,10 +_,10 @@ +@@ -648,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -673,7 +_,7 @@ +@@ -681,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +274,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -704,6 +_,12 @@ +@@ -712,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil(this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil(this.lastRecordedLevel)); -@@ -717,6 +_,20 @@ +@@ -725,6 +_,20 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -308,7 +308,7 @@ } catch (Throwable t) { CrashReport report = CrashReport.forThrowable(t, "Ticking player"); CrashReportCategory category = report.addCategory("Player being ticked"); -@@ -741,7 +_,7 @@ +@@ -749,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()) { @@ -317,7 +317,7 @@ } float saturation = this.foodData.getSaturationLevel(); -@@ -761,6 +_,7 @@ +@@ -769,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -325,7 +325,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -805,29 +_,58 @@ +@@ -813,32 +_,61 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -368,11 +368,14 @@ + @Nullable + private Entity respawnEntityOnShoulder0(final CompoundTag tag) { // CraftBukkit void->boolean + // Paper end - release entity api - return entity - overload - if (this.level() instanceof ServerLevel serverLevel && !tag.isEmpty()) { + ServerLevel serverLevel = this.level(); + if (!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 + TagValueInput.create(reporter.forChild(() -> ".shoulder"), serverLevel.registryAccess(), tag), + serverLevel, + new EntitySpawnRequest(EntitySpawnReason.LOAD, false) ) - .ifPresent(entity -> { + .map(entity -> { // Paper - release entity api @@ -391,7 +394,7 @@ } @Override -@@ -864,15 +_,36 @@ +@@ -878,15 +_,36 @@ } private void updateScoreForCriteria(final ObjectiveCriteria criteria, final int value) { @@ -437,7 +440,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -889,6 +_,64 @@ +@@ -903,6 +_,65 @@ } ) ); @@ -465,10 +468,11 @@ + } + if (!this.isSpectator() && this.shouldDropLoot(this.level())) { // Paper - fix player loottables running when mob loot gamerule is false + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) ++ this.deathDropItems = new java.util.ArrayList<>(); + this.dropFromLootTable(this.level(), source, this.lastHurtByPlayerMemoryTime > 0); + // Paper - Restore vanilla drops behaviour; custom death loot is a noop on server player, remove. -+ loot.addAll(this.drops); -+ this.drops.clear(); // SPIGOT-5188: make sure to clear ++ loot.addAll(this.deathDropItems); ++ this.deathDropItems = null; + } // Paper - fix player loottables running when mob loot gamerule is false + + Component defaultMessage = this.getCombatTracker().getDeathMessage(); @@ -498,20 +502,20 @@ + Component deathMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(apiDeathMessage); // Paper - Adventure + + // Paper - moved up to sendClientboundPlayerCombatKillPacket() -+ sendClientboundPlayerCombatKillPacket(event.getShowDeathMessages(), deathScreenMessage); // Paper - Expand PlayerDeathEvent ++ this.sendClientboundPlayerCombatKillPacket(event.getShowDeathMessages(), deathScreenMessage); // Paper - Expand PlayerDeathEvent Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -898,7 +_,7 @@ +@@ -912,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { - this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), CommonComponents.EMPTY)); -+ sendClientboundPlayerCombatKillPacket(event.getShowDeathMessages(), deathScreenMessage); // Paper - Expand PlayerDeathEvent ++ this.sendClientboundPlayerCombatKillPacket(event.getShowDeathMessages(), deathScreenMessage); // Paper - Expand PlayerDeathEvent } this.removeEntitiesOnShoulder(); -@@ -906,11 +_,35 @@ +@@ -920,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -550,7 +554,7 @@ LivingEntity killer = this.getKillCredit(); if (killer != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killer.getType())); -@@ -944,10 +_,10 @@ +@@ -958,10 +_,10 @@ if (victim != this) { super.awardKillScore(victim, killingBlow); Scoreboard scoreboard = this.level().getScoreboard(); @@ -563,21 +567,21 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -960,11 +_,11 @@ +@@ -974,11 +_,11 @@ - private void handleTeamKill(final ScoreHolder source, final ScoreHolder target, final ObjectiveCriteria[] criteriaByTeam) { + private void handleTeamKill(final ScoreHolder source, final ScoreHolder target, final Map criteriaByTeam) { Scoreboard scoreboard = this.level().getScoreboard(); - PlayerTeam ownTeam = scoreboard.getPlayersTeam(target.getScoreboardName()); + PlayerTeam ownTeam = this.getBukkitEntity().getScoreboard().getHandle().getPlayersTeam(target.getScoreboardName()); // CraftBukkit - if (ownTeam != null) { - int color = ownTeam.getColor().getId(); - if (color >= 0 && color < criteriaByTeam.length) { -- scoreboard.forAllObjectives(criteriaByTeam[color], source, ScoreAccess::increment); -+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteriaByTeam[color], source, ScoreAccess::increment); // CraftBukkit - Get our scores instead + if (ownTeam != null && ownTeam.getColor().isPresent()) { + ObjectiveCriteria criteria = criteriaByTeam.get(ownTeam.getColor().get()); + if (criteria != null) { +- scoreboard.forAllObjectives(criteria, source, ScoreAccess::increment); ++ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, source, ScoreAccess::increment); // CraftBukkit - Get our scores instead } } } -@@ -976,9 +_,20 @@ +@@ -990,9 +_,20 @@ } Entity entity = source.getEntity(); @@ -601,7 +605,7 @@ } @Override -@@ -990,24 +_,98 @@ +@@ -1004,24 +_,98 @@ return this.level().isPvpAllowed(); } @@ -707,12 +711,12 @@ } public boolean isReceivingWaypoints() { -@@ -1041,16 +_,18 @@ +@@ -1055,16 +_,18 @@ if (block instanceof RespawnAnchorBlock && (forced || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level, pos) ) { + Runnable consumeAnchorCharge = null; // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) - Optional standUpPosition = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, pos); + Optional standUpPosition = RespawnAnchorBlock.findStandUpPosition(EntityTypes.PLAYER, level, pos); if (!forced && consumeSpawnBlock && standUpPosition.isPresent()) { - level.setBlock(pos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), Block.UPDATE_ALL); + consumeAnchorCharge = () -> level.setBlock(pos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), Block.UPDATE_ALL); // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) @@ -723,13 +727,13 @@ + 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) + return BedBlock.findStandUpPosition(EntityTypes.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 @@ +@@ -1075,7 +_,7 @@ BlockState topState = level.getBlockState(pos.above()); boolean freeTop = topState.getBlock().isPossibleToRespawnInThis(topState); return freeBottom && freeTop @@ -738,7 +742,7 @@ : Optional.empty(); } } -@@ -1077,7 +_,8 @@ +@@ -1091,7 +_,8 @@ } @Override @@ -748,7 +752,7 @@ if (this.isRemoved()) { return null; } -@@ -1089,12 +_,46 @@ +@@ -1103,12 +_,46 @@ ServerLevel newLevel = transition.newLevel(); ServerLevel oldLevel = this.level(); ResourceKey lastDimension = oldLevel.dimension(); @@ -796,7 +800,7 @@ this.connection.resetPosition(); transition.postTeleportTransition().onTransition(this); return this; -@@ -1106,18 +_,19 @@ +@@ -1120,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -818,7 +822,7 @@ this.connection.resetPosition(); newLevel.addDuringTeleport(this); profiler.pop(); -@@ -1132,6 +_,15 @@ +@@ -1146,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(transition, oldLevel); @@ -834,7 +838,7 @@ return this; } -@@ -1144,12 +_,26 @@ +@@ -1158,12 +_,26 @@ public void triggerDimensionChangeTriggers(final ServerLevel oldLevel) { ResourceKey oldKey = oldLevel.dimension(); ResourceKey newKey = this.level().dimension(); @@ -864,7 +868,7 @@ this.enteredNetherPosition = null; } } -@@ -1165,9 +_,10 @@ +@@ -1179,9 +_,10 @@ this.containerMenu.broadcastChanges(); } @@ -878,7 +882,7 @@ if (!this.isSleeping() && this.isAlive()) { BedRule rule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); boolean canSleep = rule.canSleep(this.level()); -@@ -1186,7 +_,7 @@ +@@ -1200,7 +_,7 @@ if (canSetSpawn) { this.setRespawnPosition( @@ -887,7 +891,7 @@ ); } -@@ -1209,7 +_,33 @@ +@@ -1223,7 +_,33 @@ } } @@ -922,7 +926,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1219,8 +_,6 @@ +@@ -1233,8 +_,6 @@ this.level().updateSleepingPlayerList(); return result; @@ -931,7 +935,7 @@ } } -@@ -1248,19 +_,30 @@ +@@ -1262,19 +_,30 @@ @Override public void stopSleepInBed(final boolean forcefulWakeUp, final boolean updateLevelList) { @@ -964,7 +968,7 @@ } @Override -@@ -1308,8 +_,9 @@ +@@ -1323,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -975,7 +979,7 @@ } @Override -@@ -1318,12 +_,39 @@ +@@ -1333,12 +_,39 @@ return OptionalInt.empty(); } @@ -1016,7 +1020,7 @@ if (menu == null) { if (this.isSpectator()) { this.sendOverlayMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED)); -@@ -1331,9 +_,14 @@ +@@ -1346,9 +_,14 @@ return OptionalInt.empty(); } else { @@ -1033,7 +1037,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1352,27 +_,49 @@ +@@ -1367,27 +_,49 @@ @Override public void openHorseInventory(final AbstractHorse horse, final Container container) { @@ -1088,7 +1092,7 @@ this.initMenu(this.containerMenu); } -@@ -1394,10 +_,30 @@ +@@ -1409,10 +_,30 @@ @Override public void closeContainer() { @@ -1119,7 +1123,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1420,19 +_,19 @@ +@@ -1435,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); @@ -1142,7 +1146,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1443,13 +_,13 @@ +@@ -1458,13 +_,13 @@ if (horizontalDistance > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, horizontalDistance); @@ -1159,7 +1163,7 @@ } } } else if (this.isFallFlying()) { -@@ -1493,13 +_,13 @@ +@@ -1508,13 +_,13 @@ @Override public void awardStat(final Stat stat, final int count) { this.stats.increment(this, stat, count); @@ -1175,7 +1179,7 @@ } @Override -@@ -1530,9 +_,9 @@ +@@ -1545,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1187,7 +1191,7 @@ } } -@@ -1547,6 +_,13 @@ +@@ -1562,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1201,7 +1205,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1558,6 +_,7 @@ +@@ -1573,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1209,7 +1213,7 @@ } @Override -@@ -1587,18 +_,18 @@ +@@ -1602,18 +_,18 @@ this.onUpdateAbilities(); this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); if (restoreAll) { @@ -1231,7 +1235,7 @@ if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || oldPlayer.isSpectator()) { this.transferInventoryXpAndScore(oldPlayer); } -@@ -1610,7 +_,7 @@ +@@ -1625,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1239,8 +1243,8 @@ + // this.recipeBook.copyOverData(oldPlayer.recipeBook); // CraftBukkit this.seenCredits = oldPlayer.seenCredits; this.enteredNetherPosition = oldPlayer.enteredNetherPosition; - this.chunkTrackingView = oldPlayer.chunkTrackingView; -@@ -1662,9 +_,22 @@ + this.currentExplosionImpactPos = oldPlayer.currentExplosionImpactPos; +@@ -1679,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1264,7 +1268,7 @@ } @Override -@@ -1682,6 +_,7 @@ +@@ -1699,6 +_,7 @@ final float newYRot, final float newXRot, final boolean resetCamera @@ -1272,7 +1276,7 @@ ) { if (this.isSleeping()) { this.stopSleepInBed(true, true); -@@ -1691,7 +_,7 @@ +@@ -1708,7 +_,7 @@ this.setCamera(this); } @@ -1281,7 +1285,7 @@ if (success) { this.setYHeadRot(relatives.contains(Relative.Y_ROT) ? this.getYHeadRot() + newYRot : newYRot); this.connection.resetFlyingTicks(); -@@ -1730,11 +_,16 @@ +@@ -1747,11 +_,16 @@ } public boolean setGameMode(final GameType mode) { @@ -1302,7 +1306,7 @@ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, mode.getId())); if (mode == GameType.SPECTATOR) { this.removeEntitiesOnShoulder(); -@@ -1750,7 +_,7 @@ +@@ -1767,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1311,7 +1315,7 @@ } @Override -@@ -1818,8 +_,13 @@ +@@ -1835,8 +_,13 @@ } public void sendChatMessage(final OutgoingChatMessage message, final boolean filtered, final ChatType.Bound chatType) { @@ -1326,7 +1330,7 @@ } } -@@ -1830,7 +_,42 @@ +@@ -1847,7 +_,42 @@ } public void updateOptions(final ClientInformation information) { @@ -1369,7 +1373,7 @@ this.requestedViewDistance = information.viewDistance(); this.chatVisibility = information.chatVisibility(); this.canChatColor = information.chatColors(); -@@ -1915,8 +_,23 @@ +@@ -1932,8 +_,23 @@ Entity oldCamera = this.getCamera(); this.camera = newCamera == null ? this : newCamera; if (oldCamera != this.camera) { @@ -1394,7 +1398,7 @@ } if (newCamera != null) { -@@ -1940,11 +_,11 @@ +@@ -1957,11 +_,11 @@ } public @Nullable Component getTabListDisplayName() { @@ -1408,7 +1412,7 @@ } @Override -@@ -1974,11 +_,60 @@ +@@ -1991,11 +_,60 @@ } public void setRespawnPosition(final ServerPlayer.@Nullable RespawnConfig respawnConfig, final boolean showMessage) { @@ -1471,7 +1475,7 @@ } public SectionPos getLastSectionPos() { -@@ -1998,16 +_,23 @@ +@@ -2015,16 +_,23 @@ } @Override @@ -1500,7 +1504,7 @@ return entity; } -@@ -2059,7 +_,7 @@ +@@ -2076,7 +_,7 @@ super.updateUsingItem(useItem); } @@ -1509,7 +1513,7 @@ Inventory inventory = this.getInventory(); ItemStack removed = inventory.removeFromSelected(all); this.containerMenu -@@ -2069,7 +_,7 @@ +@@ -2086,7 +_,7 @@ this.stopUsingItem(); } @@ -1518,7 +1522,7 @@ } @Override -@@ -2132,9 +_,9 @@ +@@ -2149,9 +_,9 @@ } @Override @@ -1530,7 +1534,7 @@ if (oldVehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance effect : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(oldVehicle.getId(), effect.getEffect())); -@@ -2256,7 +_,7 @@ +@@ -2273,7 +_,7 @@ } public static long placeEnderPearlTicket(final ServerLevel level, final ChunkPos chunk) { @@ -1539,7 +1543,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2286,9 +_,11 @@ +@@ -2303,9 +_,11 @@ } } @@ -1554,7 +1558,7 @@ } private static float calculateLookAtYaw(final Vec3 position, final BlockPos lookAtBlockPos) { -@@ -2308,4 +_,135 @@ +@@ -2325,4 +_,135 @@ ); 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/TicketType.java.patch b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch index 418c8ded591f..8608e8cff876 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch @@ -29,7 +29,7 @@ + public static final TicketType FUTURE_AWAIT = register("future_await", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper + public static final TicketType CHUNK_LOAD = register("chunk_load", NO_TIMEOUT, FLAG_LOADING); // Paper - moonrise - private static TicketType register(final String name, final long timeout, @TicketType.Flags final int flags) { + private static TicketType register(final String name, final long timeout, final @TicketType.Flags int flags) { return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, flags)); @@ -48,12 +_,21 @@ return (this.flags & FLAG_CAN_EXPIRE_IF_UNLOADED) != 0; @@ -49,7 +49,7 @@ } @Retention(RetentionPolicy.CLASS) - @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE_USE}) + @Target(ElementType.TYPE_USE) + @org.intellij.lang.annotations.MagicConstant(flags = {FLAG_PERSIST, FLAG_LOADING, FLAG_SIMULATION, FLAG_KEEP_DIMENSION_ACTIVE, FLAG_CAN_EXPIRE_IF_UNLOADED}) // Paper - add back source-retention annotation for IDE public @interface Flags { } diff --git a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch index 2afc9c8017cd..2341cae68f21 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -146,6 +_,28 @@ +@@ -153,6 +_,28 @@ return distance < this.generatingStep.directDependencies().size(); } @@ -28,25 +28,23 @@ + @Override public BlockState getBlockState(final BlockPos pos) { - return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -@@ -221,6 +_,7 @@ - return null; + int chunkX = SectionPos.blockToSectionCoord(pos.getX()); +@@ -268,11 +_,14 @@ + return Math.abs(this.centerChunkX - chunkX) <= this.writeRadius && Math.abs(this.centerChunkZ - chunkZ) <= this.writeRadius; } + private boolean hasSetFarWarned = false; // Paper - Buffer OOB setBlock calls @Override public boolean ensureCanWrite(final BlockPos pos) { - int chunkX = SectionPos.blockToSectionCoord(pos.getX()); -@@ -238,6 +_,8 @@ - - return true; - } else { + if (!this.isWithinWriteZone(pos)) { + int chunkX = SectionPos.blockToSectionCoord(pos.getX()); + int chunkZ = SectionPos.blockToSectionCoord(pos.getZ()); + // Paper start - Buffer OOB setBlock calls + if (!hasSetFarWarned) { Util.logAndPauseIfInIde( "Detected setBlock in a far chunk [" + chunkX -@@ -249,6 +_,12 @@ +@@ -284,6 +_,12 @@ + this.generatingStep.targetStatus() + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get()) ); @@ -57,9 +55,18 @@ + } + // Paper end - Buffer OOB setBlock calls return false; + } else if (this.center.isUpgrading()) { + LevelHeightAccessor levelHeightAccessor = this.center.getHeightAccessorForGeneration(); +@@ -301,7 +_,7 @@ + + ChunkAccess chunk = this.getChunk(pos); + BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); +- if (oldState != null) { ++ if (oldState != null && (updateFlags & Block.UPDATE_SKIP_POI) == 0) { // Paper - temporary flag + this.level.updatePOIOnBlockStateChange(pos, oldState, blockState); } - } -@@ -274,6 +_,17 @@ + +@@ -314,6 +_,17 @@ chunk.removeBlockEntity(pos); } } else { @@ -77,7 +84,7 @@ CompoundTag tag = new CompoundTag(); tag.putInt("x", pos.getX()); tag.putInt("y", pos.getY()); -@@ -301,6 +_,13 @@ +@@ -341,6 +_,13 @@ @Override public boolean addFreshEntity(final Entity entity) { 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 19e75f568090..2396d8f904ad 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 @@ -138,7 +138,7 @@ + final io.papermc.paper.event.player.PaperPlayerCustomClickEvent event = new io.papermc.paper.event.player.PaperPlayerCustomClickEvent(io.papermc.paper.adventure.PaperAdventure.asAdventure(packet.id()), this.getApiConnection(), packet.payload().orElse(null)); + event.callEvent(); + io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.tryRunCallback(this.getAudience(), packet.id(), packet.payload()); -+ io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.tryRunCallback(this.getAudience(), packet.id(), packet.payload()); ++ io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.tryRunCallback(this.getAudience(), packet.id(), packet.payload()); + // Paper end - Implement click callbacks with custom click action } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch index 77ce3cb40925..c1eedcb6a179 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -49,9 +_,31 @@ +@@ -53,9 +_,31 @@ this.running = true; } @@ -33,7 +33,7 @@ this.channels .add( new ServerBootstrap() -@@ -75,22 +_,64 @@ +@@ -79,22 +_,64 @@ Connection connection = rateLimitPacketsPerSecond > 0 ? new RateKickingConnection(rateLimitPacketsPerSecond) : new Connection(PacketFlow.SERVERBOUND); @@ -100,7 +100,7 @@ public SocketAddress startMemoryChannel() { ChannelFuture newChannel; synchronized (this.channels) { -@@ -142,12 +_,26 @@ +@@ -187,12 +_,26 @@ public void tick() { synchronized (this.connections) { @@ -127,7 +127,7 @@ try { connection.tick(); } catch (Exception e) { -@@ -161,6 +_,7 @@ +@@ -206,6 +_,7 @@ connection.setReadOnly(); } } else { diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 8a9fec619627..9ca09ea04b97 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -39,17 +39,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, -@@ -242,7 +_,9 @@ - private int tickCount; - private int ackBlockChangesUpTo = -1; - private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); -+ private final TickThrottler tabSpamThrottler = new TickThrottler(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement, io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit); // Paper - configurable tab spam limits +@@ -244,6 +_,8 @@ private final TickThrottler dropSpamThrottler = new TickThrottler(20, 1480); + private final TickThrottler chatSpamThrottler; + private final TickThrottler commandSpamThrottler; ++ private final TickThrottler tabSpamThrottler = new TickThrottler(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement, io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit); // Paper - configurable tab spam limits + private final TickThrottler recipeSpamPackets = new TickThrottler(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement, io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit); private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -266,7 +_,23 @@ +@@ -267,7 +_,23 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -57,7 +56,7 @@ + private int lastTick = MinecraftServer.currentTick; + private int allowedPlayerTicks = 1; + private int lastDropTick = MinecraftServer.currentTick; -+ private int lastBookTick = MinecraftServer.currentTick; ++ private int lastBookTick = MinecraftServer.currentTick; + private int dropCount = 0; + + private boolean hasMoved = false; @@ -73,7 +72,7 @@ private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); private int nextChatIndex; -@@ -275,6 +_,9 @@ +@@ -276,6 +_,9 @@ private boolean waitingForSwitchToConfig; private boolean waitingForRespawn; private int clientLoadedTimeoutTimer; @@ -83,7 +82,7 @@ public ServerGamePacketListenerImpl(final MinecraftServer server, final Connection connection, final ServerPlayer player, final CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -284,8 +_,22 @@ +@@ -287,8 +_,22 @@ player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); @@ -91,7 +90,7 @@ - } + 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 ++ this.playerGameConnection = new io.papermc.paper.connection.PaperPlayerGameConnection(this); // Paper + } + + // Paper start - configuration phase API @@ -108,9 +107,9 @@ @Override public void tick() { -@@ -298,11 +_,13 @@ - this.keepConnectionAlive(); +@@ -302,11 +_,13 @@ this.chatSpamThrottler.tick(); + this.commandSpamThrottler.tick(); this.dropSpamThrottler.tick(); + this.tabSpamThrottler.tick(); // Paper - configurable tab spam limits + this.recipeSpamPackets.tick(); // Paper - auto recipe limit @@ -123,7 +122,7 @@ } } } -@@ -318,8 +_,8 @@ +@@ -322,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)) { @@ -134,7 +133,7 @@ return true; } } else { -@@ -337,8 +_,8 @@ +@@ -341,8 +_,8 @@ this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -145,7 +144,7 @@ return true; } } else { -@@ -351,6 +_,12 @@ +@@ -355,6 +_,12 @@ this.aboveGroundVehicleTickCount = 0; } @@ -158,7 +157,7 @@ return false; } -@@ -416,11 +_,37 @@ +@@ -420,11 +_,37 @@ @Override public void handlePlayerInput(final ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -198,7 +197,7 @@ } private static boolean containsInvalidValues(final double x, final double y, final double z, final float yRot, final float xRot) { -@@ -439,11 +_,23 @@ +@@ -443,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())) { @@ -223,7 +222,7 @@ double oldX = vehicle.getX(); double oldY = vehicle.getY(); double oldZ = vehicle.getZ(); -@@ -457,7 +_,52 @@ +@@ -461,7 +_,52 @@ double zDist = targetZ - this.vehicleFirstGoodZ; double expectedDist = vehicle.getDeltaMovement().lengthSqr(); double movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -277,7 +276,7 @@ LOGGER.warn( "{} (vehicle of {}) moved too quickly! {},{},{}", vehicle.getPlainTextName(), this.player.getPlainTextName(), xDist, yDist, zDist ); -@@ -466,9 +_,9 @@ +@@ -470,9 +_,9 @@ } AABB oldAABB = vehicle.getBoundingBox(); @@ -290,7 +289,7 @@ boolean vehicleRestsOnSomething = vehicle.verticalCollisionBelow; if (vehicle instanceof LivingEntity livingVehicle && livingVehicle.onClimbable()) { livingVehicle.resetFallDistance(); -@@ -485,7 +_,7 @@ +@@ -489,7 +_,7 @@ zDist = targetZ - vehicle.getZ(); movedDist = xDist * xDist + yDist * yDist + zDist * zDist; boolean fail = false; @@ -299,7 +298,7 @@ fail = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", vehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(movedDist)); } -@@ -498,6 +_,57 @@ +@@ -502,6 +_,57 @@ } vehicle.absSnapTo(targetX, targetY, targetZ, targetYRot, targetXRot); @@ -357,7 +356,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 @@ +@@ -532,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -366,7 +365,7 @@ return; } -@@ -545,13 +_,14 @@ +@@ -549,13 +_,14 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -382,7 +381,7 @@ } @Override -@@ -572,6 +_,7 @@ +@@ -576,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(final ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -390,7 +389,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -587,25 +_,112 @@ +@@ -591,25 +_,112 @@ } } @@ -507,7 +506,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = null; -@@ -666,7 +_,7 @@ +@@ -670,7 +_,7 @@ @Override public void handleSetCommandMinecart(final ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -516,7 +515,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -702,11 +_,11 @@ +@@ -706,11 +_,11 @@ boolean includeData = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack itemStack = blockState.getCloneItemStack(level, pos, includeData); if (!itemStack.isEmpty()) { @@ -530,7 +529,7 @@ } } } -@@ -733,7 +_,7 @@ +@@ -737,7 +_,7 @@ if (entity != null && this.player.isWithinEntityInteractionRange(entity, 3.0)) { ItemStack itemStack = entity.getPickResult(); if (itemStack != null && !itemStack.isEmpty()) { @@ -539,7 +538,7 @@ } if (packet.includeData() && this.player.canUseGameMasterBlocks() && entity instanceof Avatar avatar) { -@@ -742,22 +_,35 @@ +@@ -746,22 +_,35 @@ } } @@ -580,7 +579,7 @@ } } -@@ -790,7 +_,7 @@ +@@ -797,7 +_,7 @@ @Override public void handleSetGameRule(final ServerboundSetGameRulePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -589,7 +588,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 @@ +@@ -815,7 +_,7 @@ private void setGameRuleValue(final GameRules gameRules, final GameRule rule, final String value) { rule.deserialize(value).result().ifPresent(parsedValue -> { @@ -598,7 +597,7 @@ this.broadcastGameRuleChangeToOperators(rule, (T)parsedValue); }); } -@@ -967,6 +_,13 @@ +@@ -974,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int selection = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu menu) { @@ -612,7 +611,7 @@ if (!menu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, menu); return; -@@ -979,6 +_,51 @@ +@@ -986,6 +_,51 @@ @Override public void handleEditBook(final ServerboundEditBookPacket packet) { @@ -664,7 +663,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List contents = Lists.newArrayList(); -@@ -993,10 +_,14 @@ +@@ -1000,10 +_,14 @@ } private void updateBookContents(final List contents, final int slot) { @@ -680,7 +679,7 @@ } } -@@ -1009,7 +_,8 @@ +@@ -1016,7 +_,8 @@ writtenBook.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, pages, true) ); @@ -690,7 +689,7 @@ } } -@@ -1057,10 +_,10 @@ +@@ -1064,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))) { @@ -703,7 +702,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -1077,7 +_,15 @@ +@@ -1084,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); @@ -719,7 +718,7 @@ double startX = this.player.getX(); double startY = this.player.getY(); double startZ = this.player.getZ(); -@@ -1086,6 +_,16 @@ +@@ -1093,6 +_,16 @@ double zDist = targetZ - this.firstGoodZ; double expectedDist = this.player.getDeltaMovement().lengthSqr(); double movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -736,7 +735,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 @@ +@@ -1102,7 +_,13 @@ if (level.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int deltaPackets = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -751,7 +750,7 @@ LOGGER.debug( "{} is sending move packets too frequently ({} packets since last tick)", this.player.getPlainTextName(), -@@ -1103,30 +_,96 @@ +@@ -1110,30 +_,96 @@ ); deltaPackets = 1; } @@ -857,7 +856,7 @@ double oyDist = yDist; xDist = targetX - this.player.getX(); yDist = targetY - this.player.getY(); -@@ -1136,21 +_,101 @@ +@@ -1143,21 +_,101 @@ zDist = targetZ - this.player.getZ(); movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -968,7 +967,7 @@ this.player.absSnapTo(targetX, targetY, targetZ, targetYRot, targetXRot); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = oyDist >= -0.03125 -@@ -1185,7 +_,7 @@ +@@ -1192,7 +_,7 @@ this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -977,7 +976,7 @@ this.player .doCheckFallDamage( this.player.getX() - startX, this.player.getY() - startY, this.player.getZ() - startZ, packet.isOnGround() -@@ -1225,6 +_,7 @@ +@@ -1232,6 +_,7 @@ this.player.getXRot() ); } @@ -985,7 +984,7 @@ return true; } else { -@@ -1250,10 +_,77 @@ +@@ -1257,10 +_,77 @@ } public void teleport(final double x, final double y, final double z, final float yRot, final float xRot) { @@ -1064,7 +1063,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1261,12 +_,20 @@ +@@ -1268,12 +_,20 @@ this.player.teleportSetPosition(destination, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1085,7 +1084,7 @@ if (this.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1291,32 +_,95 @@ +@@ -1298,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack swap = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -1183,7 +1182,7 @@ return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1334,9 +_,36 @@ +@@ -1341,9 +_,36 @@ && !player.getCooldowns().isOnCooldown(itemStack); } @@ -1220,7 +1219,7 @@ if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel level = this.player.level(); -@@ -1345,6 +_,11 @@ +@@ -1352,6 +_,11 @@ if (itemStack.isItemEnabled(level.enabledFeatures())) { BlockHitResult blockHit = packet.getHitResult(); Vec3 location = blockHit.getLocation(); @@ -1232,7 +1231,7 @@ BlockPos pos = blockHit.getBlockPos(); if (this.player.isWithinBlockInteractionRange(pos, 1.0)) { Vec3 distance = location.subtract(Vec3.atCenterOf(pos)); -@@ -1359,9 +_,13 @@ +@@ -1366,9 +_,13 @@ } else if (pos.getY() < minY) { this.player.sendBuildLimitMessage(false, minY); } else { @@ -1248,7 +1247,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); -@@ -1373,7 +_,7 @@ +@@ -1380,7 +_,7 @@ && wasBlockPlacementAttempt(this.player, itemStack)) { this.player.sendBuildLimitMessage(true, maxY); } else if (interactionResult instanceof InteractionResult.Success success @@ -1257,7 +1256,7 @@ this.player.swing(hand, true); } -@@ -1387,6 +_,15 @@ +@@ -1394,6 +_,15 @@ && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); } @@ -1273,7 +1272,7 @@ } else { this.player.sendBuildLimitMessage(true, maxY); } -@@ -1394,13 +_,8 @@ +@@ -1401,13 +_,8 @@ this.send(new ClientboundBlockUpdatePacket(level, pos)); this.send(new ClientboundBlockUpdatePacket(level, pos.relative(direction))); } @@ -1289,7 +1288,7 @@ } } } -@@ -1410,6 +_,8 @@ +@@ -1417,6 +_,8 @@ @Override public void handleUseItem(final ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1298,7 +1297,7 @@ if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel level = this.player.level(); -@@ -1423,6 +_,44 @@ +@@ -1430,6 +_,44 @@ this.player.absSnapRotationTo(targetYRot, targetXRot); } @@ -1343,7 +1342,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); -@@ -1438,7 +_,7 @@ +@@ -1445,7 +_,7 @@ for (ServerLevel level : this.server.getAllLevels()) { Entity entity = packet.getEntity(level); if (entity != null) { @@ -1352,7 +1351,7 @@ return; } } -@@ -1456,23 +_,42 @@ +@@ -1463,23 +_,42 @@ @Override public void onDisconnect(final DisconnectionDetails details) { LOGGER.info("{} lost connection: {}", this.player.getPlainTextName(), details.reason().getString()); @@ -1397,7 +1396,7 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } -@@ -1482,20 +_,38 @@ +@@ -1489,20 +_,38 @@ @Override public void handleSetCarriedItem(final ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1436,7 +1435,7 @@ Optional unpackedLastSeen = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!unpackedLastSeen.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1507,25 +_,45 @@ +@@ -1514,25 +_,45 @@ return; } @@ -1465,9 +1464,9 @@ + } + // CraftBukkit end this.performUnsignedChatCommand(packet.command()); -- this.detectRateSpam(); +- this.detectCommandRateSpam(); - }); -+ this.detectRateSpam("/" + packet.command()); // Spigot ++ this.detectCommandRateSpam(packet.command()); // Spigot - spam exclusions + }, true); // CraftBukkit - sync commands } @@ -1490,7 +1489,7 @@ ParseResults parsed = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parsed)) { LOGGER.error( -@@ -1542,26 +_,55 @@ +@@ -1549,26 +_,55 @@ Optional unpackedLastSeen = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!unpackedLastSeen.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1500,9 +1499,9 @@ + } + // CraftBukkit end this.performSignedChatCommand(packet, unpackedLastSeen.get()); -- this.detectRateSpam(); +- this.detectCommandRateSpam(); - }); -+ this.detectRateSpam("/" + packet.command()); // Spigot ++ this.detectCommandRateSpam(packet.command()); // Spigot - spam exclusions + }, true); // CraftBukkit - sync commands } } @@ -1549,7 +1548,7 @@ } private void handleMessageDecodeFailure(final SignedMessageChain.DecodeException e) { -@@ -1625,14 +_,20 @@ +@@ -1632,14 +_,20 @@ return commands.parse(command, this.player.createCommandSourceStack()); } @@ -1574,7 +1573,7 @@ } } -@@ -1644,7 +_,7 @@ +@@ -1651,7 +_,7 @@ var10000 = Optional.of(result); } catch (LastSeenMessagesValidator.ValidationException e) { LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), e.getMessage()); @@ -1583,7 +1582,7 @@ return Optional.empty(); } -@@ -1662,22 +_,81 @@ +@@ -1669,31 +_,91 @@ return false; } @@ -1629,7 +1628,7 @@ private void broadcastChatMessage(final PlayerChatMessage message) { - this.server.getPlayerList().broadcastChatMessage(message, this.player, ChatType.bind(ChatType.CHAT, this.player)); -- this.detectRateSpam(); +- this.detectChatRateSpam(); + // CraftBukkit start + String rawMessage = message.signedContent(); + if (rawMessage.isEmpty()) { @@ -1644,15 +1643,14 @@ + } + // this.server.getPlayerList().broadcastChatMessage(message, this.player, ChatType.bind(ChatType.CHAT, this.player)); + // CraftBukkit end -+ this.detectRateSpam(rawMessage); // Spigot ++ this.detectChatRateSpam(rawMessage); // Spigot - spam exclusions } -- private void detectRateSpam() { -- this.chatSpamThrottler.increment(); -- if (!this.chatSpamThrottler.isUnderThreshold() +- private void detectRateSpam(final TickThrottler throttler) { +- throttler.increment(); +- if (!throttler.isUnderThreshold() + // Spigot start - spam exclusions -+ private void detectRateSpam(String message) { -+ // CraftBukkit start - replaced with thread safe throttle ++ private void detectRateSpam(final TickThrottler throttler, final String message) { + if (org.spigotmc.SpigotConfig.enableSpamExclusions) { + for (String exclude : org.spigotmc.SpigotConfig.spamExclusions) { + if (exclude != null && message.startsWith(exclude)) { @@ -1660,10 +1658,12 @@ + } + } + } -+ // Spigot end -+ // this.chatSpamThrottler.increment(); -+ if (!this.chatSpamThrottler.isIncrementAndUnderThreshold() -+ // CraftBukkit end ++ // Spigot end - spam exclusions ++ ++ // CraftBukkit start - replaced with thread safe throttle ++ // throttler.increment(); ++ if (!throttler.isIncrementAndUnderThreshold() ++ // CraftBukkit end - replaced with thread safe throttle && !this.server.getPlayerList().isOp(this.player.nameAndId()) && !this.server.isSingleplayerOwner(this.player.nameAndId())) { - this.disconnect(Component.translatable("disconnect.spam")); @@ -1671,7 +1671,20 @@ } } -@@ -1688,7 +_,7 @@ +- private void detectCommandRateSpam() { +- this.detectRateSpam(this.commandSpamThrottler); ++ private void detectCommandRateSpam(final String command) { // Spigot - spam exclusions ++ this.detectRateSpam(this.commandSpamThrottler, "/" + command); // Spigot - spam exclusions + } + +- private void detectChatRateSpam() { +- this.detectRateSpam(this.chatSpamThrottler); ++ private void detectChatRateSpam(final String message) { // Spigot - spam exclusions ++ this.detectRateSpam(this.chatSpamThrottler, message); // Spigot - spam exclusions + } + + @Override +@@ -1703,7 +_,7 @@ this.lastSeenMessages.applyOffset(packet.offset()); } catch (LastSeenMessagesValidator.ValidationException e) { LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), e.getMessage()); @@ -1680,7 +1693,7 @@ } } } -@@ -1696,7 +_,34 @@ +@@ -1711,7 +_,34 @@ @Override public void handleAnimate(final ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1715,7 +1728,7 @@ this.player.swing(packet.getHand()); } -@@ -1704,6 +_,21 @@ +@@ -1719,6 +_,21 @@ public void handlePlayerCommand(final ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (this.hasClientLoaded()) { @@ -1737,7 +1750,7 @@ this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1748,6 +_,14 @@ +@@ -1763,6 +_,14 @@ } public void sendPlayerChatMessage(final PlayerChatMessage message, final ChatType.Bound chatType) { @@ -1752,7 +1765,7 @@ this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1770,9 +_,11 @@ +@@ -1785,9 +_,11 @@ } if (trackedCount > 4096) { @@ -1765,7 +1778,7 @@ } public void sendDisguisedChatMessage(final Component content, final ChatType.Bound chatType) { -@@ -1783,6 +_,17 @@ +@@ -1798,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1783,7 +1796,7 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1798,20 +_,27 @@ +@@ -1813,20 +_,27 @@ @Override public void handleAttack(final ServerboundAttackPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1813,7 +1826,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)) { -@@ -1821,25 +_,88 @@ +@@ -1836,25 +_,88 @@ } } } @@ -1862,7 +1875,7 @@ + final boolean resendData = event.isCancelled() || !ServerGamePacketListenerImpl.this.player.getItemInHand(hand).is(itemType); + + // Entity in bucket - SPIGOT-4048 and SPIGOT-6859 -+ if (itemType == Items.WATER_BUCKET && target instanceof net.minecraft.world.entity.animal.Bucketable && target instanceof LivingEntity && resendData) { ++ if (itemType == Items.WATER_BUCKET && target instanceof net.minecraft.world.entity.Bucketable && target instanceof LivingEntity && resendData) { + target.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it + } + @@ -1903,7 +1916,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); -@@ -1850,6 +_,12 @@ +@@ -1865,6 +_,12 @@ } } } @@ -1916,16 +1929,16 @@ } } -@@ -1861,7 +_,7 @@ - ServerLevel level = this.player.level(); - Entity target = level.getEntityOrPart(packet.entityId()); - if (target != null && level.getWorldBorder().isWithinBounds(target.blockPosition())) { -- if (this.player.isWithinEntityInteractionRange(target.getBoundingBox(), 3.0)) { -+ if (this.player.isWithinEntityInteractionRange(target.getBoundingBox(), io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience - if (target.isPickable()) { - this.player.setCamera(target); - } -@@ -1879,7 +_,7 @@ +@@ -1877,7 +_,7 @@ + ServerLevel level = this.player.level(); + Entity target = level.getEntityOrPart(packet.spectateEntityId().getAsInt()); + if (target != null && level.getWorldBorder().isWithinBounds(target.blockPosition())) { +- if (this.player.isWithinEntityInteractionRange(target.getBoundingBox(), 3.0)) { ++ if (this.player.isWithinEntityInteractionRange(target.getBoundingBox(), io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience + if (target.isPickable()) { + this.player.setCamera(target); + } +@@ -1896,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -1934,7 +1947,7 @@ this.resetPosition(); this.restartClientLoadTimerAfterRespawn(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); -@@ -1888,12 +_,12 @@ +@@ -1905,12 +_,12 @@ return; } @@ -1950,7 +1963,7 @@ } } break; -@@ -1906,7 +_,7 @@ +@@ -1923,7 +_,7 @@ } private void sendGameRuleValues() { @@ -1959,7 +1972,7 @@ LOGGER.warn("Player {} tried to request game rule values without required permissions", this.player.getGameProfile().name()); } else { GameRules gameRules = this.player.level().getGameRules(); -@@ -1922,16 +_,27 @@ +@@ -1939,16 +_,27 @@ @Override public void handleContainerClose(final ServerboundContainerClosePacket packet) { @@ -1982,14 +1995,14 @@ + if (this.player.isImmobile()) return; // CraftBukkit this.player.resetLastActionTime(); - if (this.player.containerMenu.containerId == packet.containerId()) { -- if (this.player.isSpectator()) { +- if (this.player.isSpectator() || this.player.isDeadOrDying()) { + if (this.player.containerMenu.containerId == packet.containerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit -+ boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if -+ if (false/*this.player.isSpectator()*/) { // CraftBukkit ++ boolean cancelled = this.player.isSpectator() || this.player.isDeadOrDying(); // CraftBukkit - see below if ++ if (false && this.player.isSpectator() || this.player.isDeadOrDying()) { // CraftBukkit this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1947,7 +_,298 @@ +@@ -1964,7 +_,298 @@ } else { boolean fullResyncNeeded = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2019,7 +2032,7 @@ + if (!this.player.containerMenu.getCarried().isEmpty()) { + action = packet.buttonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; + } -+ } else if (slotIndex < 0) { ++ } else if (slotIndex < 0) { + action = InventoryAction.NOTHING; + } else { + Slot slot = this.player.containerMenu.getSlot(slotIndex); @@ -2289,7 +2302,7 @@ for (Entry e : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(e.getIntKey(), e.getValue()); -@@ -1960,6 +_,8 @@ +@@ -1977,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2298,7 +2311,7 @@ } } } -@@ -1967,6 +_,14 @@ +@@ -1984,6 +_,14 @@ @Override public void handlePlaceRecipe(final ServerboundPlaceRecipePacket packet) { @@ -2313,7 +2326,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1983,9 +_,44 @@ +@@ -2000,9 +_,44 @@ return; } @@ -2359,7 +2372,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, displayInfo.display().display())); } -@@ -1999,6 +_,7 @@ +@@ -2016,6 +_,7 @@ @Override public void handleContainerButtonClick(final ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2367,7 +2380,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -2008,6 +_,7 @@ +@@ -2025,6 +_,7 @@ if (clickAccepted) { this.player.containerMenu.broadcastChanges(); } @@ -2375,7 +2388,7 @@ } } } -@@ -2024,10 +_,48 @@ +@@ -2041,10 +_,48 @@ boolean validSlot = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean validData = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2424,7 +2437,7 @@ } else if (drop && validData) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -2041,15 +_,38 @@ +@@ -2058,15 +_,38 @@ @Override public void handleSignUpdate(final ServerboundSignUpdatePacket packet) { @@ -2464,7 +2477,7 @@ if (!(level.getBlockEntity(pos) instanceof SignBlockEntity sign)) { return; } -@@ -2061,14 +_,32 @@ +@@ -2078,14 +_,32 @@ @Override public void handlePlayerAbilities(final ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2498,7 +2511,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != wasHatShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -2084,21 +_,21 @@ +@@ -2101,21 +_,21 @@ packet.difficulty().getDisplayName() ); } else { @@ -2523,7 +2536,7 @@ } } -@@ -2118,7 +_,7 @@ +@@ -2135,7 +_,7 @@ ProfilePublicKey.Data newProfileKey = newChatSession.profilePublicKey(); if (!Objects.equals(oldProfileKey, newProfileKey)) { if (oldProfileKey != null && newProfileKey.expiresAt().isBefore(oldProfileKey.expiresAt())) { @@ -2532,7 +2545,7 @@ } else { try { SignatureValidator profileKeySignatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2129,8 +_,8 @@ +@@ -2146,8 +_,8 @@ this.resetPlayerChatState(newChatSession.validate(this.player.getGameProfile(), profileKeySignatureValidator)); } catch (ProfilePublicKey.ValidationException e) { @@ -2543,7 +2556,7 @@ } } } -@@ -2142,11 +_,13 @@ +@@ -2159,11 +_,13 @@ throw new IllegalStateException("Client acknowledged config, but none was requested"); } @@ -2558,7 +2571,7 @@ } @Override -@@ -2163,27 +_,32 @@ +@@ -2180,27 +_,32 @@ private void resetPlayerChatState(final RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2592,7 +2605,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2215,12 +_,23 @@ +@@ -2232,12 +_,23 @@ } public void tickClientLoadTimeout() { @@ -2618,7 +2631,7 @@ this.clientLoadedTimeoutTimer = 0; } -@@ -2232,4 +_,80 @@ +@@ -2249,4 +_,80 @@ this.waitingForRespawn = false; this.clientLoadedTimeoutTimer = 60; } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch index 6d17de399e7b..e2d38ce27f53 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -135,7 +135,7 @@ + this.connection.hostname = split[0]; + this.connection.address = new java.net.InetSocketAddress(split[1], socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0); + // Paper end - Unix domain socket support -+ this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] ); ++ this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient(split[2]); + } else { + Component message = Component.literal("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!"); + this.connection.send(new ClientboundLoginDisconnectPacket(message)); diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 760d2c14f7ef..b4321fe44619 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -38,7 +38,7 @@ this.serverActivityMonitor = this.server.getServerActivityMonitor(); this.challenge = Ints.toByteArray(RandomSource.create().nextInt()); this.transferred = transferred; -+ this.paperLoginConnection = new io.papermc.paper.connection.PaperPlayerLoginConnection(this); // Paper ++ this.paperLoginConnection = new io.papermc.paper.connection.PaperPlayerLoginConnection(this); // Paper } @Override @@ -143,7 +143,7 @@ } } } -@@ -139,9 +_,9 @@ +@@ -139,11 +_,11 @@ private void verifyLoginAndFinishConnectionSetup(final GameProfile profile) { PlayerList playerList = this.server.getPlayerList(); @@ -152,10 +152,13 @@ if (error != null) { - this.disconnect(error); + this.disconnectAsync(error); // Paper + } else if (this.connection.getIntendedProfileId() != null && !profile.id().equals(this.connection.getIntendedProfileId())) { +- this.disconnect(CommonComponents.CONNECT_FAILED); ++ this.disconnectAsync(CommonComponents.CONNECT_FAILED); // Paper } else { if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) { this.connection -@@ -151,7 +_,7 @@ +@@ -153,7 +_,7 @@ ); } @@ -164,15 +167,15 @@ if (waitForDisconnection) { this.state = ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT; } else { -@@ -163,6 +_,7 @@ +@@ -165,6 +_,7 @@ private void finishLoginAndWaitForClient(final GameProfile gameProfile) { this.state = ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING; - this.connection.send(new ClientboundLoginFinishedPacket(gameProfile)); + this.connection.send(new ClientboundLoginFinishedPacket(gameProfile, this.server.getConnection().getSessionId())); + this.server.services().paper().filledProfileCache().add(gameProfile); // Paper - update profile cache } @Override -@@ -186,7 +_,8 @@ +@@ -188,7 +_,8 @@ throw new IllegalStateException("Protocol error", e); } @@ -182,7 +185,7 @@ @Override public void run() { String name = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); -@@ -198,12 +_,18 @@ +@@ -200,12 +_,18 @@ .hasJoinedServer(name, digest, this.getAddress()); if (result != null) { GameProfile profile = result.profile(); @@ -202,7 +205,7 @@ } else { ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", name); -@@ -211,11 +_,16 @@ +@@ -213,11 +_,16 @@ } catch (AuthenticationUnavailableException ignored) { if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!"); @@ -221,8 +224,8 @@ } } -@@ -225,18 +_,123 @@ - ? ((InetSocketAddress)remoteAddress).getAddress() +@@ -227,18 +_,123 @@ + ? inetSocketAddress.getAddress() : null; } - }; @@ -349,7 +352,7 @@ 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); -@@ -253,8 +_,31 @@ +@@ -255,8 +_,31 @@ @Override public void handleCookieResponse(final ServerboundCookieResponsePacket packet) { diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch index fedd4f653880..e4b58a77dd62 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/notifications/NotificationManager.java +++ b/net/minecraft/server/notifications/NotificationManager.java -@@ -92,8 +_,8 @@ +@@ -107,8 +_,8 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch b/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch index 3509a5098176..380b52820b6e 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/BanListEntry.java.patch @@ -9,9 +9,9 @@ Date created; try { -@@ -101,4 +_,22 @@ - return false; - } +@@ -106,4 +_,22 @@ + public int hashCode() { + return Objects.hash(this.source, this.expires, this.reason, this.getUser()); } + + // CraftBukkit start 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 cc1ff3d76cab..99af78cb2fbd 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 @@ -81,7 +81,7 @@ reducedDebugInfo, !immediateRespawn, doLimitedCrafting, -@@ -185,6 +_,7 @@ +@@ -186,6 +_,7 @@ this.server.enforceSecureProfile() ) ); @@ -89,7 +89,7 @@ playerConnection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); playerConnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); playerConnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -204,24 +_,129 @@ +@@ -205,24 +_,129 @@ component = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), oldName); } @@ -223,7 +223,7 @@ } public void updateEntireScoreboard(final ServerScoreboard scoreboard, final ServerPlayer player) { -@@ -243,31 +_,40 @@ +@@ -244,31 +_,40 @@ } } @@ -269,7 +269,7 @@ } @Override -@@ -291,65 +_,146 @@ +@@ -292,65 +_,146 @@ } protected void save(final ServerPlayer player) { @@ -360,7 +360,7 @@ level.removePlayerImmediately(player, Entity.RemovalReason.UNLOADED_WITH_PLAYER); + player.retireScheduler(); // Paper - Folia schedulers - player.getAdvancements().stopListening(); + player.getAdvancements().clearTriggers(); this.players.remove(player); + this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot this.server.getCustomBossEvents().onPlayerDisconnect(player); @@ -432,7 +432,7 @@ } if (this.ipBans.isBanned(address)) { -@@ -359,20 +_,19 @@ +@@ -360,20 +_,19 @@ reason.append(Component.translatable("multiplayer.disconnect.banned_ip.expiration", BAN_DATE_FORMAT.format(ban.getExpires()))); } @@ -458,7 +458,7 @@ dupes.add(player); } } -@@ -383,23 +_,31 @@ +@@ -384,23 +_,31 @@ } for (ServerPlayer player : dupes) { @@ -495,7 +495,7 @@ player.copyRespawnPosition(serverPlayer); } -@@ -407,17 +_,26 @@ +@@ -408,17 +_,26 @@ player.addTag(tag); } @@ -523,7 +523,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)); -@@ -426,9 +_,15 @@ +@@ -427,9 +_,15 @@ this.sendPlayerPermissionLevel(player); level.addRespawnedPlayer(player); this.players.add(player); @@ -539,7 +539,7 @@ ServerPlayer.RespawnConfig respawnConfig = player.getRespawnConfig(); if (!keepAllPlayerData && respawnConfig != null) { LevelData.RespawnData respawnData = respawnConfig.respawnData(); -@@ -454,6 +_,29 @@ +@@ -455,6 +_,29 @@ } } @@ -569,7 +569,7 @@ return player; } -@@ -462,23 +_,58 @@ +@@ -463,23 +_,58 @@ } public void sendActiveEffects(final LivingEntity livingEntity, final ServerGamePacketListenerImpl connection) { @@ -631,7 +631,7 @@ public void broadcastAll(final Packet packet) { for (ServerPlayer player : this.players) { player.connection.send(packet); -@@ -564,6 +_,12 @@ +@@ -565,6 +_,12 @@ } private void sendPlayerPermissionLevel(final ServerPlayer player, final LevelBasedPermissionSet permissions) { @@ -644,7 +644,7 @@ if (player.connection != null) { byte eventId = switch (permissions.level()) { case ALL -> EntityEvent.PERMISSION_LEVEL_ALL; -@@ -575,9 +_,48 @@ +@@ -576,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, eventId)); } @@ -695,7 +695,7 @@ public boolean isWhiteListed(final NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -589,16 +_,7 @@ +@@ -592,16 +_,7 @@ } public @Nullable ServerPlayer getPlayerByName(final String name) { @@ -713,7 +713,7 @@ } public void broadcast( -@@ -612,6 +_,11 @@ +@@ -615,6 +_,11 @@ ) { for (int i = 0; i < this.players.size(); i++) { ServerPlayer player = this.players.get(i); @@ -725,7 +725,7 @@ if (player != except && player.level().dimension() == dimension) { double xd = x - player.getX(); double yd = y - player.getY(); -@@ -624,9 +_,11 @@ +@@ -627,9 +_,11 @@ } public void saveAll() { @@ -737,7 +737,7 @@ } public UserWhiteList getWhiteList() { -@@ -651,12 +_,20 @@ +@@ -654,12 +_,20 @@ public void sendLevelInfo(final ServerPlayer player, final ServerLevel level) { WorldBorder worldBorder = level.getWorldBorder(); player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); @@ -762,7 +762,7 @@ } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -665,8 +_,21 @@ +@@ -668,8 +_,21 @@ public void sendAllPlayerInfo(final ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -785,7 +785,7 @@ } public int getPlayerCount() { -@@ -710,9 +_,26 @@ +@@ -713,9 +_,26 @@ } public void removeAll() { @@ -815,7 +815,7 @@ } public void broadcastSystemMessage(final Component message, final boolean overlay) { -@@ -735,20 +_,39 @@ +@@ -738,20 +_,39 @@ } public void broadcastChatMessage(final PlayerChatMessage message, final ServerPlayer sender, final ChatType.Bound chatType) { @@ -858,7 +858,7 @@ wasFullyFiltered |= filtered && message.isFullyFiltered(); } -@@ -761,13 +_,21 @@ +@@ -764,13 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -883,7 +883,7 @@ private Path locateStatsFile(final GameProfile gameProfile) { Path statFolder = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR); -@@ -794,11 +_,11 @@ +@@ -797,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(final ServerPlayer player) { UUID uuid = player.getUUID(); @@ -897,7 +897,7 @@ } result.setPlayer(player); -@@ -846,11 +_,34 @@ +@@ -853,11 +_,34 @@ } public void reloadResources() { 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 e9aa7334268d..faada3673949 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 @@ -15,7 +15,7 @@ ProfileResult result = sessionService.fetchProfile(profileId, true); - return Optional.ofNullable(result).map(ProfileResult::profile); + // Paper start - update paper cache -+ return Optional.ofNullable(result).map(ProfileResult::profile) ++ return Optional.ofNullable(result).map(ProfileResult::profile) + .map(profile -> { + paperCache.add(profile); + return profile; diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch index 71a3892df1cd..f0de906af4b7 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconClient.java.patch @@ -10,7 +10,7 @@ + private final net.minecraft.server.rcon.RconConsoleSource rconConsoleSource; + // CraftBukkit end - RconClient(final ServerInterface serverInterface, final String rconPassword, final Socket socket) { + public RconClient(final ServerInterface serverInterface, final String rconPassword, final Socket socket) { super("RCON Client " + socket.getInetAddress()); - this.serverInterface = serverInterface; + this.serverInterface = (net.minecraft.server.dedicated.DedicatedServer) serverInterface; // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/util/TickThrottler.java.patch b/paper-server/patches/sources/net/minecraft/util/TickThrottler.java.patch index 32d86d8b6da4..bc6dc39c87f5 100644 --- a/paper-server/patches/sources/net/minecraft/util/TickThrottler.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/TickThrottler.java.patch @@ -29,9 +29,9 @@ } public boolean isUnderThreshold() { -- return this.count < this.threshold; +- return this.threshold <= 0 || this.count < this.threshold; + // CraftBukkit start - use thread-safe field access instead -+ return this.count.get() < this.threshold; ++ return this.threshold <= 0 || this.count.get() < this.threshold; + } + + public boolean isIncrementAndUnderThreshold() { diff --git a/paper-server/patches/sources/net/minecraft/util/Util.java.patch b/paper-server/patches/sources/net/minecraft/util/Util.java.patch index 5e5da68f47bc..55f84daacabd 100644 --- a/paper-server/patches/sources/net/minecraft/util/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/Util.java +++ b/net/minecraft/util/Util.java -@@ -96,9 +_,25 @@ +@@ -103,9 +_,25 @@ private static final int DEFAULT_MAX_THREADS = 255; private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10; private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; @@ -28,15 +28,15 @@ private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); public static final int LINEAR_LOOKUP_THRESHOLD = 8; private static final Set ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https"); -@@ -117,6 +_,7 @@ - .findFirst() - .orElseThrow(() -> new IllegalStateException("No jar file system provider found")); +@@ -146,6 +_,7 @@ + escaper.addEscape('\\', "\\\\"); + }).build(); private static Consumer thePauser = msg -> {}; + public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Check distance in entity interactions public static Collector, ?, Map> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); -@@ -139,7 +_,7 @@ +@@ -181,7 +_,7 @@ } public static long getNanos() { @@ -45,7 +45,7 @@ } public static long getEpochMillis() { -@@ -150,9 +_,10 @@ +@@ -192,9 +_,10 @@ return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now()); } @@ -58,7 +58,7 @@ if (threads <= 0) { executor = MoreExecutors.newDirectExecutorService(); } else { -@@ -177,16 +_,30 @@ +@@ -219,16 +_,30 @@ super.onTermination(exception); } }; @@ -91,7 +91,7 @@ } private static int getMaxThreads() { -@@ -236,6 +_,21 @@ +@@ -277,6 +_,21 @@ return thread; })); } @@ -112,4 +112,4 @@ + // Paper end - Separate dimension data IO pool public static void throwAsRuntime(final Throwable throwable) { - throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); + throw throwable instanceof RuntimeException runtimeException ? runtimeException : new RuntimeException(throwable); diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch index 7a93e5373491..50dfd448498c 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -549,6 +_,24 @@ +@@ -553,6 +_,24 @@ Schema v1456 = fixerUpper.addSchema(1456, SAME_NAMESPACED); fixerUpper.addFixer(new EntityItemFrameDirectionFix(v1456, false)); Schema v1458 = fixerUpper.addSchema(1458, V1458::new); diff --git a/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch b/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch index 934e40c3fc7d..b6a5c478366a 100644 --- a/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch @@ -8,3 +8,23 @@ LOGGER.info("Starting upgrade for world \"{}\"", worldAccess.getLevelId()); Path worldFolder = worldAccess.getLevelDirectory().path(); Path fileFixDirectory = worldFolder.resolve("filefix"); +@@ -312,7 +_,7 @@ + try { + Files.deleteIfExists(movesFile); + } catch (IOException e2) { +- LOGGER.warn("Failed to delete {}", movesFile, e); ++ LOGGER.warn("Failed to delete {}", movesFile, e2); // Paper - print correct stacktrace + } + } + +@@ -351,8 +_,8 @@ + try { + deleteDirectory(worldFolder); + } catch (Exception e2) { +- LOGGER.warn("Failed to delete outdated world folder: ", e); +- throw new FailedCleanupFileFixException(e, tempWorldTopLevel.getFileName().toString(), fileSystemCapabilities); ++ LOGGER.warn("Failed to delete outdated world folder: ", e2); // Paper - print correct stacktrace ++ throw new FailedCleanupFileFixException(e2, tempWorldTopLevel.getFileName().toString(), fileSystemCapabilities); // Paper - print correct stacktrace + } + } + diff --git a/paper-server/patches/sources/net/minecraft/util/filefix/fixes/LegacyStructureFileFix.java.patch b/paper-server/patches/sources/net/minecraft/util/filefix/fixes/LegacyStructureFileFix.java.patch index 338fe9d3c8ef..99e4c8f030dd 100644 --- a/paper-server/patches/sources/net/minecraft/util/filefix/fixes/LegacyStructureFileFix.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/filefix/fixes/LegacyStructureFileFix.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/filefix/fixes/LegacyStructureFileFix.java +++ b/net/minecraft/util/filefix/fixes/LegacyStructureFileFix.java -@@ -145,7 +_,7 @@ +@@ -147,7 +_,7 @@ } Optional generatorIdentifier = Optional.ofNullable(Identifier.tryParse(chunkGeneratorType)); diff --git a/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch index 7cc08b62e7e7..dbeec91104f1 100644 --- a/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch @@ -16,7 +16,7 @@ this.items = List.copyOf(items); this.totalWeight = WeightedRandom.getTotalWeight(items, Weighted::weight); if (this.totalWeight == 0) { -@@ -140,7 +_,7 @@ +@@ -150,7 +_,7 @@ } public static class Builder { diff --git a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch index 5de024776af7..b5676d7e994c 100644 --- a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch @@ -54,8 +54,8 @@ + } + // Paper end - LootTable API LootTable lootTable = level.getServer().reloadableRegistries().getLootTable(lootTableKey); - if (player instanceof ServerPlayer) { - CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, lootTableKey); + if (player instanceof ServerPlayer serverPlayer) { + CriteriaTriggers.GENERATE_LOOT.trigger(serverPlayer, lootTableKey); } + if (forceClearLootTable || this.lootableData() == null || this.lootableData().shouldClearLootTable(this, com.destroystokyo.paper.loottable.PaperLootableInventoryData.CONTAINER, player)) { // Paper - LootTable API diff --git a/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch index 4913e05e10b7..d5bb03e29278 100644 --- a/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/CombatTracker.java.patch @@ -23,13 +23,13 @@ this.recheckStatus(); FallLocation fallLocation = FallLocation.getCurrentFallLocation(this.mob); CombatEntry entry = new CombatEntry(source, damage, fallLocation, (float)this.mob.fallDistance); -+ // Paper start - Combat tracker API -+ recordDamageAndCheckCombatState(entry); ++ // Paper start - Combat tracker API ++ this.recordDamageAndCheckCombatState(entry); + } + + public void recordDamageAndCheckCombatState(final CombatEntry entry) { + final DamageSource source = entry.source(); -+ // Paper end - Combat tracker API ++ // Paper end - Combat tracker API + // Paper start - Fix mem leak (MC-301114) + final io.papermc.paper.configuration.type.number.IntOr.Disabled maxTrackingCombatEntries; + if (!this.entries.isEmpty() && (maxTrackingCombatEntries = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxTrackingCombatEntries).enabled()) { @@ -42,17 +42,18 @@ this.entries.add(entry); this.lastDamageTime = this.mob.tickCount; this.takingDamage = true; -@@ -147,6 +_,13 @@ +@@ -147,6 +_,14 @@ public void recheckStatus() { int reset = this.inCombat ? 300 : 100; if (this.takingDamage && (!this.mob.isAlive() || this.mob.tickCount - this.lastDamageTime > reset)) { -+ // Paper start - Combat tracker API -+ resetCombatState(); ++ // Paper start - Combat tracker API ++ this.resetCombatState(); + } + } + -+ public void resetCombatState() {{ -+ // Paper end - Combat tracker API ++ public void resetCombatState() { ++ { ++ // Paper end - Combat tracker API boolean wasInCombat = this.inCombat; this.takingDamage = false; this.inCombat = false; diff --git a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch index f546b59ffca7..421a485d2df3 100644 --- a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -17,6 +_,86 @@ +@@ -17,6 +_,90 @@ private final @Nullable Entity causingEntity; private final @Nullable Entity directEntity; private final @Nullable Vec3 damageSourcePosition; @@ -28,8 +28,12 @@ + } + + public DamageSource eventEntityDamager(final Entity entity) { ++ if (this.directEntity == entity) { // no changes needed but useful for data driven damage ++ return this; ++ } ++ + if (this.directEntity != null) { -+ throw new IllegalStateException("Cannot set an event damager when a direct entity is already set (report a bug to Paper)"); ++ throw new IllegalStateException("Cannot set an event damager when another direct entity is already set (report a bug to Paper)"); + } + final DamageSource damageSource = this.copy(); + damageSource.eventEntityDamager = entity; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch index 6ebd8b3cadb0..f16decf017cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch @@ -45,7 +45,7 @@ for (MobEffectInstance effect : allEffects) { @@ -232,14 +_,14 @@ .value() - .applyInstantenousEffect(serverLevel, this, this.getOwner(), entity, effect.getAmplifier(), 0.5); + .applyInstantaneousEffect(serverLevel, this, this.getOwner(), entity, effect.getAmplifier(), 0.5); } else { - entity.addEffect(new MobEffectInstance(effect), this); + entity.addEffect(new MobEffectInstance(effect), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Bucketable.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/Bucketable.java.patch index 09872335226f..42ade1611b52 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Bucketable.java.patch @@ -1,9 +1,9 @@ ---- a/net/minecraft/world/entity/animal/Bucketable.java -+++ b/net/minecraft/world/entity/animal/Bucketable.java -@@ -73,9 +_,25 @@ +--- a/net/minecraft/world/entity/Bucketable.java ++++ b/net/minecraft/world/entity/Bucketable.java +@@ -80,9 +_,25 @@ ) { ItemStack itemStack = player.getItemInHand(hand); - if (itemStack.getItem() == Items.WATER_BUCKET && pickupEntity.isAlive()) { + if (pickupEntity.canBePickedUpWithBucket(itemStack) && pickupEntity.isAlive()) { - pickupEntity.playSound(pickupEntity.getPickupSound(), 1.0F, 1.0F); + // CraftBukkit start + // pickupEntity.playSound(pickupEntity.getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down @@ -27,8 +27,8 @@ ItemStack result = ItemUtils.createFilledResult(itemStack, player, bucket, false); player.setItemInHand(hand, result); Level level = pickupEntity.level(); -@@ -83,7 +_,7 @@ - CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, bucket); +@@ -94,7 +_,7 @@ + leashable.dropLeash(); } - pickupEntity.discard(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch index 162fc9103da5..8adac637c9c9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch @@ -15,5 +15,5 @@ } + to.aware = from.aware; // Paper - Fix nerfed slime when splitting - this.convertCommon(from, to, params); + ConversionType.convertCommon(from, to, params); } 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 9953d5da41d4..88794037c6eb 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -168,6 +_,105 @@ +@@ -165,6 +_,105 @@ SlotProvider, DebugValueSource, TypedInstance> { @@ -115,7 +115,7 @@ public int tickCount; private int remainingFireTicks; private final EntityFluidInteraction fluidInteraction = new EntityFluidInteraction(Set.of(FluidTags.WATER, FluidTags.LAVA)); -@@ -278,7 +_,7 @@ +@@ -279,7 +_,7 @@ protected UUID uuid = Mth.createInsecureUUID(this.random); protected String stringUUID = this.uuid.toString(); private boolean hasGlowingTag; @@ -124,7 +124,7 @@ private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -292,6 +_,7 @@ +@@ -293,6 +_,7 @@ public boolean hasVisualFire; private Vec3 lastKnownSpeed = Vec3.ZERO; private @Nullable Vec3 lastKnownPosition; @@ -132,12 +132,11 @@ 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 @@ +@@ -300,6 +_,39 @@ private final LongSet visitedBlocks = new LongOpenHashSet(); private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); private CustomData customData = CustomData.EMPTY; + // CraftBukkit start -+ public boolean forceDrops; + public boolean persist = true; + public boolean visibleByDefault = true; + public boolean valid; @@ -173,16 +172,16 @@ public Entity(final EntityType type, final Level level) { this.type = type; -@@ -320,6 +_,7 @@ +@@ -322,6 +_,7 @@ this.entityData = entityDataBuilder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); -+ this.despawnTime = level == null || type == EntityType.PLAYER ? -1 : level.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit ++ this.despawnTime = level == null || type == EntityTypes.PLAYER ? -1 : level.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit } public boolean isColliding(final BlockPos pos, final BlockState state) { -@@ -332,6 +_,12 @@ - return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; +@@ -334,6 +_,12 @@ + return team != null && team.getColor().isPresent() ? team.getColor().get().rgb() : 16777215; } + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() @@ -194,7 +193,7 @@ public boolean isSpectator() { return false; } -@@ -389,7 +_,7 @@ +@@ -395,7 +_,7 @@ } public boolean addTag(final String tag) { @@ -203,7 +202,7 @@ } public boolean removeTag(final String tag) { -@@ -397,12 +_,18 @@ +@@ -403,12 +_,18 @@ } public void kill(final ServerLevel level) { @@ -224,7 +223,7 @@ } protected abstract void defineSynchedData(SynchedEntityData.Builder entityData); -@@ -411,6 +_,48 @@ +@@ -417,6 +_,48 @@ return this.entityData; } @@ -272,8 +271,8 @@ + @Override public boolean equals(final Object obj) { - return obj instanceof Entity && ((Entity)obj).id == this.id; -@@ -422,7 +_,13 @@ + return obj instanceof Entity entity && entity.getId() == this.getId(); +@@ -428,7 +_,13 @@ } public void remove(final Entity.RemovalReason reason) { @@ -288,7 +287,7 @@ } public void onClientRemoval() { -@@ -432,6 +_,15 @@ +@@ -438,6 +_,15 @@ } public void setPose(final Pose pose) { @@ -304,7 +303,7 @@ this.entityData.set(DATA_POSE, pose); } -@@ -454,7 +_,33 @@ +@@ -460,7 +_,33 @@ return Mth.lengthSquared(dx, dz) < Mth.square(distanceXZ) && Mth.square(dy) < Mth.square(distanceY); } @@ -339,7 +338,7 @@ this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -464,8 +_,8 @@ +@@ -470,8 +_,8 @@ } public void setPos(final double x, final double y, final double z) { @@ -350,7 +349,7 @@ } protected final AABB makeBoundingBox() { -@@ -499,12 +_,28 @@ +@@ -505,12 +_,28 @@ } public void tick() { @@ -379,7 +378,7 @@ this.computeSpeed(); this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -515,7 +_,7 @@ +@@ -521,7 +_,7 @@ this.boardingCooldown--; } @@ -388,7 +387,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -543,6 +_,10 @@ +@@ -549,6 +_,10 @@ if (this.isInLava()) { this.fallDistance *= 0.5; @@ -399,7 +398,7 @@ } this.checkBelowWorld(); -@@ -568,11 +_,16 @@ +@@ -574,11 +_,16 @@ } public void setSharedFlagOnFire(final boolean value) { @@ -418,7 +417,7 @@ this.onBelowWorld(); } } -@@ -600,15 +_,41 @@ +@@ -606,15 +_,41 @@ } public void lavaIgnite() { @@ -462,7 +461,7 @@ && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -623,6 +_,20 @@ +@@ -629,6 +_,20 @@ } public final void igniteForSeconds(final float numberOfSeconds) { @@ -483,7 +482,7 @@ this.igniteForTicks(Mth.floor(numberOfSeconds * 20.0F)); } -@@ -647,7 +_,7 @@ +@@ -653,7 +_,7 @@ } protected void onBelowWorld() { @@ -492,7 +491,7 @@ } public boolean isFree(final double xa, final double ya, final double za) { -@@ -703,7 +_,28 @@ +@@ -709,7 +_,28 @@ return this.onGround; } @@ -521,9 +520,9 @@ if (this.noPhysics) { this.setPos(this.getX() + delta.x, this.getY() + delta.y, this.getZ() + delta.z); this.horizontalCollision = false; -@@ -786,6 +_,27 @@ - onBlock.updateEntityMovementAfterFallOn(this.level(), this); - } +@@ -785,6 +_,27 @@ + if (this.canSimulateMovement() && (movedVertically && this.verticalCollision || this.horizontalCollision)) { + this.restituteMovementAfterCollisions(effectState, xCollision, zCollision, movement); } + // CraftBukkit start + if (this.horizontalCollision && this.getBukkitEntity() instanceof org.bukkit.entity.Vehicle) { @@ -549,7 +548,7 @@ if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission emission = this.getMovementEmission(); -@@ -799,6 +_,13 @@ +@@ -798,6 +_,13 @@ profiler.pop(); } } @@ -562,8 +561,8 @@ + // Paper end - detailed watchdog information } - private void applyMovementEmissionAndPlaySound( -@@ -994,7 +_,7 @@ + private void restituteMovementAfterCollisions(final BlockState effectState, final boolean xCollision, final boolean zCollision, final Vec3 movement) { +@@ -1057,7 +_,7 @@ } protected BlockPos getOnPos(final float offset) { @@ -572,7 +571,7 @@ BlockPos getOnPos = this.mainSupportingBlockPos.get(); if (!(offset > 1.0E-5F)) { return getOnPos; -@@ -1266,7 +_,7 @@ +@@ -1348,7 +_,7 @@ if (insideBlock) { try { boolean isPrecise = movedFar || deflatedBoundingBoxAtTarget.intersects(blockIntersection); @@ -581,7 +580,7 @@ state.entityInside(this.level(), blockIntersection, this, effectCollector, isPrecise); this.onInsideBlock(state); } catch (Throwable t) { -@@ -1280,7 +_,7 @@ +@@ -1362,7 +_,7 @@ } if (insideFluid) { @@ -590,7 +589,7 @@ state.getFluidState().entityInside(this.level(), blockIntersection, this, effectCollector); } -@@ -1692,6 +_,7 @@ +@@ -1778,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -598,7 +597,7 @@ } public void absSnapTo(final double x, final double y, final double z) { -@@ -1701,6 +_,7 @@ +@@ -1787,6 +_,7 @@ this.yo = y; this.zo = cz; this.setPos(cx, y, cz); @@ -606,7 +605,7 @@ } public void snapTo(final Vec3 pos) { -@@ -1725,6 +_,7 @@ +@@ -1811,6 +_,7 @@ this.setXRot(xRot); this.setOldPosAndRot(); this.reapplyPosition(); @@ -614,7 +613,7 @@ } public final void setOldPosAndRot() { -@@ -1791,6 +_,7 @@ +@@ -1877,6 +_,7 @@ public void push(final Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -622,7 +621,7 @@ double xa = entity.getX() - this.getX(); double za = entity.getZ() - this.getZ(); double dd = Mth.absMax(xa, za); -@@ -1826,8 +_,24 @@ +@@ -1912,8 +_,24 @@ } public void push(final double xa, final double ya, final double za) { @@ -648,7 +647,7 @@ this.needsSync = true; } } -@@ -1934,8 +_,20 @@ +@@ -2020,8 +_,20 @@ } public boolean isPushable() { @@ -668,8 +667,8 @@ + // CraftBukkit end public void awardKillScore(final Entity victim, final DamageSource killingBlow) { - if (victim instanceof ServerPlayer) { -@@ -1962,17 +_,25 @@ + if (victim instanceof ServerPlayer serverPlayer) { +@@ -2048,17 +_,25 @@ } public boolean saveAsPassenger(final ValueOutput output) { @@ -699,7 +698,7 @@ return true; } -@@ -1981,14 +_,34 @@ +@@ -2067,14 +_,34 @@ } public void saveWithoutId(final ValueOutput output) { @@ -734,7 +733,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1996,7 +_,29 @@ +@@ -2082,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -764,7 +763,7 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -2019,9 +_,14 @@ +@@ -2105,9 +_,14 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } @@ -782,7 +781,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -2031,13 +_,13 @@ +@@ -2117,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -798,7 +797,7 @@ passengersList.discardLast(); } } -@@ -2046,6 +_,33 @@ +@@ -2132,6 +_,33 @@ output.discard("Passengers"); } } @@ -832,7 +831,7 @@ } catch (Throwable t) { CrashReport report = CrashReport.forThrowable(t, "Saving entity NBT"); CrashReportCategory category = report.addCategory("Entity being saved"); -@@ -2093,7 +_,20 @@ +@@ -2179,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -854,7 +853,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2104,6 +_,58 @@ +@@ -2190,6 +_,58 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -913,7 +912,7 @@ } catch (Throwable t) { CrashReport report = CrashReport.forThrowable(t, "Loading entity NBT"); CrashReportCategory category = report.addCategory("Entity being loaded"); -@@ -2117,7 +_,13 @@ +@@ -2203,7 +_,13 @@ } public final @Nullable String getEncodeId() { @@ -928,7 +927,7 @@ return null; } -@@ -2127,6 +_,12 @@ +@@ -2213,6 +_,12 @@ protected abstract void readAdditionalSaveData(ValueInput input); @@ -941,7 +940,7 @@ protected abstract void addAdditionalSaveData(ValueOutput output); public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemLike resource) { -@@ -2138,12 +_,57 @@ +@@ -2224,12 +_,57 @@ } public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemStack itemStack, final Vec3 offset) { @@ -970,9 +969,9 @@ } - + // CraftBukkit start - Capture drops for death event -+ if (!this.forceDrops && this instanceof LivingEntity livingEntity) { ++ if (this instanceof LivingEntity livingEntity && livingEntity.deathDropItems != null) { + // Paper start - Restore vanilla drops behavior -+ livingEntity.drops.add(new DefaultDrop(itemStack, dropStack -> { ++ livingEntity.deathDropItems.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); @@ -1001,7 +1000,7 @@ level.addFreshEntity(entity); return entity; } -@@ -2187,6 +_,15 @@ +@@ -2273,6 +_,15 @@ for (Leashable mob : mobsToLeash) { if (mob.canHaveALeashAttachedTo(this)) { @@ -1017,7 +1016,7 @@ mob.setLeashedTo(this, true); anyLeashed = true; } -@@ -2201,7 +_,7 @@ +@@ -2287,7 +_,7 @@ } ItemStack heldItem = player.getItemInHand(hand); @@ -1026,7 +1025,7 @@ heldItem.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob target -@@ -2214,11 +_,13 @@ +@@ -2300,11 +_,13 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1044,7 +1043,7 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2235,9 +_,22 @@ +@@ -2321,9 +_,22 @@ if (leashable.canHaveALeashAttachedTo(player)) { if (leashable.isLeashed()) { @@ -1068,7 +1067,7 @@ leashable.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemStack.shrink(1); -@@ -2251,7 +_,13 @@ +@@ -2337,7 +_,13 @@ } public boolean shearOffAllLeashConnections(final @Nullable Player player) { @@ -1083,7 +1082,7 @@ if (dropped && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2260,15 +_,39 @@ +@@ -2346,15 +_,39 @@ } public boolean dropAllLeashConnections(final @Nullable Player player) { @@ -1127,17 +1126,7 @@ } if (dropped) { -@@ -2292,7 +_,9 @@ - this.gameEvent(GameEvent.SHEAR, player); - this.playSound(equippable.shearingSound().value()); - if (this.level() instanceof ServerLevel serverLevel) { -+ this.forceDrops = true; // Paper - this.spawnAtLocation(serverLevel, itemStack, equipmentSpawnOffset); -+ this.forceDrops = false; // Paper - CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemStack, target); - } - -@@ -2360,7 +_,7 @@ +@@ -2422,7 +_,7 @@ } public boolean startRiding(final Entity entityToRide, final boolean force, final boolean sendEventAndTriggers) { @@ -1146,7 +1135,7 @@ return false; } -@@ -2368,7 +_,7 @@ +@@ -2430,7 +_,7 @@ return false; } @@ -1155,7 +1144,7 @@ return false; } -@@ -2379,6 +_,27 @@ +@@ -2441,6 +_,27 @@ } if (force || this.canRide(entityToRide) && entityToRide.canAddPassenger(this)) { @@ -1183,7 +1172,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2410,10 +_,16 @@ +@@ -2472,10 +_,16 @@ } public void removeVehicle() { @@ -1201,7 +1190,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, oldVehicle.position); -@@ -2422,7 +_,13 @@ +@@ -2484,7 +_,13 @@ } public void stopRiding() { @@ -1216,7 +1205,7 @@ } protected void addPassenger(final Entity passenger) { -@@ -2444,11 +_,44 @@ +@@ -2506,11 +_,44 @@ } } @@ -1262,7 +1251,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2456,6 +_,7 @@ +@@ -2518,6 +_,7 @@ } passenger.boardingCooldown = 60; @@ -1270,7 +1259,7 @@ } protected boolean canAddPassenger(final Entity passenger) { -@@ -2638,7 +_,7 @@ +@@ -2700,7 +_,7 @@ } public boolean isCrouching() { @@ -1279,7 +1268,7 @@ } public boolean isSprinting() { -@@ -2654,7 +_,7 @@ +@@ -2716,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1288,7 +1277,7 @@ } public boolean isVisuallyCrawling() { -@@ -2662,6 +_,13 @@ +@@ -2724,6 +_,13 @@ } public void setSwimming(final boolean swimming) { @@ -1302,7 +1291,7 @@ this.setSharedFlag(FLAG_SWIMMING, swimming); } -@@ -2699,6 +_,7 @@ +@@ -2761,6 +_,7 @@ } public @Nullable PlayerTeam getTeam() { @@ -1310,7 +1299,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2715,7 +_,11 @@ +@@ -2777,7 +_,11 @@ } public void setInvisible(final boolean invisible) { @@ -1322,8 +1311,8 @@ + // CraftBukkit - end } - public boolean getSharedFlag(@Entity.Flags final int flag) { -@@ -2732,7 +_,7 @@ + public boolean getSharedFlag(final @Entity.Flags int flag) { +@@ -2794,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1332,7 +1321,7 @@ } public int getAirSupply() { -@@ -2740,10 +_,24 @@ +@@ -2802,10 +_,24 @@ } public void setAirSupply(final int supply) { @@ -1358,7 +1347,7 @@ this.setTicksFrozen(0); } -@@ -2770,11 +_,42 @@ +@@ -2832,11 +_,42 @@ public void thunderHit(final ServerLevel level, final LightningBolt lightningBolt) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1405,7 +1394,20 @@ } public void onAboveBubbleColumn(final boolean dragDown, final BlockPos pos) { -@@ -2924,26 +_,30 @@ +@@ -2888,6 +_,12 @@ + entity.resetFallDistance(); + } + ++ // Paper start ++ public boolean killedEntityPreEvent(final ServerLevel level, final LivingEntity entity, final DamageSource source) { ++ return true; ++ } ++ // Paper end ++ + public boolean killedEntity(final ServerLevel level, final LivingEntity entity, final DamageSource source) { + return true; + } +@@ -2986,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1439,7 +1441,7 @@ ); } -@@ -2967,6 +_,13 @@ +@@ -3033,6 +_,13 @@ } public void restoreFrom(final Entity oldEntity) { @@ -1453,7 +1455,7 @@ try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput entityData = TagValueOutput.createWithContext(reporter, oldEntity.registryAccess()); oldEntity.saveWithoutId(entityData); -@@ -2977,8 +_,66 @@ +@@ -3043,8 +_,66 @@ this.portalProcess = oldEntity.portalProcess; } @@ -1521,7 +1523,7 @@ ServerLevel newLevel = transition.newLevel(); boolean otherDimension = newLevel.dimension() != serverLevel.dimension(); if (!transition.asPassenger()) { -@@ -3028,10 +_,15 @@ +@@ -3094,10 +_,15 @@ return null; } @@ -1538,7 +1540,7 @@ for (Entity newPassenger : newPassengers) { newPassenger.startRiding(newEntity, true, false); -@@ -3117,9 +_,17 @@ +@@ -3183,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1559,7 +1561,7 @@ } if (this instanceof WaypointTransmitter waypoint && this.level instanceof ServerLevel serverLevel) { -@@ -3136,6 +_,7 @@ +@@ -3202,6 +_,7 @@ } public boolean canTeleport(final Level from, final Level to) { @@ -1567,8 +1569,8 @@ if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { for (Entity passenger : this.getPassengers()) { if (passenger instanceof ServerPlayer player && !player.seenCredits) { -@@ -3254,7 +_,7 @@ - } +@@ -3322,7 +_,7 @@ + return null; } - public boolean teleportTo( @@ -1576,7 +1578,7 @@ final ServerLevel level, final double x, final double y, -@@ -3264,14 +_,30 @@ +@@ -3332,14 +_,30 @@ final float newXRot, final boolean resetCamera ) { @@ -1609,7 +1611,7 @@ } public void teleportTo(final double x, final double y, final double z) { -@@ -3382,7 +_,26 @@ +@@ -3450,7 +_,26 @@ } public final void setBoundingBox(final AABB bb) { @@ -1637,7 +1639,7 @@ } public final float getEyeHeight(final Pose pose) { -@@ -3406,6 +_,12 @@ +@@ -3474,6 +_,12 @@ } public void stopSeenByPlayer(final ServerPlayer player) { @@ -1650,7 +1652,7 @@ } public float rotate(final Rotation rotation) { -@@ -3464,21 +_,32 @@ +@@ -3532,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1684,7 +1686,7 @@ } public int countPlayerPassengers() { -@@ -3486,6 +_,7 @@ +@@ -3554,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1692,7 +1694,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3566,9 +_,38 @@ +@@ -3634,9 +_,38 @@ return 0; } @@ -1732,7 +1734,7 @@ this.position(), this.getRotationVector(), level, -@@ -3666,7 +_,9 @@ +@@ -3734,7 +_,9 @@ public void setDeltaMovement(final Vec3 deltaMovement) { if (deltaMovement.isFinite()) { @@ -1742,7 +1744,7 @@ } } -@@ -3737,8 +_,34 @@ +@@ -3805,8 +_,34 @@ } public final void setPosRaw(final double x, final double y, final double z) { @@ -1777,7 +1779,7 @@ int fx = Mth.floor(x); int fy = Mth.floor(y); int fz = Mth.floor(z); -@@ -3760,7 +_,18 @@ +@@ -3828,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(player); } } @@ -1797,7 +1799,7 @@ } public void checkDespawn() { -@@ -3812,6 +_,12 @@ +@@ -3880,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1810,7 +1812,7 @@ public float getYRot() { return this.yRot; } -@@ -3862,7 +_,9 @@ +@@ -3930,7 +_,9 @@ } @Override @@ -1821,7 +1823,7 @@ if (this.removalReason == null) { this.removalReason = reason; } -@@ -3874,12 +_,28 @@ +@@ -3942,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(reason); this.onRemoval(reason); @@ -1850,18 +1852,14 @@ @Override public void setLevelCallback(final EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4101,4 +_,14 @@ +@@ -4169,4 +_,10 @@ return this.save; } } + -+ // Paper start - Expose entity id counter -+ public static int nextEntityId() { -+ return ENTITY_COUNTER.incrementAndGet(); -+ } -+ ++ // Paper start + public boolean isTicking() { + return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition()); + } -+ // Paper end - Expose entity id counter ++ // Paper end } 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 e6b3913dced5..06d4b873da81 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -187,6 +_,7 @@ +@@ -52,6 +_,7 @@ import org.slf4j.Logger; public class EntityType implements EntityTypeTest, FeatureElement { @@ -8,7 +8,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private final Holder.Reference> builtInRegistryHolder = BuiltInRegistries.ENTITY_TYPE.createIntrusiveHolder(this); public static final Codec> CODEC = BuiltInRegistries.ENTITY_TYPE.byNameCodec(); -@@ -1288,6 +_,22 @@ +@@ -120,6 +_,22 @@ final boolean tryMoveDown, final boolean movedUp ) { @@ -28,20 +28,20 @@ + final org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason createSpawnReason + ) { + // CraftBukkit end - Consumer postSpawnConfig; + PostSpawnProcessor postSpawnConfig; if (itemStack != null) { postSpawnConfig = createDefaultStackConfig(level, itemStack, user); -@@ -1295,7 +_,7 @@ - postSpawnConfig = entity -> {}; +@@ -127,7 +_,7 @@ + postSpawnConfig = PostSpawnProcessor.nop(); } - return this.spawn(level, postSpawnConfig, spawnPos, spawnReason, tryMoveDown, movedUp); + return this.spawn(level, postSpawnConfig, spawnPos, spawnReason, tryMoveDown, movedUp, createSpawnReason); // CraftBukkit } - public static Consumer createDefaultStackConfig(final Level level, final ItemStack itemStack, final @Nullable LivingEntity user) { -@@ -1316,11 +_,30 @@ - final Consumer initialConfig, final Level level, final ItemStack itemStack, final @Nullable LivingEntity user + public static PostSpawnProcessor createDefaultStackConfig( +@@ -150,11 +_,30 @@ + final PostSpawnProcessor initialConfig, final Level level, final ItemStack itemStack, final @Nullable LivingEntity user ) { TypedEntityData> entityData = itemStack.get(DataComponents.ENTITY_DATA); - return entityData != null ? initialConfig.andThen(entity -> updateCustomEntityTag(level, user, entity, entityData)) : initialConfig; @@ -73,7 +73,7 @@ } public @Nullable T spawn( -@@ -1331,9 +_,39 @@ +@@ -165,9 +_,39 @@ final boolean tryMoveDown, final boolean movedUp ) { @@ -84,7 +84,7 @@ + @Nullable + public T spawn( + final ServerLevel level, -+ final @Nullable Consumer postSpawnConfig, ++ final @Nullable PostSpawnProcessor postSpawnConfig, + final BlockPos spawnPos, + final EntitySpawnReason spawnReason, + final boolean tryMoveDown, @@ -114,7 +114,7 @@ if (entity instanceof Mob mob) { mob.playAmbientSound(); } -@@ -1396,6 +_,13 @@ +@@ -230,6 +_,13 @@ if (level.isClientSide() || !entity.getType().onlyOpCanSetNbt() || user instanceof Player player && server.getPlayerList().isOp(player.nameAndId())) { @@ -128,18 +128,34 @@ entityData.loadInto(entity); } } -@@ -1466,10 +_,28 @@ +@@ -296,7 +_,14 @@ } - public static Optional create(final ValueInput input, final Level level, final EntitySpawnReason reason) { + public boolean canSpawn(final Level level) { +- return this.isEnabled(level.enabledFeatures()) && (this.isAllowedInPeaceful() || level.getDifficulty() != Difficulty.PEACEFUL); ++ // Paper start - peaceful override - pass item ++ // We do not mark this method as DoNotUse as it is heavily used in #create, which would require every create call to pass a null component. ++ // Not optimal but better than giant diffs everywhere, especially when the only two places that really have this additional data are spawn egg and summon. ++ return canSpawn(level, null); ++ } ++ public boolean canSpawn(final Level level, @Nullable final CompoundTag tag) { ++ return this.isEnabled(level.enabledFeatures()) && (this.isAllowedInPeaceful(tag) || level.getDifficulty() != Difficulty.PEACEFUL); ++ // Paper end - peaceful override - pass item + } + + public @Nullable T create(final Level level, final EntitySpawnReason reason) { +@@ -308,10 +_,28 @@ + } + + public static Optional create(final ValueInput input, final Level level, final EntitySpawnRequest request) { + // Paper start - Don't fire sync event during generation -+ return create(input, level, reason, false); ++ return create(input, level, request, false); + } + -+ public static Optional create(final ValueInput input, final Level level, final EntitySpawnReason reason, final boolean generation) { ++ public static Optional create(final ValueInput input, final Level level, final EntitySpawnRequest request, final boolean generation) { + // Paper end - Don't fire sync event during generation return Util.ifElse( - by(input).map(type -> type.create(level, reason)), + by(input).map(type -> type.create(level, request)), - entity -> entity.load(input), - () -> LOGGER.warn("Skipping Entity with id {}", input.getStringOr("id", "[invalid]")) + // Paper start - Don't fire sync event during generation @@ -159,7 +175,7 @@ ); } -@@ -1610,8 +_,23 @@ +@@ -460,8 +_,23 @@ return this.builtInRegistryHolder; } @@ -183,4 +199,4 @@ + // Paper end } - private static EntityType.EntityFactory boatFactory(final Supplier boatItem) { + public boolean onlyOpCanSetNbt() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch index dfeb863c74a4..3b557be4bb39 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -50,7 +50,7 @@ + } + public ExperienceOrb(final Level level, final Vec3 pos, final Vec3 roughly, final int value, org.bukkit.entity.ExperienceOrb.@Nullable SpawnReason reason, final @Nullable Entity triggerId, final @Nullable Entity sourceId) { + // Paper end - add reasons for orbs - this(EntityType.EXPERIENCE_ORB, level); + this(EntityTypes.EXPERIENCE_ORB, level); + // Paper start - add reasons for orbs + this.sourceEntityId = sourceId != null ? sourceId.getUUID() : null; + this.triggerEntityId = triggerId != null ? triggerId.getUUID() : null; @@ -59,7 +59,7 @@ this.setPos(pos); if (!level.isClientSide()) { this.setYRot(this.random.nextFloat() * 360.0F); -@@ -146,12 +_,13 @@ +@@ -146,7 +_,7 @@ this.age++; if (this.age >= 6000) { @@ -68,13 +68,15 @@ } } } +@@ -157,6 +_,7 @@ + } private void followNearbyPlayer() { + Player prevTarget = this.followingPlayer; // CraftBukkit - store old target 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 @@ +@@ -166,7 +_,24 @@ } } @@ -100,7 +102,7 @@ Vec3 delta = new Vec3( this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(), -@@ -191,18 +_,24 @@ +@@ -196,18 +_,24 @@ } public static void awardWithDirection(final ServerLevel level, final Vec3 pos, final Vec3 roughDirection, int amount) { @@ -127,7 +129,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 @@ +@@ -224,13 +_,18 @@ } private static boolean canMerge(final ExperienceOrb orb, final int id, final int value) { @@ -148,7 +150,7 @@ } private void setUnderwaterMovement() { -@@ -251,7 +_,7 @@ +@@ -256,7 +_,7 @@ this.markHurt(); this.health = (int)(this.health - damage); if (this.health <= 0) { @@ -157,7 +159,7 @@ } return true; -@@ -261,32 +_,34 @@ +@@ -266,32 +_,34 @@ protected void addAdditionalSaveData(final ValueOutput output) { output.putShort("Health", (short)this.health); output.putShort("Age", (short)this.age); @@ -198,7 +200,7 @@ } } } -@@ -298,9 +_,19 @@ +@@ -303,9 +_,19 @@ ItemStack itemStack = selected.get().itemStack(); int toRepairFromXpAmount = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.level(), itemStack, amount); int repair = Math.min(toRepairFromXpAmount, itemStack.getDamageValue()); @@ -219,7 +221,7 @@ if (remaining > 0) { return this.repairPlayerItems(player, remaining); } -@@ -346,6 +_,24 @@ +@@ -351,6 +_,24 @@ } public static int getExperienceValue(final int maxValue) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch index 4ad4e9b1f901..64329acc54ac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch @@ -12,26 +12,6 @@ output.storeNullable("leash", Leashable.LeashData.CODEC, leashData); } -@@ -99,7 +_,9 @@ - } - - if (entity.tickCount > 100) { -+ entity.forceDrops = true; // CraftBukkit - entity.spawnAtLocation(serverLevel, Items.LEAD); -+ entity.forceDrops = false; // CraftBukkit - entity.setLeashData(null); - } - } -@@ -123,7 +_,9 @@ - entity.onLeashRemoved(); - if (entity.level() instanceof ServerLevel level) { - if (dropLead) { -+ entity.forceDrops = true; // CraftBukkit - entity.spawnAtLocation(level, Items.LEAD); -+ entity.forceDrops = false; // CraftBukkit - } - - if (sendPacket) { @@ -143,7 +_,15 @@ if (leashData != null && leashData.leashHolder != null) { 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 a23fffe83191..b6320b5cc5d5 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -140,6 +_,17 @@ +@@ -139,6 +_,17 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -18,19 +18,19 @@ 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 @@ +@@ -283,11 +_,25 @@ + protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); public @Nullable Vec3 currentImpulseImpactPos; - public @Nullable Entity currentExplosionCause; + // CraftBukkit start + public int expToDrop; -+ public List drops = new java.util.ArrayList<>(); // Paper - Restore vanilla drops behavior ++ public @Nullable List deathDropItems = null; + public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; + public boolean collides = true; + public Set collidableExemptions = new java.util.HashSet<>(); + public boolean bukkitPickUpLoot; + public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper -+ public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event ++ public boolean silentDeath = true; // Paper - mark entity as dying silently for cancellable death event + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API + public int invulnerableDuration = LivingEntity.INVULNERABLE_DURATION; // Paper - configurable invulnerable duration + // CraftBukkit end @@ -45,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -365,7 +_,13 @@ +@@ -384,7 +_,13 @@ double scale = Math.min(0.2F + power / 15.0, 2.5); int particles = (int)(150.0 * scale); @@ -59,7 +59,7 @@ } } -@@ -550,7 +_,7 @@ +@@ -573,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, EntityEvent.POOF); @@ -68,7 +68,7 @@ } } -@@ -652,7 +_,7 @@ +@@ -675,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -77,7 +77,7 @@ } public void setDiscardFriction(final boolean discardFriction) { -@@ -664,10 +_,15 @@ +@@ -687,10 +_,15 @@ } public void onEquipItem(final EquipmentSlot slot, final ItemStack oldStack, final ItemStack stack) { @@ -94,7 +94,7 @@ this.level() .playSeededSound( null, -@@ -694,12 +_,12 @@ +@@ -717,12 +_,12 @@ } @Override @@ -109,7 +109,7 @@ this.brain.clearMemories(); } -@@ -716,11 +_,17 @@ +@@ -739,11 +_,17 @@ effect.onMobRemoved(level, this, reason); } @@ -126,8 +126,8 @@ + // Paper end - Friction API output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); - output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -755,7 +_,12 @@ + output.putShort("DeathTime", (short)this.deathTime); +@@ -777,7 +_,12 @@ } } @@ -141,7 +141,7 @@ if (itemStack.isEmpty()) { return null; } -@@ -767,6 +_,31 @@ +@@ -789,6 +_,31 @@ ItemEntity entity = this.createItemStackToDrop(itemStack, randomly, thrownFromHand); if (entity != null) { @@ -173,7 +173,7 @@ this.level().addFreshEntity(entity); } -@@ -775,7 +_,22 @@ +@@ -797,7 +_,22 @@ @Override protected void readAdditionalSaveData(final ValueInput input) { @@ -197,7 +197,7 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -788,6 +_,11 @@ +@@ -810,12 +_,18 @@ this.effectsDirty = true; } @@ -209,7 +209,6 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -795,6 +_,7 @@ input.getString("Team").ifPresent(teamName -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam team = scoreboard.getPlayerTeam(teamName); @@ -217,7 +216,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); -@@ -802,11 +_,13 @@ +@@ -823,11 +_,13 @@ }); this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(sleepingPos -> { @@ -231,7 +230,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"); -@@ -825,15 +_,44 @@ +@@ -846,15 +_,44 @@ this.updateDirtyEffects(); } @@ -276,7 +275,7 @@ iterator.remove(); this.onEffectsRemoved(List.of(effect)); } else if (effect.getDuration() % 600 == 0) { -@@ -842,6 +_,18 @@ +@@ -863,6 +_,18 @@ } } catch (ConcurrentModificationException var6) { } @@ -295,7 +294,7 @@ } else { for (MobEffectInstance effect : this.activeEffects.values()) { effect.tickClient(); -@@ -952,6 +_,11 @@ +@@ -973,6 +_,11 @@ } public boolean removeAllEffects() { @@ -307,7 +306,7 @@ if (this.level().isClientSide()) { return false; } -@@ -960,10 +_,23 @@ +@@ -981,10 +_,23 @@ return false; } @@ -335,7 +334,7 @@ } public Collection getActiveEffects() { -@@ -988,24 +_,69 @@ +@@ -1009,24 +_,69 @@ } public final boolean addEffect(final MobEffectInstance newEffect) { @@ -407,7 +406,7 @@ } newEffect.onEffectStarted(this); -@@ -1039,11 +_,35 @@ +@@ -1060,11 +_,35 @@ } public final @Nullable MobEffectInstance removeEffectNoUpdate(final Holder effect) { @@ -444,7 +443,7 @@ if (effectInstance != null) { this.onEffectsRemoved(List.of(effectInstance)); return true; -@@ -1134,17 +_,62 @@ +@@ -1155,17 +_,62 @@ } public void heal(final float heal) { @@ -509,7 +508,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1158,7 +_,7 @@ +@@ -1179,7 +_,7 @@ return false; } @@ -518,7 +517,7 @@ return false; } -@@ -1177,14 +_,16 @@ +@@ -1198,14 +_,16 @@ float originalDamage = damage; ItemStack itemInUse = this.getUseItem(); @@ -539,7 +538,7 @@ this.hurtHelmet(source, damage); damage *= 0.75F; } -@@ -1193,19 +_,40 @@ +@@ -1214,19 +_,40 @@ damage = Float.MAX_VALUE; } @@ -584,7 +583,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1220,7 +_,7 @@ +@@ -1241,7 +_,7 @@ level.broadcastDamageEvent(this, source); } @@ -593,25 +592,7 @@ this.markHurt(); } -@@ -1236,7 +_,16 @@ - zd = source.getSourcePosition().z() - this.getZ(); - } - -- 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 (Math.abs(zd) > 200) { -+ zd = Math.random() - Math.random(); -+ } -+ // 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 @@ +@@ -1252,19 +_,17 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(source)) { @@ -619,12 +600,10 @@ - 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.silentDeath = !tookFullDamage; // Paper - moved into CraftEventFactory event caller for configurable death event this.die(source); -+ this.silentDeath = false; // Paper - cancellable death event - reset to default ++ this.silentDeath = true; // Paper } } else if (tookFullDamage) { this.playHurtSound(source); @@ -636,7 +615,24 @@ if (success) { this.lastDamageSource = source; this.lastDamageStamp = this.level().getGameTime(); -@@ -1282,6 +_,12 @@ +@@ -1300,13 +_,28 @@ + zd = source.getSourcePosition().z() - this.getZ(); + } + +- this.knockback(0.4F, xd, zd, source, damage); ++ // 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, source, damage, 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); + } } public float applyItemBlocking(final ServerLevel level, final DamageSource source, final float damage) { @@ -649,7 +645,7 @@ if (damage <= 0.0F) { return 0.0F; } -@@ -1308,10 +_,12 @@ +@@ -1333,10 +_,12 @@ } float damageBlocked = blocksAttacks.resolveBlockedDamage(source, damage, angle); @@ -657,13 +653,13 @@ 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); + this.blockUsingItem(level, livingEntity, source, damage); } + } // Paper return damageBlocked; } -@@ -1320,6 +_,59 @@ +@@ -1345,6 +_,59 @@ } } @@ -706,7 +702,7 @@ + return blocksAttacks.resolveBlockedDamage(source, damage, angle); + } + -+ public void blockingItemEffects(ServerLevel level, DamageSource source, float damageBlocked) { ++ public void blockingItemEffects(ServerLevel level, DamageSource source, final float damage, float damageBlocked) { + ItemStack blockingWith = this.getItemBlockingWith(); + if (blockingWith == null) return; + @@ -715,7 +711,7 @@ + + 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); ++ this.blockUsingItem(level, livingEntity, source, damage); + } + } + // Paper end - copied from above split by relevant part @@ -723,7 +719,7 @@ public void playSecondaryHurtSound(final DamageSource source) { if (source.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1351,12 +_,24 @@ +@@ -1376,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -739,17 +735,17 @@ + } + // Paper end - only call damage event when actuallyHurt will be called - move out amount computation logic + - protected void blockUsingItem(final ServerLevel level, final LivingEntity attacker) { - attacker.blockedByItem(this); + protected void blockUsingItem(final ServerLevel level, final LivingEntity attacker, final DamageSource source, final float damage) { + attacker.blockedByItem(this, source, damage); } - protected void blockedByItem(final LivingEntity defender) { -- defender.knockback(0.5, defender.getX() - this.getX(), defender.getZ() - this.getZ()); -+ defender.knockback(0.5, defender.getX() - this.getX(), defender.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events + protected void blockedByItem(final LivingEntity defender, final DamageSource source, final float damage) { +- defender.knockback(0.5, defender.getX() - this.getX(), defender.getZ() - this.getZ(), source, damage); ++ defender.knockback(0.5, defender.getX() - this.getX(), defender.getZ() - this.getZ(), source, damage, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events } private boolean checkTotemDeathProtection(final DamageSource killingDamage) { -@@ -1367,18 +_,39 @@ +@@ -1392,18 +_,39 @@ ItemStack protectionItem = null; DeathProtection protection = null; @@ -796,84 +792,62 @@ player.awardStat(Stats.ITEM_USED.get(protectionItem.getItem())); CriteriaTriggers.USED_TOTEM.trigger(player, protectionItem); protectionItem.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); -@@ -1428,6 +_,7 @@ +@@ -1449,10 +_,13 @@ + } + } + ++ public List postDeathEventTasks = new java.util.ArrayList<>(); // Paper - after death event and death (no revive as converted entity in killedEntity) ++ + public void die(final DamageSource source) { if (!this.isRemoved() && !this.dead) { Entity sourceEntity = source.getEntity(); LivingEntity killer = this.getKillCredit(); -+ /* // Paper - move down to make death event cancellable - this is the awardKillScore below ++ Runnable afterEvent = () -> { // Paper if (killer != null) { killer.awardKillScore(this, source); } -@@ -1438,68 +_,147 @@ +@@ -1463,18 +_,38 @@ this.stopUsingItem(); if (!this.level().isClientSide() && this.hasCustomName()) { - LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); + if (org.spigotmc.SpigotConfig.logNamedDeaths) LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot } -+ */ // Paper - move down to make death event cancellable - this is the awardKillScore below - this.dead = true; -- this.getCombatTracker().recheckStatus(); -+ // Paper - moved into if below + this.handleKillingBlow(); + this.getCombatTracker().recheckStatus(); ++ }; // Paper if (this.level() instanceof ServerLevel serverLevel) { -- if (sourceEntity == null || sourceEntity.killedEntity(serverLevel, this, source)) { -+ // Paper - move below into if for onKill + // Paper start -+ if (sourceEntity instanceof net.minecraft.world.entity.monster.Creeper creeper) { // Creeper has logic for drops we need capture -+ creeper.killedEntity((ServerLevel)this.level(), this, source); ++ this.deathDropItems = new java.util.ArrayList<>(); ++ if (sourceEntity != null) { ++ sourceEntity.killedEntityPreEvent(serverLevel, this, source); // safe to ignore the boolean if always true + } -+ org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(serverLevel, source); -+ if (deathEvent == null || !deathEvent.isCancelled()) { -+ //if (killer != null) { // Paper - Fix item duplication and teleport issues; moved to be run earlier in #dropAllDeathLoot before destroying the drop items in CraftEventFactory#callEntityDeathEvent -+ // killer.awardKillScore(this, source); -+ //} -+ // Paper start - clear equipment if event is not cancelled -+ if (this instanceof Mob) { -+ for (EquipmentSlot slot : this.clearedEquipmentSlots) { -+ this.setItemSlot(slot, ItemStack.EMPTY); -+ } -+ this.clearedEquipmentSlots.clear(); -+ } -+ // Paper end -+ -+ if (this.isSleeping()) { -+ this.stopSleeping(); -+ } -+ -+ if (!this.level().isClientSide() && this.hasCustomName()) { -+ if (org.spigotmc.SpigotConfig.logNamedDeaths) LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot -+ } -+ -+ this.getCombatTracker().recheckStatus(); -+ if (sourceEntity != null) { -+ sourceEntity.killedEntity((ServerLevel)this.level(), this, source); -+ } - this.gameEvent(GameEvent.ENTITY_DIE); -- this.dropAllDeathLoot(serverLevel, source); -- this.createWitherRose(killer); -+ } else { ++ this.dropAllDeathLoot(serverLevel, source); ++ org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(serverLevel, this, source, this.deathDropItems, true); ++ this.deathDropItems = null; ++ if (deathEvent.isCancelled()) { + this.dead = false; ++ this.postDeathEventTasks.clear(); + this.setHealth((float) deathEvent.getReviveHealth()); -+ if (sourceEntity instanceof net.minecraft.world.entity.monster.Creeper creeper && creeper.droppedSkulls) { // Creeper has logic for drops skull and need revert that flag -+ creeper.droppedSkulls = false; -+ } ++ return; + } ++ ++ afterEvent.run(); + // Paper end -+ this.createWitherRose(killer); ++ + if (sourceEntity == null || sourceEntity.killedEntity(serverLevel, this, source)) { + this.gameEvent(GameEvent.ENTITY_DIE); +- this.dropAllDeathLoot(serverLevel, source); ++ this.postDeathEventTasks.forEach(Runnable::run); // Paper + this.createWitherRose(killer); } -+ // Paper start -+ if (this.dead) { // Paper ++ this.postDeathEventTasks.clear(); // Paper this.level().broadcastEntityEvent(this, EntityEvent.DEATH); -- } - - this.setPose(Pose.DYING); -+ } -+ // Paper end - } - } + } +@@ -1489,18 +_,23 @@ protected void createWitherRose(final @Nullable LivingEntity killer) { if (this.level() instanceof ServerLevel serverLevel) { boolean var6 = false; @@ -900,47 +874,16 @@ this.level().addFreshEntity(itemEntity); } } - } - } - -- protected void dropAllDeathLoot(final ServerLevel level, final DamageSource source) { -+ // Paper start -+ protected boolean clearEquipmentSlots = true; -+ protected Set clearedEquipmentSlots = new java.util.HashSet<>(); -+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(final ServerLevel level, final DamageSource source) { -+ // Paper end - boolean playerKilled = this.lastHurtByPlayerMemoryTime > 0; -+ this.dropEquipment(level); // CraftBukkit - from below - if (this.shouldDropLoot(level)) { - this.dropFromLootTable(level, source, playerKilled); -+ // Paper start -+ final boolean prev = this.clearEquipmentSlots; -+ this.clearEquipmentSlots = false; -+ this.clearedEquipmentSlots.clear(); -+ // Paper end - this.dropCustomDeathLoot(level, source, playerKilled); -+ this.clearEquipmentSlots = prev; // Paper +@@ -1515,20 +_,30 @@ } -- this.dropEquipment(level); -+ // CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment -+ org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, source, this.drops, () -> { -+ final LivingEntity killer = this.getKillCredit(); -+ if (killer != null) { -+ killer.awardKillScore(this, source); -+ } -+ }); // Paper end -+ if (!deathEvent.isCancelled()) this.postDeathEventCallback(); // Paper - post death event logic -+ this.drops = new java.util.ArrayList<>(); -+ // this.dropEquipment(level); // CraftBukkit - moved up -+ // CraftBukkit end - this.dropExperience(level, source.getEntity()); -+ return deathEvent; // Paper + this.dropEquipment(level); +- this.dropExperience(level, source.getEntity()); ++ this.postDeathEventTasks.add(() -> this.dropExperience(level, source.getEntity())); // Paper } protected void dropEquipment(final ServerLevel level) { } -+ protected void postDeathEventCallback() {} // Paper - method for post death logic that must be ran if the event isn't cancelled - protected void dropExperience(final ServerLevel level, final @Nullable Entity killer) { + public int getExpReward(final ServerLevel level, final @Nullable Entity killer) { // CraftBukkit @@ -959,22 +902,22 @@ + protected void dropExperience(ServerLevel level, @Nullable Entity entity) { + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + 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 ++ ExperienceOrb.awardWithDirection(level, this.position(), 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) { -@@ -1611,9 +_,14 @@ +@@ -1640,9 +_,14 @@ } - public void knockback(double power, double xd, double zd) { + public void knockback(double power, double xd, double zd, final DamageSource source, final float damage, final boolean comesFromEffect) { + // CraftBukkit start - EntityKnockbackEvent -+ this.knockback(power, xd, zd, null, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.UNKNOWN); // Paper - knockback events ++ this.knockback(power, xd, zd, source, damage, comesFromEffect, null, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.UNKNOWN); // Paper - knockback events + } + -+ public void knockback(double power, double xd, double zd, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events ++ public void knockback(double power, double xd, double zd, final DamageSource source, final float damage, final boolean comesFromEffect, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events power *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); - if (!(power <= 0.0)) { - this.needsSync = true; @@ -983,7 +926,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (xd * xd + zd * zd < 1.0E-5F) { -@@ -1622,11 +_,22 @@ +@@ -1651,16 +_,33 @@ } Vec3 deltaVector = new Vec3(xd, 0.0, zd).normalize().scale(power); @@ -1007,7 +950,27 @@ } } -@@ -1717,7 +_,7 @@ + public void knockback(final double power, final double xd, final double zd, final DamageSource source, final float damage) { +- this.knockback(power, xd, zd, source, damage, false); ++ // Paper start - knockback events ++ this.knockback(power, xd, zd, source, damage, null, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.UNKNOWN); ++ } ++ ++ public void knockback(double power, double xd, double zd, final DamageSource source, final float damage, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { ++ this.knockback(power, xd, zd, source, damage, false, attacker, eventCause); ++ // Paper end - knockback events + } + + public void indicateDamage(final double xd, final double zd) { +@@ -1680,6 +_,7 @@ + + public void skipDropExperience() { + this.skipDropExperience = true; ++ this.expToDrop = 0; // Paper + } + + public boolean wasExperienceConsumed() { +@@ -1750,7 +_,7 @@ @Override public boolean isAlive() { @@ -1016,7 +979,7 @@ } public boolean isLookingAtMe( -@@ -1772,10 +_,15 @@ +@@ -1805,10 +_,15 @@ boolean damaged = super.causeFallDamage(effectiveFallDistance, damageModifier, damageSource); int dmg = this.calculateFallDamage(effectiveFallDistance, damageModifier); if (dmg > 0) { @@ -1033,7 +996,7 @@ return true; } else { return damaged; -@@ -1873,7 +_,7 @@ +@@ -1905,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(final DamageSource damageSource, float damage) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1042,7 +1005,7 @@ damage = CombatRules.getDamageAfterAbsorb( this, damage, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1887,7 +_,8 @@ +@@ -1919,7 +_,8 @@ return damage; } @@ -1052,7 +1015,7 @@ int absorbValue = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int absorb = 25 - absorbValue; float v = damage * absorb; -@@ -1925,25 +_,181 @@ +@@ -1957,25 +_,181 @@ return damage; } @@ -1146,6 +1109,7 @@ + if (event.isCancelled()) { + return false; + } ++ float originalDamage = (float)event.getDamage(); + + // Resistance + if (event.getDamage(DamageModifier.RESISTANCE) < 0) { @@ -1161,7 +1125,7 @@ + + // Apply damage to helmet + if (source.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { -+ float helmetDamage = (float)event.getDamage(); ++ float helmetDamage = originalDamage; + helmetDamage += (float)event.getDamage(DamageModifier.INVULNERABILITY_REDUCTION); + helmetDamage += (float)event.getDamage(DamageModifier.BLOCKING); + helmetDamage += (float)event.getDamage(DamageModifier.FREEZING); @@ -1170,7 +1134,7 @@ + + // Apply damage to armor + if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) { -+ float armorDamage = (float)event.getDamage(); ++ float armorDamage = originalDamage; + armorDamage += (float)event.getDamage(DamageModifier.INVULNERABILITY_REDUCTION); + armorDamage += (float)event.getDamage(DamageModifier.BLOCKING); + armorDamage += (float)event.getDamage(DamageModifier.FREEZING); @@ -1180,11 +1144,10 @@ + + // Apply blocking code + if (event.getDamage(DamageModifier.BLOCKING) < 0) { -+ this.blockingItemEffects(level, source, (float)-event.getDamage(DamageModifier.BLOCKING)); ++ this.blockingItemEffects(level, source, originalDamage, (float)-event.getDamage(DamageModifier.BLOCKING)); + } + + boolean human = this instanceof net.minecraft.world.entity.player.Player; -+ float originalDamage = (float)event.getDamage(); + float absorptionModifier = (float)-event.getDamage(DamageModifier.ABSORPTION); + this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F)); + float absorbedDamage = absorptionModifier; @@ -1201,7 +1164,7 @@ + // CraftBukkit start + if (dmg > 0.0F || !human) { + if (human) { -+ // PAIL: Be sure to drag all this code from the EntityHuman subclass each update. ++ // PAIL: Be sure to drag all this code from the Player subclass each update. + ((net.minecraft.world.entity.player.Player)this).causeFoodExhaustion(source.getFoodExhaustion(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent + if (dmg < 3.4028235E37F) { + ((net.minecraft.world.entity.player.Player)this).awardStat(Stats.DAMAGE_TAKEN, Math.round(dmg * 10.0F)); @@ -1227,8 +1190,8 @@ + } + } + -+ if (source.getEntity() instanceof ServerPlayer) { -+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer)source.getEntity(), this, source, originalDamage, dmg, true); // Paper - fix taken/dealt param order ++ if (source.getEntity() instanceof ServerPlayer sourcePlayer) { ++ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(sourcePlayer, this, source, originalDamage, dmg, true); // Paper - fix taken/dealt param order + } + + return !io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.skipVanillaDamageTickWhenShieldBlocked; // Paper - this should always return true, however expose an unsupported setting to flip this to false to enable "shield stunning". @@ -1242,7 +1205,7 @@ } public CombatTracker getCombatTracker() { -@@ -1971,7 +_,17 @@ +@@ -2003,7 +_,17 @@ } public final void setArrowCount(final int count) { @@ -1261,7 +1224,7 @@ } public final int getStingerCount() { -@@ -2021,7 +_,7 @@ +@@ -2053,7 +_,7 @@ @Override public void handleDamageEvent(final DamageSource source) { this.walkAnimation.setSpeed(1.5F); @@ -1270,7 +1233,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; SoundEvent hurtSound = this.getHurtSound(source); -@@ -2150,7 +_,7 @@ +@@ -2182,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1279,7 +1242,7 @@ } protected void updateSwingTime() { -@@ -2257,7 +_,13 @@ +@@ -2294,7 +_,13 @@ } public void setItemSlot(final EquipmentSlot slot, final ItemStack itemStack) { @@ -1294,7 +1257,7 @@ } public float getArmorCoverPercentage() { -@@ -2350,14 +_,27 @@ +@@ -2387,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1322,7 +1285,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(angle) * 0.2, 0.0, Mth.cos(angle) * 0.2)); } -@@ -2544,8 +_,10 @@ +@@ -2597,8 +_,10 @@ } public void stopFallFlying() { @@ -1333,16 +1296,16 @@ } private Vec3 updateFallFlyingMovement(Vec3 movement) { -@@ -2689,7 +_,7 @@ - - public void causeExtraKnockback(final Entity target, final float knockback, final Vec3 oldMovement) { +@@ -2749,7 +_,7 @@ + ) { if (knockback > 0.0F && target instanceof LivingEntity livingTarget) { -- livingTarget.knockback(knockback, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD)); -+ livingTarget.knockback(knockback, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events + livingTarget.knockback( +- knockback, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), damageSource, damage, comesFromEffect ++ knockback, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), damageSource, damage, comesFromEffect, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events + ); this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); } - } -@@ -2765,37 +_,15 @@ +@@ -2826,37 +_,15 @@ profiler.pop(); profiler.push("rangeChecks"); @@ -1389,7 +1352,7 @@ profiler.pop(); if (this.isFallFlying()) { -@@ -2877,6 +_,11 @@ +@@ -2939,6 +_,11 @@ } public void onAttack() { @@ -1401,9 +1364,9 @@ } public void detectEquipmentUpdates() { -@@ -2891,16 +_,39 @@ +@@ -2953,16 +_,39 @@ - private @Nullable Map collectEquipmentChanges() { + protected @Nullable Map collectEquipmentChanges(final Map lastEquipmentItems) { Map changedItems = null; + // Paper start - EntityEquipmentChangedEvent + record EquipmentChangeImpl(org.bukkit.inventory.ItemStack oldItem, org.bukkit.inventory.ItemStack newItem) implements io.papermc.paper.event.entity.EntityEquipmentChangedEvent.EquipmentChange { @@ -1421,7 +1384,7 @@ + // Paper end - EntityEquipmentChangedEvent for (EquipmentSlot slot : EquipmentSlot.VALUES) { - ItemStack previous = this.lastEquipmentItems.get(slot); + ItemStack previous = lastEquipmentItems.get(slot); ItemStack current = this.getItemBySlot(slot); if (this.equipmentHasChanged(previous, current)) { + // Paper start - EntityEquipmentChangedEvent, PlayerArmorChangeEvent @@ -1441,7 +1404,7 @@ AttributeMap attributes = this.getAttributes(); if (!previous.isEmpty()) { this.stopLocationBasedEffects(previous, slot, attributes); -@@ -2925,6 +_,8 @@ +@@ -2987,6 +_,8 @@ } } } @@ -1450,7 +1413,7 @@ } return changedItems; -@@ -2956,7 +_,7 @@ +@@ -3018,7 +_,7 @@ itemsToSend.add(Pair.of(slot, newItemToStore)); this.lastEquipmentItems.put(slot, newItemToStore); }); @@ -1459,9 +1422,9 @@ } protected void tickHeadTurn(final float yBodyRotT) { -@@ -3042,8 +_,10 @@ +@@ -3104,8 +_,10 @@ if (!inWaterAndHasFluidHeight || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { - if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { + if (!this.isInLava() || this.onGround() && this.isInShallowFluid(FluidTags.LAVA)) { if ((this.onGround() || inWaterAndHasFluidHeight && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API this.jumpFromGround(); @@ -1470,7 +1433,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -3084,7 +_,7 @@ +@@ -3146,7 +_,7 @@ profiler.pop(); if (this.level() instanceof ServerLevel serverLevel) { profiler.push("freezing"); @@ -1479,7 +1442,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -3105,6 +_,20 @@ +@@ -3167,6 +_,20 @@ this.pushEntities(); profiler.pop(); @@ -1500,7 +1463,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -3127,6 +_,7 @@ +@@ -3189,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1508,7 +1471,7 @@ this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -3163,10 +_,25 @@ +@@ -3225,10 +_,25 @@ } protected void pushEntities() { @@ -1535,7 +1498,7 @@ if (maxCramming > 0 && pushableEntities.size() > maxCramming - 1 && this.random.nextInt(4) == 0) { int count = 0; -@@ -3182,7 +_,16 @@ +@@ -3244,7 +_,16 @@ } } @@ -1552,7 +1515,7 @@ this.doPush(entity); } } -@@ -3191,16 +_,32 @@ +@@ -3253,16 +_,32 @@ protected void checkAutoSpinAttack(final AABB old, final AABB current) { AABB minmax = old.minmax(current); List entities = this.level().getEntities(this, minmax); @@ -1565,17 +1528,17 @@ + continue; + } + // Paper end - entity attempt spin attack event / hidden entities - skip hidden entities - if (entity instanceof LivingEntity) { + if (entity instanceof LivingEntity livingEntity) { + // Paper start - entity attempt spin attack event / hidden entities - skip hidden entities + if (!new io.papermc.paper.event.entity.EntityAttemptSpinAttackEvent( + getBukkitLivingEntity(), -+ ((LivingEntity) entity).getBukkitLivingEntity() ++ livingEntity.getBukkitLivingEntity() + ).callEvent()) { + ++skippedAttackedEntitiesCounter; + continue; + } + // Paper end - entity attempt spin attack event / hidden entities - skip hidden entities - this.doAutoAttackOnTouch((LivingEntity)entity); + this.doAutoAttackOnTouch(livingEntity); this.autoSpinAttackTicks = 0; this.setDeltaMovement(this.getDeltaMovement().scale(-0.2)); break; @@ -1586,7 +1549,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3223,10 +_,10 @@ +@@ -3285,10 +_,10 @@ } @Override @@ -1600,16 +1563,16 @@ this.dismountVehicle(oldVehicle); } } -@@ -3253,7 +_,7 @@ +@@ -3315,7 +_,7 @@ } public void onItemPickup(final ItemEntity entity) { -- Entity thrower = entity.getOwner(); -+ Entity thrower = EntityReference.getEntity(entity.thrower, this.level()::getGlobalPlayerByUUID, Entity.class); // Paper - check global player list where appropriate - if (thrower instanceof ServerPlayer) { - CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)thrower, entity.getItem(), this); +- if (entity.getOwner() instanceof ServerPlayer serverPlayer) { ++ if (EntityReference.getEntity(entity.thrower, this.level()::getGlobalPlayerByUUID, Entity.class) instanceof ServerPlayer serverPlayer) { // Paper - check global player list where appropriate + CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger(serverPlayer, entity.getItem(), this); } -@@ -3265,7 +_,7 @@ + } +@@ -3326,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1618,7 +1581,7 @@ } } -@@ -3282,7 +_,8 @@ +@@ -3343,7 +_,8 @@ Vec3 from = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 to = new Vec3(target.getX(), eyeHeight, target.getZ()); @@ -1628,7 +1591,7 @@ && this.level().clip(new ClipContext(from, to, blockCollidingContext, fluidCollidingContext, this)).getType() == HitResult.Type.MISS; } -@@ -3302,13 +_,27 @@ +@@ -3363,13 +_,27 @@ @Override public boolean isPickable() { @@ -1659,7 +1622,7 @@ @Override public float getYHeadRot() { -@@ -3339,7 +_,7 @@ +@@ -3400,7 +_,7 @@ } public final void setAbsorptionAmount(final float absorptionAmount) { @@ -1668,7 +1631,7 @@ } protected void internalSetAbsorptionAmount(final float absorptionAmount) { -@@ -3366,6 +_,15 @@ +@@ -3427,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1684,7 +1647,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3413,7 +_,12 @@ +@@ -3474,7 +_,12 @@ protected void updateUsingItem(final ItemStack useItem) { useItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1698,7 +1661,7 @@ this.completeUsingItem(); } } -@@ -3439,10 +_,19 @@ +@@ -3500,10 +_,19 @@ } public void startUsingItem(final InteractionHand hand) { @@ -1720,7 +1683,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3469,7 +_,10 @@ +@@ -3530,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1732,7 +1695,7 @@ } } } -@@ -3512,9 +_,41 @@ +@@ -3573,9 +_,41 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1775,7 +1738,7 @@ } this.stopUsingItem(); -@@ -3546,6 +_,7 @@ +@@ -3607,6 +_,7 @@ ItemStack itemInUsedHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInUsedHand, this.useItem)) { this.useItem = itemInUsedHand; @@ -1783,7 +1746,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3566,7 +_,10 @@ +@@ -3627,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1795,7 +1758,7 @@ } public boolean isBlocking() { -@@ -3589,6 +_,60 @@ +@@ -3650,6 +_,60 @@ return null; } @@ -1856,7 +1819,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3607,6 +_,12 @@ +@@ -3668,6 +_,12 @@ } public boolean randomTeleport(final double xx, final double yy, final double zz, final boolean showParticles) { @@ -1869,7 +1832,7 @@ double xo = this.getX(); double yo = this.getY(); double zo = this.getZ(); -@@ -3629,16 +_,39 @@ +@@ -3690,16 +_,39 @@ } if (landed) { @@ -1912,7 +1875,7 @@ } if (showParticles) { -@@ -3649,7 +_,7 @@ +@@ -3710,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index fdd18daa75bc..1276bcb416dd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -92,6 +_,14 @@ +@@ -96,6 +_,14 @@ import net.minecraft.world.ticks.ContainerSingleItem; import org.jspecify.annotations.Nullable; @@ -15,7 +15,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 @@ +@@ -132,6 +_,7 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; @@ -23,7 +23,7 @@ public GoalSelector targetSelector; private @Nullable LivingEntity target; private final Sensing sensing; -@@ -139,6 +_,8 @@ +@@ -144,6 +_,8 @@ private Leashable.@Nullable LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; @@ -32,7 +32,7 @@ protected Mob(final EntityType type, final Level level) { super(type, level); -@@ -244,7 +_,44 @@ +@@ -249,7 +_,44 @@ } public void setTarget(final @Nullable LivingEntity target) { @@ -78,7 +78,7 @@ } @Override -@@ -383,13 +_,27 @@ +@@ -388,13 +_,27 @@ if (this.isNoAi()) { output.putBoolean("NoAI", this.isNoAi()); } @@ -108,7 +108,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -401,11 +_,24 @@ +@@ -406,12 +_,19 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -124,16 +124,12 @@ @Override protected void dropFromLootTable(final ServerLevel level, final DamageSource source, final boolean playerKilled) { super.dropFromLootTable(level, source, playerKilled); -+ // Paper start - delay loot table removal to after death event -+ } -+ @Override -+ protected void postDeathEventCallback() { -+ if (!this.shouldDropLoot((ServerLevel) this.level())) return; // This callback can only be ran if the level is a ServerLevel -+ // Paper end - delay loot table removal to after death event - this.lootTable = Optional.empty(); +- this.lootTable = Optional.empty(); ++ this.postDeathEventTasks.add(() -> this.lootTable = Optional.empty()); // Paper } -@@ -465,6 +_,11 @@ + @Override +@@ -470,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())) { @@ -145,7 +141,7 @@ this.pickUpItem(serverLevel, entity); } } -@@ -515,18 +_,24 @@ +@@ -520,18 +_,24 @@ protected void pickUpItem(final ServerLevel level, final ItemEntity entity) { ItemStack itemStack = entity.getItem(); @@ -172,7 +168,7 @@ EquipmentSlot slot = this.getEquipmentSlotForItem(itemStack); if (!this.isEquippableInSlot(itemStack, slot)) { return ItemStack.EMPTY; -@@ -539,11 +_,18 @@ +@@ -544,8 +_,13 @@ current = this.getItemBySlot(slot); canReplace = current.isEmpty(); } @@ -187,13 +183,8 @@ + // 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 +_,38 @@ +@@ -685,25 +_,38 @@ return this.isPassenger() || this.isLeashed(); } @@ -245,7 +236,7 @@ this.noActionTime = 0; } } -@@ -681,6 +_,15 @@ +@@ -715,6 +_,15 @@ @Override protected final void serverAiStep() { this.noActionTime++; @@ -261,7 +252,7 @@ ProfilerFiller profiler = Profiler.get(); profiler.push("sensing"); this.sensing.tick(); -@@ -855,14 +_,69 @@ +@@ -885,15 +_,79 @@ public boolean stillValid(final Player player) { return player.getVehicle() == Mob.this || player.isWithinEntityInteractionRange(Mob.this, 4.0); } @@ -317,7 +308,8 @@ } + // Paper start -+ protected boolean shouldSkipLoot(EquipmentSlot slot) { // method to avoid to fallback into the global mob loot logic (e.g. the fox) ++ protected Set droppedEquipmentSlots = new java.util.HashSet<>(); ++ protected boolean guaranteedToDropUndamaged(EquipmentSlot slot) { + return false; + } + // Paper end @@ -326,36 +318,51 @@ protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) { super.dropCustomDeathLoot(level, source, killedByPlayer); ++ this.droppedEquipmentSlots.clear(); // Paper for (EquipmentSlot slot : EquipmentSlot.VALUES) { -+ if (this.shouldSkipLoot(slot)) continue; // Paper ItemStack itemStack = this.getItemBySlot(slot); ++ // Paper start ++ if (this.guaranteedToDropUndamaged(slot)) { ++ this.spawnAtLocation(level, itemStack); ++ this.droppedEquipmentSlots.add(slot); ++ this.postDeathEventTasks.add(() -> this.setItemSlot(slot, ItemStack.EMPTY)); ++ continue; ++ } ++ // Paper end float dropChance = this.dropChances.byEquipment(slot); if (dropChance != 0.0F) { -@@ -882,7 +_,13 @@ + boolean preserve = this.dropChances.isPreserved(slot); +@@ -912,7 +_,8 @@ } this.spawnAtLocation(level, itemStack); -+ if (this.clearEquipmentSlots) { // Paper - this.setItemSlot(slot, ItemStack.EMPTY); -+ // Paper start -+ } else { -+ this.clearedEquipmentSlots.add(slot); -+ } -+ // Paper end +- this.setItemSlot(slot, ItemStack.EMPTY); ++ this.droppedEquipmentSlots.add(slot); // Paper ++ this.postDeathEventTasks.add(() -> this.setItemSlot(slot, ItemStack.EMPTY)); // Paper } } } -@@ -906,7 +_,9 @@ +@@ -931,11 +_,17 @@ + + for (EquipmentSlot slot : EquipmentSlot.VALUES) { + ItemStack itemStack = this.getItemBySlot(slot); +- if (!itemStack.isEmpty()) { ++ if (!itemStack.isEmpty() && (this.deathDropItems == null || !this.droppedEquipmentSlots.contains(slot))) { // Paper - account for already dropped item in dropCustomDeathLoot to not duplicate loot + if (!shouldDrop.test(itemStack)) { slotsPreventedFromDropping.add(slot); } else if (this.dropChances.isPreserved(slot)) { - this.setItemSlot(slot, ItemStack.EMPTY); -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles +- this.setItemSlot(slot, ItemStack.EMPTY); ++ // Paper start ++ if (this.deathDropItems != null) { ++ this.postDeathEventTasks.add(() -> this.setItemSlot(slot, ItemStack.EMPTY)); ++ } else { ++ this.setItemSlot(slot, ItemStack.EMPTY); ++ } ++ // Paper end this.spawnAtLocation(level, itemStack); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles } } - } -@@ -1206,6 +_,22 @@ +@@ -1236,6 +_,22 @@ final EntitySpawnReason spawnReason, final ConversionParams.AfterConversion afterConversion ) { @@ -378,7 +385,7 @@ if (this.isRemoved()) { return null; } -@@ -1216,13 +_,23 @@ +@@ -1246,13 +_,23 @@ } params.type().convert(this, newMob, params); @@ -405,7 +412,7 @@ } return newMob; -@@ -1231,7 +_,17 @@ +@@ -1261,7 +_,17 @@ public @Nullable T convertTo( final EntityType entityType, final ConversionParams params, final ConversionParams.AfterConversion afterConversion ) { @@ -424,7 +431,7 @@ } @Override -@@ -1272,7 +_,17 @@ +@@ -1302,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()) { @@ -443,7 +450,7 @@ } return result; -@@ -1435,7 +_,7 @@ +@@ -1471,7 +_,7 @@ Set availableGoals = this.goalSelector.getAvailableGoals(); List goalInfo = new ArrayList<>(availableGoals.size()); availableGoals.forEach( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch index 36af4acb6414..e7b682bf321c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java -@@ -148,20 +_,20 @@ +@@ -149,20 +_,20 @@ double base = this.getBaseValue(); for (AttributeModifier modifier : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_VALUE)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch index 266bf345f9a1..f63c00d21faa 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/Attributes.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/Attributes.java +++ b/net/minecraft/world/entity/ai/attributes/Attributes.java -@@ -11,7 +_,7 @@ +@@ -14,7 +_,7 @@ public static final Holder ARMOR_TOUGHNESS = register( "armor_toughness", new RangedAttribute("attribute.name.armor_toughness", 0.0, 0.0, 20.0).setSyncable(true) ); @@ -9,7 +9,7 @@ public static final Holder ATTACK_KNOCKBACK = register("attack_knockback", new RangedAttribute("attribute.name.attack_knockback", 0.0, 0.0, 5.0)); public static final Holder ATTACK_SPEED = register( "attack_speed", new RangedAttribute("attribute.name.attack_speed", 4.0, 0.0, 1024.0).setSyncable(true) -@@ -53,10 +_,10 @@ +@@ -63,10 +_,10 @@ ); public static final Holder LUCK = register("luck", new RangedAttribute("attribute.name.luck", 0.0, -1024.0, 1024.0).setSyncable(true)); public static final Holder MAX_ABSORPTION = register( @@ -22,12 +22,12 @@ ); public static final Holder MINING_EFFICIENCY = register( "mining_efficiency", new RangedAttribute("attribute.name.mining_efficiency", 0.0, 0.0, 1024.0).setSyncable(true) -@@ -65,7 +_,7 @@ +@@ -75,7 +_,7 @@ "movement_efficiency", new RangedAttribute("attribute.name.movement_efficiency", 0.0, 0.0, 1.0).setSyncable(true) ); public static final Holder MOVEMENT_SPEED = register( - "movement_speed", new RangedAttribute("attribute.name.movement_speed", 0.7, 0.0, 1024.0).setSyncable(true) + "movement_speed", new RangedAttribute("attribute.name.movement_speed", 0.7, 0.0, org.spigotmc.SpigotConfig.movementSpeed).setSyncable(true) // Spigot ); - public static final Holder OXYGEN_BONUS = register( - "oxygen_bonus", new RangedAttribute("attribute.name.oxygen_bonus", 0.0, 0.0, 1024.0).setSyncable(true) + public static final Holder NAME_TAG_DISTANCE = register( + "name_tag_distance", new RangedAttribute("attribute.name.name_tag_distance", 64.0, 0.0, 512.0).setSyncable(true) 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 3832201368a2..cb992242625e 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 @@ -3,7 +3,7 @@ @@ -110,7 +_,9 @@ Block block = blockState.getBlock(); Block blockBelow = level.getBlockState(this.aboveFarmlandPos.below()).getBlock(); - if (block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockState)) { + if (block instanceof CropBlock cropBlock && cropBlock.isMaxAge(blockState)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(body, this.aboveFarmlandPos, blockState.getFluidState().createLegacyBlock())) { // CraftBukkit // Paper - fix wrong block state level.destroyBlock(this.aboveFarmlandPos, true, body); + } // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch index 2cc236f61e81..2048d85da300 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/behavior/RamTarget.java +++ b/net/minecraft/world/entity/ai/behavior/RamTarget.java -@@ -96,7 +_,7 @@ - DamageSource source = level.damageSources().mobAttack(body); +@@ -97,7 +_,7 @@ float blockedDamage = ramTarget.applyItemBlocking(level, source, damage); float blockingFactor = blockedDamage > 0.0F ? 0.5F : 1.0F; -- ramTarget.knockback(blockingFactor * speedFactor * this.getKnockbackForce.applyAsDouble(body), this.ramDirection.x(), this.ramDirection.z()); -+ ramTarget.knockback(blockingFactor * speedFactor * this.getKnockbackForce.applyAsDouble(body), this.ramDirection.x(), this.ramDirection.z(), body, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + ramTarget.knockback( +- blockingFactor * speedFactor * this.getKnockbackForce.applyAsDouble(body), this.ramDirection.x(), this.ramDirection.z(), source, damage ++ blockingFactor * speedFactor * this.getKnockbackForce.applyAsDouble(body), this.ramDirection.x(), this.ramDirection.z(), source, damage, body, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + ); this.finishRam(level, body); level.playSound(null, body, this.getImpactSound.apply(body), SoundSource.NEUTRAL, 1.0F, 1.0F); - } else if (this.hasRammedHornBreakingBlock(level, body)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch deleted file mode 100644 index 80f6741907df..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java -+++ b/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java -@@ -87,7 +_,9 @@ - inventory.removeItemType(Items.WHEAT, howMuchWheatToUse); - ItemStack breadICantCarry = inventory.addItem(new ItemStack(Items.BREAD, howMuchBreadToMake)); - if (!breadICantCarry.isEmpty()) { -+ body.forceDrops = true; // Paper - Add missing forceDrop toggles - body.spawnAtLocation(level, breadICantCarry, 0.5F); -+ body.forceDrops = false; // Paper - Add missing forceDrop toggles - } - } - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch index 73fb01ecad5e..757271b65985 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -@@ -42,7 +_,7 @@ +@@ -41,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ LevelChunk chunk = this.level.getChunkSource().getChunkNow(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); if (chunk == null) { return null; -@@ -52,7 +_,7 @@ +@@ -51,7 +_,7 @@ pos = this.findSurfacePosition(chunk, pos, reachRange); } @@ -17,8 +17,8 @@ + return super.createPath(pos, entity, reachRange); // Paper - EntityPathfindEvent } - final BlockPos findSurfacePosition(final LevelChunk chunk, BlockPos pos, final int reachRange) { -@@ -91,7 +_,7 @@ + private BlockPos findSurfacePosition(final LevelChunk chunk, BlockPos pos, final int reachRange) { +@@ -90,7 +_,7 @@ @Override public Path createPath(final Entity target, final int reachRange) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/AgeableWaterCreature.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/AgeableWaterCreature.java.patch index fa39b973453d..684d5f00f511 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/AgeableWaterCreature.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/AgeableWaterCreature.java.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/world/entity/animal/AgeableWaterCreature.java +++ b/net/minecraft/world/entity/animal/AgeableWaterCreature.java +@@ -39,7 +_,7 @@ + this.setAirSupply(preTickAirSupply - 1); + if (this.shouldTakeDrowningDamage()) { + this.setAirSupply(0); +- this.hurt(this.damageSources().drown(), 2.0F); ++ this.hurt(this.damageSources().drown().knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.DRYOUT), 2.0F); // Paper + } + } else { + this.setAirSupply(300); @@ -72,6 +_,10 @@ ) { int seaLevel = level.getSeaLevel(); 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 4f0f4e0f07d2..1499eb1343f5 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -99,6 +_,7 @@ +@@ -100,6 +_,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,7 +8,7 @@ public Allay(final EntityType type, final Level level) { super(type, level); -@@ -112,6 +_,12 @@ +@@ -113,6 +_,12 @@ ); } @@ -21,7 +21,7 @@ @Override protected Brain makeBrain(final Brain.Packed packedBrain) { return BRAIN_PROVIDER.makeBrain(this, packedBrain); -@@ -214,7 +_,7 @@ +@@ -215,7 +_,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide() && this.isAlive() && this.tickCount % 10 == 0) { @@ -30,7 +30,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -282,7 +_,12 @@ +@@ -283,7 +_,12 @@ ItemStack interactionItem = player.getItemInHand(hand); ItemStack itemInHand = this.getItemInHand(InteractionHand.MAIN_HAND); if (this.isDancing() && interactionItem.is(ItemTags.DUPLICATES_ALLAYS) && this.canDuplicate()) { @@ -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); -@@ -385,6 +_,7 @@ +@@ -386,6 +_,7 @@ } private boolean shouldStopDancing() { @@ -52,7 +52,22 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), GameEvent.JUKEBOX_PLAY.value().notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); -@@ -437,7 +_,7 @@ +@@ -412,11 +_,12 @@ + @Override + protected void dropEquipment(final ServerLevel level) { + super.dropEquipment(level); +- this.inventory.removeAllItems().forEach(stack -> this.spawnAtLocation(level, stack)); ++ this.inventory.getItems().stream().filter(item -> !item.isEmpty()).forEach(stack -> this.spawnAtLocation(level, stack)); // Paper - delay removal post event - taken from removeAllItems ++ this.postDeathEventTasks.add(this.inventory::clearContent); // Paper - only clear after death event + ItemStack itemStack = this.getItemBySlot(EquipmentSlot.MAINHAND); + if (!itemStack.isEmpty() && !EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { + this.spawnAtLocation(level, itemStack); +- this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); ++ this.postDeathEventTasks.add(() -> this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY)); // Paper + } + } + +@@ -438,7 +_,7 @@ super.readAdditionalSaveData(input); this.readInventoryFromTag(input); this.vibrationData = input.read("listener", VibrationSystem.Data.CODEC).orElseGet(VibrationSystem.Data::new); @@ -61,13 +76,13 @@ } @Override -@@ -456,15 +_,17 @@ +@@ -457,15 +_,17 @@ this.entityData.set(DATA_CAN_DUPLICATE, duplicationCooldown == 0L); } - public void duplicateAllay() { + @Nullable public Allay duplicateAllay() { // CraftBukkit - return allay - Allay allay = EntityType.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); + Allay allay = EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); if (allay != null) { allay.snapTo(this.position()); allay.setPersistenceRequired(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index eebfeca11a01..4dd0f42f21c5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,19 +1,6 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -144,10 +_,12 @@ - ArmadilloAi.updateActivity(this); - profiler.pop(); - if (this.isAlive() && --this.scuteTime <= 0 && this.shouldDropLoot(level)) { -+ this.forceDrops = true; // CraftBukkit - if (this.dropFromGiftLootTable(level, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) { - this.playSound(SoundEvents.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - this.gameEvent(GameEvent.ENTITY_PLACE); - } -+ this.forceDrops = false; // CraftBukkit - - this.scuteTime = this.pickNextScuteDropTime(); - } -@@ -284,8 +_,11 @@ +@@ -293,8 +_,11 @@ } @Override @@ -27,7 +14,7 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (source.getEntity() instanceof LivingEntity) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -296,6 +_,7 @@ +@@ -305,6 +_,7 @@ this.rollOut(); } } @@ -35,13 +22,3 @@ } @Override -@@ -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/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 dbfa9347d75d..4e259c9c0ccd 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 -@@ -269,7 +_,7 @@ +@@ -274,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -9,7 +9,7 @@ } public Axolotl.Variant getVariant() { -@@ -483,10 +_,10 @@ +@@ -488,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 -@@ -564,6 +_,13 @@ +@@ -569,6 +_,13 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.AXOLOTLS_SPAWNABLE_ON); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch index d34102f08aa1..e773cff624cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/bee/Bee.java +++ b/net/minecraft/world/entity/animal/bee/Bee.java -@@ -149,10 +_,26 @@ +@@ -147,10 +_,26 @@ private Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -8,9 +8,9 @@ public Bee(final EntityType type, final Level level) { super(type, level); -- this.moveControl = new FlyingMoveControl(this, 20, true); +- this.moveControl = new FlyingMoveControl<>(this, 20, true); + // Paper start - Fix MC-167279 -+ class BeeFlyingMoveControl extends FlyingMoveControl { ++ class BeeFlyingMoveControl extends FlyingMoveControl { + public BeeFlyingMoveControl(final Mob mob, final int maxTurn, final boolean hoversInPlace) { + super(mob, maxTurn, hoversInPlace); + } @@ -26,9 +26,9 @@ + this.moveControl = new BeeFlyingMoveControl(this, 20, true); + // Paper end - Fix MC-167279 this.lookControl = new Bee.BeeLookControl(this); - this.setPathfindingMalus(PathType.FIRE_IN_NEIGHBOR, -1.0F); + this.setPathfindingMalus(PathType.FIRE, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -199,9 +_,18 @@ +@@ -197,9 +_,18 @@ @Override protected void addAdditionalSaveData(final ValueOutput output) { @@ -47,7 +47,7 @@ output.putBoolean("HasNectar", this.hasNectar()); output.putBoolean("HasStung", this.hasStung()); output.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); -@@ -239,7 +_,7 @@ +@@ -237,7 +_,7 @@ } if (poisonTime > 0) { @@ -56,20 +56,20 @@ } } -@@ -482,7 +_,11 @@ +@@ -474,7 +_,11 @@ if (this.hivePos == null) { return null; } else { -- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); +- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityTypes.BEEHIVE).orElse(null); + // Paper start - move over logic to accommodate isTooFarAway with chunk load check + return this.isTooFarAway(this.hivePos) || this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) == null + ? null -+ : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); ++ : this.level().getBlockEntity(this.hivePos, BlockEntityTypes.BEEHIVE).orElse(null); + // Paper end } } -@@ -514,7 +_,8 @@ +@@ -506,7 +_,8 @@ return this.getFlag(FLAG_ROLL); } @@ -79,7 +79,7 @@ this.setFlag(FLAG_ROLL, rolling); } -@@ -571,7 +_,7 @@ +@@ -563,7 +_,7 @@ if (effect != null) { this.usePlayerItem(player, hand, heldItem); if (!this.level().isClientSide()) { @@ -88,7 +88,7 @@ } return InteractionResult.SUCCESS; -@@ -640,8 +_,9 @@ +@@ -636,8 +_,9 @@ return false; } @@ -99,7 +99,7 @@ } @Override -@@ -981,7 +_,7 @@ +@@ -977,7 +_,7 @@ } } @@ -108,7 +108,7 @@ Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, belowPos, 15); Bee.this.level().setBlockAndUpdate(belowPos, growState); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1005,7 +_,7 @@ +@@ -1001,7 +_,7 @@ @Override protected void alertOther(final Mob other, final LivingEntity hurtByMob) { if (other instanceof Bee && this.mob.hasLineOfSight(hurtByMob)) { @@ -117,7 +117,7 @@ } } } -@@ -1162,7 +_,7 @@ +@@ -1158,7 +_,7 @@ 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/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch index f8b8732305f8..9e30e829889f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -419,12 +_,12 @@ +@@ -426,12 +_,12 @@ boolean couldHeal = this.getHealth() < this.getMaxHealth(); if (couldHeal) { @@ -15,7 +15,7 @@ } boolean couldAgeUp = this.canAgeUp(); -@@ -481,9 +_,13 @@ +@@ -488,9 +_,13 @@ } @Override @@ -31,7 +31,7 @@ } @Override -@@ -580,7 +_,7 @@ +@@ -588,7 +_,7 @@ } public void sitDown() { @@ -40,7 +40,7 @@ this.makeSound(this.getSitDownSound()); this.setPose(Pose.SITTING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -589,7 +_,7 @@ +@@ -597,7 +_,7 @@ } public void standUp() { @@ -49,7 +49,7 @@ this.makeSound(this.getStandUpSound()); this.setPose(Pose.STANDING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -606,6 +_,7 @@ +@@ -614,6 +_,7 @@ } public void standUpInstantly() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch deleted file mode 100644 index 87b77809a3cd..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/world/entity/animal/chicken/Chicken.java -+++ b/net/minecraft/world/entity/animal/chicken/Chicken.java -@@ -128,10 +_,12 @@ - - this.flap = this.flap + this.flapping * 2.0F; - if (this.level() instanceof ServerLevel level && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { -+ this.forceDrops = true; // CraftBukkit - if (this.dropFromGiftLootTable(level, BuiltInLootTables.CHICKEN_LAY, this::spawnAtLocation)) { - this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - this.gameEvent(GameEvent.ENTITY_PLACE); - } -+ this.forceDrops = false; // CraftBukkit - - this.eggTime = this.random.nextInt(6000) + 6000; - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch index 0d24fa52ee3b..8605eec822b8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/cow/AbstractCow.java +++ b/net/minecraft/world/entity/animal/cow/AbstractCow.java -@@ -89,8 +_,15 @@ +@@ -90,8 +_,15 @@ public InteractionResult mobInteract(final Player player, final InteractionHand hand) { ItemStack itemStack = player.getItemInHand(hand); if (itemStack.is(Items.BUCKET) && !this.isBaby()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch index 8f0b1d75a5ef..5d5f48ed88d5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch @@ -1,25 +1,21 @@ --- a/net/minecraft/world/entity/animal/cow/MushroomCow.java +++ b/net/minecraft/world/entity/animal/cow/MushroomCow.java -@@ -116,7 +_,17 @@ +@@ -124,7 +_,13 @@ return InteractionResult.SUCCESS; } else if (itemStack.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel level) { - this.shear(level, SoundSource.PLAYERS, itemStack); -+ // CraftBukkit start -+ // Paper start - custom shear drops ++ // Paper start - call PlayerShearEntityEvent + java.util.List drops = this.generateDefaultDrops(level, itemStack); + org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemStack, hand, drops); -+ if (event != null) { -+ if (event.isCancelled()) return InteractionResult.PASS; -+ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); -+ // Paper end - custom shear drops -+ } -+ // CraftBukkit end -+ this.shear(level, SoundSource.PLAYERS, itemStack, drops); // Paper - custom shear drops ++ if (event.isCancelled()) return InteractionResult.PASS; ++ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); ++ this.shear(level, SoundSource.PLAYERS, itemStack, drops); ++ // Paper end - call PlayerShearEntityEvent this.gameEvent(GameEvent.SHEAR, player); itemStack.hurtAndBreak(1, player, hand.asEquipmentSlot()); } -@@ -170,15 +_,31 @@ +@@ -178,15 +_,31 @@ @Override public void shear(final ServerLevel level, final SoundSource soundSource, final ItemStack tool) { @@ -40,7 +36,7 @@ + public void shear(final ServerLevel level, final SoundSource soundSource, final ItemStack tool, java.util.List drops) { + // Paper end level.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, soundSource, 1.0F, 1.0F); - this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), cow -> { + this.convertTo(EntityTypes.COW, ConversionParams.single(this, false, false), cow -> { level.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); - this.dropFromShearingLootTable(level, BuiltInLootTables.SHEAR_MOOSHROOM, tool, (l, drop) -> { - for (int i = 0; i < drop.getCount(); i++) { 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 9d5f60997782..695cbbb92268 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 @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/dolphin/Dolphin.java +++ b/net/minecraft/world/entity/animal/dolphin/Dolphin.java -@@ -100,6 +_,13 @@ - return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING); +@@ -109,6 +_,13 @@ + return EntityTypes.DOLPHIN.create(level, EntitySpawnReason.BREEDING); } + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() @@ -14,7 +14,7 @@ @Override public float getAgeScale() { return this.isBaby() ? 0.65F : 1.0F; -@@ -185,7 +_,7 @@ +@@ -194,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -23,7 +23,7 @@ } @Override -@@ -218,11 +_,15 @@ +@@ -222,11 +_,15 @@ if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ItemStack itemStack = entity.getItem(); if (this.canHoldItem(itemStack)) { @@ -40,7 +40,7 @@ } } } -@@ -480,7 +_,7 @@ +@@ -489,7 +_,7 @@ @Override public void start() { @@ -49,7 +49,7 @@ } @Override -@@ -499,7 +_,7 @@ +@@ -508,7 +_,7 @@ } if (this.player.isSwimming() && this.player.level().getRandom().nextInt(6) == 0) { @@ -58,7 +58,7 @@ } } } -@@ -571,7 +_,7 @@ +@@ -580,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 28d537a14740..dc8885701bd0 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,17 +1,11 @@ --- a/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java -@@ -74,6 +_,14 @@ +@@ -74,7 +_,7 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); -+ // Paper start - moved to post death logic -+ } -+ } -+ @Override -+ protected void postDeathEventCallback() { -+ super.postDeathEventCallback(); -+ if (this.hasChest()) { -+ // Paper end - moved to post death logic - this.setChest(false); +- this.setChest(false); ++ this.postDeathEventTasks.add(() -> this.setChest(false)); // Paper } } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch index 5e819a923671..e0f8cef5ef29 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/equine/Llama.java +++ b/net/minecraft/world/entity/animal/equine/Llama.java -@@ -74,18 +_,19 @@ +@@ -75,18 +_,19 @@ .scale(0.5F); private boolean didSpit; private @Nullable Llama caravanHead; @@ -22,7 +22,7 @@ this.entityData.set(DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength))); } -@@ -190,12 +_,12 @@ +@@ -191,12 +_,12 @@ heal = 10.0F; if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) { itemUsed = true; @@ -37,7 +37,7 @@ itemUsed = true; } -@@ -307,7 +_,7 @@ +@@ -308,7 +_,7 @@ @Override public int getMaxTemper() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch index 528468435da6..8821f9c9ec95 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/equine/SkeletonHorse.java +++ b/net/minecraft/world/entity/animal/equine/SkeletonHorse.java -@@ -126,7 +_,7 @@ +@@ -127,7 +_,7 @@ public void aiStep() { super.aiStep(); if (!this.isPersistenceRequired() && this.isTrap() && this.trapTime++ >= 18000) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch index 911be680c2b7..dfccc2499122 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/equine/TraderLlama.java +++ b/net/minecraft/world/entity/animal/equine/TraderLlama.java -@@ -92,7 +_,7 @@ +@@ -94,7 +_,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { this.removeLeash(); @@ -9,12 +9,12 @@ } } } -@@ -154,7 +_,7 @@ +@@ -156,7 +_,7 @@ @Override public void start() { - this.mob.setTarget(this.ownerLastHurtBy); + this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER); // CraftBukkit - Entity leashHolder = this.llama.getLeashHolder(); - if (leashHolder instanceof WanderingTrader) { - this.timestamp = ((WanderingTrader)leashHolder).getLastHurtByMobTimestamp(); + if (this.llama.getLeashHolder() instanceof WanderingTrader wanderingTrader) { + this.timestamp = wanderingTrader.getLastHurtByMobTimestamp(); + } 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 d2befdb881c0..f04eab847b55 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/feline/Cat.java +++ b/net/minecraft/world/entity/animal/feline/Cat.java -@@ -400,6 +_,11 @@ +@@ -412,6 +_,11 @@ if (itemStack.is(ItemTags.CAT_COLLAR_DYES)) { DyeColor color = itemStack.get(DataComponents.DYE); if (color != null && color != this.getCollarColor()) { @@ -12,7 +12,7 @@ if (!this.level().isClientSide()) { this.setCollarColor(color); itemStack.consume(1, player); -@@ -471,7 +_,7 @@ +@@ -483,7 +_,7 @@ } private void tryToTame(final Player player) { @@ -21,7 +21,7 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -603,15 +_,20 @@ +@@ -615,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -46,7 +46,7 @@ ); } -@@ -637,7 +_,7 @@ +@@ -649,7 +_,7 @@ } private static class CatTemptGoal extends TemptGoal { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch index 1b4bd7317427..442abb3c5238 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/feline/Ocelot.java +++ b/net/minecraft/world/entity/animal/feline/Ocelot.java -@@ -129,7 +_,7 @@ +@@ -136,7 +_,7 @@ @Override public boolean removeWhenFarAway(final double distSqr) { @@ -9,7 +9,7 @@ } public static AttributeSupplier.Builder createAttributes() { -@@ -162,7 +_,7 @@ +@@ -169,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemStack) && player.distanceToSqr(this) < 9.0) { this.usePlayerItem(player, hand, itemStack); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch index e4f46df3d56f..107111dc5bf6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/world/entity/animal/fish/WaterAnimal.java +++ b/net/minecraft/world/entity/animal/fish/WaterAnimal.java +@@ -41,7 +_,7 @@ + this.setAirSupply(preTickAirSupply - 1); + if (this.shouldTakeDrowningDamage()) { + this.setAirSupply(0); +- this.hurtServer(level, this.damageSources().drown(), 2.0F); ++ this.hurtServer(level, this.damageSources().drown().knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.DRYOUT), 2.0F); // Paper + } + } else { + this.setAirSupply(300); @@ -76,6 +_,10 @@ ) { int seaLevel = level.getSeaLevel(); 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 0a4c063705b7..f99b412f3574 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 -@@ -446,7 +_,7 @@ +@@ -453,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(); -@@ -463,6 +_,12 @@ +@@ -470,6 +_,12 @@ } public void setSitting(final boolean value) { @@ -22,7 +22,7 @@ this.setFlag(FLAG_SITTING, value); } -@@ -522,19 +_,20 @@ +@@ -529,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)); -@@ -545,7 +_,7 @@ +@@ -552,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; } } -@@ -636,12 +_,12 @@ +@@ -643,12 +_,12 @@ } @Override @@ -70,45 +70,22 @@ } private void wakeUp() { -@@ -702,15 +_,33 @@ - return this.getTrustedEntities().anyMatch(trusted -> trusted.matches(entity)); +@@ -710,7 +_,13 @@ } -- @Override + @Override - protected void dropAllDeathLoot(final ServerLevel level, final DamageSource source) { -+ // Paper start - handle the bitten item separately like vanilla -+ @Override -+ protected boolean shouldSkipLoot(EquipmentSlot slot) { ++ // Paper start - Fix MC-153010 (dropCustomDeathLoot is only called when shouldDropLoot = true) ++ protected boolean guaranteedToDropUndamaged(final net.minecraft.world.entity.EquipmentSlot slot) { + return slot == EquipmentSlot.MAINHAND; + } -+ // Paper end + -+ @Override -+ // Paper start - Cancellable death event -+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(final ServerLevel level, final DamageSource source) { ++ protected void dropAllDeathLootDisabled(final ServerLevel level, final DamageSource source) { ++ // Paper end ItemStack itemStack = this.getItemBySlot(EquipmentSlot.MAINHAND); -- if (!itemStack.isEmpty()) { -+ boolean releaseMouth = false; -+ if (!itemStack.isEmpty() && level.getGameRules().get(GameRules.MOB_DROPS)) { // Fix MC-153010 + if (!itemStack.isEmpty()) { this.spawnAtLocation(level, itemStack); -+ releaseMouth = true; -+ } -+ -+ org.bukkit.event.entity.EntityDeathEvent deathEvent = super.dropAllDeathLoot(level, source); -+ // Below is code to drop -+ if (deathEvent == null || deathEvent.isCancelled()) return deathEvent; -+ -+ if (releaseMouth) { -+ // Paper end - this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); - } - -- super.dropAllDeathLoot(level, source); -+ return deathEvent; // Paper - Cancellable death event - } - - public static boolean isPathClear(final Fox fox, final LivingEntity target) { -@@ -883,6 +_,19 @@ +@@ -890,6 +_,19 @@ offspring.addTrustedEntity(partnerLoveCause); } @@ -128,7 +105,7 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(loveCause, this.animal, this.partner, offspring); -@@ -892,14 +_,12 @@ +@@ -899,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -146,7 +123,7 @@ ); } } -@@ -963,6 +_,7 @@ +@@ -970,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/frog/Frog.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch index 432dea63b573..c4bf7df52e8c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/Frog.java +++ b/net/minecraft/world/entity/animal/frog/Frog.java -@@ -257,7 +_,12 @@ +@@ -254,7 +_,12 @@ @Override public void spawnChildFromBreeding(final ServerLevel level, final Animal partner) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch index 1511a5b2ac95..02fdda0f6b98 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -127,7 +_,7 @@ +@@ -128,7 +_,7 @@ entityData.define(AGE_LOCKED, false); } @@ -9,7 +9,7 @@ this.entityData.set(AGE_LOCKED, locked); } -@@ -157,6 +_,11 @@ +@@ -158,6 +_,11 @@ this.feed(player, itemStack); return InteractionResult.SUCCESS; } else if (AgeableMob.canUseGoldenDandelion(itemStack, true, this.ageLockParticleTimer, this)) { @@ -21,12 +21,12 @@ AgeableMob.setAgeLocked(this, this::isAgeLocked, player, itemStack, mob -> this.setAgeLockedData()); return InteractionResult.SUCCESS; } else { -@@ -236,12 +_,17 @@ +@@ -237,12 +_,17 @@ private void ageUp() { if (this.level() instanceof ServerLevel serverLevel) { -- this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), frog -> { -+ Frog converted = this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), frog -> { // CraftBukkit +- this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), frog -> { ++ Frog converted = this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), frog -> { // CraftBukkit frog.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(frog.blockPosition()), EntitySpawnReason.CONVERSION, null); frog.setPersistenceRequired(); frog.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); 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 9f0ecb43c037..4b5a49dc59d7 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -213,8 +_,16 @@ +@@ -219,8 +_,16 @@ public InteractionResult mobInteract(final Player player, final InteractionHand hand) { ItemStack heldItem = player.getItemInHand(hand); if (heldItem.is(Items.BUCKET) && !this.isBaby()) { @@ -18,7 +18,7 @@ player.setItemInHand(hand, bucketOrMilkBucket); return InteractionResult.SUCCESS; } -@@ -330,8 +_,7 @@ +@@ -337,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); @@ -28,7 +28,7 @@ } public boolean isScreamingGoat() { -@@ -352,4 +_,15 @@ +@@ -359,4 +_,15 @@ ) { 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/golem/CopperGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch index a9689ab74200..986baf7bfd40 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 @@ -20,35 +20,35 @@ private int idleAnimationStartTick = 0; private final AnimationState idleAnimationState = new AnimationState(); private final AnimationState interactionGetItemAnimationState = new AnimationState(); -@@ -218,7 +_,15 @@ +@@ -218,7 +_,13 @@ Level level = this.level(); if (itemStack.is(Items.SHEARS) && this.readyForShearing()) { if (level instanceof ServerLevel serverLevel) { - this.shear(serverLevel, SoundSource.PLAYERS, itemStack); -+ // Paper start ++ // Paper start - call PlayerShearEntityEvent + java.util.List drops = this.generateDefaultDrops(serverLevel, itemStack); + org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemStack, hand, drops); -+ if (event != null) { -+ if (event.isCancelled()) return InteractionResult.PASS; -+ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); -+ } ++ if (event.isCancelled()) return InteractionResult.PASS; ++ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); + this.shear(serverLevel, SoundSource.PLAYERS, itemStack, drops); -+ // Paper end ++ // Paper end - call PlayerShearEntityEvent this.gameEvent(GameEvent.SHEAR, player); itemStack.hurtAndBreak(1, player, hand); } -@@ -287,20 +_,27 @@ +@@ -287,8 +_,10 @@ private void turnToStatue(final ServerLevel level) { BlockPos pos = this.blockPosition(); - level.setBlock( - pos, + // Paper start - call EntityChangeBlockEvent -+ //level.setBlock( -+ // pos, ++ // level.setBlock( ++ // pos, + BlockState newState = - Blocks.OXIDIZED_COPPER_GOLEM_STATUE - .defaultBlockState() + Blocks.COPPER_GOLEM_STATUE + .weathering() + .oxidized() +@@ -296,13 +_,18 @@ .setValue( CopperGolemStatueBlock.POSE, CopperGolemStatueBlock.Pose.values()[this.random.nextInt(0, CopperGolemStatueBlock.Pose.values().length)] ) @@ -56,8 +56,8 @@ - Block.UPDATE_ALL - ); + .setValue(CopperGolemStatueBlock.FACING, Direction.fromYRot(this.getYRot())); -+ // Block.UPDATE_ALL -+ //); ++ // Block.UPDATE_ALL ++ // ); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, newState)) { + return; + } @@ -71,7 +71,7 @@ this.playSound(SoundEvents.COPPER_GOLEM_BECOME_STATUE); if (this.isLeashed()) { if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { -@@ -430,12 +_,32 @@ +@@ -432,12 +_,30 @@ } @Override @@ -84,9 +84,7 @@ - this.spawnAtLocation(level, itemStack, 1.5F); - } + for (ItemStack drop : drops) { -+ this.forceDrops = true; + this.spawnAtLocation(level, drop, 1.5F); -+ this.forceDrops = false; + } + } + @@ -108,7 +106,7 @@ @Override public boolean readyForShearing() { -@@ -449,9 +_,13 @@ +@@ -451,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 88a50e071cab..b5907d699cdb 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/golem/IronGolem.java +++ b/net/minecraft/world/entity/animal/golem/IronGolem.java -@@ -106,7 +_,7 @@ +@@ -107,7 +_,7 @@ @Override protected void doPush(final Entity entity) { if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) { @@ -9,7 +9,7 @@ } super.doPush(entity); -@@ -304,7 +_,7 @@ +@@ -305,7 +_,7 @@ BlockPos pos = this.blockPosition(); BlockPos belowPos = pos.below(); BlockState below = level.getBlockState(belowPos); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch index 00b0d31e243c..5f42e0859876 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch @@ -18,28 +18,24 @@ this.level().gameEvent(GameEvent.BLOCK_PLACE, snowPos, GameEvent.Context.of(this, snow)); } } -@@ -138,7 +_,19 @@ +@@ -138,7 +_,15 @@ ItemStack itemStack = player.getItemInHand(hand); if (itemStack.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel level) { - this.shear(level, SoundSource.PLAYERS, itemStack); -+ // CraftBukkit start -+ // Paper start - custom shear drops ++ // Paper start - call PlayerShearEntityEvent + java.util.List drops = this.generateDefaultDrops(level, itemStack); + org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemStack, hand, drops); -+ if (event != null) { -+ if (event.isCancelled()) { -+ return InteractionResult.PASS; -+ } -+ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); -+ // Paper end - custom shear drops ++ if (event.isCancelled()) { ++ return InteractionResult.PASS; + } -+ // CraftBukkit end -+ this.shear(level, SoundSource.PLAYERS, itemStack, drops); // Paper - custom shear drops ++ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); ++ this.shear(level, SoundSource.PLAYERS, itemStack, drops); ++ // Paper end - call PlayerShearEntityEvent this.gameEvent(GameEvent.SHEAR, player); itemStack.hurtAndBreak(1, player, hand.asEquipmentSlot()); } -@@ -151,9 +_,31 @@ +@@ -151,9 +_,29 @@ @Override public void shear(final ServerLevel level, final SoundSource soundSource, final ItemStack tool) { @@ -64,9 +60,7 @@ - this.dropFromShearingLootTable(level, BuiltInLootTables.SHEAR_SNOW_GOLEM, tool, (l, drop) -> this.spawnAtLocation(l, drop, this.getEyeHeight())); + // Paper start - custom shear drops + drops.forEach(drop -> { -+ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(level, drop, this.getEyeHeight()); -+ this.forceDrops = false; // CraftBukkit + }); + // Paper end - custom shear drops } 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 270b632f02a4..80cb1a340908 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 -@@ -299,7 +_,7 @@ +@@ -308,7 +_,7 @@ @Override protected void addPassenger(final Entity passenger) { if (!this.isVehicle()) { @@ -9,7 +9,7 @@ } super.addPassenger(passenger); -@@ -313,16 +_,21 @@ +@@ -322,16 +_,21 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch index a17b2fd11b2b..657730a25e84 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/nautilus/Nautilus.java +++ b/net/minecraft/world/entity/animal/nautilus/Nautilus.java -@@ -111,8 +_,14 @@ +@@ -125,8 +_,14 @@ @Override public int getMaxAirSupply() { @@ -17,7 +17,7 @@ protected void handleAirSupply(final ServerLevel level, final int preTickAirSupply) { if (this.isAlive() && !this.isInWater()) { -@@ -122,7 +_,7 @@ +@@ -136,7 +_,7 @@ this.hurtServer(level, this.damageSources().dryOut(), 2.0F); } } else { 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 91e231893a2b..c3634055ae58 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 -@@ -132,6 +_,7 @@ +@@ -134,6 +_,7 @@ } public void sit(final boolean value) { @@ -8,7 +8,7 @@ this.setFlag(FLAG_SIT, value); } -@@ -516,24 +_,28 @@ +@@ -518,7 +_,9 @@ for (Panda panda : level.getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0))) { if (!panda.isBaby() && panda.onGround() && !panda.isInWater() && panda.canPerformAction()) { @@ -18,12 +18,7 @@ } } - if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.MOB_DROPS)) { -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.PANDA_SNEEZE, this::spawnAtLocation); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles - } - } +@@ -529,13 +_,13 @@ @Override protected void pickUpItem(final ServerLevel level, final ItemEntity entity) { @@ -39,7 +34,7 @@ } } -@@ -632,8 +_,9 @@ +@@ -634,8 +_,9 @@ } if (!this.level().isClientSide() && this.getAge() == 0 && this.canFallInLove()) { @@ -50,17 +45,7 @@ } else { if (!(this.level() instanceof ServerLevel level) || this.isSitting() || this.isInWater()) { return InteractionResult.PASS; -@@ -643,7 +_,9 @@ - this.eat(true); - ItemStack pandasCurrentItem = this.getItemBySlot(EquipmentSlot.MAINHAND); - if (!pandasCurrentItem.isEmpty() && !player.hasInfiniteMaterials()) { -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.spawnAtLocation(level, pandasCurrentItem); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles - } - - this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(interactionItemStack.getItem(), 1)); -@@ -867,7 +_,7 @@ +@@ -869,7 +_,7 @@ @Override protected void alertOther(final Mob other, final LivingEntity hurtByMob) { if (other instanceof Panda && other.isAggressive()) { @@ -69,13 +54,3 @@ } } } -@@ -1094,7 +_,9 @@ - public void stop() { - ItemStack itemStack = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); - if (!itemStack.isEmpty()) { -+ Panda.this.forceDrops = true; // Paper - Add missing forceDrop toggles - Panda.this.spawnAtLocation(getServerLevel(Panda.this.level()), itemStack); -+ Panda.this.forceDrops = false; // Paper - Add missing forceDrop toggles - Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); - int waitSeconds = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10; - this.cooldown = Panda.this.tickCount + waitSeconds * 20; 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 a2a9d4c236a9..b8f43102ffa7 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,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/pig/Pig.java +++ b/net/minecraft/world/entity/animal/pig/Pig.java -@@ -196,7 +_,14 @@ - ZombifiedPiglin zombifiedPiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), zp -> { +@@ -204,7 +_,14 @@ + ZombifiedPiglin zombifiedPiglin = this.convertTo(EntityTypes.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/animal/rabbit/Rabbit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch index 0deae6397e12..af6ebe6768c3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/rabbit/Rabbit.java +++ b/net/minecraft/world/entity/animal/rabbit/Rabbit.java -@@ -113,7 +_,7 @@ +@@ -114,7 +_,7 @@ super(type, level); this.jumpControl = new Rabbit.RabbitJumpControl(this); - this.moveControl = new Rabbit.RabbitMoveControl(this); + this.moveControl = new Rabbit.RabbitMoveControl<>(this); - this.setSpeedModifier(0.0); + // this.setSpeedModifier(0.0); // CraftBukkit } @Override -@@ -637,9 +_,11 @@ +@@ -636,9 +_,11 @@ if (this.canRaid && block instanceof CarrotBlock) { int carrotAge = blockState.getValue(CarrotBlock.AGE); if (carrotAge == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch index c9a21385ac4b..f3ea0ce45ba9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch @@ -1,27 +1,23 @@ --- a/net/minecraft/world/entity/animal/sheep/Sheep.java +++ b/net/minecraft/world/entity/animal/sheep/Sheep.java -@@ -140,7 +_,19 @@ +@@ -148,7 +_,15 @@ ItemStack itemStack = player.getItemInHand(hand); if (itemStack.is(Items.SHEARS)) { if (this.level() instanceof ServerLevel level && this.readyForShearing()) { - this.shear(level, SoundSource.PLAYERS, itemStack); -+ // CraftBukkit start -+ // Paper start - custom shear drops ++ // Paper start - call PlayerShearEntityEvent + java.util.List drops = this.generateDefaultDrops(level, itemStack); + org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemStack, hand, drops); -+ if (event != null) { -+ if (event.isCancelled()) { -+ return InteractionResult.PASS; -+ } -+ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); -+ // Paper end - custom shear drops ++ if (event.isCancelled()) { ++ return InteractionResult.PASS; + } -+ // CraftBukkit end -+ this.shear(level, SoundSource.PLAYERS, itemStack, drops); // Paper - custom shear drops ++ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); ++ this.shear(level, SoundSource.PLAYERS, itemStack, drops); ++ // Paper end - call PlayerShearEntityEvent this.gameEvent(GameEvent.SHEAR, player); itemStack.hurtAndBreak(1, player, hand.asEquipmentSlot()); return InteractionResult.SUCCESS_SERVER; -@@ -154,14 +_,28 @@ +@@ -162,14 +_,26 @@ @Override public void shear(final ServerLevel level, final SoundSource soundSource, final ItemStack tool) { @@ -33,7 +29,7 @@ + public java.util.List generateDefaultDrops(final ServerLevel level, final ItemStack tool) { + final java.util.List drops = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); + this.dropFromShearingLootTable(level, BuiltInLootTables.SHEAR_SHEEP, tool, (ignored, stack) -> { -+ for (int i = 0; i < stack.getCount(); ++i) drops.add(stack.copyWithCount(1)); ++ for (int i = 0; i < stack.getCount(); ++i) drops.add(stack.copyWithCount(1)); + }); + return drops; + } @@ -51,13 +47,11 @@ - ItemEntity entity = this.spawnAtLocation(l, drop.copyWithCount(1), 1.0F); + drops.forEach(itemStack -> { // Paper - custom drops - loop in generated default drops + { // Paper - custom drops - loop in generated default drops -+ this.forceDrops = true; // CraftBukkit + ItemEntity entity = this.spawnAtLocation(level, itemStack, 1.0F); // Paper - custom drops - copy already done above -+ this.forceDrops = false; // CraftBukkit if (entity != null) { entity.setDeltaMovement( entity.getDeltaMovement() -@@ -279,6 +_,7 @@ +@@ -292,6 +_,7 @@ @Override public void ate() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index 15676ec795c0..01f9842b4b43 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -288,6 +_,13 @@ +@@ -289,6 +_,13 @@ this.dropFromGiftLootTable(level, BuiltInLootTables.SNIFFER_DIGGING, (l, itemStack) -> { ItemEntity entity = new ItemEntity(this.level(), head.getX(), head.getY(), head.getZ(), itemStack); entity.setDefaultPickUpDelay(); @@ -14,7 +14,7 @@ l.addFreshEntity(entity); }); this.playSound(SoundEvents.SNIFFER_DROP_SEED, 1.0F, 1.0F); -@@ -346,12 +_,17 @@ +@@ -347,12 +_,17 @@ @Override public void spawnChildFromBreeding(final ServerLevel level, final Animal partner) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch deleted file mode 100644 index 6cb1af19242e..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/animal/squid/Squid.java -+++ b/net/minecraft/world/entity/animal/squid/Squid.java -@@ -51,7 +_,7 @@ - - public Squid(final EntityType type, final Level level) { - super(type, level); -- this.random.setSeed(this.getId()); -+ // this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random - this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; - } - diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch index 607e65c3a8fa..262cf654407b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch @@ -1,16 +1,6 @@ --- a/net/minecraft/world/entity/animal/turtle/Turtle.java +++ b/net/minecraft/world/entity/animal/turtle/Turtle.java -@@ -256,7 +_,9 @@ - protected void ageBoundaryReached() { - super.ageBoundaryReached(); - if (!this.isBaby() && this.level() instanceof ServerLevel level && level.getGameRules().get(GameRules.MOB_DROPS)) { -+ this.forceDrops = true; // CraftBukkit - this.dropFromGiftLootTable(level, BuiltInLootTables.TURTLE_GROW, this::spawnAtLocation); -+ this.forceDrops = false; // CraftBukkit - } - } - -@@ -277,7 +_,7 @@ +@@ -282,7 +_,7 @@ @Override public void thunderHit(final ServerLevel level, final LightningBolt lightningBolt) { @@ -19,7 +9,7 @@ } @Override -@@ -304,6 +_,10 @@ +@@ -309,6 +_,10 @@ if (loveCause == null && this.partner.getLoveCause() != null) { loveCause = this.partner.getLoveCause(); } @@ -30,7 +20,7 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); -@@ -317,7 +_,7 @@ +@@ -322,7 +_,7 @@ this.partner.resetLove(); RandomSource random = this.animal.getRandom(); if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_DROPS)) { @@ -39,7 +29,7 @@ } } } -@@ -340,7 +_,7 @@ +@@ -345,7 +_,7 @@ && ( this.turtle.hasEgg() || this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 && !this.turtle.homePos.closerToCenterThan(this.turtle.position(), 64.0) @@ -48,7 +38,7 @@ } @Override -@@ -448,14 +_,20 @@ +@@ -453,14 +_,20 @@ BlockPos turtlePos = this.turtle.blockPosition(); if (!this.turtle.isInWater() && this.isReachedTarget()) { if (this.turtle.layEggCounter < 1) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index baad5b92c99b..4fc1452f7f68 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/wolf/Wolf.java +++ b/net/minecraft/world/entity/animal/wolf/Wolf.java -@@ -396,15 +_,18 @@ +@@ -404,15 +_,18 @@ return false; } @@ -22,7 +22,7 @@ ItemStack armorBefore = this.getBodyArmorItem(); int damageBefore = armorBefore.getDamageValue(); int maxDamage = armorBefore.getMaxDamage(); -@@ -416,6 +_,7 @@ +@@ -424,6 +_,7 @@ ); } } @@ -30,7 +30,7 @@ } private boolean canArmorAbsorb(final DamageSource source) { -@@ -426,7 +_,7 @@ +@@ -434,7 +_,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0); @@ -39,7 +39,7 @@ } else { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0); } -@@ -476,7 +_,7 @@ +@@ -484,7 +_,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -48,7 +48,7 @@ return InteractionResult.SUCCESS.withoutItem(); } -@@ -485,6 +_,25 @@ +@@ -493,6 +_,25 @@ DyeColor color = itemStack.get(DataComponents.DYE); if (color != null && color != this.getCollarColor()) { @@ -74,7 +74,7 @@ this.setCollarColor(color); itemStack.consume(1, player); return InteractionResult.SUCCESS; -@@ -499,7 +_,7 @@ +@@ -507,7 +_,7 @@ } 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/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch index 6c255ac04f2e..f7ef5cdbb983 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java -@@ -26,6 +_,7 @@ +@@ -27,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; @@ -8,7 +8,7 @@ public EndCrystal(final EntityType type, final Level level) { super(type, level); -@@ -57,21 +_,37 @@ +@@ -58,21 +_,37 @@ if (this.level() instanceof ServerLevel) { BlockPos pos = this.blockPosition(); if (((ServerLevel)this.level()).getDragonFight() != null && this.level().getBlockState(pos).isAir()) { @@ -48,7 +48,7 @@ } @Override -@@ -95,10 +_,24 @@ +@@ -96,10 +_,24 @@ } if (!this.isRemoved()) { 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 b7c12399fc8e..9713e242bdf9 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -86,6 +_,10 @@ +@@ -88,6 +_,10 @@ private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); @@ -10,8 +10,8 @@ + // Paper end public EnderDragon(final EntityType type, final Level level) { - super(EntityType.ENDER_DRAGON, level); -@@ -101,6 +_,7 @@ + super(EntityTypes.ENDER_DRAGON, level); +@@ -103,6 +_,7 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -19,7 +19,7 @@ } public void setDragonFight(final EnderDragonFight fight) { -@@ -119,6 +_,19 @@ +@@ -121,6 +_,19 @@ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0).add(Attributes.CAMERA_DISTANCE, 16.0); } @@ -39,7 +39,7 @@ @Override public boolean isFlapping() { float flap = Mth.cos(this.flapTime * (Mth.PI * 2.0F)); -@@ -210,7 +_,7 @@ +@@ -212,7 +_,7 @@ } Vec3 targetLocation = currentPhase.getFlyTargetLocation(); @@ -48,7 +48,7 @@ double xdd = targetLocation.x - this.getX(); double ydd = targetLocation.y - this.getY(); double zdd = targetLocation.z - this.getZ(); -@@ -359,7 +_,12 @@ +@@ -361,7 +_,12 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -62,7 +62,7 @@ } } -@@ -389,7 +_,7 @@ +@@ -391,7 +_,7 @@ double xd = entity.getX() - xm; double zd = entity.getZ() - zm; double dd = Math.max(xd * xd + zd * zd, 0.1); @@ -71,7 +71,7 @@ if (!this.phaseManager.getCurrentPhase().isSitting() && livingTarget.getLastHurtByMobTimestamp() < entity.tickCount - 2) { DamageSource damageSource = this.damageSources().mobAttack(this); entity.hurtServer(serverLevel, damageSource, 5.0F); -@@ -422,6 +_,7 @@ +@@ -424,6 +_,7 @@ int z1 = Mth.floor(bb.maxZ); boolean hitWall = false; boolean destroyedBlock = false; @@ -79,7 +79,7 @@ for (int x = x0; x <= x1; x++) { for (int y = y0; y <= y1; y++) { -@@ -430,7 +_,11 @@ +@@ -432,7 +_,11 @@ BlockState state = level.getBlockState(blockPos); if (!state.isAir() && !state.is(BlockTags.DRAGON_TRANSPARENT)) { if (level.getGameRules().get(GameRules.MOB_GRIEFING) && !state.is(BlockTags.DRAGON_IMMUNE)) { @@ -92,7 +92,7 @@ } else { hitWall = true; } -@@ -439,6 +_,59 @@ +@@ -441,6 +_,59 @@ } } @@ -152,16 +152,23 @@ if (destroyedBlock) { BlockPos randomPos = new BlockPos( x0 + this.random.nextInt(x1 - x0 + 1), y0 + this.random.nextInt(y1 - y0 + 1), z0 + this.random.nextInt(z1 - z0 + 1) -@@ -501,7 +_,15 @@ +@@ -498,15 +_,20 @@ + } + + @Override +- public void knockback(final double power, final double xd, final double zd, final DamageSource source, final float damage) { ++ public void knockback(final double power, final double xd, final double zd, final DamageSource source, final float damage, final boolean comesFromEffect, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events + if (!this.phaseManager.getCurrentPhase().isSitting()) { +- super.knockback(power, xd, zd, source, damage); ++ super.knockback(power, xd, zd, source, damage, comesFromEffect, attacker, eventCause); // Paper - knockback events + } + } @Override public void kill(final ServerLevel level) { - this.remove(Entity.RemovalReason.KILLED); + // Paper start - Fire entity death event -+ this.silentDeath = true; -+ org.bukkit.event.entity.EntityDeathEvent deathEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, this.damageSources().genericKill()); -+ if (deathEvent.isCancelled()) { -+ this.silentDeath = false; // Reset to default if event was cancelled ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(level, this, this.damageSources().genericKill())) { + return; + } + this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause @@ -169,25 +176,17 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -523,18 +_,41 @@ - this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + xo, this.getY() + 2.0 + yo, this.getZ() + zo, 0.0, 0.0, 0.0); - } - -+ // CraftBukkit start - SPIGOT-2420: Moved up to #getExpReward method -+ /* - int xpCount = 500; +@@ -532,14 +_,33 @@ if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { xpCount = 12000; } -+ */ -+ int xpCount = this.expToDrop; -+ // CraftBukkit end ++ xpCount = this.expToDrop; // CraftBukkit - SPIGOT-2420: Moved up to #getExpReward method if (this.level() instanceof ServerLevel level) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && level.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(level, this.position(), Mth.floor(xpCount * 0.08F)); + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp -+ ExperienceOrb.awardWithDirection(level, this.position(), net.minecraft.world.phys.Vec3.ZERO, Mth.floor(xpCount * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper ++ ExperienceOrb.awardWithDirection(level, this.position(), Vec3.ZERO, Mth.floor(xpCount * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper } if (this.dragonDeathTime == 1 && !this.isSilent()) { @@ -214,14 +213,14 @@ } } -@@ -547,15 +_,15 @@ +@@ -552,15 +_,15 @@ } if (this.dragonDeathTime >= 200 && this.level() instanceof ServerLevel level) { - if (level.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(level, this.position(), Mth.floor(xpCount * 0.2F)); + if (true) { // Paper - SPIGOT-2420: Already checked for the game rule when calculating the xp -+ ExperienceOrb.awardWithDirection(level, this.position(), net.minecraft.world.phys.Vec3.ZERO, Mth.floor(xpCount * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper ++ ExperienceOrb.awardWithDirection(level, this.position(), Vec3.ZERO, Mth.floor(xpCount * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper } if (this.dragonFight != null) { @@ -233,23 +232,23 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -739,6 +_,7 @@ - super.addAdditionalSaveData(output); +@@ -745,6 +_,7 @@ output.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); output.putInt("DragonDeathTime", this.dragonDeathTime); + output.putFloat("sitting_damage_received", this.sittingDamageReceived); + output.putInt("Bukkit.expToDrop", this.expToDrop); // CraftBukkit - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts } @Override -@@ -746,6 +_,7 @@ - super.readAdditionalSaveData(input); +@@ -753,6 +_,7 @@ input.getInt("DragonPhase").ifPresent(phaseId -> this.phaseManager.setPhase(EnderDragonPhase.getById(phaseId))); this.dragonDeathTime = input.getIntOr("DragonDeathTime", 0); -+ this.expToDrop = input.getIntOr("Bukkit.expToDrop", 0); // CraftBukkit - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts + this.sittingDamageReceived = input.getFloatOr("sitting_damage_received", 0.0F); ++ this.expToDrop = input.getIntOr("Bukkit.expToDrop", this.getDefaultExpToDrop()); // CraftBukkit - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts } @Override -@@ -786,7 +_,7 @@ +@@ -793,7 +_,7 @@ EnderDragonPhase phase = phaseInstance.getPhase(); Vec3 result; if (phase == EnderDragonPhase.LANDING || phase == EnderDragonPhase.TAKEOFF) { @@ -258,7 +257,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(); -@@ -873,4 +_,19 @@ +@@ -880,4 +_,23 @@ protected float sanitizeScale(final float scale) { return 1.0F; } @@ -266,15 +265,19 @@ + // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time. + @Override + public int getExpReward(ServerLevel level, Entity entity) { -+ // CraftBukkit - Moved from #tickDeath method -+ boolean shouldDrop = level.getGameRules().get(GameRules.MOB_DROPS); -+ int xpCount = 500; ++ if (!level.getGameRules().get(GameRules.MOB_DROPS)) { ++ return 0; ++ } ++ return this.getDefaultExpToDrop(); ++ } ++ // CraftBukkit end + ++ // Paper start - init expToDrop for already dying spawned dragon (like in MC-306798) ++ private int getDefaultExpToDrop() { + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { -+ xpCount = 12000; ++ return 12000; + } -+ -+ return shouldDrop ? xpCount : 0; ++ return 500; + } -+ // CraftBukkit end ++ // Paper end - init expToDrop for already dying spawned dragon } 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 8301b5f05a36..5b56ab670b64 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 @@ -86,7 +86,7 @@ protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) { super.dropCustomDeathLoot(level, source, killedByPlayer); - ItemEntity netherStar = this.spawnAtLocation(level, Items.NETHER_STAR); -+ ItemEntity netherStar = this.spawnAtLocation(level, new net.minecraft.world.item.ItemStack(Items.NETHER_STAR), net.minecraft.world.phys.Vec3.ZERO, ItemEntity::setExtendedLifetime); // Paper - Restore vanilla drops behavior; spawnAtLocation returns null so modify the item entity with a consumer ++ ItemEntity netherStar = this.spawnAtLocation(level, new net.minecraft.world.item.ItemStack(Items.NETHER_STAR), Vec3.ZERO, ItemEntity::setExtendedLifetime); // Paper - Restore vanilla drops behavior; spawnAtLocation returns null so modify the item entity with a consumer if (netherStar != null) { - netherStar.setExtendedLifetime(); + netherStar.setExtendedLifetime(); // Paper - diff on change diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch index d56896d3e894..faf0d3a19b17 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -88,9 +_,16 @@ +@@ -89,9 +_,16 @@ private boolean invisible = false; public long lastHit; public int disabledSlots = 0; @@ -17,7 +17,7 @@ } public ArmorStand(final Level level, final double x, final double y, final double z) { -@@ -102,6 +_,13 @@ +@@ -103,6 +_,13 @@ return createLivingAttributes().add(Attributes.STEP_HEIGHT, 0.0); } @@ -31,7 +31,7 @@ @Override public void refreshDimensions() { double oldX = this.getX(); -@@ -137,6 +_,14 @@ +@@ -138,6 +_,14 @@ return slot != EquipmentSlot.BODY && slot != EquipmentSlot.SADDLE && !this.isDisabled(slot); } @@ -46,7 +46,7 @@ @Override protected void addAdditionalSaveData(final ValueOutput output) { super.addAdditionalSaveData(output); -@@ -150,6 +_,7 @@ +@@ -151,6 +_,7 @@ } output.store("Pose", ArmorStand.ArmorStandPose.CODEC, this.getArmorStandPose()); @@ -54,7 +54,7 @@ } @Override -@@ -163,10 +_,16 @@ +@@ -164,10 +_,16 @@ this.setMarker(input.getBooleanOr("Marker", false)); this.noPhysics = !this.hasPhysics(); input.read("Pose", ArmorStand.ArmorStandPose.CODEC).ifPresent(this::setArmorStandPose); @@ -72,7 +72,7 @@ return false; } -@@ -176,6 +_,7 @@ +@@ -177,6 +_,7 @@ @Override protected void pushEntities() { @@ -80,7 +80,7 @@ for (Entity entity : this.level().getEntities(this, this.getBoundingBox(), RIDABLE_MINECARTS)) { if (this.distanceToSqr(entity) <= 0.2) { entity.push(this); -@@ -256,6 +_,23 @@ +@@ -257,6 +_,23 @@ return false; } @@ -104,7 +104,7 @@ if (player.hasInfiniteMaterials() && itemStack.isEmpty() && !playerItemStack.isEmpty()) { this.setItemSlot(slot, playerItemStack.copyWithCount(1)); return true; -@@ -286,21 +_,38 @@ +@@ -287,21 +_,38 @@ } if (source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { @@ -147,7 +147,7 @@ if (this.isOnFire()) { this.causeDamage(level, source, 0.15F); } else { -@@ -309,9 +_,19 @@ +@@ -310,9 +_,19 @@ return false; } else if (source.is(DamageTypeTags.BURNS_ARMOR_STANDS) && this.getHealth() > 0.5F) { @@ -167,7 +167,7 @@ boolean allowIncrementalBreaking = source.is(DamageTypeTags.CAN_BREAK_ARMOR_STAND); boolean shouldKill = source.is(DamageTypeTags.ALWAYS_KILLS_ARMOR_STANDS); if (!allowIncrementalBreaking && !shouldKill) { -@@ -322,7 +_,7 @@ +@@ -323,7 +_,7 @@ if (source.isCreativePlayer()) { this.playBrokenSound(); this.showBreakingParticles(); @@ -176,7 +176,7 @@ return true; } -@@ -332,9 +_,9 @@ +@@ -333,9 +_,9 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); this.lastHit = time; } else { @@ -188,7 +188,7 @@ } return true; -@@ -386,31 +_,42 @@ +@@ -387,31 +_,45 @@ float health = this.getHealth(); health -= dmg; if (health <= 0.5F) { @@ -210,39 +210,39 @@ result.set(DataComponents.CUSTOM_NAME, this.getCustomName()); - Block.popResource(this.level(), this.blockPosition(), result); - this.brokenByAnything(level, source); -+ this.drops.add(new DefaultDrop(result, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior ++ this.deathDropItems = new java.util.ArrayList<>(); // Paper ++ this.deathDropItems.add(new DefaultDrop(result, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior + return this.brokenByAnything(level, source); // Paper } - private void brokenByAnything(final ServerLevel level, final DamageSource source) { + private org.bukkit.event.entity.EntityDeathEvent brokenByAnything(final ServerLevel level, final DamageSource source) { // Paper this.playBrokenSound(); -- this.dropAllDeathLoot(level, source); -+ // this.dropAllDeathLoot(level, source); // CraftBukkit - moved down ++ if (this.deathDropItems == null) this.deathDropItems = new java.util.ArrayList<>(); // Paper + this.dropAllDeathLoot(level, source); for (EquipmentSlot slot : EquipmentSlot.VALUES) { - ItemStack itemStack = this.equipment.set(slot, ItemStack.EMPTY); -+ ItemStack itemStack = this.equipment.get(slot); // Paper - move equipment removal past event call ++ this.postDeathEventTasks.add(() -> this.equipment.set(slot, ItemStack.EMPTY)); // Paper - move equipment removal past event call ++ ItemStack itemStack = this.equipment.get(slot); // Paper 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} -+ } -+ } -+ // Paper start - move equipment removal past event call -+ org.bukkit.event.entity.EntityDeathEvent event = this.dropAllDeathLoot(level, source); -+ if (!event.isCancelled()) { -+ for (EquipmentSlot slot : EquipmentSlot.VALUES) { -+ this.equipment.set(slot, ItemStack.EMPTY); -+ } ++ this.deathDropItems.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} + } + } ++ // Paper start - call EntityDeathEvent ++ org.bukkit.event.entity.EntityDeathEvent deathEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(level, this, source, this.deathDropItems, true); ++ this.deathDropItems = null; ++ if (!deathEvent.isCancelled()) { ++ this.postDeathEventTasks.forEach(Runnable::run); + } -+ return event; -+ // Paper end - move equipment removal past event call ++ this.postDeathEventTasks.clear(); ++ return deathEvent; ++ // Paper end - call EntityDeathEvent } private void playBrokenSound() { -@@ -458,9 +_,40 @@ +@@ -459,9 +_,37 @@ return this.isSmall(); } @@ -264,27 +264,24 @@ @Override public void kill(final ServerLevel level) { - this.remove(Entity.RemovalReason.KILLED); -+ // CraftBukkit start - pass DamageSource for kill ++ // Paper start - pass damage source for event + this.kill(level, null); + } + -+ public void kill(final ServerLevel level, @Nullable final DamageSource source) { -+ // Paper start - make cancellable ++ public void kill(final ServerLevel level, final @Nullable DamageSource source) { + this.kill(level, source, true); + } + -+ public void kill(final ServerLevel level, @Nullable final DamageSource source, final boolean callEvent) { -+ if (callEvent) { -+ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (source == null ? this.damageSources().genericKill() : source), this.drops); // CraftBukkit - call event -+ if (event.isCancelled()) return; ++ public void kill(final ServerLevel level, final @Nullable DamageSource source, final boolean callEvent) { ++ if (callEvent && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(level, this, (source == null ? this.damageSources().genericKill() : source))) { ++ return; + } + // Paper end + this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause -+ // CraftBukkit end this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -707,4 +_,13 @@ +@@ -708,4 +_,13 @@ .apply(i, ArmorStand.ArmorStandPose::new) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch index 29cd1f73ffd7..818cd20495d0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -54,6 +_,7 @@ +@@ -55,6 +_,7 @@ private static final boolean DEFAULT_FIXED = false; public float dropChance = 1.0F; public boolean fixed = false; @@ -8,7 +8,7 @@ public ItemFrame(final EntityType type, final Level level) { super(type, level); -@@ -111,6 +_,11 @@ +@@ -112,6 +_,11 @@ } private AABB createBoundingBox(final BlockPos blockPos, final Direction direction, final boolean hasFramedMap) { @@ -20,7 +20,7 @@ float shiftToBlockWall = 0.46875F; Vec3 position = Vec3.atCenterOf(blockPos).relative(direction, -0.46875); float width = hasFramedMap ? 1.0F : 0.75F; -@@ -144,9 +_,9 @@ +@@ -145,9 +_,9 @@ } @Override @@ -32,7 +32,7 @@ } } -@@ -175,6 +_,18 @@ +@@ -176,6 +_,18 @@ if (this.isInvulnerableToBase(source)) { return false; } else if (this.shouldDamageDropItem(source)) { @@ -51,7 +51,7 @@ this.dropItem(level, source.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -258,6 +_,13 @@ +@@ -259,6 +_,13 @@ return this.getEntityData().get(DATA_ITEM); } @@ -65,7 +65,7 @@ public @Nullable MapId getFramedMapId(final ItemStack itemStack) { return itemStack.get(DataComponents.MAP_ID); } -@@ -271,13 +_,19 @@ +@@ -272,13 +_,19 @@ } public void setItem(ItemStack itemStack, final boolean updateNeighbours) { @@ -86,7 +86,7 @@ this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } -@@ -304,6 +_,7 @@ +@@ -305,6 +_,7 @@ } private void onItemChanged(final ItemStack item) { @@ -94,7 +94,7 @@ this.recalculateBoundingBox(); } -@@ -371,7 +_,13 @@ +@@ -372,7 +_,13 @@ return InteractionResult.FAIL; } @@ -109,7 +109,7 @@ this.gameEvent(GameEvent.BLOCK_CHANGE, player); itemStack.consume(1, player); return InteractionResult.SUCCESS; -@@ -379,6 +_,13 @@ +@@ -380,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 index df6708a939c7..e168205fa73c 100644 --- 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java +++ b/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java -@@ -86,7 +_,7 @@ +@@ -87,7 +_,7 @@ boolean attachedMob = false; for (Leashable leashable : Leashable.leashableLeashedTo(player)) { @@ -9,7 +9,7 @@ leashable.setLeashedTo(this, true); attachedMob = true; } -@@ -95,7 +_,7 @@ +@@ -96,7 +_,7 @@ boolean anyDropped = false; if (!attachedMob && !player.isSecondaryUseActive()) { for (Leashable mob : Leashable.leashableLeashedTo(this)) { @@ -18,7 +18,7 @@ mob.setLeashedTo(player, true); anyDropped = true; } -@@ -114,7 +_,7 @@ +@@ -115,7 +_,7 @@ @Override public void notifyLeasheeRemoved(final Leashable entity) { if (Leashable.leashableLeashedTo(this).isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch index 8b0c9da412b1..6b8f13bc2542 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/Mannequin.java +++ b/net/minecraft/world/entity/decoration/Mannequin.java -@@ -33,7 +_,7 @@ +@@ -34,7 +_,7 @@ Mannequin.class, EntityDataSerializers.OPTIONAL_COMPONENT ); public static final byte ALL_LAYERS = (byte)Arrays.stream(PlayerModelPart.values()).mapToInt(PlayerModelPart::getMask).reduce(0, (a, b) -> a | b); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch index 07d6a2cb048e..35fa2c8a7aac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/painting/Painting.java +++ b/net/minecraft/world/entity/decoration/painting/Painting.java -@@ -149,21 +_,31 @@ +@@ -150,21 +_,31 @@ @Override protected AABB calculateBoundingBox(final BlockPos pos, final Direction direction) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index 90e39c2f53d1..733174078fc1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -71,6 +_,7 @@ +@@ -72,6 +_,7 @@ public @Nullable CompoundTag blockData; public boolean forceTickAfterTeleportToDuplicate; protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); @@ -8,7 +8,7 @@ public FallingBlockEntity(final EntityType type, final Level level) { super(type, level); -@@ -96,6 +_,7 @@ +@@ -97,6 +_,7 @@ pos.getZ() + 0.5, state.hasProperty(BlockStateProperties.WATERLOGGED) ? state.setValue(BlockStateProperties.WATERLOGGED, false) : state ); @@ -16,7 +16,7 @@ level.setBlock(pos, state.getFluidState().createLegacyBlock(), Block.UPDATE_ALL); level.addFreshEntity(entity); return entity; -@@ -146,13 +_,22 @@ +@@ -147,13 +_,22 @@ @Override public void tick() { if (this.blockState.isAir()) { @@ -40,7 +40,7 @@ this.handlePortal(); if (this.level() instanceof ServerLevel serverLevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos pos = this.blockPosition(); -@@ -173,12 +_,12 @@ +@@ -174,12 +_,12 @@ } if (!this.onGround() && !isStuckInWater) { @@ -55,7 +55,7 @@ } } else { BlockState currentState = this.level().getBlockState(pos); -@@ -195,11 +_,17 @@ +@@ -196,11 +_,17 @@ this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); } @@ -74,7 +74,7 @@ if (block instanceof Fallable fallable) { fallable.onLand(this.level(), pos, this.blockState, currentState, this); } -@@ -224,19 +_,19 @@ +@@ -225,19 +_,19 @@ } } } else if (this.dropItem && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { @@ -97,7 +97,7 @@ this.callOnBrokenAfterFall(block, pos); } } -@@ -296,6 +_,7 @@ +@@ -297,6 +_,7 @@ } output.putBoolean("CancelDrop", this.cancelDrop); @@ -105,7 +105,7 @@ } @Override -@@ -307,8 +_,9 @@ +@@ -308,8 +_,9 @@ this.fallDamagePerDistance = input.getFloatOr("FallHurtAmount", 0.0F); this.fallDamageMax = input.getIntOr("FallHurtMax", 40); this.dropItem = input.getBooleanOr("DropItem", true); @@ -116,7 +116,7 @@ } public void setHurtsEntities(final float damagePerDistance, final int damageMax) { -@@ -364,7 +_,7 @@ +@@ -365,7 +_,7 @@ ResourceKey oldDimension = this.level().dimension(); boolean fromOrToEnd = (oldDimension == Level.END || newDimension == Level.END) && oldDimension != newDimension; Entity newEntity = super.teleport(transition); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index 57f1315b9295..ac084092e1c9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -51,6 +_,9 @@ +@@ -52,6 +_,9 @@ public @Nullable EntityReference thrower; public @Nullable UUID target; public final float bobOffs = this.random.nextFloat() * (float) Math.PI * 2.0F; @@ -10,7 +10,7 @@ public ItemEntity(final EntityType type, final Level level) { super(type, level); -@@ -80,6 +_,14 @@ +@@ -81,6 +_,14 @@ this.setDeltaMovement(deltaX, deltaY, deltaZ); } @@ -25,7 +25,7 @@ @Override public boolean dampensVibrations() { return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS); -@@ -116,7 +_,7 @@ +@@ -117,7 +_,7 @@ @Override public void tick() { if (this.getItem().isEmpty()) { @@ -34,7 +34,7 @@ } else { super.tick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { -@@ -144,13 +_,17 @@ +@@ -145,14 +_,18 @@ } } @@ -44,17 +44,18 @@ } else { this.move(MoverType.SELF, this.getDeltaMovement()); this.applyEffectsFromBlocks(); - float friction = 0.98F; + float airDrag = this.getAirDrag(); + float groundFriction = airDrag; - if (this.onGround()) { + // Paper start - Friction API + if (this.frictionState == net.kyori.adventure.util.TriState.FALSE) { -+ friction = 1F; ++ groundFriction = 1F; + } else if (this.onGround()) { -+ // Paper end - Friction API - friction = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; ++ // Paper end - Friction API + groundFriction *= this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction(); } -@@ -183,8 +_,14 @@ +@@ -185,8 +_,14 @@ } } @@ -71,7 +72,7 @@ } } } -@@ -209,9 +_,18 @@ +@@ -211,9 +_,18 @@ private void mergeWithNeighbours() { if (this.isMergable()) { @@ -91,7 +92,7 @@ this.tryToMerge(entity); if (this.isRemoved()) { break; -@@ -223,7 +_,7 @@ +@@ -225,7 +_,7 @@ private boolean isMergable() { ItemStack item = this.getItem(); @@ -100,7 +101,7 @@ } private void tryToMerge(final ItemEntity other) { -@@ -256,11 +_,16 @@ +@@ -258,11 +_,16 @@ } private static void merge(final ItemEntity toItem, final ItemStack toStack, final ItemEntity fromItem, final ItemStack fromStack) { @@ -118,7 +119,7 @@ } } -@@ -293,12 +_,17 @@ +@@ -295,12 +_,17 @@ return false; } @@ -137,7 +138,7 @@ } return true; -@@ -319,6 +_,11 @@ +@@ -321,6 +_,11 @@ if (!this.getItem().isEmpty()) { output.store("Item", ItemStack.CODEC, this.getItem()); } @@ -149,7 +150,7 @@ } @Override -@@ -329,8 +_,17 @@ +@@ -331,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)); @@ -168,7 +169,7 @@ } } -@@ -340,10 +_,73 @@ +@@ -342,10 +_,73 @@ ItemStack itemStack = this.getItem(); Item item = itemStack.getItem(); int orgCount = itemStack.getCount(); @@ -243,7 +244,7 @@ itemStack.setCount(orgCount); } -@@ -380,6 +_,7 @@ +@@ -382,6 +_,7 @@ public void setItem(final ItemStack itemStack) { this.getEntityData().set(DATA_ITEM, itemStack); @@ -251,7 +252,7 @@ } public void setTarget(final @Nullable UUID target) { -@@ -424,7 +_,7 @@ +@@ -426,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch index ed22259d6bcd..4ada6b8570a7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java -@@ -28,6 +_,12 @@ +@@ -30,6 +_,12 @@ import net.minecraft.world.level.storage.ValueOutput; import org.jspecify.annotations.Nullable; @@ -13,7 +13,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { private static final EntityDataAccessor DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE); -@@ -53,6 +_,7 @@ +@@ -56,6 +_,7 @@ public @Nullable EntityReference owner; private boolean usedPortal; public float explosionPower = 4.0F; @@ -21,16 +21,16 @@ public PrimedTnt(final EntityType type, final Level level) { super(type, level); -@@ -62,7 +_,7 @@ +@@ -65,7 +_,7 @@ public PrimedTnt(final Level level, final double x, final double y, final double z, final @Nullable LivingEntity owner) { - this(EntityType.TNT, level); + this(EntityTypes.TNT, level); this.setPos(x, y, z); - double rot = level.getRandom().nextDouble() * (float) (Math.PI * 2); + double rot = this.getRandom().nextDouble() * (float) (Math.PI * 2); // Paper - Don't use level random in entity constructors this.setDeltaMovement(-Math.sin(rot) * 0.02, 0.2F, -Math.cos(rot) * 0.02); this.setFuse(80); this.xo = x; -@@ -94,10 +_,17 @@ +@@ -97,10 +_,17 @@ @Override public void tick() { @@ -45,10 +45,10 @@ + return; + } + // Paper end - Configurable TNT height nerf - this.setDeltaMovement(this.getDeltaMovement().scale(0.98)); + this.setDeltaMovement(this.getDeltaMovement().scale(this.getAirDrag())); if (this.onGround()) { this.setDeltaMovement(this.getDeltaMovement().multiply(0.7, -0.5, 0.7)); -@@ -106,20 +_,35 @@ +@@ -109,20 +_,35 @@ int fuse = this.getFuse() - 1; this.setFuse(fuse); if (fuse <= 0) { @@ -85,7 +85,7 @@ this.level() .explode( this, -@@ -128,8 +_,8 @@ +@@ -131,8 +_,8 @@ this.getX(), this.getY(0.0625), this.getZ(), @@ -96,7 +96,7 @@ Level.ExplosionInteraction.TNT ); } -@@ -201,4 +_,11 @@ +@@ -208,4 +_,11 @@ public final boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch index 7f4bb9c08612..3420bb386c81 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch @@ -30,6 +30,25 @@ + return false; // CraftBukkit } + @Override +@@ -168,15 +_,15 @@ + } + + @Override +- public boolean killedEntity(final ServerLevel level, final LivingEntity entity, final DamageSource source) { ++ public boolean killedEntityPreEvent(final ServerLevel level, final LivingEntity entity, final DamageSource source) { // Paper + if (this.shouldDropLoot(level) && this.isPowered() && !this.droppedSkulls) { + entity.dropFromLootTable(level, source, false, BuiltInLootTables.CHARGED_CREEPER, itemStack -> { + entity.spawnAtLocation(level, itemStack); +- this.droppedSkulls = true; ++ entity.postDeathEventTasks.add(() -> this.droppedSkulls = true); // Paper + }); + } + +- return super.killedEntity(level, entity, source); ++ return super.killedEntityPreEvent(level, entity, source); // Paper + } + @Override @@ -203,9 +_,20 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch index 08823a50a2b6..3a6fa27653b9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ElderGuardian.java +++ b/net/minecraft/world/entity/monster/ElderGuardian.java -@@ -65,7 +_,7 @@ +@@ -66,7 +_,7 @@ super.customServerAiStep(level); if ((this.tickCount + this.getId()) % 1200 == 0) { MobEffectInstance miningFatigue = new MobEffectInstance(MobEffects.MINING_FATIGUE, 6000, 2); 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 9206393a4921..831086353ed5 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; } -@@ -377,6 +_,7 @@ +@@ -375,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/Monster.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Monster.java.patch index 3ec4199e6dfb..855c211ef17a 100644 --- 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Monster.java +++ b/net/minecraft/world/entity/monster/Monster.java -@@ -89,7 +_,7 @@ +@@ -88,7 +_,7 @@ } DimensionType dimensionType = level.dimensionType(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch index 9b646732659e..cf5675deb524 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -153,12 +_,19 @@ +@@ -154,12 +_,19 @@ BlockState state = serverLevel.getBlockState(pos); Block block = state.getBlock(); if (block instanceof LeavesBlock) { @@ -20,7 +20,7 @@ } } -@@ -249,7 +_,7 @@ +@@ -250,7 +_,7 @@ double xd = entity.getX() - this.getX(); double zd = entity.getZ() - this.getZ(); double dd = Math.max(xd * xd + zd * zd, 0.001); 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 c0103a325d3a..fc1fab99f599 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 -@@ -276,8 +_,10 @@ +@@ -288,8 +_,10 @@ } @Override @@ -13,7 +13,7 @@ if (this.level().isClientSide()) { this.clientOldAttachPosition = this.blockPosition(); } -@@ -388,6 +_,14 @@ +@@ -400,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); -@@ -452,7 +_,12 @@ +@@ -464,7 +_,12 @@ if (baby != null) { baby.setVariant(this.getVariant()); baby.snapTo(oldPosition); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch index aa80f388768c..48fdf6ffe2a4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -25,12 +25,12 @@ } } } -@@ -214,6 +_,12 @@ +@@ -213,6 +_,12 @@ + BlockPos testPos = basePos.offset(xOff, yOff, zOff); BlockState blockState = level.getBlockState(testPos); - Block block = blockState.getBlock(); - if (block instanceof InfestedBlock) { + if (blockState.getBlock() instanceof InfestedBlock infestedBlock) { + // CraftBukkit start -+ BlockState afterState = getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING) ? blockState.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(level.getBlockState(testPos)); // Paper - fix wrong block state ++ BlockState afterState = getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING) ? blockState.getFluidState().createLegacyBlock() : infestedBlock.hostStateByInfested(level.getBlockState(testPos)); // Paper - fix wrong block state + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, testPos, afterState)) { // Paper - fix wrong block state + continue; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch deleted file mode 100644 index 5bcb18c5999e..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch +++ /dev/null @@ -1,216 +0,0 @@ ---- a/net/minecraft/world/entity/monster/Slime.java -+++ b/net/minecraft/world/entity/monster/Slime.java -@@ -59,6 +_,7 @@ - public float squish; - public float oSquish; - private boolean wasOnGround = false; -+ private boolean canWander = true; // Paper - Slime pathfinder events - - public Slime(final EntityType type, final Level level) { - super(type, level); -@@ -113,6 +_,7 @@ - super.addAdditionalSaveData(output); - output.putInt("Size", this.getSize() - 1); - output.putBoolean("wasOnGround", this.wasOnGround); -+ output.putBoolean("Paper.canWander", this.canWander); // Paper - } - - @Override -@@ -120,6 +_,7 @@ - this.setSize(input.getIntOr("Size", 0) + 1, false); - super.readAdditionalSaveData(input); - this.wasOnGround = input.getBooleanOr("wasOnGround", false); -+ this.canWander = input.getBooleanOr("Paper.canWander", true); // Paper - } - - public boolean isTiny() { -@@ -194,7 +_,7 @@ - } - - @Override -- public void remove(final Entity.RemovalReason reason) { -+ public void remove(final Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause - int size = this.getSize(); - if (!this.level().isClientSide() && size > 1 && this.isDeadOrDying()) { - float width = this.getDimensions(this.getPose()).width(); -@@ -202,18 +_,43 @@ - int halfSize = size / 2; - int count = 2 + this.random.nextInt(3); - PlayerTeam team = this.getTeam(); -+ // CraftBukkit start -+ org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), count); -+ if (event.callEvent() && event.getCount() > 0) { -+ count = event.getCount(); -+ } else { -+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause -+ return; -+ } -+ -+ java.util.List slimes = new java.util.ArrayList<>(count); -+ // CraftBukkit end - - for (int i = 0; i < count; i++) { - float xd = (i % 2 - 0.5F) * xzSlimeSpawnOffset; - float zd = (i / 2 - 0.5F) * xzSlimeSpawnOffset; -- this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, team), EntitySpawnReason.TRIGGERED, slime -> { -+ Slime converted = this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, team), EntitySpawnReason.TRIGGERED, slime -> { // CraftBukkit - slime.setSize(halfSize, true); - slime.snapTo(this.getX() + xd, this.getY() + 0.5, this.getZ() + zd, this.random.nextFloat() * 360.0F, 0.0F); -- }); -- } -+ // CraftBukkit start -+ }, null, null); -+ if (converted != null) { -+ slimes.add(converted); -+ } -+ // CraftBukkit end -+ } -+ // CraftBukkit start -+ if (!slimes.isEmpty() && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, slimes, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { // check for empty converted entities or cancel event -+ super.remove(reason, eventCause); // add Bukkit remove cause -+ return; -+ } -+ for (LivingEntity living : slimes) { -+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); -+ } -+ // CraftBukkit end - } - -- super.remove(reason); -+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause - } - - @Override -@@ -276,7 +_,11 @@ - return checkMobSpawnRules(type, level, spawnReason, pos, random); - } - -- if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > 50 && pos.getY() < 70) { -+ // Paper start - Replace rules for Height in Swamp Biomes -+ final double maxHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.maximum; -+ final double minHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum; -+ // Paper end - Replace rules for Height in Swamp Biomes -+ if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp) { // Paper - Replace rules for Height in Swamp Biomes - float surfaceSlimeSpawnChance = level.environmentAttributes().getValue(EnvironmentAttributes.SURFACE_SLIME_SPAWN_CHANCE, pos); - if (random.nextFloat() < surfaceSlimeSpawnChance && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { - return checkMobSpawnRules(type, level, spawnReason, pos, random); -@@ -288,8 +_,11 @@ - } - - ChunkPos chunkPos = ChunkPos.containing(pos); -- boolean slimeChunk = WorldgenRandom.seedSlimeChunk(chunkPos.x(), chunkPos.z(), ((WorldGenLevel)level).getSeed(), 987234911L).nextInt(10) == 0; -- if (random.nextInt(10) == 0 && slimeChunk && pos.getY() < 40) { -+ boolean slimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x(), chunkPos.z(), ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Paper -+ // Paper start - Replace rules for Height in Slime Chunks -+ final double maxHeightSlimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum; -+ if (random.nextInt(10) == 0 && slimeChunk && pos.getY() < maxHeightSlimeChunk) { -+ // Paper end - Replace rules for Height in Slime Chunks - return checkMobSpawnRules(type, level, spawnReason, pos, random); - } - } -@@ -347,6 +_,16 @@ - return super.getDefaultDimensions(pose).scale(this.getSize()); - } - -+ // Paper start - Slime pathfinder events -+ public boolean canWander() { -+ return this.canWander; -+ } -+ -+ public void setWander(boolean canWander) { -+ this.canWander = canWander; -+ } -+ // Paper end - Slime pathfinder events -+ - private static class SlimeAttackGoal extends Goal { - private final Slime slime; - private int growTiredTimer; -@@ -359,7 +_,16 @@ - @Override - public boolean canUse() { - LivingEntity target = this.slime.getTarget(); -- return target != null && this.slime.canAttack(target) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; -+ -+ // Paper start - Slime pathfinder events -+ if (target == null || !target.isAlive()) { -+ return false; -+ } -+ if (!this.slime.canAttack(target)) { -+ return false; -+ } -+ return this.slime.getMoveControl() instanceof Slime.SlimeMoveControl && this.slime.canWander && new com.destroystokyo.paper.event.entity.SlimeTargetLivingEntityEvent((org.bukkit.entity.Slime) this.slime.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity()).callEvent(); -+ // Paper end - Slime pathfinder events - } - - @Override -@@ -371,7 +_,16 @@ - @Override - public boolean canContinueToUse() { - LivingEntity target = this.slime.getTarget(); -- return target != null && this.slime.canAttack(target) && --this.growTiredTimer > 0; -+ -+ // Paper start - Slime pathfinder events -+ if (target == null || !target.isAlive()) { -+ return false; -+ } -+ if (!this.slime.canAttack(target)) { -+ return false; -+ } -+ return --this.growTiredTimer > 0 && this.slime.canWander && new com.destroystokyo.paper.event.entity.SlimeTargetLivingEntityEvent((org.bukkit.entity.Slime) this.slime.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity()).callEvent(); -+ // Paper end - Slime pathfinder events - } - - @Override -@@ -390,6 +_,13 @@ - slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage()); - } - } -+ -+ // Paper start - Slime pathfinder events; clear timer and target when goal resets -+ public void stop() { -+ this.growTiredTimer = 0; -+ this.slime.setTarget(null); -+ } -+ // Paper end - Slime pathfinder events - } - - private static class SlimeFloatGoal extends Goal { -@@ -403,7 +_,7 @@ - - @Override - public boolean canUse() { -- return (this.slime.isInWater() || this.slime.isInLava()) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; -+ return (this.slime.isInWater() || this.slime.isInLava()) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl && this.slime.canWander && new com.destroystokyo.paper.event.entity.SlimeSwimEvent((org.bukkit.entity.Slime) this.slime.getBukkitEntity()).callEvent(); // Paper - Slime pathfinder events - } - - @Override -@@ -433,7 +_,7 @@ - - @Override - public boolean canUse() { -- return !this.slime.isPassenger(); -+ return !this.slime.isPassenger() && this.slime.canWander && new com.destroystokyo.paper.event.entity.SlimeWanderEvent((org.bukkit.entity.Slime) this.slime.getBukkitEntity()).callEvent(); // Paper - Slime pathfinder events - } - - @Override -@@ -511,7 +_,7 @@ - - @Override - public boolean canUse() { -- return this.slime.getTarget() == null -+ return this.slime.getTarget() == null && this.slime.canWander // Paper - Slime pathfinder events - && (this.slime.onGround() || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION)) - && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; - } -@@ -521,6 +_,11 @@ - if (--this.nextRandomizeTime <= 0) { - this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60)); - this.chosenDegrees = this.slime.getRandom().nextInt(360); -+ // Paper start - Slime pathfinder events -+ com.destroystokyo.paper.event.entity.SlimeChangeDirectionEvent event = new com.destroystokyo.paper.event.entity.SlimeChangeDirectionEvent((org.bukkit.entity.Slime) this.slime.getBukkitEntity(), this.chosenDegrees); -+ if (!this.slime.canWander || !event.callEvent()) return; -+ this.chosenDegrees = event.getNewYaw(); -+ // Paper end - Slime pathfinder events - } - - if (this.slime.getMoveControl() instanceof Slime.SlimeMoveControl slimeMoveControl) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch index 1293ab1271f9..57ce887650da 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Strider.java +++ b/net/minecraft/world/entity/monster/Strider.java -@@ -299,7 +_,14 @@ +@@ -310,7 +_,14 @@ || stateOn.is(BlockTags.STRIDER_WARM_BLOCKS) || this.getFluidHeight(FluidTags.LAVA) > 0.0; boolean onWarmStrider = this.getVehicle() instanceof Strider strider && !strider.isSuffocating(); 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 aab60ca41e1f..ff896e39b787 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,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/Vex.java +++ b/net/minecraft/world/entity/monster/Vex.java -@@ -288,7 +_,7 @@ +@@ -293,7 +_,7 @@ + @Override public void start() { - Mob owner = Vex.this.getOwner(); -- Vex.this.setTarget(owner != null ? owner.getTarget() : null); -+ Vex.this.setTarget(owner != null ? owner.getTarget() : null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET); // CraftBukkit +- Vex.this.setTarget(Vex.this.getOwner() instanceof Targeting owner ? owner.getTarget() : null); ++ Vex.this.setTarget(Vex.this.getOwner() instanceof Targeting owner ? owner.getTarget() : null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET); // CraftBukkit super.start(); } } -@@ -347,7 +_,10 @@ +@@ -352,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/Witch.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch index ba743428ffc4..e34cc86ae3e0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Witch.java +++ b/net/minecraft/world/entity/monster/Witch.java -@@ -123,8 +_,14 @@ +@@ -124,8 +_,14 @@ ItemStack itemStack = this.getMainHandItem(); this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); PotionContents potion = itemStack.get(DataComponents.POTION_CONTENTS); @@ -16,7 +16,7 @@ } this.gameEvent(GameEvent.DRINK); -@@ -148,26 +_,7 @@ +@@ -149,26 +_,7 @@ } if (potion != null) { @@ -44,7 +44,7 @@ } } -@@ -179,6 +_,23 @@ +@@ -180,6 +_,23 @@ super.aiStep(); } @@ -68,7 +68,7 @@ @Override public SoundEvent getCelebrateSound() { return SoundEvents.WITCH_CELEBRATE; -@@ -245,6 +_,13 @@ +@@ -246,6 +_,13 @@ if (this.level() instanceof ServerLevel serverLevel) { ItemStack itemStack = PotionContents.createItemStack(Items.SPLASH_POTION, potion); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/breeze/Breeze.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/breeze/Breeze.java.patch index 0cbe4ba51bf8..d16a19259720 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/breeze/Breeze.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/breeze/Breeze.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/breeze/Breeze.java +++ b/net/minecraft/world/entity/monster/breeze/Breeze.java -@@ -242,6 +_,11 @@ +@@ -243,6 +_,11 @@ @Override public boolean canAttack(final LivingEntity target) { @@ -9,6 +9,6 @@ + // LivingEntity targetFromBrain = this.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); + // if (targetFromBrain != null) return target.is(targetFromBrain); + // CraftBukkit end - return (target.is(EntityType.PLAYER) || target.is(EntityType.IRON_GOLEM)) && super.canAttack(target); + return (target.is(EntityTypes.PLAYER) || target.is(EntityTypes.IRON_GOLEM)) && super.canAttack(target); } 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 309b070b4b0b..f82f4ca21556 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 @@ -5,7 +5,7 @@ @Override - public void push(final double xa, final double ya, final double za) { -+ public void push(final double xa, final double ya, final double za, @Nullable final Entity pushingEntity) { // Paper - add push source entity param ++ public void push(final double xa, final double ya, final double za, @Nullable Entity pushingEntity) { // Paper - add push source entity param if (this.canMove()) { - super.push(xa, ya, za); + super.push(xa, ya, za, pushingEntity); // Paper - add push source entity param @@ -25,11 +25,11 @@ } @Override -- public void knockback(final double power, final double xd, final double zd) { -+ public void knockback(final double power, final double xd, final double zd, @Nullable final Entity attacker, final io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events +- public void knockback(final double power, final double xd, final double zd, final DamageSource source, final float damage) { ++ public void knockback(final double power, final double xd, final double zd, final DamageSource source, final float damage, final boolean comesFromEffect, @Nullable final Entity attacker, final io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events if (this.canMove()) { -- super.knockback(power, xd, zd); -+ super.knockback(power, xd, zd, attacker, cause); // Paper - knockback events +- super.knockback(power, xd, zd, source, damage); ++ super.knockback(power, xd, zd, source, damage, comesFromEffect, attacker, cause); // Paper - knockback events } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/AbstractCubeMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/AbstractCubeMob.java.patch new file mode 100644 index 000000000000..d60041243d2e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/AbstractCubeMob.java.patch @@ -0,0 +1,192 @@ +--- a/net/minecraft/world/entity/monster/cubemob/AbstractCubeMob.java ++++ b/net/minecraft/world/entity/monster/cubemob/AbstractCubeMob.java +@@ -49,6 +_,7 @@ + public float squish; + public float oSquish; + private boolean wasOnGround = false; ++ private boolean canWander = true; // Paper - Slime pathfinder events + + protected AbstractCubeMob(final EntityType type, final Level level) { + super(type, level); +@@ -101,6 +_,7 @@ + super.addAdditionalSaveData(output); + output.putInt("Size", this.getSize() - 1); + output.putBoolean("wasOnGround", this.wasOnGround); ++ output.putBoolean("Paper.canWander", this.canWander); // Paper + } + + @Override +@@ -108,6 +_,7 @@ + this.setSize(input.getIntOr("Size", 0) + 1, false); + super.readAdditionalSaveData(input); + this.wasOnGround = input.getBooleanOr("wasOnGround", false); ++ this.canWander = input.getBooleanOr("Paper.canWander", true); // Paper + } + + public boolean isTiny() { +@@ -183,7 +_,7 @@ + } + + @Override +- public void remove(final Entity.RemovalReason reason) { ++ public void remove(final Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause + int size = this.getSize(); + if (!this.level().isClientSide() && size > 1 && this.isDeadOrDying()) { + float width = this.getDimensions(this.getPose()).width(); +@@ -191,20 +_,46 @@ + int halfSize = size / 2; + int count = this.getSplitCount(); + PlayerTeam team = this.getTeam(); ++ // CraftBukkit start ++ org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent((org.bukkit.entity.AbstractCubeMob) this.getBukkitEntity(), count); ++ if (event.callEvent() && event.getCount() > 0) { ++ count = event.getCount(); ++ } else { ++ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause ++ return; ++ } ++ ++ java.util.List cubeMobs = new java.util.ArrayList<>(count); ++ // CraftBukkit end + + for (int i = 0; i < count; i++) { + float xd = (i % 2 - 0.5F) * xzCubeSpawnOffset; + float zd = (i / 2 - 0.5F) * xzCubeSpawnOffset; +- this.convertTo( ++ AbstractCubeMob converted = this.convertTo( // CraftBukkit + this.getType(), + new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, team), + EntitySpawnReason.TRIGGERED, +- cubeMob -> this.setUpSplitCube(cubeMob, halfSize, xd, zd) ++ cubeMob -> { this.setUpSplitCube(cubeMob, halfSize, xd, zd); } // Paper - fix convertTo method not being resolved ++ // CraftBukkit start ++ , null, null + ); +- } ++ if (converted != null) { ++ cubeMobs.add(converted); ++ } ++ // CraftBukkit end ++ } ++ // CraftBukkit start ++ if (!cubeMobs.isEmpty() && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, cubeMobs, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { // check for empty converted entities or cancel event ++ super.remove(reason, eventCause); // add Bukkit remove cause ++ return; ++ } ++ for (LivingEntity cubeMob : cubeMobs) { ++ this.level().addFreshEntity(cubeMob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); ++ } ++ // CraftBukkit end + } + +- super.remove(reason); ++ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause + } + + protected void setUpSplitCube(final AbstractCubeMob cubeMob, final int halfSize, final float xd, final float zd) { +@@ -259,6 +_,16 @@ + return this.getType().getDimensions().scale(this.getSize()); + } + ++ // Paper start - Slime pathfinder events ++ public boolean canWander() { ++ return this.canWander; ++ } ++ ++ public void setWander(boolean canWander) { ++ this.canWander = canWander; ++ } ++ // Paper end - Slime pathfinder events ++ + @Override + public void jumpFromGround() { + Vec3 movement = this.getDeltaMovement(); +@@ -337,7 +_,16 @@ + @Override + public boolean canUse() { + LivingEntity target = this.cubeMob.getTarget(); +- return target != null && this.cubeMob.canAttack(target) && this.cubeMob.getMoveControl() instanceof AbstractCubeMob.CubeMobMoveControl; ++ ++ // Paper start - Slime pathfinder events ++ if (target == null || !target.isAlive()) { ++ return false; ++ } ++ if (!this.cubeMob.canAttack(target)) { ++ return false; ++ } ++ return this.cubeMob.getMoveControl() instanceof AbstractCubeMob.CubeMobMoveControl && this.cubeMob.canWander && new com.destroystokyo.paper.event.entity.SlimeTargetLivingEntityEvent((org.bukkit.entity.AbstractCubeMob) this.cubeMob.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity()).callEvent(); ++ // Paper end - Slime pathfinder events + } + + @Override +@@ -349,7 +_,16 @@ + @Override + public boolean canContinueToUse() { + LivingEntity target = this.cubeMob.getTarget(); +- return target != null && this.cubeMob.canAttack(target) && --this.growTiredTimer > 0; ++ ++ // Paper start - Slime pathfinder events ++ if (target == null || !target.isAlive()) { ++ return false; ++ } ++ if (!this.cubeMob.canAttack(target)) { ++ return false; ++ } ++ return --this.growTiredTimer > 0 && this.cubeMob.canWander && new com.destroystokyo.paper.event.entity.SlimeTargetLivingEntityEvent((org.bukkit.entity.AbstractCubeMob) this.cubeMob.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity()).callEvent(); ++ // Paper end - Slime pathfinder events + } + + @Override +@@ -368,6 +_,13 @@ + cubeMobMoveControl.setDirection(this.cubeMob.getYRot(), this.cubeMob.isDealsDamage()); + } + } ++ ++ // Paper start - Slime pathfinder events; clear timer and target when goal resets ++ public void stop() { ++ this.growTiredTimer = 0; ++ this.cubeMob.setTarget(null); ++ } ++ // Paper end - Slime pathfinder events + } + + private static class CubeMobFloatGoal extends Goal { +@@ -381,7 +_,7 @@ + + @Override + public boolean canUse() { +- return (this.cubeMob.isInWater() || this.cubeMob.isInLava()) && this.cubeMob.getMoveControl() instanceof AbstractCubeMob.CubeMobMoveControl; ++ return (this.cubeMob.isInWater() || this.cubeMob.isInLava()) && this.cubeMob.getMoveControl() instanceof AbstractCubeMob.CubeMobMoveControl && this.cubeMob.canWander && new com.destroystokyo.paper.event.entity.SlimeSwimEvent((org.bukkit.entity.AbstractCubeMob) this.cubeMob.getBukkitEntity()).callEvent(); // Paper - Slime pathfinder events + } + + @Override +@@ -411,7 +_,7 @@ + + @Override + public boolean canUse() { +- return !this.cubeMob.isPassenger(); ++ return !this.cubeMob.isPassenger() && this.cubeMob.canWander && new com.destroystokyo.paper.event.entity.SlimeWanderEvent((org.bukkit.entity.AbstractCubeMob) this.cubeMob.getBukkitEntity()).callEvent(); // Paper - Slime pathfinder events + } + + @Override +@@ -487,7 +_,7 @@ + + @Override + public boolean canUse() { +- return this.cubeMob.getTarget() == null ++ return this.cubeMob.getTarget() == null && this.cubeMob.canWander // Paper - Slime pathfinder events + && (this.cubeMob.onGround() || this.cubeMob.isInWater() || this.cubeMob.isInLava() || this.cubeMob.hasEffect(MobEffects.LEVITATION)) + && this.cubeMob.getMoveControl() instanceof AbstractCubeMob.CubeMobMoveControl; + } +@@ -497,6 +_,11 @@ + if (--this.nextRandomizeTime <= 0) { + this.nextRandomizeTime = this.adjustedTickDelay(40 + this.cubeMob.getRandom().nextInt(60)); + this.chosenDegrees = this.cubeMob.getRandom().nextInt(360); ++ // Paper start - Slime pathfinder events ++ com.destroystokyo.paper.event.entity.SlimeChangeDirectionEvent event = new com.destroystokyo.paper.event.entity.SlimeChangeDirectionEvent((org.bukkit.entity.AbstractCubeMob) this.cubeMob.getBukkitEntity(), this.chosenDegrees); ++ if (!this.cubeMob.canWander || !event.callEvent()) return; ++ this.chosenDegrees = event.getNewYaw(); ++ // Paper end - Slime pathfinder events + } + + if (this.cubeMob.getMoveControl() instanceof AbstractCubeMob.CubeMobMoveControl cubeMobMoveControl) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/Slime.java.patch new file mode 100644 index 000000000000..e7bdc9eac9fe --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/Slime.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/entity/monster/cubemob/Slime.java ++++ b/net/minecraft/world/entity/monster/cubemob/Slime.java +@@ -78,7 +_,11 @@ + return checkMobSpawnRules(type, level, spawnReason, pos, random); + } + +- if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > 50 && pos.getY() < 70) { ++ // Paper start - Replace rules for Height in Swamp Biomes ++ final double maxHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.maximum; ++ final double minHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum; ++ // Paper end - Replace rules for Height in Swamp Biomes ++ if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp) { // Paper - Replace rules for Height in Swamp Biomes + float surfaceSlimeSpawnChance = level.environmentAttributes().getValue(EnvironmentAttributes.SURFACE_SLIME_SPAWN_CHANCE, pos); + if (random.nextFloat() < surfaceSlimeSpawnChance && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { + return checkMobSpawnRules(type, level, spawnReason, pos, random); +@@ -90,8 +_,11 @@ + } + + ChunkPos chunkPos = ChunkPos.containing(pos); +- boolean slimeChunk = WorldgenRandom.seedSlimeChunk(chunkPos.x(), chunkPos.z(), worldGenLevel.getSeed(), 987234911L).nextInt(10) == 0; +- if (random.nextInt(10) == 0 && slimeChunk && pos.getY() < 40) { ++ boolean slimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x(), chunkPos.z(), worldGenLevel.getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Paper ++ // Paper start - Replace rules for Height in Slime Chunks ++ final double maxHeightSlimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum; ++ if (random.nextInt(10) == 0 && slimeChunk && pos.getY() < maxHeightSlimeChunk) { ++ // Paper end - Replace rules for Height in Slime Chunks + return checkMobSpawnRules(type, level, spawnReason, pos, random); + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch new file mode 100644 index 000000000000..944fc58fcafb --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch @@ -0,0 +1,153 @@ +--- a/net/minecraft/world/entity/monster/cubemob/SulfurCube.java ++++ b/net/minecraft/world/entity/monster/cubemob/SulfurCube.java +@@ -295,13 +_,31 @@ + + if (!this.explosionData.isEmpty()) { + if (this.fuse == 0) { +- this.dropLeash(); +- this.dead = true; ++ // Paper start - Fire events for SulfurCube explosions ++ // todo - snapshot - only call if the explosion really occur after the prime event, also see MC-308659 for later change (if confirmed) ++ final org.bukkit.event.entity.EntityUnleashEvent unleashEvent = new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.LEASHED_GONE, true); ++ unleashEvent.callEvent(); ++ if (unleashEvent.isDropLeash()) { ++ this.dropLeash(); ++ } else { ++ this.removeLeash(); ++ } ++ // Paper end - Fire events for SulfurCube explosions ++ // this.dead = true; // Paper - move after prime event so that the entity is alive during the event + if (this.level() instanceof ServerLevel level) { + if (level.getGameRules().get(GameRules.TNT_EXPLODES)) { + Level.ExplosionInteraction explosionInteraction = level.getGameRules().get(GameRules.MOB_GRIEFING) + ? Level.ExplosionInteraction.TNT + : Level.ExplosionInteraction.NONE; ++ // Paper start - Fire events for SulfurCube explosions ++ final org.bukkit.event.entity.ExplosionPrimeEvent primeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callExplosionPrimeEvent(this, this.explosionData.get().power(), this.explosionData.get().causesFire()); ++ if (primeEvent.isCancelled()) { ++ this.setFuse(PrimedTnt.NO_FUSE); ++ this.entityData.set(MAX_FUSE, PrimedTnt.NO_FUSE); ++ return; ++ } ++ // Paper end - Fire events for SulfurCube explosions ++ this.dead = true; // Paper - moved from above + level.explode( + this, + Explosion.getDefaultDamageSource(this.level(), this), +@@ -309,16 +_,20 @@ + this.getX(), + this.getY(0.0625), + this.getZ(), +- this.explosionData.get().power(), +- this.explosionData.get().causesFire(), ++ primeEvent.getRadius(), // Paper - ExplosionPrimeEvent ++ primeEvent.getFire(), // Paper - ExplosionPrimeEvent + explosionInteraction + ); ++ // Paper start - moved from above ++ } else { ++ this.dead = true; ++ // Paper end - moved from above + } + + this.triggerOnDeathMobEffects(level, Entity.RemovalReason.KILLED); + } + +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + } + } + } +@@ -340,6 +_,12 @@ + && !this.isPrimed()) { + int fuse = this.explosionData.get().fuse(); + int fuseTime = imminent ? PrimedTnt.getRandomShortFuse(fuse, this.getRandom()) : fuse; ++ // Paper start - call EntityIgniteEvent ++ fuseTime = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityIgniteEvent(this, fuseTime); ++ if (fuseTime == PrimedTnt.NO_FUSE) { ++ return false; ++ } ++ // Paper end - call EntityIgniteEvent + this.setInvulnerable(true); + this.setFuse(fuseTime); + this.entityData.set(MAX_FUSE, fuseTime); +@@ -455,7 +_,15 @@ + if (heldItem.is(Items.SHEARS) && this.readyForShearing()) { + if (this.level() instanceof ServerLevel level) { + ItemStack itemStackToShear = this.getItemBySlot(EquipmentSlot.BODY); +- this.shear(level, SoundSource.PLAYERS, heldItem); ++ // Paper start - call PlayerShearEntityEvent ++ java.util.List drops = this.generateDefaultDrops(level, heldItem); ++ org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, heldItem, hand, drops); ++ if (event.isCancelled()) { ++ return InteractionResult.PASS; ++ } ++ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); ++ this.shear(level, SoundSource.PLAYERS, heldItem, drops); ++ // Paper end - call PlayerShearEntityEvent + this.gameEvent(GameEvent.SHEAR, player); + heldItem.hurtAndBreak(1, player, hand.asEquipmentSlot()); + CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemStackToShear, this); +@@ -525,7 +_,7 @@ + if (this.level() instanceof ServerLevel serverLevel) { + for (SulfurCubeArchetype.ContactDamage damage : this.contactDamages) { + entity.hurtServer( +- serverLevel, new DamageSource(damage.damageType(), damage.attributeToSource() ? this : null), damage.amount().sample(this.getRandom()) ++ serverLevel, new DamageSource(damage.damageType(), damage.attributeToSource() ? this : null).eventEntityDamager(this).knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.CONTACT), damage.amount().sample(this.getRandom()) // Paper - add damager for EntityDamageEvent + ); + } + } +@@ -605,10 +_,24 @@ + + @Override + public void shear(final ServerLevel level, final SoundSource soundSource, final ItemStack tool) { +- Vec3 equipmentSpawnOffset = this.getAttachments().getAverage(EntityAttachment.PASSENGER); ++ // Paper start - custom shear drops ++ this.shear(level, soundSource, tool, this.generateDefaultDrops(level, tool)); ++ } ++ ++ @Override ++ public java.util.List generateDefaultDrops(final ServerLevel level, final ItemStack tool) { + ItemStack itemStackToShear = this.getItemBySlot(EquipmentSlot.BODY); ++ final java.util.List drops = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(1); ++ drops.add(itemStackToShear); ++ return drops; ++ } ++ ++ @Override ++ public void shear(final ServerLevel level, final SoundSource soundSource, final ItemStack tool, final java.util.List drops) { ++ // Paper end - custom shear drops ++ Vec3 equipmentSpawnOffset = this.getAttachments().getAverage(EntityAttachment.PASSENGER); + this.setItemSlot(EquipmentSlot.BODY, ItemStack.EMPTY); +- this.spawnAtLocation(level, itemStackToShear, equipmentSpawnOffset); ++ drops.forEach(drop -> this.spawnAtLocation(level, drop, equipmentSpawnOffset)); // Paper - custom shear drops + this.playSound(this.getEjectSound()); + this.pickupTimer = 100; + } +@@ -827,7 +_,7 @@ + } + + @Override +- public void knockback(final double power, double xd, double zd, final DamageSource source, final float damage, final boolean comesFromEffect) { ++ public void knockback(final double power, double xd, double zd, final DamageSource source, final float damage, final boolean comesFromEffect, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events + if (source.getEntity() != null && this.hasBodyItem()) { + float horizontalHitAngleScale = 1.6F; + float verticalHitAngleScale = 0.5F; +@@ -874,7 +_,7 @@ + this.setDeltaMovement(deltaMovement.x - horizontalKnockback.x, deltaMovement.y + verticalPower * 1.2, deltaMovement.z - horizontalKnockback.z); + this.playSound(hitSound.value()); + } else { +- super.knockback(power, xd, zd, source, damage, comesFromEffect); ++ super.knockback(power, xd, zd, source, damage, comesFromEffect, attacker, eventCause); // Paper - knockback events + } + } + +@@ -1006,7 +_,7 @@ + } + + @Override +- protected void navigateTowards(final Player player) { ++ protected void navigateTowards(final net.minecraft.world.entity.LivingEntity player) { // Paper + this.mob.lookAt(player, 10.0F, 10.0F); + if (this.mob.getMoveControl() instanceof AbstractCubeMob.CubeMobMoveControl cubeMobMoveControl) { + cubeMobMoveControl.setDirection(this.mob.getYRot(), true); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 690df3a34440..5b5c4895e654 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,13 +1,14 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -237,9 +_,12 @@ +@@ -250,9 +_,14 @@ } private void finishConversion() { - this.convertTo( -- EntityType.ZOGLIN, ConversionParams.single(this, true, false), zoglin -> zoglin.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) -- ); -+ final Entity converted = this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), zoglin -> {zoglin.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons +- EntityTypes.ZOGLIN, ConversionParams.single(this, true, false), zoglin -> zoglin.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) ++ final Entity converted = this.convertTo( // Paper - Fix issues with mob conversion; reset to prevent event spam ++ EntityTypes.ZOGLIN, ConversionParams.single(this, true, false), zoglin -> {zoglin.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED // CraftBukkit - add spawn and transform reasons + ); + // Paper start - Fix issues with mob conversion; reset to prevent event spam + if (converted == null) { + this.timeInOverworld = 0; 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 41c71c41f3d6..26b298279c8b 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 -@@ -254,7 +_,7 @@ +@@ -268,7 +_,7 @@ serverLevel.getScoreboard().addPlayerToTeam(vex.getScoreboardName(), evokerTeam); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch index a88a50bae4af..42424b33e899 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch @@ -5,7 +5,7 @@ private static class VindicatorBreakDoorGoal extends BreakDoorGoal { public VindicatorBreakDoorGoal(final Mob mob) { - super(mob, 6, Vindicator.DOOR_BREAKING_PREDICATE); -+ super(mob, 6, com.google.common.base.Predicates.in(mob.level().paperConfig().entities.behavior.doorBreakingDifficulty.getOrDefault(mob.getType(), mob.level().paperConfig().entities.behavior.doorBreakingDifficulty.get(EntityType.VINDICATOR)))); // Paper - Configurable door breaking difficulty ++ super(mob, 6, com.google.common.base.Predicates.in(mob.level().paperConfig().entities.behavior.doorBreakingDifficulty.getOrDefault(mob.getType(), mob.level().paperConfig().entities.behavior.doorBreakingDifficulty.get(net.minecraft.world.entity.EntityTypes.VINDICATOR)))); // Paper - Configurable door breaking difficulty this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index f0ec4bf4ca57..1d67f9ca65a0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -102,11 +_,16 @@ +@@ -107,11 +_,16 @@ } protected void finishConversion(final ServerLevel level) { - this.convertTo( + net.minecraft.world.entity.Entity converted = this.convertTo( // Paper - Fix issues with mob conversion; reset to prevent event spam - EntityType.ZOMBIFIED_PIGLIN, + EntityTypes.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), - zombified -> zombified.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) + zombified -> {zombified.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED // CraftBukkit - add spawn and transform reasons diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index c24dbb871d6b..b711fdfe3dfe 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -96,6 +_,12 @@ +@@ -97,6 +_,12 @@ List.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR), PiglinAi::getActivities ); @@ -13,7 +13,7 @@ public Piglin(final EntityType type, final Level level) { super(type, level); -@@ -108,6 +_,10 @@ +@@ -109,6 +_,10 @@ output.putBoolean("IsBaby", this.isBaby()); output.putBoolean("CannotHunt", this.cannotHunt); this.writeInventoryToTag(output); @@ -24,7 +24,7 @@ } @Override -@@ -116,6 +_,10 @@ +@@ -117,6 +_,10 @@ this.setBaby(input.getBooleanOr("IsBaby", false)); this.setCannotHunt(input.getBooleanOr("CannotHunt", false)); this.readInventoryFromTag(input); @@ -35,25 +35,25 @@ } @VisibleForDebug -@@ -282,7 +_,9 @@ +@@ -128,7 +_,8 @@ @Override - protected void finishConversion(final ServerLevel level) { - PiglinAi.cancelAdmiring(level, this); -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.inventory.removeAllItems().forEach(itemStack -> this.spawnAtLocation(level, itemStack)); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles - super.finishConversion(level); + protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) { + super.dropCustomDeathLoot(level, source, killedByPlayer); +- this.inventory.removeAllItems().forEach(itemStack -> this.spawnAtLocation(level, itemStack)); ++ this.inventory.getItems().stream().filter(item -> !item.isEmpty()).forEach(itemStack -> this.spawnAtLocation(level, itemStack)); // Paper - delay removal post event - taken from removeAllItems ++ this.postDeathEventTasks.add(this.inventory::clearContent); // Paper - only clear after death event } -@@ -359,7 +_,7 @@ - } + protected ItemStack addToInventory(final ItemStack itemStack) { +@@ -362,7 +_,7 @@ protected void holdInOffHand(final ItemStack itemStack) { -- if (itemStack.is(PiglinAi.BARTERING_ITEM)) { -+ if (itemStack.is(PiglinAi.BARTERING_ITEM) || this.allowedBarterItems.contains(itemStack.getItem())) { // CraftBukkit - Changes to accept custom payment items - this.setItemSlot(EquipmentSlot.OFFHAND, itemStack); - this.setGuaranteedDrop(EquipmentSlot.OFFHAND); - } else { + this.setItemSlotAndDropWhenKilled(EquipmentSlot.OFFHAND, itemStack); +- if (!itemStack.is(PiglinAi.BARTERING_ITEM)) { ++ if (!itemStack.is(PiglinAi.BARTERING_ITEM) && !this.allowedBarterItems.contains(itemStack.getItem())) { // CraftBukkit - Changes to accept custom payment items - do not mark persistence required if added to allowed bartering items + this.setPersistenceRequired(); + } + } @@ -385,15 +_,15 @@ } 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 0d41994c6fd3..44e503f5a7c7 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -338,16 +_,18 @@ +@@ -336,16 +_,18 @@ protected static void pickUpItem(final ServerLevel level, final Piglin body, final ItemEntity itemEntity) { stopWalking(body); ItemStack taken; @@ -21,17 +21,7 @@ body.getBrain().eraseMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM); holdInOffhand(level, body, taken); admireGoldItem(body); -@@ -363,7 +_,9 @@ - - private static void holdInOffhand(final ServerLevel level, final Piglin body, final ItemStack itemStack) { - if (isHoldingItemInOffHand(body)) { -+ body.forceDrops = true; // Paper - Add missing forceDrop toggles - body.spawnAtLocation(level, body.getItemInHand(InteractionHand.OFF_HAND)); -+ body.forceDrops = false; // Paper - Add missing forceDrop toggles - } - - body.holdInOffHand(itemStack); -@@ -373,7 +_,7 @@ +@@ -371,7 +_,7 @@ ItemStack sourceStack = itemEntity.getItem(); ItemStack removedStack = sourceStack.split(1); if (sourceStack.isEmpty()) { @@ -40,7 +30,7 @@ } else { itemEntity.setItem(sourceStack); } -@@ -385,9 +_,14 @@ +@@ -383,9 +_,14 @@ ItemStack itemStack = body.getItemInHand(InteractionHand.OFF_HAND); body.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); if (body.isAdult()) { @@ -57,7 +47,7 @@ } else if (!barterCurrency) { boolean equipped = !body.equipItemIfPossible(level, itemStack).isEmpty(); if (!equipped) { -@@ -398,7 +_,7 @@ +@@ -396,7 +_,7 @@ boolean equipped = !body.equipItemIfPossible(level, itemStack).isEmpty(); if (!equipped) { ItemStack mainHandItem = body.getMainHandItem(); @@ -66,17 +56,7 @@ putInInventory(body, mainHandItem); } else { throwItems(body, Collections.singletonList(mainHandItem)); -@@ -411,7 +_,9 @@ - - protected static void cancelAdmiring(final ServerLevel level, final Piglin body) { - if (isAdmiringItem(body) && !body.getOffhandItem().isEmpty()) { -+ body.forceDrops = true; // Paper - Add missing forceDrop toggles - body.spawnAtLocation(level, body.getOffhandItem()); -+ body.forceDrops = false; // Paper - Add missing forceDrop toggles - body.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); - } - } -@@ -466,7 +_,7 @@ +@@ -464,7 +_,7 @@ return false; } else if (isAdmiringDisabled(body) && body.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -85,7 +65,7 @@ return isNotHoldingLovedItemInOffHand(body); } else { boolean hasSpace = body.canAddToInventory(itemStack); -@@ -475,11 +_,16 @@ +@@ -473,11 +_,16 @@ } else if (isFood(itemStack)) { return !hasEatenRecently(body) && hasSpace; } else { @@ -103,7 +83,7 @@ protected static boolean isLovedItem(final ItemStack itemStack) { return itemStack.is(ItemTags.PIGLIN_LOVED); } -@@ -537,6 +_,7 @@ +@@ -535,6 +_,7 @@ } public static void angerNearbyPiglins(final ServerLevel level, final Player player, final boolean onlyIfTheySeeThePlayer) { @@ -111,7 +91,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)) { -@@ -561,7 +_,7 @@ +@@ -559,7 +_,7 @@ } protected static boolean canAdmire(final Piglin body, final ItemStack playerHeldItemStack) { @@ -120,7 +100,7 @@ } protected static void wasHurtBy(final ServerLevel level, final Piglin body, final LivingEntity attacker) { -@@ -811,6 +_,11 @@ +@@ -809,6 +_,11 @@ return body.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -132,7 +112,7 @@ private static boolean isBarterCurrency(final ItemStack itemStack) { return itemStack.is(BARTERING_ITEM); } -@@ -848,7 +_,7 @@ +@@ -846,7 +_,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(final Piglin body) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch index f01a51ba7da2..fa0b0a446dac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch @@ -1,27 +1,23 @@ --- a/net/minecraft/world/entity/monster/skeleton/Bogged.java +++ b/net/minecraft/world/entity/monster/skeleton/Bogged.java -@@ -72,7 +_,19 @@ +@@ -72,7 +_,15 @@ ItemStack itemStack = player.getItemInHand(hand); if (itemStack.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel level) { - this.shear(level, SoundSource.PLAYERS, itemStack); -+ // CraftBukkit start -+ // Paper start - custom shear drops ++ // Paper start - call PlayerShearEntityEvent + java.util.List drops = this.generateDefaultDrops(level, itemStack); + org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemStack, hand, drops); -+ if (event != null) { -+ if (event.isCancelled()) { -+ return InteractionResult.PASS; -+ } -+ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); -+ // Paper end - custom shear drops ++ if (event.isCancelled()) { ++ return InteractionResult.PASS; + } -+ // CraftBukkit end -+ this.shear(level, SoundSource.PLAYERS, itemStack, drops); // Paper - custom shear drops ++ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); ++ this.shear(level, SoundSource.PLAYERS, itemStack, drops); ++ // Paper end - call PlayerShearEntityEvent this.gameEvent(GameEvent.SHEAR, player); itemStack.hurtAndBreak(1, player, hand.asEquipmentSlot()); } -@@ -125,13 +_,33 @@ +@@ -125,13 +_,31 @@ @Override public void shear(final ServerLevel level, final SoundSource soundSource, final ItemStack tool) { @@ -51,9 +47,7 @@ - this.dropFromShearingLootTable(level, BuiltInLootTables.BOGGED_SHEAR, tool, (l, drop) -> this.spawnAtLocation(l, drop, this.getBbHeight())); + // Paper start - custom shear drops + private void spawnShearedMushrooms(final ServerLevel level, final ItemStack tool, java.util.List drops) { -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles + drops.forEach(drop -> this.spawnAtLocation(level, drop, this.getBbHeight())); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles + // Paper end - custom shear drops } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch index 131968034af6..5241f9d608de 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/skeleton/Skeleton.java +++ b/net/minecraft/world/entity/monster/skeleton/Skeleton.java -@@ -93,11 +_,17 @@ +@@ -94,11 +_,17 @@ } protected void doFreezeConversion() { -- this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), stray -> { -+ final Stray entity = this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), stray -> { // Paper - Fix issues with mob conversion; reset conversion time to prevent event spam +- this.convertTo(EntityTypes.STRAY, ConversionParams.single(this, true, true), stray -> { ++ final Stray entity = this.convertTo(EntityTypes.STRAY, ConversionParams.single(this, true, true), stray -> { // Paper - Fix issues with mob conversion; reset conversion time to prevent event spam if (!this.isSilent()) { this.level().levelEvent(null, LevelEvent.SOUND_SKELETON_TO_STRAY, this.blockPosition(), 0); } 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 index c1bb12ba5eae..c507ab7a0397 100644 --- 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 @@ -3,9 +3,9 @@ @@ -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 + if (target instanceof LivingEntity livingEntity) { +- livingEntity.addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this); ++ livingEntity.addEffect(new MobEffectInstance(MobEffects.WITHER, 200), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } return true; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch index f7dea5bb6029..0c5b29392a11 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch @@ -4,8 +4,8 @@ } if (poisonTime > 0) { -- ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.POISON, poisonTime * 20, 0), this); -+ ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.POISON, poisonTime * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- livingEntity.addEffect(new MobEffectInstance(MobEffects.POISON, poisonTime * 20, 0), this); ++ livingEntity.addEffect(new MobEffectInstance(MobEffects.POISON, poisonTime * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch index 554064f767f0..920933db6b8a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/spider/Spider.java +++ b/net/minecraft/world/entity/monster/spider/Spider.java -@@ -81,7 +_,7 @@ +@@ -82,7 +_,7 @@ public void tick() { super.tick(); if (!this.level().isClientSide()) { @@ -9,7 +9,7 @@ } } -@@ -123,7 +_,7 @@ +@@ -124,7 +_,7 @@ @Override public boolean canBeAffected(final MobEffectInstance newEffect) { @@ -18,7 +18,7 @@ } public boolean isClimbing() { -@@ -166,7 +_,7 @@ +@@ -167,7 +_,7 @@ if (groupData instanceof Spider.SpiderEffectsGroupData spiderEffectsGroupData) { Holder effect = spiderEffectsGroupData.effect; if (effect != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/AngerManagement.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/AngerManagement.java.patch index 94d69cd0ece1..d90a2ef26291 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/AngerManagement.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/AngerManagement.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/AngerManagement.java +++ b/net/minecraft/world/entity/monster/warden/AngerManagement.java -@@ -142,7 +_,7 @@ +@@ -141,7 +_,7 @@ public int increaseAnger(final Entity entity, final int increment) { boolean newSuspect = !this.angerBySuspect.containsKey(entity); 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 0350347f6d76..9c6ff87f41aa 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 -@@ -403,7 +_,7 @@ +@@ -409,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 -@@ -445,8 +_,17 @@ +@@ -451,8 +_,17 @@ } @VisibleForTesting diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch index a263f3c521aa..925cfb08bed9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/zombie/Drowned.java +++ b/net/minecraft/world/entity/monster/zombie/Drowned.java -@@ -96,7 +_,7 @@ +@@ -97,7 +_,7 @@ this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Drowned.class).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (target, level) -> this.okTarget(target))); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch index 51508102f963..8a104c072729 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/zombie/Husk.java +++ b/net/minecraft/world/entity/monster/zombie/Husk.java -@@ -67,7 +_,7 @@ +@@ -68,7 +_,7 @@ boolean result = super.doHurtTarget(level, target); - if (result && this.getMainHandItem().isEmpty() && target instanceof LivingEntity) { + if (result && this.getMainHandItem().isEmpty() && target instanceof LivingEntity livingEntity) { float difficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); -- ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)difficulty), this); -+ ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)difficulty), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- livingEntity.addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)difficulty), this); ++ livingEntity.addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)difficulty), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } return result; -@@ -94,7 +_,7 @@ +@@ -95,7 +_,7 @@ groupData = super.finalizeSpawn(level, difficulty, spawnReason, groupData); float difficultyModifier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch index 8d29fc28d428..6771344f6050 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/zombie/Zombie.java +++ b/net/minecraft/world/entity/monster/zombie/Zombie.java -@@ -70,8 +_,10 @@ +@@ -71,8 +_,10 @@ public class Zombie extends Monster { private static final Identifier SPEED_MODIFIER_BABY_ID = Identifier.withDefaultNamespace("baby"); @@ -13,7 +13,7 @@ ); private static final Identifier REINFORCEMENT_CALLER_CHARGE_ID = Identifier.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( -@@ -95,13 +_,15 @@ +@@ -96,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; @@ -26,11 +26,11 @@ public Zombie(final EntityType type, final Level level) { super(type, level); -+ this.breakDoorGoal = new BreakDoorGoal(this, com.google.common.base.Predicates.in(level.paperConfig().entities.behavior.doorBreakingDifficulty.getOrDefault(type, level.paperConfig().entities.behavior.doorBreakingDifficulty.get(EntityType.ZOMBIE)))); // Paper - Configurable door breaking difficulty ++ this.breakDoorGoal = new BreakDoorGoal(this, com.google.common.base.Predicates.in(level.paperConfig().entities.behavior.doorBreakingDifficulty.getOrDefault(type, level.paperConfig().entities.behavior.doorBreakingDifficulty.get(EntityTypes.ZOMBIE)))); // Paper - Configurable door breaking difficulty } public Zombie(final Level level) { -@@ -110,7 +_,7 @@ +@@ -111,7 +_,7 @@ @Override protected void registerGoals() { @@ -39,7 +39,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -123,7 +_,7 @@ +@@ -124,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)); @@ -48,7 +48,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)); } -@@ -177,11 +_,16 @@ +@@ -178,11 +_,16 @@ @Override protected int getBaseExperienceReward(final ServerLevel level) { @@ -66,7 +66,7 @@ } @Override -@@ -232,6 +_,13 @@ +@@ -233,6 +_,13 @@ super.tick(); } @@ -80,7 +80,7 @@ public void startUnderWaterConversion(final int time) { this.conversionTime = time; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -245,17 +_,28 @@ +@@ -246,17 +_,28 @@ } protected void convertToZombieType(final ServerLevel level, final EntityType zombieType) { @@ -111,9 +111,9 @@ + public static @Nullable ZombieVillager convertVillagerToZombieVillager(final ServerLevel level, final Villager villager, final net.minecraft.core.BlockPos blockPosition, boolean silent, org.bukkit.event.entity.EntityTransformEvent.TransformReason transformReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + // CraftBukkit end ZombieVillager zombieVillager = villager.convertTo( - EntityType.ZOMBIE_VILLAGER, + EntityTypes.ZOMBIE_VILLAGER, ConversionParams.single(villager, true, true), -@@ -267,17 +_,24 @@ +@@ -269,17 +_,24 @@ zombie.setGossips(villager.getGossips().copy()); zombie.setTradeOffers(villager.getOffers().copy()); zombie.setVillagerXp(villager.getVillagerXp()); @@ -145,7 +145,7 @@ @Override public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) { -@@ -311,13 +_,13 @@ +@@ -313,13 +_,13 @@ if (SpawnPlacements.isSpawnPositionOk(type, level, spawnPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, spawnPos, level.getRandom())) { reinforcement.setPos(xt, yt, zt); @@ -162,7 +162,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; -@@ -341,7 +_,12 @@ +@@ -343,7 +_,12 @@ if (result) { float difficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < difficulty * 0.3F) { @@ -176,7 +176,7 @@ } } -@@ -403,6 +_,7 @@ +@@ -405,6 +_,7 @@ output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -184,7 +184,7 @@ } @Override -@@ -417,13 +_,15 @@ +@@ -419,13 +_,15 @@ } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -202,7 +202,7 @@ return perished; } -@@ -458,7 +_,7 @@ +@@ -460,7 +_,7 @@ groupData = super.finalizeSpawn(level, difficulty, spawnReason, groupData); float difficultyModifier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -211,7 +211,7 @@ } if (groupData == null) { -@@ -485,7 +_,7 @@ +@@ -487,7 +_,7 @@ chicken.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken.setChickenJockey(true); this.startRiding(chicken, false, false); @@ -220,7 +220,7 @@ } } } -@@ -511,7 +_,7 @@ +@@ -513,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/monster/zombie/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch index 23251af58f11..b8b3b8748bd9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/zombie/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/zombie/ZombieVillager.java -@@ -200,12 +_,20 @@ +@@ -196,12 +_,20 @@ } public void startConverting(final @Nullable UUID player, final int time) { @@ -24,23 +24,23 @@ } @Override -@@ -235,7 +_,7 @@ +@@ -231,7 +_,7 @@ } private void finishConversion(final ServerLevel level) { - this.convertTo( + Villager converted = this.convertTo( // CraftBukkit - EntityType.VILLAGER, + EntityTypes.VILLAGER, ConversionParams.single(this, false, false), villager -> { -@@ -261,19 +_,24 @@ +@@ -258,19 +_,24 @@ villager.finalizeSpawn(level, level.getCurrentDifficultyAt(villager.blockPosition()), EntitySpawnReason.CONVERSION, null); villager.refreshBrain(level); if (this.conversionStarter != null) { - Player player = level.getPlayerByUUID(this.conversionStarter); + Player player = level.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate - if (player instanceof ServerPlayer) { - CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer)player, this, villager); + if (player instanceof ServerPlayer serverPlayer) { + CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger(serverPlayer, this, villager); level.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, player, villager); } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch index 80cca6bf31af..3bace0ec1da1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/entity/npc/CatSpawner.java @@ -65,12 +_,12 @@ private void spawnCat(final BlockPos spawnPos, final ServerLevel level, final boolean makePersistent) { - Cat cat = EntityType.CAT.create(level, EntitySpawnReason.NATURAL); + Cat cat = EntityTypes.CAT.create(level, EntitySpawnReason.NATURAL); if (cat != null) { + cat.snapTo(spawnPos, 0.0F, 0.0F); // Paper - move up - Fix MC-147659 cat.finalizeSpawn(level, level.getCurrentDifficultyAt(spawnPos), EntitySpawnReason.NATURAL, null); 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 2f2138fa9c6a..df56336ca8f3 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/villager/AbstractVillager.java +++ b/net/minecraft/world/entity/npc/villager/AbstractVillager.java -@@ -56,7 +_,7 @@ +@@ -57,7 +_,7 @@ private static final EntityDataAccessor DATA_UNHAPPY_COUNTER = SynchedEntityData.defineId(AbstractVillager.class, EntityDataSerializers.INT); private @Nullable Player tradingPlayer; protected @Nullable MerchantOffers offers; @@ -9,7 +9,7 @@ public AbstractVillager(final EntityType type, final Level level) { super(type, level); -@@ -108,6 +_,20 @@ +@@ -109,6 +_,20 @@ return this.tradingPlayer != null; } @@ -30,7 +30,7 @@ @Override public MerchantOffers getOffers() { if (this.level() instanceof ServerLevel serverLevel) { -@@ -130,11 +_,24 @@ +@@ -131,11 +_,24 @@ public void overrideXp(final int xp) { } @@ -57,7 +57,7 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, offer.getResult()); } -@@ -232,6 +_,11 @@ +@@ -230,6 +_,11 @@ protected abstract void updateTrades(ServerLevel level); protected void addOffersFromTradeSet(final ServerLevel level, final MerchantOffers offers, final ResourceKey resourceKey) { @@ -69,7 +69,7 @@ Optional tradeSetOpt = this.registryAccess().lookupOrThrow(Registries.TRADE_SET).getOptional(resourceKey); if (tradeSetOpt.isEmpty()) { LOGGER.debug("Missing expected trade set {}", resourceKey); -@@ -245,17 +_,17 @@ +@@ -243,18 +_,18 @@ .create(LootContextParamSets.VILLAGER_TRADE) ) .create(tradeSet.randomSequence()); @@ -85,16 +85,17 @@ } } - private static void addOffersFromItemListings( + @VisibleForTesting + static void addOffersFromItemListings( - final LootContext lootContext, final MerchantOffers merchantOffers, final HolderSet potentialOffers, final int numberOfOffers + final LootContext lootContext, final MerchantOffers merchantOffers, final HolderSet potentialOffers, final int numberOfOffers, AbstractVillager villager // Paper ) { + List> potentialOffersList = Lists.newArrayList(potentialOffers); int offersFound = 0; - -@@ -267,14 +_,14 @@ - - MerchantOffer offer = villagerTrade.get().value().getOffer(lootContext); - if (offer != null) { +@@ -266,14 +_,14 @@ + if (offer == null) { + potentialOffersList.remove(roll); + } else { - merchantOffers.add(offer); + tryAcquireTrade(villager, merchantOffers, offer); // Paper offersFound++; @@ -108,7 +109,7 @@ ) { List> leftoverOffers = Lists.newArrayList(potentialOffers); int offersFound = 0; -@@ -283,11 +_,30 @@ +@@ -282,11 +_,30 @@ Holder villagerTrade = leftoverOffers.remove(lootContext.getRandom().nextInt(leftoverOffers.size())); MerchantOffer offer = villagerTrade.value().getOffer(lootContext); if (offer != null) { 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 781915b36cfa..b61d0eebece9 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/villager/Villager.java +++ b/net/minecraft/world/entity/npc/villager/Villager.java -@@ -262,7 +_,7 @@ +@@ -253,7 +_,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -9,7 +9,7 @@ } } -@@ -378,7 +_,12 @@ +@@ -369,7 +_,12 @@ this.updateDemand(); for (MerchantOffer offer : this.getOffers()) { @@ -23,7 +23,7 @@ } this.resendOffersToTradingPlayer(); -@@ -439,7 +_,12 @@ +@@ -430,7 +_,12 @@ int missedUpdates = 2 - this.numberOfRestocksToday; if (missedUpdates > 0) { for (MerchantOffer offer : this.getOffers()) { @@ -37,7 +37,7 @@ } } -@@ -460,6 +_,7 @@ +@@ -451,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())); } } -@@ -469,6 +_,7 @@ +@@ -460,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)); -@@ -584,7 +_,7 @@ +@@ -585,7 +_,7 @@ } if (offer.shouldRewardExp()) { @@ -62,7 +62,7 @@ } } -@@ -602,7 +_,7 @@ +@@ -603,7 +_,7 @@ @Override public void die(final DamageSource source) { @@ -71,7 +71,7 @@ Entity murderer = source.getEntity(); if (murderer != null) { this.tellWitnessesThatIWasMurdered(murderer); -@@ -701,7 +_,7 @@ +@@ -702,7 +_,7 @@ return VillagerData.canLevelUp(currentLevel) && this.villagerXp >= VillagerData.getMaxXpPerLevel(currentLevel); } @@ -86,7 +86,7 @@ if (level.getDifficulty() != Difficulty.PEACEFUL) { - LOGGER.info("Villager {} was struck by lightning {}.", this, lightningBolt); + // Paper - Add EntityZapEvent; move log down, event can cancel - Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), w -> { + Witch witch = this.convertTo(EntityTypes.WITCH, ConversionParams.single(this, false, false), w -> { + // Paper start - Add EntityZapEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightningBolt, w).isCancelled()) { + return false; @@ -133,7 +133,7 @@ if (nearbyVillagersThatWantAGolem.size() >= villagersNeededToAgree) { - if (!SpawnUtil.trySpawnMob( + if (SpawnUtil.trySpawnMob( // Paper - Set Golem Last Seen to stop it from spawning another one - switch to isPresent - EntityType.IRON_GOLEM, + EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, level, @@ -858,9 +_,11 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch index 96b800ecd908..f424b1e8737e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch @@ -51,8 +51,8 @@ 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 +- WanderingTrader trader = EntityTypes.WANDERING_TRADER.spawn(level, spawnPosition, EntitySpawnReason.EVENT); ++ WanderingTrader trader = EntityTypes.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); @@ -67,8 +67,8 @@ private void tryToSpawnLlamaFor(final ServerLevel level, final WanderingTrader trader, final int radius) { BlockPos spawnPosition = this.findSpawnPositionNear(level, trader.blockPosition(), radius); if (spawnPosition != null) { -- TraderLlama llama = EntityType.TRADER_LLAMA.spawn(level, spawnPosition, EntitySpawnReason.EVENT); -+ TraderLlama llama = EntityType.TRADER_LLAMA.spawn(level, spawnPosition, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- TraderLlama llama = EntityTypes.TRADER_LLAMA.spawn(level, spawnPosition, EntitySpawnReason.EVENT); ++ TraderLlama llama = EntityTypes.TRADER_LLAMA.spawn(level, spawnPosition, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (llama != null) { llama.setLeashedTo(trader, true); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index ce5a696bc2ad..fb7007df9e5c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -149,7 +_,7 @@ +@@ -150,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; @@ -9,7 +9,7 @@ public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -171,6 +_,18 @@ +@@ -172,6 +_,18 @@ private Optional lastDeathLocation = Optional.empty(); public @Nullable FishingHook fishing; public float hurtDir; @@ -27,8 +27,8 @@ + // CraftBukkit end public Player(final Level level, final GameProfile gameProfile) { - super(EntityType.PLAYER, level); -@@ -241,6 +_,13 @@ + super(EntityTypes.PLAYER, level); +@@ -242,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -42,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -270,7 +_,7 @@ +@@ -271,7 +_,7 @@ ItemStack mainHandItemStack = this.getMainHandItem(); if (!ItemStack.matches(this.lastItemInMainHand, mainHandItemStack)) { if (!ItemStack.isSameItem(this.lastItemInMainHand, mainHandItemStack)) { @@ -51,7 +51,7 @@ } this.lastItemInMainHand = mainHandItemStack.copy(); -@@ -321,7 +_,7 @@ +@@ -322,7 +_,7 @@ } private void turtleHelmetTick() { @@ -60,7 +60,7 @@ } private boolean isEquipped(final Item item) { -@@ -422,6 +_,18 @@ +@@ -423,6 +_,18 @@ } } @@ -79,11 +79,10 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -433,8 +_,14 @@ +@@ -434,7 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); -- this.setShiftKeyDown(false); - } else { + // CraftBukkit start - SPIGOT-7316: no longer passenger, dismount and return + if (!this.isPassenger()) { @@ -258,7 +257,7 @@ baseDamage *= 1.5F; } -@@ -990,7 +_,7 @@ +@@ -992,7 +_,7 @@ this.setLastHurtMob(entity); this.itemAttackInteraction(entity, attackingItemStack, damageSource, true); this.damageStatsAndHearts(entity, oldLivingEntityHealth); @@ -267,7 +266,7 @@ } else { this.playServerSideSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); } -@@ -1002,7 +_,7 @@ +@@ -1004,7 +_,7 @@ } private void playServerSideSound(final SoundEvent sound) { @@ -276,7 +275,7 @@ } private DamageSource createAttackSource(final ItemStack attackingItemStack) { -@@ -1013,11 +_,12 @@ +@@ -1015,11 +_,12 @@ return !entity.isAttackable() || entity.skipAttackInteraction(this); } @@ -291,12 +290,13 @@ return true; } else { return false; -@@ -1117,19 +_,40 @@ - public void causeExtraKnockback(final Entity entity, final float knockbackAmount, final Vec3 oldMovement) { +@@ -1127,20 +_,41 @@ if (knockbackAmount > 0.0F) { if (entity instanceof LivingEntity livingTarget) { -- livingTarget.knockback(knockbackAmount, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD)); -+ livingTarget.knockback(knockbackAmount, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events + livingTarget.knockback( +- knockbackAmount, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), damageSource, damage, comesFromEffect ++ knockbackAmount, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), damageSource, damage, comesFromEffect, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events + ); } else { - entity.push(-Mth.sin(this.getYRot() * Mth.DEG_TO_RAD) * knockbackAmount, 0.1, Mth.cos(this.getYRot() * Mth.DEG_TO_RAD) * knockbackAmount); + entity.push(-Mth.sin(this.getYRot() * Mth.DEG_TO_RAD) * knockbackAmount, 0.1, Mth.cos(this.getYRot() * Mth.DEG_TO_RAD) * knockbackAmount, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent @@ -310,7 +310,7 @@ + // Paper end - Configurable sprint interruption on attack } - if (entity instanceof ServerPlayer && entity.hurtMarked) { + if (entity instanceof ServerPlayer serverPlayer && entity.hurtMarked) { + // CraftBukkit start - Add Velocity Event + boolean cancelled = false; + org.bukkit.entity.Player player = (org.bukkit.entity.Player) entity.getBukkitEntity(); @@ -326,7 +326,7 @@ + } + + if (!cancelled) { - ((ServerPlayer)entity).connection.send(new ClientboundSetEntityMotionPacket(entity)); + serverPlayer.connection.send(new ClientboundSetEntityMotionPacket(entity)); entity.hurtMarked = false; entity.setDeltaMovement(oldMovement); + } @@ -334,21 +334,22 @@ } } -@@ -1150,8 +_,11 @@ +@@ -1161,9 +_,12 @@ && !(nearby instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(nearby) < 9.0) { float enchantedDamage = this.getEnchantedDamage(nearby, var12, damageSource) * attackStrengthScale; - if (nearby.hurtServer(serverLevel, damageSource, enchantedDamage)) { -- nearby.knockback(0.4F, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD)); + // Paper start - Only apply knockback if the event is not canceled + nearby.lastDamageCancelled = false; + if (nearby.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), enchantedDamage) && !nearby.lastDamageCancelled) { + // Paper end - Only apply knockback if the event is not canceled -+ nearby.knockback(0.4F, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // Paper - knockback events + nearby.knockback( +- 0.4F, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), damageSource, enchantedDamage ++ 0.4F, Mth.sin(this.getYRot() * Mth.DEG_TO_RAD), -Mth.cos(this.getYRot() * Mth.DEG_TO_RAD), damageSource, enchantedDamage, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // Paper - knockback events + ); EnchantmentHelper.doPostAttackEffects(serverLevel, nearby, damageSource); } - } -@@ -1184,7 +_,16 @@ +@@ -1197,7 +_,16 @@ public boolean stabAttack( final EquipmentSlot slot, final Entity target, float baseDamage, final boolean dealsDamage, final boolean dealsKnockback, final boolean dismounts ) { @@ -366,7 +367,7 @@ return false; } -@@ -1196,7 +_,8 @@ +@@ -1209,7 +_,8 @@ baseDamage *= this.baseDamageScaleFactor(); } @@ -376,7 +377,7 @@ return true; } -@@ -1226,7 +_,7 @@ +@@ -1240,7 +_,7 @@ this.setLastHurtMob(target); this.itemAttackInteraction(target, weaponItem, damageSource, wasHurt); this.damageStatsAndHearts(target, oldLivingEntityHealth); @@ -385,7 +386,7 @@ return true; } -@@ -1234,8 +_,8 @@ +@@ -1248,8 +_,8 @@ } @Override @@ -396,7 +397,7 @@ this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1303,6 +_,12 @@ +@@ -1317,6 +_,12 @@ } public Either startSleepInBed(final BlockPos pos) { @@ -409,7 +410,7 @@ this.startSleeping(pos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1419,7 +_,7 @@ +@@ -1433,7 +_,7 @@ @Override public boolean causeFallDamage(final double fallDistance, final float damageModifier, final DamageSource damageSource) { @@ -418,7 +419,7 @@ return false; } -@@ -1440,7 +_,15 @@ +@@ -1454,7 +_,15 @@ } public void startFallFlying() { @@ -434,7 +435,7 @@ } @Override -@@ -1538,7 +_,7 @@ +@@ -1552,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; @@ -443,7 +444,7 @@ this.lastLevelUpTime = this.tickCount; } } -@@ -1546,15 +_,35 @@ +@@ -1560,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -481,7 +482,7 @@ } } } -@@ -1807,10 +_,39 @@ +@@ -1821,10 +_,39 @@ } @Override @@ -525,7 +526,7 @@ public void resetOnlyAttackStrengthTicker() { this.attackStrengthTicker = 0; -@@ -1843,19 +_,34 @@ +@@ -1857,19 +_,34 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -562,7 +563,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack itemStack = this.inventory.getItem(i); -@@ -1864,6 +_,7 @@ +@@ -1878,6 +_,7 @@ } } @@ -570,7 +571,7 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } -@@ -2027,5 +_,6 @@ +@@ -2046,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/entity/projectile/EvokerFangs.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch index 0be361d50e24..18a60182e1ed 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EvokerFangs.java -@@ -99,7 +_,7 @@ +@@ -100,7 +_,7 @@ } if (--this.lifeTicks < 0) { @@ -9,7 +9,7 @@ } } } -@@ -108,7 +_,7 @@ +@@ -109,7 +_,7 @@ LivingEntity currentOwner = this.getOwner(); if (entity.isAlive() && !entity.isInvulnerable() && entity != currentOwner) { if (currentOwner == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch index 0c9a562f8db8..108da4816d4b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EyeOfEnder.java +++ b/net/minecraft/world/entity/projectile/EyeOfEnder.java -@@ -72,6 +_,12 @@ +@@ -73,6 +_,12 @@ } public void signalTo(final Vec3 target) { @@ -13,7 +13,7 @@ Vec3 delta = target.subtract(this.position()); double horizontalDistance = delta.horizontalDistance(); if (horizontalDistance > 12.0) { -@@ -80,8 +_,10 @@ +@@ -81,8 +_,10 @@ this.target = target; } @@ -24,7 +24,7 @@ } @Override -@@ -102,7 +_,7 @@ +@@ -103,7 +_,7 @@ this.life++; if (this.life > 80 && !this.level().isClientSide()) { this.playSound(SoundEvents.ENDER_EYE_DEATH, 1.0F, 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 99599a64ff97..f2306324efda 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -48,6 +_,7 @@ +@@ -49,6 +_,7 @@ public int life = 0; public int lifetime = 0; public @Nullable LivingEntity attachedToEntity; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch index 9632b2c537da..fb0a0b48e740 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -69,10 +_,26 @@ +@@ -70,10 +_,26 @@ private final int lureSpeed; private final InterpolationHandler interpolationHandler = new InterpolationHandler(this); @@ -27,7 +27,7 @@ } public FishingHook(final EntityType type, final Level level) { -@@ -152,12 +_,12 @@ +@@ -153,12 +_,12 @@ super.tick(); Player owner = this.getPlayerOwner(); if (owner == null) { @@ -42,7 +42,7 @@ return; } } else { -@@ -175,12 +_,14 @@ +@@ -176,12 +_,14 @@ if (this.currentState == FishingHook.FishHookState.FLYING) { if (this.hookedIn != null) { this.setDeltaMovement(Vec3.ZERO); @@ -57,7 +57,7 @@ this.currentState = FishingHook.FishHookState.BOBBING; return; } -@@ -195,6 +_,7 @@ +@@ -196,6 +_,7 @@ this.setPos(this.hookedIn.getX(), this.hookedIn.getY(0.8), this.hookedIn.getZ()); } else { this.setHookedEntity(null); @@ -65,7 +65,7 @@ this.currentState = FishingHook.FishHookState.FLYING; } } -@@ -261,13 +_,13 @@ +@@ -262,13 +_,13 @@ } } @@ -81,7 +81,7 @@ } @Override -@@ -298,11 +_,11 @@ +@@ -299,11 +_,11 @@ ServerLevel serverLevel = (ServerLevel)this.level(); int fishingSpeed = 1; BlockPos above = blockPos.above(); @@ -95,7 +95,7 @@ fishingSpeed--; } -@@ -312,6 +_,10 @@ +@@ -313,6 +_,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(DATA_BITING, false); @@ -106,7 +106,7 @@ } } else if (this.timeUntilHooked > 0) { this.timeUntilHooked -= fishingSpeed; -@@ -335,6 +_,12 @@ +@@ -336,6 +_,12 @@ serverLevel.sendParticles(ParticleTypes.FISHING, fishX, fishY, fishZ, 0, -particleZMovement, 0.01, particleXMovement, 1.0); } } else { @@ -119,7 +119,7 @@ this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double y = this.getY() + 0.5; serverLevel.sendParticles( -@@ -378,14 +_,31 @@ +@@ -379,14 +_,31 @@ } if (this.timeUntilLured <= 0) { @@ -155,7 +155,7 @@ public boolean calculateOpenWater(final BlockPos blockPos) { FishingHook.OpenWaterType previousLayer = FishingHook.OpenWaterType.INVALID; -@@ -444,15 +_,30 @@ +@@ -445,15 +_,30 @@ protected void readAdditionalSaveData(final ValueInput input) { } @@ -186,7 +186,7 @@ } else if (this.nibble > 0) { LootParams params = new LootParams.Builder((ServerLevel)this.level()) .withParameter(LootContextParams.ORIGIN, this.position()) -@@ -466,14 +_,27 @@ +@@ -467,14 +_,27 @@ for (ItemStack itemStack : items) { ItemEntity entity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemStack); @@ -216,7 +216,7 @@ if (itemStack.is(ItemTags.FISHES)) { owner.awardStat(Stats.FISH_CAUGHT, 1); } -@@ -483,10 +_,24 @@ +@@ -484,10 +_,24 @@ } if (this.onGround()) { @@ -242,7 +242,7 @@ return dmg; } else { return 0; -@@ -516,9 +_,9 @@ +@@ -517,9 +_,9 @@ } @Override @@ -254,7 +254,7 @@ } @Override -@@ -564,7 +_,7 @@ +@@ -565,7 +_,7 @@ if (this.getPlayerOwner() == null) { int ownerId = packet.getData(); LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(ownerId), ownerId); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch index 311ea6aa01f7..81272527e9d4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/LlamaSpit.java +++ b/net/minecraft/world/entity/projectile/LlamaSpit.java -@@ -43,16 +_,16 @@ +@@ -44,15 +_,15 @@ super.tick(); Vec3 movement = this.getDeltaMovement(); HitResult hitResult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -10,7 +10,6 @@ double y = this.getY() + movement.y; double z = this.getZ() + movement.z; this.updateRotation(); - float inertia = 0.99F; if (this.level().getBlockStates(this.getBoundingBox()).noneMatch(BlockBehaviour.BlockStateBase::isAir)) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause @@ -18,9 +17,9 @@ - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { - this.setDeltaMovement(movement.scale(0.99F)); + this.setDeltaMovement(movement.scale(this.getAirDrag())); this.applyGravity(); -@@ -76,7 +_,7 @@ +@@ -81,7 +_,7 @@ protected void onHitBlock(final BlockHitResult hitResult) { super.onHitBlock(hitResult); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index a60b569a11de..38211b3ca734 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -55,7 +_,21 @@ +@@ -56,7 +_,21 @@ this.finalTarget = EntityReference.of(target); this.currentMoveDirection = Direction.UP; this.selectNextMoveDirection(invalidStartAxis, target); @@ -23,7 +23,7 @@ @Override public SoundSource getSoundSource() { -@@ -176,7 +_,7 @@ +@@ -177,7 +_,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == Difficulty.PEACEFUL) { @@ -32,7 +32,7 @@ } } -@@ -218,7 +_,7 @@ +@@ -219,7 +_,7 @@ } if (hitResult != null && this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { @@ -41,7 +41,7 @@ } ProjectileUtil.rotateTowardsMovement(this, 0.5F); -@@ -288,7 +_,7 @@ +@@ -289,7 +_,7 @@ } if (target instanceof LivingEntity livingTarget) { @@ -50,7 +50,7 @@ } } } -@@ -301,14 +_,20 @@ +@@ -302,14 +_,20 @@ } private void destroy() { @@ -73,7 +73,7 @@ } @Override -@@ -323,9 +_,14 @@ +@@ -324,9 +_,14 @@ @Override public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch index 61080a99da0f..6ad7884b21b5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java +++ b/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java -@@ -92,7 +_,14 @@ +@@ -93,7 +_,14 @@ final ItemStack pickupItemStack, final @Nullable ItemStack firedFromWeapon ) { @@ -15,7 +15,7 @@ this.pickupItemStack = pickupItemStack.copy(); this.applyComponentsFromItemStack(pickupItemStack); Unit intangible = pickupItemStack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -121,8 +_,8 @@ +@@ -122,8 +_,8 @@ final ItemStack pickupItemStack, final @Nullable ItemStack firedFromWeapon ) { @@ -26,7 +26,7 @@ } public void setSoundEvent(final SoundEvent soundEvent) { -@@ -156,7 +_,11 @@ +@@ -157,7 +_,11 @@ @Override public void lerpMotion(final Vec3 movement) { super.lerpMotion(movement); @@ -39,7 +39,7 @@ if (this.isInGround() && movement.lengthSqr() > 0.0) { this.setInGround(false); } -@@ -217,6 +_,10 @@ +@@ -218,6 +_,10 @@ this.setSharedFlagOnFire(this.getRemainingFireTicks() > 0); } } else { @@ -50,7 +50,7 @@ this.inGroundTime = 0; Vec3 originalPosition = this.position(); if (this.isInWater()) { -@@ -288,7 +_,7 @@ +@@ -294,7 +_,7 @@ if (entitiesHit.isEmpty()) { if (this.isAlive() && blockHitResult.getType() != HitResult.Type.MISS) { @@ -59,7 +59,7 @@ this.needsSync = true; } break; -@@ -305,7 +_,7 @@ +@@ -311,7 +_,7 @@ private ProjectileDeflection hitTargetsOrDeflectSelf(final Collection entityHitResults) { for (EntityHitResult e : entityHitResults) { @@ -68,7 +68,7 @@ if (!this.isAlive() || deflection != ProjectileDeflection.NONE) { return deflection; } -@@ -337,20 +_,37 @@ +@@ -343,20 +_,37 @@ } } @@ -108,7 +108,7 @@ } public boolean isInGround() { -@@ -376,8 +_,8 @@ +@@ -382,8 +_,8 @@ protected void tickDespawn() { this.life++; @@ -119,7 +119,7 @@ } } -@@ -411,9 +_,9 @@ +@@ -417,9 +_,9 @@ } @Override @@ -131,7 +131,7 @@ } } -@@ -440,7 +_,7 @@ +@@ -446,7 +_,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -140,12 +140,12 @@ return; } -@@ -456,10 +_,16 @@ +@@ -462,10 +_,16 @@ livingOwner.setLastHurtMob(entity); } + if (this.isCritArrow()) damageSource = damageSource.critical(); // Paper - add critical damage API - boolean isEnderman = entity.is(EntityType.ENDERMAN); + boolean isEnderman = entity.is(EntityTypes.ENDERMAN); int remainingFireTicks = entity.getRemainingFireTicks(); if (this.isOnFire() && !isEnderman) { - entity.igniteForSeconds(5.0F); @@ -158,7 +158,7 @@ } if (entity.hurtOrSimulate(damageSource, damage)) { -@@ -497,7 +_,7 @@ +@@ -503,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -167,7 +167,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -508,7 +_,7 @@ +@@ -514,7 +_,7 @@ this.spawnAtLocation(level, this.getPickupItem(), 0.1F); } @@ -176,7 +176,7 @@ } } } -@@ -521,7 +_,7 @@ +@@ -527,7 +_,7 @@ double knockbackResistance = Math.max(0.0, 1.0 - mob.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 movement = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(knockback * 0.6 * knockbackResistance); if (movement.lengthSqr() > 0.0) { @@ -185,7 +185,7 @@ } } } -@@ -632,7 +_,14 @@ +@@ -638,7 +_,14 @@ @Override public void setOwner(final @Nullable Entity owner) { @@ -200,7 +200,7 @@ this.pickup = switch (owner) { case Player ignored when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -644,9 +_,22 @@ +@@ -650,9 +_,22 @@ @Override public void playerTouch(final Player player) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch index e1c73cb88a51..df2f8b43ba59 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/arrow/Arrow.java +++ b/net/minecraft/world/entity/projectile/arrow/Arrow.java -@@ -115,7 +_,7 @@ +@@ -116,7 +_,7 @@ Entity effectSource = this.getEffectSource(); PotionContents potionContents = this.getPotionContents(); float durationScale = this.getPotionDurationScale(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch index 706a0a310a9b..86f2bc4cb0ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java +++ b/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java -@@ -43,7 +_,7 @@ +@@ -44,7 +_,7 @@ protected void doPostHurtEffects(final LivingEntity mob) { super.doPostHurtEffects(mob); MobEffectInstance effect = new MobEffectInstance(MobEffects.GLOWING, this.duration, 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 d64989c78893..e451c4dcb70c 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java +++ b/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java -@@ -51,6 +_,12 @@ +@@ -52,6 +_,12 @@ this.entityData.set(ID_FOIL, tridentItem.hasFoil()); } @@ -13,7 +13,7 @@ @Override protected void defineSynchedData(final SynchedEntityData.Builder entityData) { super.defineSynchedData(entityData); -@@ -72,10 +_,10 @@ +@@ -73,10 +_,10 @@ this.spawnAtLocation(level, this.getPickupItem(), 0.1F); } @@ -26,7 +26,7 @@ return; } -@@ -104,6 +_,20 @@ +@@ -105,6 +_,20 @@ return this.entityData.get(ID_FOIL); } @@ -47,7 +47,7 @@ @Override protected @Nullable EntityHitResult findHitEntity(final Vec3 from, final Vec3 to) { return this.dealtDamage ? null : super.findHitEntity(from, to); -@@ -118,7 +_,7 @@ +@@ -119,7 +_,7 @@ @Override protected void onHitEntity(final EntityHitResult hitResult) { Entity entity = hitResult.getEntity(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch index e13954640c9b..3b0c77c3653d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java +++ b/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java -@@ -55,9 +_,11 @@ +@@ -54,9 +_,11 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch index 084ee5d2c013..ee776b7aeba4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java +++ b/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java -@@ -20,20 +_,27 @@ +@@ -21,20 +_,27 @@ public LargeFireball(final EntityType type, final Level level) { super(type, level); @@ -8,7 +8,7 @@ } public LargeFireball(final Level level, final LivingEntity mob, final Vec3 direction, final int explosionPower) { - super(EntityType.FIREBALL, mob, direction, level); + super(EntityTypes.FIREBALL, mob, direction, level); this.explosionPower = explosionPower; + this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); // CraftBukkit } @@ -31,7 +31,7 @@ } } -@@ -58,6 +_,6 @@ +@@ -59,6 +_,6 @@ @Override protected void readAdditionalSaveData(final ValueInput input) { super.readAdditionalSaveData(input); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch index 0d214aca2064..1ac872dd5951 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java +++ b/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java -@@ -23,6 +_,11 @@ +@@ -24,6 +_,11 @@ public SmallFireball(final Level level, final LivingEntity mob, final Vec3 direction) { - super(EntityType.SMALL_FIREBALL, mob, direction, level); + super(EntityTypes.SMALL_FIREBALL, mob, direction, level); + // CraftBukkit start + if (this.getOwner() != null && this.getOwner() instanceof Mob) { + this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); @@ -12,7 +12,7 @@ } public SmallFireball(final Level level, final double x, final double y, final double z, final Vec3 direction) { -@@ -36,7 +_,14 @@ +@@ -37,7 +_,14 @@ Entity var7 = hitResult.getEntity(); Entity owner = this.getOwner(); int remainingFireTicks = var7.getRemainingFireTicks(); @@ -28,7 +28,7 @@ DamageSource damageSource = this.damageSources().fireball(this, owner); if (!var7.hurtServer(serverLevel, damageSource, 5.0F)) { var7.setRemainingFireTicks(remainingFireTicks); -@@ -51,9 +_,9 @@ +@@ -52,9 +_,9 @@ super.onHitBlock(hitResult); if (this.level() instanceof ServerLevel serverLevel) { Entity owner = this.getOwner(); @@ -40,7 +40,7 @@ this.level().setBlockAndUpdate(pos, BaseFireBlock.getState(this.level(), pos)); } } -@@ -64,7 +_,7 @@ +@@ -65,7 +_,7 @@ protected void onHit(final HitResult hitResult) { super.onHit(hitResult); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch index ee9ee10a94b3..3e12c276450c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java +++ b/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java -@@ -67,11 +_,11 @@ +@@ -68,11 +_,11 @@ if (var8.isAlive()) { EnchantmentHelper.doPostAttackEffects(serverLevel, var8, damageSource); } else { @@ -14,7 +14,7 @@ } if (wasHurt && var8 instanceof LivingEntity livingEntity) { -@@ -83,7 +_,7 @@ +@@ -84,7 +_,7 @@ } if (witherSeconds > 0) { @@ -23,7 +23,7 @@ } } } -@@ -93,8 +_,13 @@ +@@ -94,8 +_,13 @@ protected void onHit(final HitResult hitResult) { super.onHit(hitResult); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch index 8b49c138e55b..d0ed43a96939 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java +++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java -@@ -89,7 +_,7 @@ +@@ -90,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ } public abstract void explode(final Vec3 position); -@@ -102,7 +_,7 @@ +@@ -103,7 +_,7 @@ Vec3 scaledNormal = Vec3.atLowerCornerOf(collisionNormal).multiply(0.25, 0.25, 0.25); Vec3 explosionPos = hitResult.getLocation().add(scaledNormal); this.explode(explosionPos); @@ -18,7 +18,7 @@ } } -@@ -110,7 +_,7 @@ +@@ -111,7 +_,7 @@ protected void onHit(final HitResult hitResult) { super.onHit(hitResult); if (!this.level().isClientSide()) { @@ -27,7 +27,7 @@ } } -@@ -143,7 +_,7 @@ +@@ -144,7 +_,7 @@ public void tick() { if (!this.level().isClientSide() && this.getBlockY() > this.level().getMaxY() + 30) { this.explode(this.position()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch index 1cc4e7797769..1ef8627e6391 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java +++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java -@@ -21,6 +_,12 @@ +@@ -22,6 +_,12 @@ @Override public void explode(final Vec3 position) { @@ -13,7 +13,7 @@ this.level() .explode( this, -@@ -29,8 +_,8 @@ +@@ -30,8 +_,8 @@ position.x(), position.y(), position.z(), diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch index 9248bff35d6a..1ad9995c833b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java +++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java -@@ -59,6 +_,12 @@ +@@ -60,6 +_,12 @@ @Override public void explode(final Vec3 position) { @@ -13,7 +13,7 @@ this.level() .explode( this, -@@ -67,8 +_,8 @@ +@@ -68,8 +_,8 @@ position.x(), position.y(), position.z(), 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 ccfbd149040b..9751d8305645 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 -@@ -63,7 +_,7 @@ +@@ -64,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/projectile/throwableitemprojectile/ThrownEgg.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch index 8969dcd4c4c3..c2237ce7d5a4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java +++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java -@@ -66,29 +_,64 @@ +@@ -67,29 +_,64 @@ protected void onHit(final HitResult hitResult) { super.onHit(hitResult); if (!this.level().isClientSide()) { @@ -39,7 +39,7 @@ + // Paper end - Add ThrownEggHatchEvent for (int i = 0; i < count; i++) { -- Chicken chicken = EntityType.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED); +- Chicken chicken = EntityTypes.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED); + net.minecraft.world.entity.Entity chicken = newEntityType.create(this.level(), net.minecraft.world.entity.EntitySpawnReason.TRIGGERED); // CraftBukkit if (chicken != null) { - chicken.setAge(-24000); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch index 6b6532ae31bf..f56abbf166b6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java -@@ -102,11 +_,22 @@ +@@ -104,11 +_,22 @@ Vec3 teleportPos = this.oldPosition(); if (owner instanceof ServerPlayer player) { if (player.connection.isAcceptingMessages()) { @@ -15,8 +15,8 @@ + return; + } + // CraftBukkit end - if (this.random.nextFloat() < 0.05F && level.isSpawningMonsters()) { - Endermite endermite = EntityType.ENDERMITE.create(level, EntitySpawnReason.TRIGGERED); + if (this.random.nextFloat() < 0.05F && level.isSpawningMonsters() && level.getLevelData().getDifficulty() != Difficulty.PEACEFUL) { + Endermite endermite = EntityTypes.ENDERMITE.create(level, EntitySpawnReason.TRIGGERED); if (endermite != null) { - endermite.snapTo(owner.getX(), owner.getY(), owner.getZ(), owner.getYRot(), owner.getXRot()); - level.addFreshEntity(endermite); @@ -25,7 +25,7 @@ } } -@@ -114,15 +_,17 @@ +@@ -116,15 +_,17 @@ owner.setPortalCooldown(); } @@ -49,7 +49,7 @@ } this.playSound(level, teleportPos); -@@ -142,9 +_,9 @@ +@@ -144,9 +_,9 @@ this.playSound(level, teleportPos); } @@ -61,7 +61,7 @@ } } } -@@ -167,7 +_,7 @@ +@@ -169,7 +_,7 @@ && !owner.isAlive() && !serverPlayer.wonGame && serverPlayer.level().getGameRules().get(GameRules.ENDER_PEARLS_VANISH_ON_DEATH)) { @@ -70,7 +70,7 @@ } else { super.tick(); } -@@ -196,7 +_,7 @@ +@@ -198,7 +_,7 @@ public @Nullable Entity teleport(final TeleportTransition transition) { Entity newEntity = super.teleport(transition); if (newEntity != null) { @@ -79,7 +79,7 @@ } return newEntity; -@@ -204,7 +_,7 @@ +@@ -206,7 +_,7 @@ @Override public boolean canTeleport(final Level from, final Level to) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch index 15d79a480337..2a4ae8a8a08e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java +++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java -@@ -40,16 +_,25 @@ +@@ -41,16 +_,25 @@ protected void onHit(final HitResult hitResult) { super.onHit(hitResult); if (this.level() instanceof ServerLevel level) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch index 11f9feb86424..3c496ba166cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java +++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java -@@ -29,7 +_,7 @@ +@@ -30,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ AreaEffectCloud cloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); if (this.getOwner() instanceof LivingEntity owner) { cloud.setOwner(owner); -@@ -41,6 +_,15 @@ +@@ -42,6 +_,15 @@ cloud.setWaitTime(10); cloud.setRadiusPerTick(-cloud.getRadius() / cloud.getDuration()); cloud.applyComponentsFromItemStack(potionItem); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch index 730333abc10e..b32cc39ff02d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java +++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java -@@ -37,13 +_,14 @@ +@@ -38,13 +_,14 @@ } @Override @@ -17,7 +17,7 @@ float margin = ProjectileUtil.computeMargin(this); if (!entities.isEmpty()) { Entity effectSource = this.getEffectSource(); -@@ -52,8 +_,25 @@ +@@ -53,8 +_,25 @@ if (entity.isAffectedByPotions()) { double dist = potionAabb.distanceToSqr(entity.getBoundingBox().inflate(margin)); if (dist < 16.0) { @@ -44,8 +44,8 @@ + // CraftBukkit end for (MobEffectInstance effectInstance : mobEffects) { Holder effect = effectInstance.getEffect(); - if (effect.value().isInstantenous()) { -@@ -64,7 +_,7 @@ + if (effect.value().isInstantaneous()) { +@@ -65,7 +_,7 @@ effect, duration, effectInstance.getAmplifier(), effectInstance.isAmbient(), effectInstance.isVisible() ); if (!newEffect.endsWithin(20)) { @@ -54,7 +54,7 @@ } } } -@@ -72,5 +_,6 @@ +@@ -73,5 +_,6 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch index 440b9cd9aef2..2f8a2a467d5b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -63,6 +_,12 @@ +@@ -64,6 +_,12 @@ import org.jspecify.annotations.Nullable; public class Raid { @@ -10,10 +10,10 @@ + public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; + public int idOrNegativeOne = -1; + // Paper end - public static final SpawnPlacementType RAVAGER_SPAWN_PLACEMENT_TYPE = SpawnPlacements.getPlacementType(EntityType.RAVAGER); + public static final SpawnPlacementType RAVAGER_SPAWN_PLACEMENT_TYPE = SpawnPlacements.getPlacementType(EntityTypes.RAVAGER); public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( i -> i.group( -@@ -78,6 +_,8 @@ +@@ -79,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) @@ -22,7 +22,7 @@ ) .apply(i, Raid::new) ); -@@ -131,6 +_,7 @@ +@@ -132,6 +_,7 @@ this.center = center; this.numGroups = this.getNumGroups(difficulty); this.status = Raid.RaidStatus.ONGOING; @@ -30,7 +30,7 @@ } private Raid( -@@ -146,6 +_,7 @@ +@@ -147,6 +_,7 @@ final Raid.RaidStatus status, final BlockPos center, final Set heroesOfTheVillage @@ -38,7 +38,7 @@ ) { this.started = started; this.active = active; -@@ -159,6 +_,7 @@ +@@ -160,6 +_,7 @@ this.numGroups = numGroups; this.status = status; this.heroesOfTheVillage.addAll(heroesOfTheVillage); @@ -46,7 +46,7 @@ } public boolean isOver() { -@@ -185,6 +_,12 @@ +@@ -186,6 +_,12 @@ return this.status == Raid.RaidStatus.LOSS; } @@ -59,7 +59,7 @@ public float getTotalHealth() { return this.totalHealth; } -@@ -271,6 +_,7 @@ +@@ -272,6 +_,7 @@ boolean oldActive = this.active; this.active = level.hasChunkAt(this.center); if (level.getDifficulty() == Difficulty.PEACEFUL) { @@ -67,7 +67,7 @@ this.stop(); return; } -@@ -290,13 +_,16 @@ +@@ -291,13 +_,16 @@ if (!level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.RaidStatus.LOSS; @@ -84,7 +84,7 @@ this.stop(); return; } -@@ -385,6 +_,7 @@ +@@ -386,6 +_,7 @@ } if (attempt > 5) { @@ -92,7 +92,7 @@ this.stop(); break; } -@@ -396,6 +_,7 @@ +@@ -397,6 +_,7 @@ } else { this.status = Raid.RaidStatus.VICTORY; @@ -100,7 +100,7 @@ for (UUID heroUUID : this.heroesOfTheVillage) { Entity entity = level.getEntity(heroUUID); if (entity instanceof LivingEntity hero && !entity.isSpectator()) { -@@ -403,9 +_,11 @@ +@@ -404,9 +_,11 @@ if (hero instanceof ServerPlayer playerHero) { playerHero.awardStat(Stats.RAID_WIN); CriteriaTriggers.RAID_WIN.trigger(playerHero); @@ -112,7 +112,7 @@ } } -@@ -413,6 +_,7 @@ +@@ -414,6 +_,7 @@ } else if (this.isOver()) { this.celebrationTicks++; if (this.celebrationTicks >= 600) { @@ -120,7 +120,7 @@ this.stop(); return; } -@@ -568,6 +_,7 @@ +@@ -569,6 +_,7 @@ this.groupsSpawned++; this.updateBossbar(); this.setDirty(level); @@ -128,7 +128,7 @@ } public void joinRaid(final ServerLevel level, final int groupNumber, final Raider raider, final @Nullable BlockPos pos, final boolean exists) { -@@ -582,7 +_,7 @@ +@@ -583,7 +_,7 @@ raider.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null); raider.applyRaidBuffs(level, groupNumber, false); raider.setOnGround(true); @@ -137,7 +137,7 @@ } } } -@@ -809,6 +_,12 @@ +@@ -810,6 +_,12 @@ public void addHeroOfTheVillage(final Entity killer) { this.heroesOfTheVillage.add(killer.getUUID()); } 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 3bb1d81c52d4..687756b5861c 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raider.java +++ b/net/minecraft/world/entity/raid/Raider.java -@@ -213,17 +_,24 @@ +@@ -214,6 +_,11 @@ if (this.hasActiveRaid() && !hasRaidLeader && ItemStack.matches(itemStack, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) { @@ -12,12 +12,7 @@ EquipmentSlot slot = EquipmentSlot.HEAD; ItemStack current = this.getItemBySlot(slot); double dropChance = this.getDropChances().byEquipment(slot); - if (!current.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < dropChance) { -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.spawnAtLocation(level, current); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles - } - +@@ -224,7 +_,7 @@ this.onItemPickup(entity); this.setItemSlot(slot, itemStack); this.take(entity, itemStack.getCount()); @@ -26,7 +21,7 @@ this.getCurrentRaid().setLeader(this.getWave(), this); this.setPatrolLeader(true); } else { -@@ -296,7 +_,7 @@ +@@ -297,7 +_,7 @@ for (Raider entity : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { @@ -35,7 +30,7 @@ } } -@@ -307,7 +_,7 @@ +@@ -308,7 +_,7 @@ if (target != null) { for (Raider entity : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { @@ -44,7 +39,7 @@ entity.setAggressive(true); } -@@ -390,6 +_,7 @@ +@@ -391,6 +_,7 @@ } private boolean cannotPickUpBanner() { 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 d540df29e0fb..15fec8c28375 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; } -@@ -702,12 +_,20 @@ +@@ -707,12 +_,20 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch index 3cb5b2ff19bc..f6e9cbd62bad 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch @@ -9,9 +9,9 @@ + private double derailedX = 0.5; + private double derailedY = 0.5; + private double derailedZ = 0.5; -+ private double flyingX = 0.95; -+ private double flyingY = 0.95; -+ private double flyingZ = 0.95; ++ private double flyingX = this.getAirDrag(); ++ private double flyingY = this.getAirDrag(); ++ private double flyingZ = this.getAirDrag(); + public @Nullable Double maxSpeed; + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API + // CraftBukkit end @@ -89,14 +89,14 @@ this.move(MoverType.SELF, this.getDeltaMovement()); if (!this.onGround()) { -- this.setDeltaMovement(this.getDeltaMovement().scale(0.95)); +- this.setDeltaMovement(this.getDeltaMovement().scale(this.getAirDrag())); + // CraftBukkit start - replace magic numbers with our variables + this.setDeltaMovement(new Vec3(this.getDeltaMovement().x * this.flyingX, this.getDeltaMovement().y * this.flyingY, this.getDeltaMovement().z * this.flyingZ)); + // CraftBukkit end } } -@@ -478,6 +_,15 @@ +@@ -483,6 +_,15 @@ this.setDisplayOffset(input.getIntOr("DisplayOffset", this.getDefaultDisplayOffset())); this.flipped = input.getBooleanOr("FlippedRotation", false); this.firstTick = input.getBooleanOr("HasTicked", false); @@ -112,7 +112,7 @@ } @Override -@@ -490,13 +_,26 @@ +@@ -495,13 +_,26 @@ output.putBoolean("FlippedRotation", this.flipped); output.putBoolean("HasTicked", this.firstTick); @@ -139,7 +139,7 @@ double xa = entity.getX() - this.getX(); double za = entity.getZ() - this.getZ(); double dd = xa * xa + za * za; -@@ -605,4 +_,26 @@ +@@ -610,4 +_,26 @@ public boolean isFurnace() { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch index 228857bf91fd..6dde57357abf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java -@@ -38,6 +_,7 @@ +@@ -36,6 +_,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; public float explosionSpeedFactor = 1.0F; @@ -8,7 +8,7 @@ public MinecartTNT(final EntityType type, final Level level) { super(type, level); -@@ -52,6 +_,12 @@ +@@ -50,6 +_,12 @@ public void tick() { super.tick(); if (this.fuse > 0) { @@ -21,7 +21,17 @@ this.fuse--; this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0); } else if (this.fuse == 0) { -@@ -103,6 +_,17 @@ +@@ -81,8 +_,7 @@ + this.destroy(level, this.getDropItem()); + } else { + if (this.fuse < 0) { +- this.primeFuse(source); +- this.fuse = this.random.nextInt(20) + this.random.nextInt(20); ++ this.primeFuse(source, this.random.nextInt(20) + this.random.nextInt(20)); // Paper - call EntityIgniteEvent + } + } + } +@@ -101,6 +_,17 @@ if (this.level() instanceof ServerLevel level) { if (level.getGameRules().get(GameRules.TNT_EXPLODES)) { double speed = Math.min(Math.sqrt(speedSqr), 5.0); @@ -32,14 +42,14 @@ + this.isIncendiary + ); + if (!event.callEvent()) { -+ this.fuse = -1; ++ this.fuse = net.minecraft.world.entity.item.PrimedTnt.NO_FUSE; + return; + } + // CraftBukkit end level.explode( this, damageSource, -@@ -110,13 +_,13 @@ +@@ -108,13 +_,13 @@ this.getX(), this.getY(), this.getZ(), @@ -57,3 +67,25 @@ } } } +@@ -146,8 +_,20 @@ + } + + public void primeFuse(final @Nullable DamageSource source) { ++ // Paper start - add fuseTime param ++ this.primeFuse(source, 80); ++ } ++ ++ public void primeFuse(final @Nullable DamageSource source, int fuseTime) { ++ // Paper end - add fuseTime param + if (!(this.level() instanceof ServerLevel serverLevel && !serverLevel.getGameRules().get(GameRules.TNT_EXPLODES))) { +- this.fuse = 80; ++ // Paper start - call EntityIgniteEvent ++ fuseTime = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityIgniteEvent(this, fuseTime); ++ if (fuseTime == net.minecraft.world.entity.item.PrimedTnt.NO_FUSE) { ++ return; ++ } ++ this.fuse = fuseTime; ++ // Paper end - call EntityIgniteEvent + if (!this.level().isClientSide()) { + if (source != null && this.ignitionSource == null) { + this.ignitionSource = this.damageSources().explosion(this, source.getEntity()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch index 05af618c7eeb..ca5830a34577 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java -@@ -482,6 +_,12 @@ +@@ -484,6 +_,12 @@ @Override public double getMaxSpeed(final ServerLevel level) { @@ -13,7 +13,7 @@ return level.getGameRules().get(GameRules.MAX_MINECART_SPEED).intValue() * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; } -@@ -497,7 +_,8 @@ +@@ -499,7 +_,8 @@ @Override public double getSlowdownFactor() { @@ -23,7 +23,7 @@ } @Override -@@ -521,6 +_,13 @@ +@@ -523,6 +_,13 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -37,7 +37,7 @@ boolean pickedUp = entity.startRiding(this.minecart); if (pickedUp) { return true; -@@ -544,6 +_,17 @@ +@@ -546,6 +_,17 @@ || entity instanceof AbstractMinecart || this.minecart.isVehicle() || entity.isPassenger()) { @@ -55,7 +55,7 @@ entity.push(this.minecart); pushed = true; } -@@ -552,6 +_,15 @@ +@@ -554,6 +_,15 @@ } else { for (Entity entity : this.level().getEntities(this.minecart, hitbox)) { if (!this.minecart.hasPassenger(entity) && entity.isPushable() && entity instanceof AbstractMinecart) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index acf6056d0032..d96b21456935 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -157,7 +157,7 @@ this.resetQuickCraft(); @@ -405,8 +_,11 @@ - if (slotIndex == -999) { + if (slotIndex == SLOT_CLICKED_OUTSIDE) { if (!this.getCarried().isEmpty()) { if (clickAction == ClickAction.PRIMARY) { - player.drop(this.getCarried(), true); @@ -188,7 +188,7 @@ ItemStack source = inventory.getItem(buttonNum); Slot target = this.slots.get(slotIndex); ItemStack targetItemStack = target.getItem(); -@@ -529,7 +_,11 @@ +@@ -528,7 +_,11 @@ } itemStack = slot.safeTake(amount, Integer.MAX_VALUE, player); @@ -201,7 +201,7 @@ player.handleCreativeModeItemDrop(itemStack); } } -@@ -590,14 +_,15 @@ +@@ -589,14 +_,15 @@ if (player instanceof ServerPlayer) { ItemStack carried = this.getCarried(); if (!carried.isEmpty()) { @@ -219,7 +219,7 @@ boolean serverPlayerHasDisconnected = player instanceof ServerPlayer serverPlayer && serverPlayer.hasDisconnected(); if (playerRemovedNotChangingDimension || serverPlayerHasDisconnected) { player.drop(carried, false); -@@ -637,6 +_,14 @@ +@@ -636,6 +_,14 @@ public abstract boolean stillValid(Player player); protected boolean moveItemStackTo(final ItemStack itemStack, final int startSlot, final int endSlot, final boolean backwards) { @@ -234,7 +234,7 @@ boolean anythingChanged = false; int destSlot = startSlot; if (backwards) { -@@ -647,18 +_,27 @@ +@@ -646,18 +_,27 @@ while (!itemStack.isEmpty() && (backwards ? destSlot >= startSlot : destSlot < endSlot)) { Slot slot = this.slots.get(destSlot); ItemStack target = slot.getItem(); @@ -262,7 +262,7 @@ anythingChanged = true; } } -@@ -681,10 +_,21 @@ +@@ -680,10 +_,21 @@ while (backwards ? destSlot >= startSlot : destSlot < endSlot) { Slot slot = this.slots.get(destSlot); ItemStack target = slot.getItem(); @@ -284,7 +284,7 @@ anythingChanged = true; break; } -@@ -768,6 +_,11 @@ +@@ -767,6 +_,11 @@ } public ItemStack getCarried() { @@ -296,7 +296,7 @@ return this.carried; } -@@ -821,4 +_,15 @@ +@@ -820,4 +_,15 @@ this.stateId = this.stateId + 1 & 32767; return this.stateId; } 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 b23652ee19a3..4f47a8f1022f 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,7 +1,7 @@ --- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java +++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -34,6 +_,21 @@ - private final RecipeType recipeType; +@@ -32,6 +_,21 @@ + protected final Level level; private final RecipePropertySet acceptedInputs; private final RecipeBookType recipeBookType; + // CraftBukkit start @@ -22,7 +22,7 @@ protected AbstractFurnaceMenu( final MenuType menuType, -@@ -68,6 +_,7 @@ +@@ -63,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); } -@@ -85,6 +_,7 @@ +@@ -80,6 +_,7 @@ @Override public boolean stillValid(final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch index fdf2796bc797..6e97c073f385 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java -@@ -22,20 +_,14 @@ +@@ -23,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; @@ -26,7 +26,7 @@ public BeaconMenu(final int containerId, final Container inventory) { this(containerId, inventory, new SimpleContainerData(3), ContainerLevelAccess.NULL); -@@ -43,6 +_,25 @@ +@@ -44,6 +_,25 @@ public BeaconMenu(final int containerId, final Container inventory, final ContainerData beaconData, final ContainerLevelAccess access) { super(MenuType.BEACON, containerId); @@ -52,7 +52,7 @@ checkContainerDataCount(beaconData, 3); this.beaconData = beaconData; this.access = access; -@@ -65,6 +_,7 @@ +@@ -66,6 +_,7 @@ @Override public boolean stillValid(final Player player) { @@ -60,7 +60,7 @@ return stillValid(this.access, player, Blocks.BEACON); } -@@ -138,13 +_,30 @@ +@@ -139,6 +_,11 @@ public @Nullable Holder getSecondaryEffect() { return decodeEffect(this.beaconData.get(2)); } @@ -70,31 +70,28 @@ + } + // Paper end - Add PlayerChangeBeaconEffectEvent -- public void updateEffects(final Optional> primary, final Optional> secondary) { -+ public void updateEffects(final Optional> primary, Optional> secondary) { // Paper - fix MC-174630 - make non-final -+ // Paper start - fix MC-174630 - validate secondary power -+ if (secondary.isPresent() && secondary.get() != net.minecraft.world.effect.MobEffects.REGENERATION && (primary.isPresent() && secondary.get() != primary.get())) { -+ secondary = Optional.empty(); -+ } -+ // Paper end + public boolean updateEffects(final Optional> primary, final Optional> secondary) { if (this.paymentSlot.hasItem()) { -- this.beaconData.set(1, encodeEffect(primary.orElse(null))); -- this.beaconData.set(2, encodeEffect(secondary.orElse(null))); +@@ -149,8 +_,16 @@ + return false; + } + +- this.beaconData.set(1, encodeEffect(primaryEffect)); +- this.beaconData.set(2, encodeEffect(secondaryEffect)); + // Paper start - Add PlayerChangeBeaconEffectEvent + io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent event = new io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.inventory.player.getBukkitEntity(), convert(primary), convert(secondary), this.access.getLocation().getBlock()); -+ if (event.callEvent()) { -+ // Paper end - Add PlayerChangeBeaconEffectEvent -+ this.beaconData.set(1, BeaconMenu.encodeEffect(event.getPrimary() == null ? null : org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraftHolder(event.getPrimary()))); // CraftBukkit -+ this.beaconData.set(2, BeaconMenu.encodeEffect(event.getSecondary() == null ? null : org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraftHolder(event.getSecondary()))); // CraftBukkit -+ if (event.willConsumeItem()) { // Paper ++ if (!event.callEvent()) { ++ return true; // don't disconnect player when the event is cancelled ++ } ++ ++ this.beaconData.set(1, encodeEffect(event.getPrimary() == null ? null : org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraftHolder(event.getPrimary()))); ++ this.beaconData.set(2, encodeEffect(event.getSecondary() == null ? null : org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraftHolder(event.getSecondary()))); ++ if (event.willConsumeItem()) ++ // Paper end - Add PlayerChangeBeaconEffectEvent this.paymentSlot.remove(1); -+ } // Paper this.access.execute(Level::blockEntityChanged); -+ } // Paper end - Add PlayerChangeBeaconEffectEvent - } - } - -@@ -167,4 +_,17 @@ + return true; +@@ -178,4 +_,17 @@ return 1; } } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch index 2faa1d0a05de..a841f04f7f93 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch @@ -80,7 +80,7 @@ this.access = access; this.addSlot(new Slot(this.container, 0, 15, 15) { @Override -@@ -80,10 +_,12 @@ +@@ -87,10 +_,12 @@ } }); this.addStandardInventorySlots(inventory, 8, 84); @@ -93,7 +93,7 @@ return stillValid(this.access, player, Blocks.CARTOGRAPHY_TABLE); } -@@ -99,6 +_,7 @@ +@@ -106,6 +_,7 @@ } else { this.resultContainer.removeItemNoUpdate(2); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch index e7b0142bc662..f78556570f66 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -65,12 +65,12 @@ @@ -68,7 +_,11 @@ public void onTake(final Player player, final ItemStack carried) { access.execute((level, pos) -> { - if (level instanceof ServerLevel) { -- ExperienceOrb.award((ServerLevel)level, Vec3.atCenterOf(pos), this.getExperienceAmount(level)); + if (level instanceof ServerLevel serverLevel) { +- ExperienceOrb.award(serverLevel, Vec3.atCenterOf(pos), this.getExperienceAmount(level)); + // Paper start - Fire BlockExpEvent on grindstone use + org.bukkit.event.block.BlockExpEvent event = new org.bukkit.event.block.BlockExpEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), this.getExperienceAmount(level)); + event.callEvent(); -+ ExperienceOrb.awardWithDirection((ServerLevel) level, Vec3.atCenterOf(pos), Vec3.ZERO, event.getExpToDrop(), org.bukkit.entity.ExperienceOrb.SpawnReason.GRINDSTONE, player, null); ++ ExperienceOrb.awardWithDirection(serverLevel, Vec3.atCenterOf(pos), Vec3.ZERO, event.getExpToDrop(), org.bukkit.entity.ExperienceOrb.SpawnReason.GRINDSTONE, player, null); + // Paper end - Fire BlockExpEvent on grindstone use } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch index 0b1e4e071bbd..2fe82f342fce 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch @@ -52,7 +52,7 @@ + LoomMenu.this.slotUpdateListener.run(); + } + }; -+ this.outputContainer = new SimpleContainer(this.createBlockHolder(access), 1) { // Paper - Add missing InventoryHolders ++ this.outputContainer = new SimpleContainer(this.createBlockHolder(access), 1) { // Paper - Add missing InventoryHolders + @Override + public void setChanged() { + super.setChanged(); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ResultSlot.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ResultSlot.java.patch index e545b51623ec..90c6afa4f651 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ResultSlot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ResultSlot.java.patch @@ -12,7 +12,7 @@ } @Override -@@ -72,7 +_,7 @@ +@@ -79,7 +_,7 @@ private NonNullList getRemainingItems(final CraftingInput input, final Level level) { return level instanceof ServerLevel serverLevel ? serverLevel.recipeAccess() @@ -21,7 +21,7 @@ .map(recipe -> recipe.value().getRemainingItems(input)) .orElseGet(() -> copyAllInputItems(input)) : CraftingRecipe.defaultCraftingReminder(input); -@@ -80,6 +_,11 @@ +@@ -87,6 +_,11 @@ @Override public void onTake(final Player player, final ItemStack carried) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch index d59204c41915..1a97f0caa588 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch @@ -10,8 +10,8 @@ private SelectableRecipe.SingleInputSet recipesForInput = SelectableRecipe.SingleInputSet.empty(); private ItemStack input = ItemStack.EMPTY; @@ -33,15 +_,23 @@ - final Slot inputSlot; - final Slot resultSlot; + private final Slot inputSlot; + private final Slot resultSlot; private Runnable slotUpdateListener = () -> {}; - public final Container container = new SimpleContainer(1) { - @Override 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 index 88f4f50a083c..608fc069d780 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ArmorStandItem.java +++ b/net/minecraft/world/item/ArmorStandItem.java -@@ -46,6 +_,12 @@ +@@ -47,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); 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 index 832a16a44bcf..160a7cbc7f00 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/AxeItem.java.patch @@ -9,6 +9,6 @@ + return InteractionResult.PASS; + } + // Paper end - if (player instanceof ServerPlayer) { - CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, pos, itemInHand); + if (player instanceof ServerPlayer serverPlayer) { + CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(serverPlayer, 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 index 23859e38c217..91b414fa6501 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch @@ -17,7 +17,7 @@ this.updateCustomBlockEntityTag(pos, level, player, itemStack, placedState); updateBlockEntityComponents(level, pos, itemStack); + } catch (Exception ex) { -+ ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(); ++ ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(false); + 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")); @@ -31,15 +31,15 @@ + 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(); ++ ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(false); + + player.containerMenu.forceHeldSlot(updatedPlaceContext.getHand()); + return InteractionResult.FAIL; + } + } + // CraftBukkit end - if (player instanceof ServerPlayer) { - CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, pos, itemStack); + if (player instanceof ServerPlayer serverPlayer) { + CriteriaTriggers.PLACED_BLOCK.trigger(serverPlayer, pos, itemStack); } } 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 index 739a4d4d0079..8a324ab85f8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BowItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BowItem.java +++ b/net/minecraft/world/item/BowItem.java -@@ -40,7 +_,7 @@ +@@ -38,7 +_,7 @@ 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/sources/net/minecraft/world/item/BucketItem.java.patch index 511dda21445b..9b17c075014e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch @@ -8,40 +8,40 @@ 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 { +@@ -57,7 +_,7 @@ + if (level.mayInteract(player, pos) && player.mayUseItemAt(directionOffsetPos, direction, itemStack)) { 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 @@ + if (player instanceof ServerPlayer serverPlayer && this.content != Fluids.EMPTY) { + CriteriaTriggers.PLACED_BLOCK.trigger(serverPlayer, placePos, itemStack); +@@ -70,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); + } +@@ -97,6 +_,13 @@ } public static ItemStack getEmptySuccessItem(final ItemStack itemStack, final Player player) { @@ -55,11 +55,13 @@ return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : itemStack; } -@@ -104,6 +_,12 @@ +@@ -105,7 +_,13 @@ + } @Override - public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult) { -+ // CraftBukkit start +- public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult) { ++ // CraftBukkit start ++ public final boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult) { + return this.emptyContents(user, level, pos, hitResult, null, null, null, InteractionHand.MAIN_HAND); + } + @@ -68,7 +70,7 @@ if (!(this.content instanceof FlowingFluid flowingFluid)) { return false; } else { -@@ -114,8 +_,18 @@ +@@ -116,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); diff --git a/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch index 96811e2e44cd..6bcc58cd3d4c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch @@ -23,7 +23,7 @@ if (projectile.is(Items.FIREWORK_ROCKET)) { - return new FireworkRocketEntity(level, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15F, shooter.getZ(), true); + // Paper start -+ FireworkRocketEntity entity = new FireworkRocketEntity(level, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15F, shooter.getZ(), true); ++ FireworkRocketEntity entity = new FireworkRocketEntity(level, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15F, shooter.getZ(), true); + entity.spawningEntity = shooter.getUUID(); // Paper + return entity; + // Paper end 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 index b26965ea3b7d..f2df6ad3abca 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/EndCrystalItem.java +++ b/net/minecraft/world/item/EndCrystalItem.java @@ -44,11 +_,17 @@ - if (level instanceof ServerLevel) { + if (level instanceof ServerLevel serverLevel) { EndCrystal crystal = new EndCrystal(level, x + 0.5, y, z + 0.5); crystal.setShowBottom(false); + // CraftBukkit start @@ -12,7 +12,7 @@ + // CraftBukkit end level.addFreshEntity(crystal); level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, above); - EnderDragonFight fight = ((ServerLevel)level).getDragonFight(); + EnderDragonFight fight = serverLevel.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/sources/net/minecraft/world/item/HangingEntityItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch index 208052922fe2..0dde2d64b042 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/HangingEntityItem.java +++ b/net/minecraft/world/item/HangingEntityItem.java -@@ -63,6 +_,20 @@ - EntityType.createDefaultStackConfig(level, itemInHand, player).accept(entity); +@@ -64,6 +_,20 @@ + EntityType.createDefaultStackConfig(level, itemInHand, player).apply(entity); if (entity.survives()) { if (!level.isClientSide()) { + // CraftBukkit start - fire HangingPlaceEvent diff --git a/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch index 4b222bd71be1..26b1a9a283d7 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/HoneycombItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/HoneycombItem.java +++ b/net/minecraft/world/item/HoneycombItem.java -@@ -146,6 +_,14 @@ +@@ -70,6 +_,14 @@ return getWaxed(oldState).map(waxedState -> { Player player = context.getPlayer(); ItemStack itemInHand = context.getItemInHand(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index e3f537d542d7..7d038d8d3e55 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -187,12 +_,20 @@ +@@ -186,12 +_,20 @@ @Override public void encode(final RegistryFriendlyByteBuf output, final ItemStack itemStack) { @@ -23,7 +23,7 @@ } } }; -@@ -204,7 +_,7 @@ +@@ -203,7 +_,7 @@ public ItemStack decode(final RegistryFriendlyByteBuf input) { ItemStack itemStack = codec.decode(input); if (!itemStack.isEmpty()) { @@ -32,7 +32,7 @@ ItemStack.CODEC.encodeStart(ops, itemStack).getOrThrow(DecoderException::new); } -@@ -369,10 +_,165 @@ +@@ -368,10 +_,156 @@ } Item usedItem = this.getItem(); @@ -45,34 +45,42 @@ + + if (!(usedItem instanceof BucketItem)) { + level.captureBlockStates = true; -+ if (isBonemeal) { -+ level.captureTreeGeneration = true; -+ } ++ level.captureTreeGeneration = isBonemeal; + } ++ ++ List capturedBlockStates; ++ java.util.Map capturedTileEntities; ++ org.bukkit.TreeType treeType; + InteractionResult result; + try { + result = usedItem.useOn(context); + } finally { + level.captureBlockStates = false; ++ level.captureTreeGeneration = false; ++ ++ capturedBlockStates = new java.util.ArrayList<>(level.capturedBlockStates.values()); ++ level.capturedBlockStates.clear(); ++ ++ capturedTileEntities = new java.util.LinkedHashMap<>(level.capturedTileEntities); ++ level.capturedTileEntities.clear(); ++ ++ treeType = net.minecraft.world.level.block.SaplingBlock.treeType; ++ net.minecraft.world.level.block.SaplingBlock.treeType = null; + } ++ + 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; ++ if (result.consumesAction() && isBonemeal && !capturedBlockStates.isEmpty()) { + 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); ++ structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, isBonemeal, (org.bukkit.entity.Player) player.getBukkitEntity(), (List) (List) capturedBlockStates); + 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); ++ 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) capturedBlockStates); + fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled()); + org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent); + @@ -82,7 +90,7 @@ + this.restorePatch(newPatch); + this.setCount(newCount); + } -+ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : blocks) { ++ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : capturedBlockStates) { + // 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 @@ -93,27 +101,23 @@ + 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 (capturedBlockStates.size() > 1) { ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(level, player, hand, (List) (List) capturedBlockStates, pos); ++ } else if (capturedBlockStates.size() == 1 && usedItem != Items.POWDER_SNOW_BUCKET) { // Paper - Fix cancelled powdered snow bucket placement ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(level, player, hand, capturedBlockStates.getFirst(), pos); + } + + 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 (org.bukkit.craftbukkit.block.CraftBlockState snapshot : capturedBlockStates) { ++ snapshot.revertPlace(true); // poi updates needs to be skipped since the poi were never registered as part of the capture + } + + SignItem.openSign = null; // SPIGOT-6758 - Reset on early return @@ -124,14 +128,14 @@ + this.setCount(newCount); + } + -+ for (java.util.Map.Entry e : level.capturedTileEntities.entrySet()) { ++ for (java.util.Map.Entry e : capturedTileEntities.entrySet()) { + level.setBlockEntity(e.getValue()); + } + -+ 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(); ++ for (org.bukkit.block.BlockState snapshot : capturedBlockStates) { ++ int updateFlags = ((org.bukkit.craftbukkit.block.CraftBlockState) snapshot).getFlags(); ++ net.minecraft.world.level.block.state.BlockState oldBlock = ((org.bukkit.craftbukkit.block.CraftBlockState) snapshot).getHandle(); ++ BlockPos newPos = ((org.bukkit.craftbukkit.block.CraftBlockState) snapshot).getPosition(); + net.minecraft.world.level.block.state.BlockState block = level.getBlockState(newPos); + + if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically @@ -171,17 +175,6 @@ + } + } + -+ // 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-1288 - play sound stripped from BlockItem + if (usedItem instanceof BlockItem && success.paperSuccessContext().placedPos() != null) { + // Paper start - Fix spigot sound playing for BlockItem ItemStacks @@ -194,13 +187,11 @@ + player.awardStat(Stats.ITEM_USED.get(usedItem)); + } } -+ level.capturedTileEntities.clear(); -+ level.capturedBlockStates.clear(); + // CraftBukkit end return result; } -@@ -448,31 +_,67 @@ +@@ -447,31 +_,67 @@ return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -276,7 +267,7 @@ this.shrink(1); onBreak.accept(item); } -@@ -485,7 +_,26 @@ +@@ -484,7 +_,26 @@ return; } @@ -304,7 +295,7 @@ this.applyDamage(newDamage, serverPlayer, i -> {}); } } -@@ -495,9 +_,14 @@ +@@ -494,9 +_,14 @@ } public void hurtAndBreak(final int amount, final LivingEntity owner, final EquipmentSlot slot) { @@ -320,7 +311,7 @@ ); } } -@@ -756,6 +_,12 @@ +@@ -755,6 +_,12 @@ return this.getItem().useOnRelease(this); } @@ -333,7 +324,7 @@ public @Nullable T set(final DataComponentType type, final @Nullable T value) { return this.components.set(type, value); } -@@ -799,6 +_,28 @@ +@@ -798,6 +_,28 @@ this.components.setAll(components); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch index 1159ff5092b7..e1c94b1481b5 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MobBucketItem.java +++ b/net/minecraft/world/item/MobBucketItem.java -@@ -49,7 +_,7 @@ +@@ -52,18 +_,18 @@ } if (mob != null) { @@ -9,3 +9,16 @@ mob.playAmbientSound(); } } + + @Override +- public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult) { ++ public boolean emptyContents(final @Nullable LivingEntity user, final Level level, final BlockPos pos, final @Nullable BlockHitResult hitResult, final net.minecraft.core.Direction direction, final BlockPos clicked, final ItemStack itemStack, final net.minecraft.world.InteractionHand hand) { // Paper + if (this.content == Fluids.EMPTY) { + this.playEmptySound(user, level, pos); + return true; + } else { +- return super.emptyContents(user, level, pos, hitResult); ++ return super.emptyContents(user, level, pos, hitResult, direction, clicked, itemStack, hand); // Paper + } + } + 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 index 274ee7f95a33..4372e82df07a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -63,6 +_,7 @@ +@@ -44,7 +_,7 @@ + Level level = context.getLevel(); + ItemStack itemStack = context.getItemInHand(); + EntityType type = getType(itemStack); +- if (type == null || !type.canSpawn(level)) { ++ if (type == null || !type.canSpawn(level, itemStack.get(DataComponents.ENTITY_DATA).getUnsafe())) { // Paper - check peaceful override + return InteractionResult.FAIL; + } else if (!(level instanceof ServerLevel serverLevel)) { + return InteractionResult.SUCCESS; +@@ -60,6 +_,7 @@ return InteractionResult.FAIL; } else { @@ -8,16 +17,16 @@ 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; +@@ -108,7 +_,7 @@ } -- if (!type.isAllowedInPeaceful() && level.getDifficulty() == Difficulty.PEACEFUL) { -+ if (!type.isAllowedInPeaceful(itemStack.get(DataComponents.ENTITY_DATA).getUnsafe()) && level.getDifficulty() == Difficulty.PEACEFUL) { // Paper - check peaceful override + EntityType type = getType(itemStack); +- if (type == null || !type.canSpawn(level)) { ++ if (type == null || !type.canSpawn(level, itemStack.get(DataComponents.ENTITY_DATA).getUnsafe())) { // Paper - check peaceful override return InteractionResult.FAIL; } -@@ -174,7 +_,7 @@ +@@ -171,7 +_,7 @@ 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/alchemy/PotionContents.java.patch b/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionContents.java.patch index 9c5ba623b7c6..5fd6ed9569b2 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionContents.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/alchemy/PotionContents.java +++ b/net/minecraft/world/item/alchemy/PotionContents.java @@ -158,7 +_,7 @@ - if (effect.getEffect().value().isInstantenous()) { - effect.getEffect().value().applyInstantenousEffect(serverLevel, player, player, entity, effect.getAmplifier(), 1.0); + if (effect.getEffect().value().isInstantaneous()) { + effect.getEffect().value().applyInstantaneousEffect(serverLevel, player, player, entity, effect.getAmplifier(), 1.0); } else { - entity.addEffect(effect); + entity.addEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch index d3fbec29c866..d90297f46f7b 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch @@ -1,24 +1,10 @@ --- a/net/minecraft/world/item/component/ChargedProjectiles.java +++ b/net/minecraft/world/item/component/ChargedProjectiles.java -@@ -18,10 +_,19 @@ - - public record ChargedProjectiles(List items) implements TooltipProvider { - public static final ChargedProjectiles EMPTY = new ChargedProjectiles(List.of()); -- public static final Codec CODEC = ItemStackTemplate.CODEC.listOf().xmap(ChargedProjectiles::new, projectiles -> projectiles.items); -+ public static final Codec CODEC = ItemStackTemplate.CODEC.sizeLimitedListOf(64).xmap(ChargedProjectiles::new, projectiles -> projectiles.items); // Paper - limit size +@@ -27,6 +_,7 @@ + .xmap(ChargedProjectiles::new, projectiles -> projectiles.items); public static final StreamCodec STREAM_CODEC = ItemStackTemplate.STREAM_CODEC -- .apply(ByteBufCodecs.list()) -+ .apply(ByteBufCodecs.list(64)) // Paper - limit size + .apply(ByteBufCodecs.list(1024)) + .apply(ByteBufCodecs::increaseDepth) // Paper - Track codec depth .map(ChargedProjectiles::new, projectiles -> projectiles.items); -+ -+ // Paper start - limit size -+ public ChargedProjectiles { -+ if (items.size() > 64) { -+ throw new IllegalArgumentException("Too many items"); -+ } -+ } -+ // Paper end - limit size - public static ChargedProjectiles of(final ItemStackTemplate stack) { - return new ChargedProjectiles(List.of(stack)); + public ChargedProjectiles { 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 45d5ff42e209..1307e5de9ddb 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 @@ -50,4 +50,4 @@ + return o instanceof Ingredient other && Objects.equals(this.values, other.values) && Objects.equals(this.itemStacks, other.itemStacks); // CraftBukkit } - public static Ingredient of(final ItemLike itemLike) { + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/item/equipment/Equippable.java.patch b/paper-server/patches/sources/net/minecraft/world/item/equipment/Equippable.java.patch index df11d8473a45..2832b83c1b96 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/equipment/Equippable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/equipment/Equippable.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/equipment/Equippable.java +++ b/net/minecraft/world/item/equipment/Equippable.java -@@ -129,6 +_,19 @@ +@@ -130,6 +_,19 @@ ItemStack inEquipmentSlot = player.getItemBySlot(this.slot); if ((!EnchantmentHelper.has(inEquipmentSlot, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || player.isCreative()) && !ItemStack.isSameItemSameComponents(inHand, inEquipmentSlot)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch index df4955477bdd..96f904889de1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -52,13 +_,15 @@ +@@ -58,13 +_,15 @@ public int maxNearbyEntities = 6; public int requiredPlayerRange = 16; public int spawnRange = 4; @@ -17,7 +17,7 @@ } public void clientTick(final Level level, final BlockPos pos) { -@@ -81,13 +_,19 @@ +@@ -87,13 +_,19 @@ } public void serverTick(final ServerLevel level, final BlockPos pos) { @@ -39,7 +39,7 @@ } else { boolean delay = false; RandomSource random = level.getRandom(); -@@ -125,6 +_,21 @@ +@@ -131,6 +_,21 @@ continue; } @@ -61,7 +61,7 @@ Entity entity = EntityType.loadEntityRecursive(input, level, EntitySpawnReason.SPAWNER, e -> { e.snapTo(spawnPos.x, spawnPos.y, spawnPos.z, e.getYRot(), e.getXRot()); return e; -@@ -159,9 +_,22 @@ +@@ -165,9 +_,22 @@ } nextSpawnData.getEquipment().ifPresent(mob::equip); @@ -85,8 +85,8 @@ this.delay(level, pos); return; } -@@ -172,7 +_,7 @@ - ((Mob)entity).spawnAnim(); +@@ -178,7 +_,7 @@ + mob.spawnAnim(); } - delay = true; @@ -94,7 +94,7 @@ } } } -@@ -199,12 +_,14 @@ +@@ -205,12 +_,14 @@ } public void load(final @Nullable Level level, final BlockPos pos, final ValueInput input) { @@ -112,7 +112,7 @@ this.spawnCount = input.getIntOr("SpawnCount", 4); this.maxNearbyEntities = input.getIntOr("MaxNearbyEntities", 6); this.requiredPlayerRange = input.getIntOr("RequiredPlayerRange", 16); -@@ -213,9 +_,19 @@ +@@ -219,9 +_,19 @@ } public void save(final ValueOutput output) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/ChunkPos.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ChunkPos.java.patch index 7b6feb28b42c..36d1eda8403f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ChunkPos.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ChunkPos.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/ChunkPos.java +++ b/net/minecraft/world/level/ChunkPos.java -@@ -17,7 +_,16 @@ - import net.minecraft.world.level.chunk.status.ChunkStatus; +@@ -16,7 +_,16 @@ + import net.minecraft.world.level.chunk.status.ChunkPyramid; import org.jspecify.annotations.Nullable; -public record ChunkPos(int x, int z) { @@ -18,7 +18,7 @@ public static final Codec CODEC = Codec.INT_STREAM .comapFlatMap(input -> Util.fixedSize(input, 2).map(ints -> new ChunkPos(ints[0], ints[1])), pos -> IntStream.of(pos.x, pos.z)) .stable(); -@@ -72,7 +_,7 @@ +@@ -69,7 +_,7 @@ } public long pack() { 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 941c945f7692..4398c1967ca8 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 @@ -20,7 +20,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 @@ +@@ -133,6 +_,55 @@ private final PalettedContainerFactory palettedContainerFactory; private long subTickCount; @@ -76,7 +76,7 @@ protected Level( final WritableLevelData levelData, final ResourceKey dimension, -@@ -141,7 +_,25 @@ +@@ -142,7 +_,25 @@ final boolean isDebug, final long biomeZoomSeed, final int maxChainedNeighborUpdates @@ -102,8 +102,8 @@ this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; this.dimension = dimension; -@@ -155,6 +_,46 @@ - this.damageSources = new DamageSources(registryAccess); +@@ -160,6 +_,46 @@ + return 0; } + // Paper start - Cancel hit for vanished players @@ -149,7 +149,7 @@ @Override public boolean isClientSide() { return this.isClientSide; -@@ -165,8 +_,15 @@ +@@ -170,8 +_,15 @@ return null; } @@ -166,7 +166,7 @@ } public boolean isInValidBounds(final BlockPos pos) { -@@ -178,7 +_,7 @@ +@@ -183,7 +_,7 @@ } private static boolean isInWorldBoundsHorizontal(final BlockPos pos) { @@ -175,7 +175,7 @@ } private static boolean isInValidBoundsHorizontal(final BlockPos pos) { -@@ -191,14 +_,79 @@ +@@ -196,14 +_,79 @@ return y < -20000000 || y >= 20000000; } @@ -259,10 +259,10 @@ @Override public @Nullable ChunkAccess getChunk(final int chunkX, final int chunkZ, final ChunkStatus status, final boolean loadOrGenerate) { -@@ -217,6 +_,22 @@ +@@ -222,6 +_,22 @@ @Override - public boolean setBlock(final BlockPos pos, final BlockState blockState, @Block.UpdateFlags final int updateFlags, final int updateLimit) { + public boolean setBlock(final BlockPos pos, final BlockState blockState, final @Block.UpdateFlags int updateFlags, final int updateLimit) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { + // Paper start - Protect Bedrock and End Portal/Frames from being destroyed @@ -282,7 +282,7 @@ if (!this.isInValidBounds(pos)) { return false; } -@@ -227,12 +_,32 @@ +@@ -232,12 +_,32 @@ LevelChunk chunk = this.getChunkAt(pos); Block block = blockState.getBlock(); @@ -315,7 +315,7 @@ if (newState == blockState) { if (oldState != newState) { this.setBlocksDirty(pos, oldState, newState); -@@ -260,9 +_,63 @@ +@@ -265,9 +_,64 @@ this.updatePOIOnBlockStateChange(pos, oldState, newState); } @@ -372,6 +372,7 @@ + } // Paper - Fix block place logic + } + ++ if ((updateFlags & Block.UPDATE_SKIP_POI) == 0) // Paper - temporary flag + this.updatePOIOnBlockStateChange(pos, oldState, newState); + } + } @@ -379,7 +380,7 @@ public void updatePOIOnBlockStateChange(final BlockPos pos, final BlockState oldState, final BlockState newState) { } -@@ -274,20 +_,38 @@ +@@ -279,20 +_,38 @@ } @Override @@ -422,7 +423,7 @@ } boolean destroyed = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, updateLimit); -@@ -361,11 +_,19 @@ +@@ -366,11 +_,19 @@ @Override public BlockState getBlockState(final BlockPos pos) { @@ -443,7 +444,7 @@ return chunk.getBlockState(pos); } -@@ -525,6 +_,7 @@ +@@ -530,6 +_,7 @@ } public void addBlockEntityTicker(final TickingBlockEntity ticker) { @@ -451,7 +452,7 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(ticker); } -@@ -535,18 +_,23 @@ +@@ -540,18 +_,23 @@ this.pendingBlockEntityTickers.clear(); } @@ -479,7 +480,7 @@ this.tickingBlockEntities = false; } -@@ -554,12 +_,23 @@ +@@ -559,12 +_,23 @@ try { tick.accept(entity); } catch (Throwable t) { @@ -507,7 +508,7 @@ public boolean shouldTickDeath(final Entity entity) { return true; -@@ -693,6 +_,12 @@ +@@ -698,6 +_,12 @@ @Override public @Nullable BlockEntity getBlockEntity(final BlockPos pos) { @@ -520,7 +521,7 @@ if (!this.isInValidBounds(pos)) { return null; } else { -@@ -705,6 +_,12 @@ +@@ -710,6 +_,12 @@ public void setBlockEntity(final BlockEntity blockEntity) { BlockPos pos = blockEntity.getBlockPos(); if (this.isInValidBounds(pos)) { @@ -533,7 +534,7 @@ this.getChunkAt(pos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1116,7 +_,8 @@ +@@ -1121,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), @@ -543,7 +544,7 @@ public static final Codec CODEC = StringRepresentable.fromEnum(Level.ExplosionInteraction::values); private final String id; -@@ -1130,4 +_,16 @@ +@@ -1135,4 +_,16 @@ return this.id; } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelSettings.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelSettings.java.patch index 70bf9a58d5ab..c8a77928e8a9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelSettings.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelSettings.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelSettings.java +++ b/net/minecraft/world/level/LevelSettings.java -@@ -51,6 +_,16 @@ +@@ -55,6 +_,16 @@ return new LevelSettings(this.levelName, this.gameType, this.difficultySettings, this.allowCommands, this.dataConfiguration); } 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 4082bf1cc21c..b7e07d83722b 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 @@ -14,13 +14,13 @@ BlockPos pos = entity.blockPosition(); chunkGetter.query(ChunkPos.pack(pos), chunk -> { MobSpawnSettings.MobSpawnCost mobSpawnCost = getRoughBiome(pos, chunk).getMobSettings().getMobSpawnCost(entity.getType()); -@@ -101,17 +_,34 @@ +@@ -101,13 +_,30 @@ return chunk.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ())).value(); } + // CraftBukkit start - add server public static List getFilteredSpawningCategories( -- final NaturalSpawner.SpawnState state, final boolean spawnFriendlies, final boolean spawnEnemies, final boolean spawnPersistent +- final NaturalSpawner.SpawnState state, final boolean spawnEnemies, final boolean spawnPersistent + final NaturalSpawner.SpawnState state, final boolean spawnFriendlies, final boolean spawnEnemies, final boolean spawnPersistent, final ServerLevel level ) { + net.minecraft.world.level.storage.LevelData worlddata = level.getLevelData(); // CraftBukkit - Other mob type spawn tick rate @@ -28,6 +28,7 @@ List spawningCategories = new ArrayList<>(SPAWNING_CATEGORIES.length); for (MobCategory mobCategory : SPAWNING_CATEGORIES) { +- if ((spawnEnemies || mobCategory.isFriendly()) && (spawnPersistent || !mobCategory.isPersistent()) && state.canSpawnForCategoryGlobal(mobCategory)) { + // CraftBukkit start - Use per-world spawn limits + boolean spawnThisTick = true; + int limit = mobCategory.getMaxInstancesPerChunk(); @@ -41,17 +42,12 @@ + continue; + } + - if ((spawnFriendlies || !mobCategory.isFriendly()) - && (spawnEnemies || mobCategory.isFriendly()) - && (spawnPersistent || !mobCategory.isPersistent()) -- && state.canSpawnForCategoryGlobal(mobCategory)) { -+ && state.canSpawnForCategoryGlobal(mobCategory, limit)) { // Paper - Optional per player mob spawns; remove global check, check later during the local one - spawningCategories.add(mobCategory); ++ if ((spawnFriendlies || !mobCategory.isFriendly()) && (spawnEnemies || mobCategory.isFriendly()) && (spawnPersistent || !mobCategory.isPersistent()) && state.canSpawnForCategoryGlobal(mobCategory, limit)) { // Paper - Optional per player mob spawns; remove global check, check later during the local one + // CraftBukkit end + spawningCategories.add(mobCategory); } } - -@@ -133,6 +_,16 @@ +@@ -130,6 +_,16 @@ profiler.pop(); } @@ -68,7 +64,7 @@ public static void spawnCategoryForChunk( final MobCategory mobCategory, final ServerLevel level, -@@ -162,8 +_,8 @@ +@@ -159,8 +_,8 @@ StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int yStart = start.getY(); @@ -79,7 +75,7 @@ BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); int clusterSize = 0; -@@ -185,7 +_,7 @@ +@@ -182,7 +_,7 @@ Player nearestPlayer = level.getNearestPlayer(xx, yStart, zz, -1.0, false); if (nearestPlayer != null) { double nearestPlayerDistanceSqr = nearestPlayer.distanceToSqr(xx, yStart, zz); @@ -88,7 +84,7 @@ if (currentSpawnData == null) { Optional nextSpawnData = getRandomSpawnMobAt( level, structureManager, generator, mobCategory, level.random, pos -@@ -198,7 +_,13 @@ +@@ -195,7 +_,13 @@ max = currentSpawnData.minCount() + level.random.nextInt(1 + currentSpawnData.maxCount() - currentSpawnData.minCount()); } @@ -103,7 +99,7 @@ && extraTest.test(currentSpawnData.type(), pos, chunk)) { Mob mob = getMobForSpawn(level, currentSpawnData.type()); if (mob == null) { -@@ -210,10 +_,15 @@ +@@ -207,10 +_,15 @@ groupData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.NATURAL, groupData ); @@ -123,7 +119,7 @@ if (clusterSize >= mob.getMaxSpawnClusterSize()) { return; } -@@ -247,7 +_,15 @@ +@@ -244,7 +_,15 @@ return Objects.equals(chunkPos, chunk.getPos()) || level.canSpawnEntitiesInChunk(chunkPos); } @@ -140,7 +136,7 @@ final ServerLevel level, final MobCategory mobCategory, final StructureManager structureManager, -@@ -256,14 +_,27 @@ +@@ -253,14 +_,27 @@ final BlockPos.MutableBlockPos pos, final double nearestPlayerDistanceSqr ) { @@ -169,7 +165,7 @@ } private static @Nullable Mob getMobForSpawn(final ServerLevel level, final EntityType type) { -@@ -275,6 +_,7 @@ +@@ -272,6 +_,7 @@ LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(type)); } catch (Exception e) { LOGGER.warn("Failed to create mob", e); @@ -177,7 +173,7 @@ } return null; -@@ -402,6 +_,7 @@ +@@ -399,6 +_,7 @@ entity = spawnerData.type().create(level.getLevel(), EntitySpawnReason.NATURAL); } catch (Exception e) { LOGGER.warn("Failed to create mob", e); @@ -185,7 +181,7 @@ continue; } -@@ -416,7 +_,7 @@ +@@ -413,7 +_,7 @@ groupSpawnData = mob.finalizeSpawn( level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, groupSpawnData ); @@ -194,7 +190,7 @@ success = true; } } -@@ -534,8 +_,10 @@ +@@ -531,8 +_,10 @@ return this.unmodifiableMobCategoryCounts; } 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 f88ec87b1a39..24052a5a5595 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,19 +23,21 @@ } private ExplosionDamageCalculator makeDamageCalculator(final @Nullable Entity source) { -@@ -142,7 +_,8 @@ +@@ -142,7 +_,7 @@ while (remainingPower > 0.0F) { BlockPos pos = BlockPos.containing(xp, yp, zp); BlockState block = this.level.getBlockState(pos); - FluidState fluid = this.level.getFluidState(pos); -+ if (!block.isDestroyable()) continue; // Paper - Protect Bedrock and End Portal/Frames from being destroyed + FluidState fluid = block.getFluidState(); // Paper - Perf: Optimize call to getFluid for explosions if (!this.level.isInWorldBounds(pos)) { break; } -@@ -154,6 +_,15 @@ +@@ -152,8 +_,17 @@ + remainingPower -= (resistance.get() + 0.3F) * 0.3F; + } - if (remainingPower > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, pos, block, remainingPower)) { +- if (remainingPower > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, pos, block, remainingPower)) { ++ if (remainingPower > 0.0F && block.isDestroyable() && this.damageCalculator.shouldBlockExplode(this, this.level, pos, block, remainingPower)) { // Paper - Protect Bedrock and End Portal/Frames from being destroyed toBlowSet.add(pos); + // Paper start - prevent headless pistons from forming + if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && block.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch index b9f1404094d7..215c53df7b74 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -67,9 +_,33 @@ +@@ -68,9 +_,33 @@ } public static class Builder { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/AbstractSkullBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/AbstractSkullBlock.java.patch index afc9a36e9041..4d0b6c1338e2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/AbstractSkullBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/AbstractSkullBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/AbstractSkullBlock.java +++ b/net/minecraft/world/level/block/AbstractSkullBlock.java -@@ -76,6 +_,11 @@ +@@ -77,6 +_,11 @@ if (!level.isClientSide()) { boolean signal = level.hasNeighborSignal(pos); if (signal != state.getValue(POWERED)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch index 439cead433ab..321c2834858e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BeaconBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeaconBlock.java +++ b/net/minecraft/world/level/block/BeaconBlock.java -@@ -47,8 +_,7 @@ +@@ -48,8 +_,7 @@ protected InteractionResult useWithoutItem( final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult ) { 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 bf9483606f7d..5f564a9cc104 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BedBlock.java +++ b/net/minecraft/world/level/block/BedBlock.java -@@ -92,7 +_,7 @@ +@@ -90,7 +_,7 @@ } BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); @@ -9,7 +9,7 @@ bedRule.errorMessage().ifPresent(player::sendOverlayMessage); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); -@@ -104,21 +_,60 @@ +@@ -102,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)) { @@ -52,7 +52,7 @@ 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 @@ -62,24 +62,11 @@ + level.removeBlock(blockPos, false); + } + -+ Vec3 boomPos = pos.getCenter(); ++ Vec3 boomPos = Vec3.atCenterOf(pos); + 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)); - 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/BeehiveBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BeehiveBlock.java.patch index 4173f2362fd8..743b87a78718 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java -@@ -94,8 +_,9 @@ +@@ -95,8 +_,9 @@ final BlockState state, final @Nullable BlockEntity blockEntity, final ItemStack destroyedWith @@ -11,7 +11,7 @@ if (!level.isClientSide() && blockEntity instanceof BeehiveBlockEntity beehiveBlockEntity) { if (!EnchantmentHelper.hasTag(destroyedWith, EnchantmentTags.PREVENTS_BEE_SPAWNS_WHEN_MINING)) { beehiveBlockEntity.emptyAllLivingFromHive(player, state, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY); -@@ -103,7 +_,7 @@ +@@ -104,7 +_,7 @@ this.angerNearbyBees(level, pos); } @@ -20,7 +20,7 @@ } } -@@ -127,7 +_,7 @@ +@@ -128,7 +_,7 @@ for (Bee bee : beesToAnger) { if (bee.getTarget() == null) { Player angerTarget = Util.getRandom(playersToBeAngryAt, level.getRandom()); @@ -29,7 +29,7 @@ } } } -@@ -142,7 +_,7 @@ +@@ -143,7 +_,7 @@ final BlockPos pos ) { dropFromBlockInteractLootTable( @@ -38,7 +38,7 @@ ); } -@@ -161,7 +_,19 @@ +@@ -162,7 +_,19 @@ if (honeyLevel >= 5) { Item item = itemStack.getItem(); if (level instanceof ServerLevel serverLevel && itemStack.is(Items.SHEARS)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch index 15ce28af4727..27df520ea1f9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BellBlock.java +++ b/net/minecraft/world/level/block/BellBlock.java -@@ -73,6 +_,11 @@ +@@ -74,6 +_,11 @@ ) { boolean signal = level.hasNeighborSignal(pos); if (signal != state.getValue(POWERED)) { @@ -12,7 +12,7 @@ if (signal) { this.attemptToRing(level, pos, null); } -@@ -143,6 +_,11 @@ +@@ -139,6 +_,11 @@ direction = level.getBlockState(pos).getValue(FACING); } @@ -21,6 +21,6 @@ + return false; + } + // CraftBukkit end - ((BellBlockEntity)blockEntity).onHit(direction); + bellBlockEntity.onHit(direction); level.playSound(null, pos, SoundEvents.BELL_BLOCK, SoundSource.BLOCKS, 2.0F, 1.0F); level.gameEvent(ringingEntity, GameEvent.BLOCK_CHANGE, pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch index bb2f89f0f519..91e95812c38a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BlastFurnaceBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlastFurnaceBlock.java +++ b/net/minecraft/world/level/block/BlastFurnaceBlock.java -@@ -44,8 +_,7 @@ +@@ -45,8 +_,7 @@ @Override protected void openContainer(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/Block.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch index 36289740b667..1d718731767a 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -89,29 +_,46 @@ +@@ -89,25 +_,43 @@ return !Shapes.joinIsNotEmpty(Shapes.block(), shape, BooleanOp.NOT_SAME); } }); @@ -14,14 +14,10 @@ - public static final int UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE = 128; - public static final int UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS = 256; - public static final int UPDATE_SKIP_ON_PLACE = 512; -- @Block.UpdateFlags -- public static final int UPDATE_NONE = 260; -- @Block.UpdateFlags -- public static final int UPDATE_ALL = 3; -- @Block.UpdateFlags -- public static final int UPDATE_ALL_IMMEDIATE = 11; -- @Block.UpdateFlags -- public static final int UPDATE_SKIP_ALL_SIDEEFFECTS = 816; +- public static final @Block.UpdateFlags int UPDATE_NONE = 260; +- public static final @Block.UpdateFlags int UPDATE_ALL = 3; +- public static final @Block.UpdateFlags int UPDATE_ALL_IMMEDIATE = 11; +- public static final @Block.UpdateFlags int UPDATE_SKIP_ALL_SIDEEFFECTS = 816; + // Paper start - diff on change - all listed in UpdateFlags annotation + public static final int UPDATE_NEIGHBORS = 1; // Paper - diff on change - all listed in UpdateFlags annotation + public static final int UPDATE_CLIENTS = 2; // Paper - diff on change - all listed in UpdateFlags annotation @@ -33,15 +29,12 @@ + public static final int UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE = 128; // Paper - diff on change - all listed in UpdateFlags annotation + public static final int UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS = 256; // Paper - diff on change - all listed in UpdateFlags annotation + public static final int UPDATE_SKIP_ON_PLACE = 512; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_SKIP_POI = 4096; // Paper - temporary flag until ItemStack cleanup is merged + // Paper end - diff on change - all listed in UpdateFlags annotation -+ @Block.UpdateFlags -+ public static final int UPDATE_NONE = UPDATE_INVISIBLE | UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS; // Paper - help unpick a bit -+ @Block.UpdateFlags -+ public static final int UPDATE_ALL = UPDATE_NEIGHBORS | UPDATE_CLIENTS; // Paper - help unpick a bit -+ @Block.UpdateFlags -+ public static final int UPDATE_ALL_IMMEDIATE = UPDATE_NEIGHBORS | UPDATE_CLIENTS | UPDATE_IMMEDIATE; // Paper - help unpick a bit -+ @Block.UpdateFlags -+ public static final int UPDATE_SKIP_ALL_SIDEEFFECTS = UPDATE_KNOWN_SHAPE | UPDATE_SUPPRESS_DROPS | UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS | UPDATE_SKIP_ON_PLACE; // Paper - help unpick a bit ++ public static final @Block.UpdateFlags int UPDATE_NONE = UPDATE_INVISIBLE | UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS; // Paper - help unpick a bit ++ public static final @Block.UpdateFlags int UPDATE_ALL = UPDATE_NEIGHBORS | UPDATE_CLIENTS; // Paper - help unpick a bit ++ public static final @Block.UpdateFlags int UPDATE_ALL_IMMEDIATE = UPDATE_NEIGHBORS | UPDATE_CLIENTS | UPDATE_IMMEDIATE; // Paper - help unpick a bit ++ public static final @Block.UpdateFlags int UPDATE_SKIP_ALL_SIDEEFFECTS = UPDATE_KNOWN_SHAPE | UPDATE_SUPPRESS_DROPS | UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS | UPDATE_SKIP_ON_PLACE; // Paper - help unpick a bit public static final float INDESTRUCTIBLE = -1.0F; public static final float INSTANT = 0.0F; public static final int UPDATE_LIMIT = 512; @@ -65,7 +58,7 @@ private @Nullable Item item; private static final int CACHE_SIZE = 256; private static final ThreadLocal> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> { -@@ -386,6 +_,27 @@ +@@ -382,6 +_,27 @@ return state.getDrops(params); } @@ -93,7 +86,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)); -@@ -400,6 +_,12 @@ +@@ -396,6 +_,12 @@ } } @@ -106,7 +99,7 @@ public static void dropResources( final BlockState state, final Level level, -@@ -407,10 +_,11 @@ +@@ -403,10 +_,11 @@ final @Nullable BlockEntity blockEntity, final @Nullable Entity breaker, final ItemStack tool @@ -119,7 +112,7 @@ } } -@@ -443,13 +_,25 @@ +@@ -439,13 +_,25 @@ if (level instanceof ServerLevel serverLevel && !itemStack.isEmpty() && serverLevel.getGameRules().get(GameRules.BLOCK_DROPS)) { ItemEntity entity = entityFactory.get(); entity.setDefaultPickUpDelay(); @@ -147,7 +140,7 @@ } } -@@ -467,6 +_,13 @@ +@@ -463,6 +_,13 @@ return this.defaultBlockState(); } @@ -161,7 +154,7 @@ public void playerDestroy( final Level level, final Player player, -@@ -474,10 +_,13 @@ +@@ -470,10 +_,13 @@ final BlockState state, final @Nullable BlockEntity blockEntity, final ItemStack destroyedWith @@ -177,7 +170,7 @@ } public void setPlacedBy(final Level level, final BlockPos pos, final BlockState state, final @Nullable LivingEntity by, final ItemStack itemStack) { -@@ -617,12 +_,20 @@ +@@ -613,12 +_,20 @@ return this.builtInRegistryHolder; } @@ -201,10 +194,10 @@ private record ShapePairKey(VoxelShape first, VoxelShape second) { @Override -@@ -638,6 +_,7 @@ +@@ -634,6 +_,7 @@ @Retention(RetentionPolicy.CLASS) - @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.TYPE_USE}) + @Target(ElementType.TYPE_USE) + @org.intellij.lang.annotations.MagicConstant(flags = {UPDATE_NEIGHBORS, UPDATE_CLIENTS, UPDATE_INVISIBLE, UPDATE_IMMEDIATE, UPDATE_KNOWN_SHAPE, UPDATE_SUPPRESS_DROPS, UPDATE_MOVE_BY_PISTON, UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE, UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS, UPDATE_SKIP_ON_PLACE}) // Paper - add back source-retention annotation for IDE public @interface UpdateFlags { } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch index 0b1eadfd9045..e56a6ff13996 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BrewingStandBlock.java +++ b/net/minecraft/world/level/block/BrewingStandBlock.java -@@ -65,8 +_,7 @@ +@@ -66,8 +_,7 @@ protected InteractionResult useWithoutItem( final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult ) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch index c21b9f52a73c..0902a01d6772 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -120,8 +_,9 @@ +@@ -121,8 +_,9 @@ final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { @@ -11,7 +11,7 @@ } super.entityInside(state, level, pos, entity, effectApplier, isPrecise); -@@ -232,6 +_,11 @@ +@@ -233,6 +_,11 @@ && projectile.mayInteract(serverLevel, pos) && !state.getValue(LIT) && !state.getValue(WATERLOGGED)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch index 53f2111574c8..461a81293a6b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/CarvedPumpkinBlock.java +++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java @@ -87,6 +_,7 @@ - CopperGolem copperGolem = EntityType.COPPER_GOLEM.create(level, EntitySpawnReason.TRIGGERED); + CopperGolem copperGolem = EntityTypes.COPPER_GOLEM.create(level, EntitySpawnReason.TRIGGERED); if (copperGolem != null) { spawnGolemInWorld(level, copperGolemMatch, copperGolem, copperGolemMatch.getBlock(0, 0, 0).getPos()); + if (!copperGolem.valid) return; // Paper - entityspawnevent - entity was not added to the world so prevent world mutation @@ -18,9 +18,9 @@ - level.addFreshEntity(golem); + // Paper start + org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; -+ if (golem.getType() == net.minecraft.world.entity.EntityType.SNOW_GOLEM) { ++ if (golem.getType() == net.minecraft.world.entity.EntityTypes.SNOW_GOLEM) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_SNOWMAN; -+ } else if (golem.getType() == net.minecraft.world.entity.EntityType.COPPER_GOLEM) { ++ } else if (golem.getType() == net.minecraft.world.entity.EntityTypes.COPPER_GOLEM) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_COPPERGOLEM; + } else { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_IRONGOLEM; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch index 7b55fc8b18f8..44e4dc8f7230 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/CeilingHangingSignBlock.java +++ b/net/minecraft/world/level/block/CeilingHangingSignBlock.java -@@ -177,7 +_,7 @@ +@@ -178,7 +_,7 @@ @Override public @Nullable BlockEntityTicker getTicker(final Level level, final BlockState blockState, final BlockEntityType type) { -- return createTickerHelper(type, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick); +- return createTickerHelper(type, BlockEntityTypes.HANGING_SIGN, SignBlockEntity::tick); + return null; // CraftBukkit - remove unnecessary sign ticking } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch index 2f76a675854e..c3d90ae9732d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -96,7 +_,7 @@ +@@ -97,7 +_,7 @@ @Override public Optional acceptDouble(final ChestBlockEntity first, final ChestBlockEntity second) { final Container container = new CompoundContainer(first, second); @@ -9,7 +9,7 @@ @Override public @Nullable AbstractContainerMenu createMenu(final int containerId, final Inventory inventory, final Player player) { if (first.canOpen(player) && second.canOpen(player)) { -@@ -117,10 +_,10 @@ +@@ -118,10 +_,10 @@ if (first.hasCustomName()) { return first.getDisplayName(); } else { @@ -22,7 +22,7 @@ } @Override -@@ -263,8 +_,7 @@ +@@ -264,8 +_,7 @@ ) { if (level instanceof ServerLevel serverLevel) { MenuProvider menuProvider = this.getMenuProvider(state, level, pos); @@ -32,7 +32,7 @@ player.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -305,7 +_,13 @@ +@@ -306,7 +_,13 @@ @Override public @Nullable MenuProvider getMenuProvider(final BlockState state, final Level level, final BlockPos pos) { @@ -47,7 +47,7 @@ } public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity entity) { -@@ -347,6 +_,11 @@ +@@ -348,6 +_,11 @@ } private static boolean isCatSittingOnChest(final LevelAccessor level, final BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch index 1e1f1fbf9aa5..264dcd54cdbe 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch @@ -16,12 +16,12 @@ commandBlock.setPowered(isPowered); if (isPowered) { if (commandBlock.isAutomatic() || commandBlock.getMode() == CommandBlockEntity.Mode.SEQUENCE) { -@@ -129,7 +_,7 @@ +@@ -128,7 +_,7 @@ + protected InteractionResult useWithoutItem( final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult ) { - BlockEntity blockEntity = level.getBlockEntity(pos); -- if (blockEntity instanceof CommandBlockEntity && player.canUseGameMasterBlocks()) { -+ if (blockEntity instanceof CommandBlockEntity && (player.canUseGameMasterBlocks() || (player.isCreative() && player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission - player.openCommandBlock((CommandBlockEntity)blockEntity); +- if (level.getBlockEntity(pos) instanceof CommandBlockEntity commandBlockEntity && player.canUseGameMasterBlocks()) { ++ if (level.getBlockEntity(pos) instanceof CommandBlockEntity commandBlockEntity && (player.canUseGameMasterBlocks() || (player.isCreative() && player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission + player.openCommandBlock(commandBlockEntity); return InteractionResult.SUCCESS; } else { 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 index 02b1fb8e6e41..c650cedfecea 100644 --- 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 @@ -1,15 +1,6 @@ --- 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 @@ +@@ -171,8 +_,18 @@ 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/CopperGolemStatueBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch index e73773c04e7a..0fdfc78a07e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CopperGolemStatueBlock.java.patch @@ -9,9 +9,9 @@ + return this.updatePose(level, state, pos, player); // Paper - call EntityChangeBlockEvent } -- void updatePose(final Level level, final BlockState state, final BlockPos pos, final Player player) { +- protected void updatePose(final Level level, final BlockState state, final BlockPos pos, final Player player) { + // Paper start - call EntityChangeBlockEvent -+ InteractionResult updatePose(final Level level, final BlockState state, final BlockPos pos, final Player player) { ++ protected InteractionResult updatePose(final Level level, final BlockState state, final BlockPos pos, final Player player) { + BlockState newState = state.setValue(POSE, state.getValue(POSE).getNextPose()); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newState)) { + return InteractionResult.PASS; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch index 0384dbfd35f1..26a046cc97a1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -155,6 +_,13 @@ +@@ -156,6 +_,13 @@ } else { RecipeHolder pickedRecipe = recipe.get(); ItemStack results = pickedRecipe.value().assemble(var11); @@ -14,7 +14,7 @@ if (results.isEmpty()) { level.levelEvent(LevelEvent.SOUND_CRAFTER_FAIL, pos, 0); } else { -@@ -196,7 +_,25 @@ +@@ -197,7 +_,25 @@ Container into = HopperBlockEntity.getContainerAt(level, pos.relative(direction)); ItemStack remaining = results.copy(); if (into != null && (into instanceof CrafterBlockEntity || results.getCount() > into.getMaxStackSize(results))) { @@ -40,7 +40,7 @@ ItemStack copy = remaining.copyWithCount(1); ItemStack itemStack = HopperBlockEntity.addItem(blockEntity, into, copy, direction.getOpposite()); if (!itemStack.isEmpty()) { -@@ -206,7 +_,25 @@ +@@ -207,7 +_,25 @@ remaining.shrink(1); } } else if (into != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch index 2964d5298d82..ecfdbd6bfc9e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DaylightDetectorBlock.java +++ b/net/minecraft/world/level/block/DaylightDetectorBlock.java -@@ -70,6 +_,7 @@ +@@ -65,6 +_,7 @@ target = Mth.clamp(target, 0, 15); if (state.getValue(POWER) != target) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch index 6bea43766359..b2acb7c6b225 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DetectorRailBlock.java +++ b/net/minecraft/world/level/block/DetectorRailBlock.java -@@ -57,6 +_,7 @@ +@@ -62,6 +_,7 @@ final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch index b5e1ab0e5323..ebf122093d84 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -19,11 +19,3 @@ level.setBlock(pos, state.setValue(POWERED, true), Block.UPDATE_CLIENTS); if (!shouldTurnOn) { level.scheduleTick(pos, this, this.getDelay(state), TickPriority.VERY_HIGH); -@@ -85,6 +_,7 @@ - protected void neighborChanged( - final BlockState state, final Level level, final BlockPos pos, final Block block, final @Nullable Orientation orientation, final boolean movedByPiston - ) { -+ if (!level.getBlockState(pos).is(this)) return; // Paper - Fix blockstate validation issues - if (state.canSurvive(level, pos)) { - this.checkTickOnNeighbor(level, pos, state); - } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch index 7bf41effb2eb..2a2840611225 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DispenserBlock.java +++ b/net/minecraft/world/level/block/DispenserBlock.java -@@ -75,8 +_,7 @@ +@@ -77,8 +_,7 @@ protected InteractionResult useWithoutItem( final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult ) { @@ -10,7 +10,7 @@ player.awardStat(dispenser instanceof DropperBlockEntity ? Stats.INSPECT_DROPPER : Stats.INSPECT_DISPENSER); } -@@ -91,17 +_,26 @@ +@@ -93,17 +_,26 @@ BlockSource source = new BlockSource(level, pos, state, blockEntity); int slot = blockEntity.getRandomSlot(level.getRandom()); if (slot < 0) { 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 index f591d40643d1..3d7e088a6ff4 100644 --- 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 @@ -42,7 +42,7 @@ + return serverPlayer.findRespawnPositionAndUseSpawnBlock(false, TeleportTransition.DO_NOTHING, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason.END_PORTAL); // CraftBukkit } - spawnPos = entity.adjustSpawnLocation(newLevel, spawnBlockPos).getBottomCenter(); + spawnPos = Vec3.atBottomCenterOf(entity.adjustSpawnLocation(newLevel, spawnBlockPos)); } + // CraftBukkit start 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 index 6816771d3bc9..62456fc18d2b 100644 --- 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/EnderChestBlock.java +++ b/net/minecraft/world/level/block/EnderChestBlock.java -@@ -82,13 +_,16 @@ +@@ -83,13 +_,16 @@ 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/FenceGateBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch index 317e07504cbd..1e37c75b5b8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java -@@ -189,6 +_,11 @@ +@@ -185,6 +_,11 @@ if (!level.isClientSide()) { boolean hasPower = level.hasNeighborSignal(pos); if (state.getValue(POWERED) != hasPower) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch index 86a07210ae37..3fd8d9a7d116 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch @@ -5,7 +5,7 @@ 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.is(EntityType.FALLING_BLOCK)) { + if (entity.is(EntityTypes.FALLING_BLOCK)) { this.destroyBlock(level, pos); } @@ -111,6 +_,11 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch index 3b49693c82d2..a7cd48d2827c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FurnaceBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FurnaceBlock.java +++ b/net/minecraft/world/level/block/FurnaceBlock.java -@@ -44,8 +_,7 @@ +@@ -45,8 +_,7 @@ @Override protected void openContainer(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/HopperBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch index 7b243614f309..a96f8c65236b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java -@@ -106,8 +_,7 @@ +@@ -107,8 +_,7 @@ protected InteractionResult useWithoutItem( final BlockState state, final Level level, final BlockPos pos, final Player player, final BlockHitResult hitResult ) { @@ -10,11 +10,11 @@ player.awardStat(Stats.INSPECT_HOPPER); } -@@ -167,6 +_,7 @@ +@@ -168,6 +_,7 @@ 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 - BlockEntity blockEntity = level.getBlockEntity(pos); - if (blockEntity instanceof HopperBlockEntity) { - HopperBlockEntity.entityInside(level, pos, state, entity, (HopperBlockEntity)blockEntity); + if (level.getBlockEntity(pos) instanceof HopperBlockEntity hopperBlockEntity) { + HopperBlockEntity.entityInside(level, pos, state, entity, hopperBlockEntity); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch index 54834bd834da..c432d8caf2bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/InfestedBlock.java +++ b/net/minecraft/world/level/block/InfestedBlock.java @@ -52,7 +_,7 @@ - Silverfish silverfish = EntityType.SILVERFISH.create(level, EntitySpawnReason.TRIGGERED); + Silverfish silverfish = EntityTypes.SILVERFISH.create(level, EntitySpawnReason.TRIGGERED); if (silverfish != null) { silverfish.snapTo(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0.0F, 0.0F); - level.addFreshEntity(silverfish); 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 b826df878d41..d6d88c6ef453 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,13 +40,13 @@ level.setBlock(pos, state.setValue(POWERED, isPowered), Block.UPDATE_ALL); updateBelow(level, pos, state); } -@@ -256,8 +_,7 @@ +@@ -250,8 +_,7 @@ + } private void openScreen(final Level level, final BlockPos pos, final Player player) { - BlockEntity blockEntity = level.getBlockEntity(pos); -- if (blockEntity instanceof LecternBlockEntity) { -- player.openMenu((LecternBlockEntity)blockEntity); -+ if (blockEntity instanceof LecternBlockEntity lecternBlockEntity && player.openMenu(lecternBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation +- if (level.getBlockEntity(pos) instanceof LecternBlockEntity lecternBlockEntity) { +- player.openMenu(lecternBlockEntity); ++ if (level.getBlockEntity(pos) instanceof LecternBlockEntity lecternBlockEntity && player.openMenu(lecternBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation player.awardStat(Stats.INTERACT_WITH_LECTERN); } } 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 e9574c2450a9..caa4c09ce6ee 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,7 +1,7 @@ --- a/net/minecraft/world/level/block/MultifaceSpreader.java +++ b/net/minecraft/world/level/block/MultifaceSpreader.java @@ -178,14 +_,14 @@ - level.getChunk(spreadPos.pos()).markPosForPostprocessing(spreadPos.pos()); + level.getChunk(spreadPos.pos()).markPosForPostProcessing(spreadPos.pos()); } - return level.setBlock(spreadPos.pos(), spreadState, Block.UPDATE_CLIENTS); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch index b71f0beae512..b82083e1cd49 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/block/NetherPortalBlock.java +++ b/net/minecraft/world/level/block/NetherPortalBlock.java -@@ -66,7 +_,7 @@ +@@ -67,7 +_,7 @@ @Override protected void randomTick(final BlockState state, final ServerLevel level, BlockPos pos, final RandomSource random) { - if (level.isSpawningMonsters() -+ if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.isSpawningMonsters() // Spigot ++ if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.isSpawningMonsters() // Paper + && level.getLevelData().getDifficulty() != Difficulty.PEACEFUL && level.environmentAttributes().getValue(EnvironmentAttributes.NETHER_PORTAL_SPAWNS_PIGLINS, pos) && random.nextInt(2000) < level.getDifficulty().getId() - && level.anyPlayerCloseEnoughForSpawning(pos)) { -@@ -75,9 +_,13 @@ +@@ -77,9 +_,13 @@ } - if (level.getBlockState(pos).isValidSpawn(level, pos, EntityType.ZOMBIFIED_PIGLIN)) { -- Entity entity = EntityType.ZOMBIFIED_PIGLIN.spawn(level, pos.above(), EntitySpawnReason.STRUCTURE); -+ Entity entity = EntityType.ZOMBIFIED_PIGLIN.spawn(level, pos.above(), EntitySpawnReason.STRUCTURE, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); // CraftBukkit - set spawn reason to NETHER_PORTAL + if (level.getBlockState(pos).isValidSpawn(level, pos, EntityTypes.ZOMBIFIED_PIGLIN)) { +- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(level, pos.above(), EntitySpawnReason.STRUCTURE); ++ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(level, pos.above(), EntitySpawnReason.STRUCTURE, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); // CraftBukkit - set spawn reason to NETHER_PORTAL if (entity != null) { entity.setPortalCooldown(); + // Paper start - Add option to nerf pigmen from nether portals @@ -24,7 +24,7 @@ Entity vehicle = entity.getVehicle(); if (vehicle != null) { vehicle.setPortalCooldown(); -@@ -115,7 +_,13 @@ +@@ -117,7 +_,13 @@ final InsideBlockEffectApplier effectApplier, final boolean isPrecise ) { @@ -38,7 +38,7 @@ entity.setAsInsidePortal(this, pos); } } -@@ -133,17 +_,40 @@ +@@ -135,17 +_,40 @@ @Override public @Nullable TeleportTransition getPortalDestination(final ServerLevel currentLevel, final Entity entity, final BlockPos portalEntryPos) { @@ -82,7 +82,7 @@ } private @Nullable TeleportTransition getExitPortal( -@@ -153,8 +_,9 @@ +@@ -155,8 +_,9 @@ final BlockPos approximateExitPos, final boolean toNether, final WorldBorder worldBorder @@ -93,7 +93,7 @@ BlockUtil.FoundRectangle exitPortal; TeleportTransition.PostTeleportTransition post; if (exitPortalPos.isPresent()) { -@@ -169,17 +_,22 @@ +@@ -171,17 +_,22 @@ blockPos -> newLevel.getBlockState(blockPos) == portalState ); post = TeleportTransition.PLAY_PORTAL_SOUND.then(e -> e.placePortalTicket(pos)); @@ -119,7 +119,7 @@ return getDimensionTransitionFromExit(entity, portalEntryPos, exitPortal, newLevel, post); } -@@ -234,7 +_,7 @@ +@@ -236,7 +_,7 @@ ); Vec3 collisionFreePos = PortalShape.findCollisionFreePosition(targetPos, newLevel, entity, dimensions); return new TeleportTransition( 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 5fc931aaec80..f06ade2e2409 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,27 +1,15 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -146,6 +_,11 @@ - && projectile.mayBreak(serverLevel) - && projectile instanceof ThrownTrident - && projectile.getDeltaMovement().length() > 0.6) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockPos, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state -+ return; -+ } -+ // CraftBukkit end - level.destroyBlock(blockPos, true); - } - } -@@ -154,7 +_,7 @@ +@@ -63,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) { + if (state.getValue(TIP_DIRECTION) == Direction.UP && state.getValue(THICKNESS) == SpeleothemThickness.TIP) { - entity.causeFallDamage(fallDistance + 2.5, 2.0F, level.damageSources().stalagmite()); + entity.causeFallDamage(fallDistance + 2.5, 2.0F, level.damageSources().stalagmite().eventBlockDamager(level, pos)); // CraftBukkit } else { super.fallOn(level, state, pos, entity, fallDistance); } -@@ -212,10 +_,11 @@ +@@ -110,10 +_,11 @@ if (stalactiteTipPos != null) { if (fluidInfo.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) { BlockState newState = Blocks.CLAY.defaultBlockState(); @@ -34,35 +22,3 @@ } else { BlockPos cauldronPos = findFillableCauldronBelowStalactiteTip(level, stalactiteTipPos, fluid); if (cauldronPos != null) { -@@ -361,17 +_,17 @@ - if (isUnmergedTipWithDirection(existingStateAtTargetPos, growToDirection.getOpposite())) { - createMergedTips(existingStateAtTargetPos, level, targetPos); - } else if (existingStateAtTargetPos.isAir() || existingStateAtTargetPos.is(Blocks.WATER)) { -- createDripstone(level, targetPos, growToDirection, DripstoneThickness.TIP); -+ createDripstone(level, targetPos, growToDirection, DripstoneThickness.TIP, growFromPos); // CraftBukkit - } - } - -- private static void createDripstone(final LevelAccessor level, final BlockPos pos, final Direction direction, final DripstoneThickness thickness) { -+ private static void createDripstone(final LevelAccessor level, final BlockPos pos, final Direction direction, final DripstoneThickness thickness, final BlockPos source) { // CraftBukkit - BlockState state = Blocks.POINTED_DRIPSTONE - .defaultBlockState() - .setValue(TIP_DIRECTION, direction) - .setValue(THICKNESS, thickness) - .setValue(WATERLOGGED, level.getFluidState(pos).is(Fluids.WATER)); -- level.setBlock(pos, state, Block.UPDATE_ALL); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, pos, state, Block.UPDATE_ALL); // CraftBukkit - } - - private static void createMergedTips(final BlockState tipState, final LevelAccessor level, final BlockPos tipPos) { -@@ -385,8 +_,8 @@ - stalagmitePos = tipPos.below(); - } - -- createDripstone(level, stalactitePos, Direction.DOWN, DripstoneThickness.TIP_MERGE); -- createDripstone(level, stalagmitePos, Direction.UP, DripstoneThickness.TIP_MERGE); -+ createDripstone(level, stalactitePos, Direction.DOWN, DripstoneThickness.TIP_MERGE, tipPos); // CraftBukkit -+ createDripstone(level, stalagmitePos, Direction.UP, DripstoneThickness.TIP_MERGE, tipPos); // CraftBukkit - } - - public static void spawnDripParticle(final Level level, final BlockPos stalactiteTipPos, final BlockState stalactiteTipState) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch index c5661ecbf5e7..2ffe10d40089 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch @@ -9,7 +9,7 @@ public static final int RECENT_TOGGLE_TIMER = 60; public static final int MAX_RECENT_TOGGLES = 8; public static final int RESTART_DELAY = 160; -@@ -73,14 +_,23 @@ +@@ -68,14 +_,23 @@ @Override protected void tick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random) { boolean neighborSignal = this.hasNeighborSignal(level, pos, state); @@ -37,7 +37,7 @@ level.setBlock(pos, state.setValue(LIT, false), Block.UPDATE_ALL); if (isToggledTooFrequently(level, pos, true)) { level.levelEvent(LevelEvent.REDSTONE_TORCH_BURNOUT, pos, 0); -@@ -88,6 +_,11 @@ +@@ -83,6 +_,11 @@ } } } else if (!neighborSignal && !isToggledTooFrequently(level, pos, false)) { @@ -49,7 +49,7 @@ level.setBlock(pos, state.setValue(LIT, true), Block.UPDATE_ALL); } } -@@ -127,7 +_,12 @@ +@@ -132,7 +_,12 @@ } private static boolean isToggledTooFrequently(final Level level, final BlockPos pos, final boolean add) { 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 cc22bcf4d953..db899b325e83 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 @@ -24,7 +24,7 @@ @@ -171,7 +_,7 @@ } }; - Vec3 boomPos = pos.getCenter(); + Vec3 boomPos = Vec3.atCenterOf(pos); - 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 } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch index 0500e2141d60..bd0131600971 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -17,7 +17,7 @@ this.advanceTree(level, pos, state, random); } } -@@ -52,7 +_,34 @@ +@@ -52,7 +_,40 @@ if (state.getValue(STAGE) == 0) { level.setBlock(pos, state.cycle(STAGE), Block.UPDATE_NONE); } else { @@ -27,24 +27,30 @@ + this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random); + } else { + level.captureTreeGeneration = true; -+ this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random); -+ level.captureTreeGeneration = false; -+ if (!level.capturedBlockStates.isEmpty()) { -+ org.bukkit.TreeType treeType = SaplingBlock.treeType; ++ java.util.List capturedBlockStates; ++ org.bukkit.TreeType treeType; ++ try { ++ this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random); ++ } finally { ++ level.captureTreeGeneration = false; ++ ++ capturedBlockStates = new java.util.ArrayList<>(level.capturedBlockStates.values()); ++ level.capturedBlockStates.clear(); ++ ++ treeType = SaplingBlock.treeType; + SaplingBlock.treeType = null; ++ } ++ if (!capturedBlockStates.isEmpty()) { + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); -+ java.util.List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); -+ level.capturedBlockStates.clear(); + org.bukkit.event.world.StructureGrowEvent event = null; + if (treeType != null) { -+ event = new org.bukkit.event.world.StructureGrowEvent(location, treeType, false, null, blocks); ++ event = new org.bukkit.event.world.StructureGrowEvent(location, treeType, false, null, (java.util.List) (java.util.List) capturedBlockStates); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + } + if (event == null || !event.isCancelled()) { -+ for (org.bukkit.block.BlockState blockstate : blocks) { -+ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) blockstate; -+ craftBlockState.place(craftBlockState.getFlags()); -+ level.checkCapturedTreeStateForObserverNotify(pos, craftBlockState); // Paper - notify observers even if grow failed ++ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : capturedBlockStates) { ++ snapshot.place(snapshot.getFlags()); ++ level.checkCapturedTreeStateForObserverNotify(pos, snapshot); // Paper - notify observers even if grow failed + } + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch index 3cfe30ec4e29..45c49ad0500d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkCatalystBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkCatalystBlock.java +++ b/net/minecraft/world/level/block/SculkCatalystBlock.java -@@ -59,8 +_,16 @@ +@@ -60,8 +_,16 @@ @Override protected void spawnAfterBreak(final BlockState state, final ServerLevel level, final BlockPos pos, final ItemStack tool, final boolean dropExperience) { super.spawnAfterBreak(state, level, pos, tool, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch index dcd92bf5dc1b..bf0b063cc6ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -102,6 +_,18 @@ +@@ -103,6 +_,18 @@ && level.getBlockEntity(pos) instanceof SculkSensorBlockEntity sculkSensor && level instanceof ServerLevel serverLevel && sculkSensor.getVibrationUser().canReceiveVibration(serverLevel, pos, GameEvent.STEP, GameEvent.Context.of(onState))) { @@ -19,7 +19,7 @@ sculkSensor.getListener().forceScheduleVibration(serverLevel, GameEvent.STEP, GameEvent.Context.of(entity), entity.position()); } -@@ -189,10 +_,17 @@ +@@ -190,10 +_,17 @@ } public static boolean canActivate(final BlockState state) { @@ -38,7 +38,7 @@ level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.COOLDOWN).setValue(POWER, 0), Block.UPDATE_ALL); level.scheduleTick(pos, state.getBlock(), 10); updateNeighbours(level, pos, state); -@@ -208,9 +_,15 @@ +@@ -209,9 +_,15 @@ final Level level, final BlockPos pos, final BlockState state, @@ -55,7 +55,7 @@ level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, calculatedPower), Block.UPDATE_ALL); level.scheduleTick(pos, state.getBlock(), this.getActiveTicks()); updateNeighbours(level, pos, state); -@@ -288,8 +_,16 @@ +@@ -289,8 +_,16 @@ @Override protected void spawnAfterBreak(final BlockState state, final ServerLevel level, final BlockPos pos, final ItemStack tool, final boolean dropExperience) { super.spawnAfterBreak(state, level, pos, tool, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index 22527605c07a..40de2746a207 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java -@@ -60,6 +_,7 @@ +@@ -61,6 +_,7 @@ if (level instanceof ServerLevel serverLevel) { ServerPlayer player = SculkShriekerBlockEntity.tryGetPlayer(entity); if (player != null) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null).isCancelled()) return; // CraftBukkit - serverLevel.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent(shrieker -> shrieker.tryShriek(serverLevel, player)); + serverLevel.getBlockEntity(pos, BlockEntityTypes.SCULK_SHRIEKER).ifPresent(shrieker -> shrieker.tryShriek(serverLevel, player)); } } -@@ -126,9 +_,16 @@ +@@ -127,9 +_,16 @@ @Override protected void spawnAfterBreak(final BlockState state, final ServerLevel level, final BlockPos pos, final ItemStack tool, final boolean dropExperience) { super.spawnAfterBreak(state, level, pos, tool, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch index 7e59a7ff1345..a790b97df28c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -76,8 +_,8 @@ +@@ -78,8 +_,8 @@ ) { if (level instanceof ServerLevel serverLevel && level.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity @@ -11,7 +11,7 @@ player.awardStat(Stats.OPEN_SHULKER_BOX); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -115,7 +_,7 @@ +@@ -117,7 +_,7 @@ entity.setDefaultPickUpDelay(); level.addFreshEntity(entity); } else { @@ -20,7 +20,7 @@ } } -@@ -125,7 +_,15 @@ +@@ -127,7 +_,15 @@ @Override protected List getDrops(final BlockState state, LootParams.Builder params) { BlockEntity blockEntity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); @@ -36,7 +36,7 @@ params = params.withDynamicDrop(CONTENTS, output -> { for (int i = 0; i < shulkerBoxBlockEntity.getContainerSize(); i++) { output.accept(shulkerBoxBlockEntity.getItem(i)); -@@ -133,7 +_,13 @@ +@@ -135,7 +_,13 @@ }); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch index 136e9b71aa14..da43556f6426 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SignBlock.java +++ b/net/minecraft/world/level/block/SignBlock.java -@@ -137,7 +_,7 @@ +@@ -138,7 +_,7 @@ } else if (executedClickCommand) { return InteractionResult.SUCCESS_SERVER; } else if (!this.otherPlayerIsEditingSign(player, sign) && player.mayBuild() && this.hasEditableText(player, sign, isFrontText)) { @@ -9,7 +9,7 @@ return InteractionResult.SUCCESS_SERVER; } else { return InteractionResult.PASS; -@@ -176,7 +_,34 @@ +@@ -177,7 +_,34 @@ return block instanceof SignBlock signBlock ? signBlock.type() : WoodType.OAK; } @@ -44,11 +44,11 @@ sign.setAllowedPlayerEditor(player.getUUID()); player.openTextEdit(sign, isFrontText); } -@@ -188,6 +_,6 @@ +@@ -189,6 +_,6 @@ @Override public @Nullable BlockEntityTicker getTicker(final Level level, final BlockState blockState, final BlockEntityType type) { -- return createTickerHelper(type, BlockEntityType.SIGN, SignBlockEntity::tick); +- return createTickerHelper(type, BlockEntityTypes.SIGN, SignBlockEntity::tick); + return null; // CraftBukkit - remove unnecessary sign ticking } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch index 2c05e9127682..cf0de6c2421c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SmokerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SmokerBlock.java +++ b/net/minecraft/world/level/block/SmokerBlock.java -@@ -43,8 +_,7 @@ +@@ -44,8 +_,7 @@ @Override protected void openContainer(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/SnifferEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch index 97b3651f8394..71b04474072c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch @@ -32,9 +32,9 @@ + // Paper end - Call BlockFadeEvent level.playSound(null, position, SoundEvents.SNIFFER_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); level.destroyBlock(position, false); - Sniffer sniffer = EntityType.SNIFFER.create(level, EntitySpawnReason.BREEDING); + Sniffer sniffer = EntityTypes.SNIFFER.create(level, EntitySpawnReason.BREEDING); @@ -74,7 +_,7 @@ - Vec3 spawnAt = position.getCenter(); + Vec3 spawnAt = Vec3.atCenterOf(position); sniffer.setBaby(true); sniffer.snapTo(spawnAt.x(), spawnAt.y(), spawnAt.z(), Mth.wrapDegrees(level.getRandom().nextFloat() * 360.0F), 0.0F); - level.addFreshEntity(sniffer); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch index a6d2a1368fad..b3b23514bdd1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpawnerBlock.java +++ b/net/minecraft/world/level/block/SpawnerBlock.java -@@ -39,10 +_,18 @@ +@@ -40,10 +_,18 @@ @Override protected void spawnAfterBreak(final BlockState state, final ServerLevel level, final BlockPos pos, final ItemStack tool, final boolean dropExperience) { super.spawnAfterBreak(state, level, pos, tool, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpeleothemBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpeleothemBlock.java.patch new file mode 100644 index 000000000000..6883969d2cb3 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpeleothemBlock.java.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/world/level/block/SpeleothemBlock.java ++++ b/net/minecraft/world/level/block/SpeleothemBlock.java +@@ -192,6 +_,11 @@ + && projectile.mayBreak(serverLevel) + && projectile instanceof ThrownTrident + && projectile.getDeltaMovement().length() > 0.6) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockPos, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state ++ return; ++ } ++ // CraftBukkit end + level.destroyBlock(blockPos, true); + } + } +@@ -381,16 +_,16 @@ + if (this.isUnmergedTipWithDirection(existingStateAtTargetPos, growToDirection.getOpposite())) { + this.createMergedTips(existingStateAtTargetPos, level, targetPos); + } else if (existingStateAtTargetPos.isAir() || existingStateAtTargetPos.is(Blocks.WATER)) { +- this.createSpeleothem(level, targetPos, growToDirection, SpeleothemThickness.TIP); ++ this.createSpeleothem(level, targetPos, growToDirection, SpeleothemThickness.TIP, growFromPos); // CraftBukkit + } + } + +- private void createSpeleothem(final LevelAccessor level, final BlockPos pos, final Direction direction, final SpeleothemThickness thickness) { ++ private void createSpeleothem(final LevelAccessor level, final BlockPos pos, final Direction direction, final SpeleothemThickness thickness, final BlockPos source) { // CraftBukkit + BlockState state = this.defaultBlockState() + .setValue(TIP_DIRECTION, direction) + .setValue(THICKNESS, thickness) + .setValue(WATERLOGGED, level.getFluidState(pos).is(Fluids.WATER)); +- level.setBlock(pos, state, Block.UPDATE_ALL); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, pos, state, Block.UPDATE_ALL); // CraftBukkit + } + + private void createMergedTips(final BlockState tipState, final LevelAccessor level, final BlockPos tipPos) { +@@ -404,8 +_,8 @@ + stalagmitePos = tipPos.below(); + } + +- this.createSpeleothem(level, stalactitePos, Direction.DOWN, SpeleothemThickness.TIP_MERGE); +- this.createSpeleothem(level, stalagmitePos, Direction.UP, SpeleothemThickness.TIP_MERGE); ++ this.createSpeleothem(level, stalactitePos, Direction.DOWN, SpeleothemThickness.TIP_MERGE, tipPos); // CraftBukkit ++ this.createSpeleothem(level, stalagmitePos, Direction.UP, SpeleothemThickness.TIP_MERGE, tipPos); // CraftBukkit + } + + private void growStalagmiteBelow(final ServerLevel level, final BlockPos posAboveStalagmite) { 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 f218455abdfa..b4d97a77fb7e 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 @@ -17,7 +17,7 @@ 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 instanceof LivingEntity && !entity.is(EntityType.FOX) && !entity.is(EntityType.BEE)) { + if (entity instanceof LivingEntity && !entity.is(EntityTypes.FOX) && !entity.is(EntityTypes.BEE)) { entity.makeStuckInBlock(state, new Vec3(0.8F, 0.75, 0.8F)); if (level instanceof ServerLevel serverLevel && state.getValue(AGE) != 0) { @@ -95,7 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch index 80b2aa7bf557..07e5f70fd8e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch @@ -27,7 +27,7 @@ } return super.playerWillDestroy(level, pos, state, player); -@@ -82,11 +_,16 @@ +@@ -81,11 +_,16 @@ } public static boolean prime(final Level level, final BlockPos pos) { @@ -47,7 +47,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,8 +_,7 @@ +@@ -109,8 +_,7 @@ if (!itemStack.is(Items.FLINT_AND_STEEL) && !itemStack.is(Items.FIRE_CHARGE)) { return super.useItemOn(itemStack, state, level, pos, player, hand, hitResult); } @@ -57,12 +57,12 @@ level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); Item item = itemStack.getItem(); if (itemStack.is(Items.FLINT_AND_STEEL)) { -@@ -136,7 +_,7 @@ +@@ -135,7 +_,7 @@ Entity owner = projectile.getOwner(); if (projectile.isOnFire() && projectile.mayInteract(serverLevel, pos) -- && prime(level, pos, owner instanceof LivingEntity ? (LivingEntity)owner : null)) { -+ && prime(level, pos, owner instanceof LivingEntity ? (LivingEntity)owner : null, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, pos, state.getFluidState().createLegacyBlock()) && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PROJECTILE, projectile, null))) { // Paper +- && prime(level, pos, owner instanceof LivingEntity livingEntity ? livingEntity : null)) { ++ && prime(level, pos, owner instanceof LivingEntity livingEntity ? livingEntity : null, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, pos, state.getFluidState().createLegacyBlock()) && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PROJECTILE, projectile, null))) { // Paper level.removeBlock(pos, false); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch index c6d0fed98679..ddbc68ef90d6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java -@@ -133,7 +_,31 @@ +@@ -129,7 +_,31 @@ if (!level.isClientSide()) { boolean signal = level.hasNeighborSignal(pos); if (signal != state.getValue(POWERED)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch index 56e3ed1b8398..fbb85e8be989 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -55,7 +55,7 @@ + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent tripwires from detecting collision + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!level.isClientSide()) { - if (!state.getValue(POWERED)) { + if (!state.getValue(POWERED) && !level.getBlockTicks().hasScheduledTick(pos, this)) { this.checkPressed(level, pos, List.of(entity)); @@ -163,6 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch index b44dd55e2012..e6ad0cb9e261 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/WallHangingSignBlock.java +++ b/net/minecraft/world/level/block/WallHangingSignBlock.java -@@ -181,7 +_,7 @@ +@@ -182,7 +_,7 @@ @Override public @Nullable BlockEntityTicker getTicker(final Level level, final BlockState blockState, final BlockEntityType type) { -- return createTickerHelper(type, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick); +- return createTickerHelper(type, BlockEntityTypes.HANGING_SIGN, SignBlockEntity::tick); + return null; // CraftBukkit - remove unnecessary sign ticking } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch index 5aa9ac611b52..efdf2890169b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch @@ -10,7 +10,7 @@ boolean correctBlock = blockState.is(Blocks.WITHER_SKELETON_SKULL) || blockState.is(Blocks.WITHER_SKELETON_WALL_SKULL); @@ -57,7 +_,7 @@ if (match != null) { - WitherBoss witherBoss = EntityType.WITHER.create(level, EntitySpawnReason.TRIGGERED); + WitherBoss witherBoss = EntityTypes.WITHER.create(level, EntitySpawnReason.TRIGGERED); if (witherBoss != null) { - CarvedPumpkinBlock.clearPatternBlocks(level, match); + // CarvedPumpkinBlock.clearPatternBlocks(level, match); // CraftBukkit - move down 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 2a9b6fa87339..2f2614cb4a55 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 -@@ -107,6 +_,51 @@ +@@ -109,6 +_,51 @@ return 3; } }; @@ -52,7 +52,7 @@ private static @Nullable Holder filterEffect(final @Nullable Holder effect) { return VALID_EFFECTS.contains(effect) ? effect : null; -@@ -170,10 +_,19 @@ +@@ -172,10 +_,19 @@ } if (entity.levels > 0 && !entity.beamSections.isEmpty()) { @@ -73,7 +73,7 @@ if (entity.lastCheckY >= lastSetBlock) { entity.lastCheckY = level.getMinY() - 1; -@@ -224,7 +_,15 @@ +@@ -226,7 +_,15 @@ @Override public void setRemoved() { @@ -89,7 +89,7 @@ super.setRemoved(); } -@@ -234,29 +_,78 @@ +@@ -264,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); -@@ -284,7 +_,7 @@ +@@ -314,7 +_,7 @@ } private static @Nullable Holder loadEffect(final ValueInput input, final String field) { @@ -195,7 +195,7 @@ } @Override -@@ -292,8 +_,10 @@ +@@ -322,8 +_,10 @@ super.loadAdditional(input); this.primaryPower = loadEffect(input, "primary_effect"); this.secondaryPower = loadEffect(input, "secondary_effect"); @@ -206,7 +206,7 @@ } @Override -@@ -304,6 +_,7 @@ +@@ -334,6 +_,7 @@ output.putInt("Levels", this.levels); output.storeNullable("CustomName", ComponentSerialization.CODEC, this.name); this.lockKey.addToTag(output); @@ -214,7 +214,7 @@ } public void setCustomName(final @Nullable Component name) { -@@ -317,7 +_,7 @@ +@@ -347,7 +_,7 @@ @Override public @Nullable AbstractContainerMenu createMenu(final int containerId, final Inventory inventory, final Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index b9d27d8405fa..51feb32952f0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -7,7 +7,7 @@ + public int maxBees = MAX_OCCUPANTS; // CraftBukkit - allow setting max amount of bees a hive can hold public BeehiveBlockEntity(final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.BEEHIVE, worldPosition, blockState); + super(BlockEntityTypes.BEEHIVE, worldPosition, blockState); @@ -119,16 +_,17 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch index dc9dcd3abff4..ffe24b191114 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BellBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BellBlockEntity.java -@@ -62,6 +_,11 @@ +@@ -63,6 +_,11 @@ if (entity.ticks >= 50) { entity.shaking = false; @@ -12,7 +12,7 @@ entity.ticks = 0; } -@@ -75,6 +_,7 @@ +@@ -76,6 +_,7 @@ entity.resonationTicks++; } else { onResonationEnd.run(level, pos, entity.nearbyEntities); @@ -20,7 +20,7 @@ entity.resonating = false; } } -@@ -115,6 +_,8 @@ +@@ -116,6 +_,8 @@ } } } @@ -29,7 +29,7 @@ } private static boolean areRaidersNearby(final BlockPos bellPos, final List nearbyEntities) { -@@ -128,7 +_,10 @@ +@@ -129,7 +_,10 @@ } private static void makeRaidersGlow(final Level level, final BlockPos blockPos, final List nearbyEntities) { @@ -41,7 +41,7 @@ } private static void showBellParticles(final Level level, final BlockPos bellPos, final List nearbyEntities) { -@@ -159,7 +_,16 @@ +@@ -160,7 +_,16 @@ return entity.isAlive() && !entity.isRemoved() && blockPos.closerToCenterThan(entity.position(), 48.0) && entity.is(EntityTypeTags.RAIDERS); } 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 f2535a9d05e5..d9598f172f97 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 @@ -53,30 +53,18 @@ } public final void loadWithComponents(final ValueInput input) { -@@ -136,6 +_,11 @@ - public void saveWithoutMetadata(final ValueOutput output) { - this.saveAdditional(output); - output.store("components", DataComponentMap.CODEC, this.components); -+ // CraftBukkit start - store container -+ if (!this.persistentDataContainer.isEmpty()) { -+ output.store("PublicBukkitValues", CompoundTag.CODEC, this.persistentDataContainer.toTagCompound()); -+ } -+ // CraftBukkit end +@@ -105,6 +_,11 @@ } - public final CompoundTag saveCustomOnly(final HolderLookup.Provider registries) { -@@ -148,6 +_,11 @@ - - public void saveCustomOnly(final ValueOutput output) { - this.saveAdditional(output); -+ // Paper start - store PDC here as well + protected void saveAdditional(final ValueOutput output) { ++ // CraftBukkit start - store container + if (!this.persistentDataContainer.isEmpty()) { + output.store("PublicBukkitValues", CompoundTag.CODEC, this.persistentDataContainer.toTagCompound()); + } -+ // Paper end ++ // CraftBukkit end } - public void saveId(final ValueOutput output) { + public final CompoundTag saveWithFullMetadata(final HolderLookup.Provider registries) { @@ -278,6 +_,12 @@ } 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 dfa24016506b..215f9620d8cc 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 @@ -71,7 +71,7 @@ + // CraftBukkit end public BrewingStandBlockEntity(final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.BREWING_STAND, worldPosition, blockState); + super(BlockEntityTypes.BREWING_STAND, worldPosition, blockState); @@ -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); 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 b690fe965c48..deddc645b9e9 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 @@ -7,7 +7,7 @@ + public final boolean[] stopCooking = new boolean[4]; // Paper - Add more Campfire API public CampfireBlockEntity(final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.CAMPFIRE, worldPosition, blockState); + super(BlockEntityTypes.CAMPFIRE, worldPosition, blockState); @@ -64,12 +_,42 @@ ItemStack itemStack = entity.items.get(slot); if (!itemStack.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch index 5cd1132dcad6..ecacf9199452 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch @@ -41,7 +41,7 @@ + // CraftBukkit end + public ChiseledBookShelfBlockEntity(final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.CHISELED_BOOKSHELF, worldPosition, blockState); + super(BlockEntityTypes.CHISELED_BOOKSHELF, worldPosition, blockState); } @@ -68,7 +_,7 @@ 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 bc4d881c4e5c..6f1c222dbc98 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 @@ -46,5 +46,5 @@ + // CraftBukkit end + public CrafterBlockEntity(final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.CRAFTER, worldPosition, blockState); + super(BlockEntityTypes.CRAFTER, worldPosition, blockState); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java.patch index 18cad5b8445d..fcb575c41734 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java -@@ -111,7 +_,7 @@ +@@ -112,7 +_,7 @@ if (entity.creakingInfo == null) { if (updatedState.getValue(CreakingHeartBlock.STATE) == CreakingHeartState.AWAKE) { - if (serverLevel.isSpawningMonsters()) { + if (serverLevel.isSpawningMonsters() && serverLevel.getLevelData().getDifficulty() != Difficulty.PEACEFUL) { - Player player = level.getNearestPlayer(pos.getX(), pos.getY(), pos.getZ(), 32.0, false); + Player player = level.getNearestPlayerThatAffectsSpawning(pos.getX(), pos.getY(), pos.getZ(), 32.0, false); // Paper - Affects Spawning API if (player != null) { 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 da4859bb303a..1cc98e1eb2ed 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 @@ -39,7 +39,7 @@ + // CraftBukkit end + public HopperBlockEntity(final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.HOPPER, worldPosition, blockState); + super(BlockEntityTypes.HOPPER, worldPosition, blockState); this.facing = blockState.getValue(HopperBlock.FACING); @@ -99,7 +_,12 @@ entity.tickedGameTime = level.getGameTime(); @@ -299,5 +299,5 @@ private static @Nullable Container getBlockContainer(final Level level, final BlockPos pos, final BlockState state) { + if (!level.spigotConfig.hopperCanLoadChunks && !level.hasChunkAt(pos)) return null; // Spigot Block block = state.getBlock(); - if (block instanceof WorldlyContainerHolder) { - return ((WorldlyContainerHolder)block).getContainer(state, level, pos); + if (block instanceof WorldlyContainerHolder worldlyContainerHolder) { + return worldlyContainerHolder.getContainer(state, level, pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch index 6d6aa3f05104..8559be84569b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch @@ -6,7 +6,7 @@ Registry poolRegistry = level.registryAccess().lookupOrThrow(Registries.TEMPLATE_POOL); - Holder pool = poolRegistry.getOrThrow(this.pool); + // Paper start - Replace getHolderOrThrow with a null check -+ Holder pool = poolRegistry.get(this.pool).orElse(null); ++ Holder pool = poolRegistry.get(this.pool).orElse(null); + if (pool == null) { + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch index 796a821f5366..078a0e0f20ab 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -117,4 +_,13 @@ +@@ -118,4 +_,13 @@ output.discard("LootTable"); output.discard("LootTableSeed"); } 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 c208f2289dd0..943a3b380c54 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 @@ -18,8 +18,8 @@ private boolean trySummonWarden(final ServerLevel level) { return this.warningLevel >= 4 && SpawnUtil.trySpawnMob( -- EntityType.WARDEN, EntitySpawnReason.TRIGGERED, level, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER, false -+ EntityType.WARDEN, EntitySpawnReason.TRIGGERED, level, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL, null // Paper - Entity#getEntitySpawnReason +- EntityTypes.WARDEN, EntitySpawnReason.TRIGGERED, level, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER, false ++ EntityTypes.WARDEN, EntitySpawnReason.TRIGGERED, level, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL, null // Paper - Entity#getEntitySpawnReason ) .isPresent(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch index c070757f53da..6fec288b199a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShelfBlockEntity.java.patch @@ -46,5 +46,5 @@ + // CraftBukkit end + public ShelfBlockEntity(final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.SHELF, worldPosition, blockState); + super(BlockEntityTypes.SHELF, worldPosition, blockState); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index 5e0eb33688b7..fd3bfc5ed4e2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -41,14 +41,14 @@ + // CraftBukkit end + public ShulkerBoxBlockEntity(final @Nullable DyeColor color, final BlockPos worldPosition, final BlockState blockState) { - super(BlockEntityType.SHULKER_BOX, worldPosition, blockState); + super(BlockEntityTypes.SHULKER_BOX, worldPosition, blockState); this.color = color; @@ -171,6 +_,7 @@ } this.openCount++; + if (this.opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call - this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); + this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), EVENT_SET_OPEN_COUNT, this.openCount); if (this.openCount == 1) { this.level.gameEvent(containerUser.getLivingEntity(), GameEvent.CONTAINER_OPEN, this.worldPosition); @@ -186,6 +_,7 @@ @@ -56,6 +56,6 @@ if (!this.remove && !containerUser.getLivingEntity().isSpectator()) { this.openCount--; + if (this.opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); + this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), EVENT_SET_OPEN_COUNT, this.openCount); if (this.openCount <= 0) { this.level.gameEvent(containerUser.getLivingEntity(), GameEvent.CONTAINER_CLOSE, this.worldPosition); 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 8265f984dff7..d2cb2271768d 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 @@ -85,7 +85,7 @@ - level.getServer().getCommands().performPrefixedCommand(createCommandSourceStack(player, level, pos), command.command()); + // Paper start - Fix commands from signs not firing command events + String commandLine = command.command().startsWith("/") ? command.command() : "/" + command.command(); -+ if (org.spigotmc.SpigotConfig.logCommands) { ++ if (org.spigotmc.SpigotConfig.logCommands) { + LOGGER.info("{} issued server command: {}", player.getScoreboardName(), commandLine); + } + final io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent bukkitEvent = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch index d322861d25fc..bdf8a417b956 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch @@ -1,5 +1,13 @@ --- a/net/minecraft/world/level/block/entity/TestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/TestBlockEntity.java +@@ -31,6 +_,7 @@ + + @Override + protected void saveAdditional(final ValueOutput output) { ++ super.saveAdditional(output); // Paper - save the PDC + output.store("mode", TestBlockMode.CODEC, this.mode); + output.putString("message", this.message); + output.putBoolean("powered", this.powered); @@ -38,6 +_,7 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch index 5654b523a96f..5d73914290fa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch @@ -8,6 +8,14 @@ input.read("data", TestInstanceBlockEntity.Data.CODEC).ifPresent(this::set); this.errorMarkers.clear(); this.errorMarkers.addAll(input.read("errors", TestInstanceBlockEntity.ErrorMarker.LIST_CODEC).orElse(List.of())); +@@ -170,6 +_,7 @@ + + @Override + protected void saveAdditional(final ValueOutput output) { ++ super.saveAdditional(output); // Paper - save the PDC + output.store("data", TestInstanceBlockEntity.Data.CODEC, this.data); + if (!this.errorMarkers.isEmpty()) { + output.store("errors", TestInstanceBlockEntity.ErrorMarker.LIST_CODEC, this.errorMarkers); @@ -343,7 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/PlayerDetector.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/PlayerDetector.java.patch index 406af683d0a3..b229d0988af7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/PlayerDetector.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/PlayerDetector.java.patch @@ -8,4 +8,4 @@ + level, p -> p.blockPosition().closerThan(pos, requiredPlayerRange) && !p.isCreative() && !p.isSpectator() && p.affectsSpawning // Paper - Affects Spawning API ) .stream() - .filter(player -> !requireLineOfSight || inLineOfSight(level, pos.getCenter(), player.getEyePosition())) + .filter(player -> !requireLineOfSight || inLineOfSight(level, Vec3.atCenterOf(pos), player.getEyePosition())) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch index 2cf57ffee996..9ea2285b2328 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerStateData.java -@@ -187,7 +_,7 @@ +@@ -188,7 +_,7 @@ mob.dropPreservedEquipment(level); } 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 b03601bd1c54..ae8a05b71bb6 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultServerData.java +++ b/net/minecraft/world/level/block/entity/vault/VaultServerData.java -@@ -62,7 +_,12 @@ +@@ -64,7 +_,12 @@ @VisibleForTesting public void addToRewardedPlayers(final Player player) { @@ -14,7 +14,7 @@ if (this.rewardedPlayers.size() > 128) { Iterator iterator = this.rewardedPlayers.iterator(); if (iterator.hasNext()) { -@@ -72,6 +_,7 @@ +@@ -74,6 +_,7 @@ } this.markChanged(); @@ -22,7 +22,7 @@ } public long stateUpdatingResumesAt() { -@@ -127,4 +_,15 @@ +@@ -129,4 +_,15 @@ public float ejectionProgress() { return this.totalEjectionsNeeded == 1 ? 1.0F : 1.0F - Mth.inverseLerp(this.getItemsToEject().size(), 1.0F, this.totalEjectionsNeeded); } 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 index 8ade0ce1da95..8e5c3f6f8887 100644 --- 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 @@ -13,7 +13,7 @@ BlockState extendedState = state.setValue(EXTENDED, true); if (!level.isClientSide()) { boolean extend = this.getNeighborSignal(level, pos, direction); -@@ -182,10 +_,17 @@ +@@ -181,10 +_,17 @@ .defaultBlockState() .setValue(MovingPistonBlock.FACING, direction) .setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT); @@ -32,7 +32,7 @@ ) ); level.updateNeighborsAt(pos, movingPistonState.getBlock()); -@@ -209,13 +_,27 @@ +@@ -208,13 +_,27 @@ || movingState.getPistonPushReaction() != PushReaction.NORMAL && !movingState.is(Blocks.PISTON) && !movingState.is(Blocks.STICKY_PISTON)) { @@ -61,7 +61,7 @@ } level.playSound(null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.15F + 0.6F); -@@ -233,7 +_,7 @@ +@@ -232,7 +_,7 @@ final boolean allowDestroyable, final Direction connectionDirection ) { @@ -70,7 +70,7 @@ return false; } -@@ -298,12 +_,58 @@ +@@ -297,12 +_,58 @@ BlockState[] toUpdate = new BlockState[toPush.size() + toDestroy.size()]; Direction pushDirection = extending ? direction : direction.getOpposite(); int updateIndex = 0; @@ -130,7 +130,7 @@ if (!state.is(BlockTags.FIRE) && level.isClientSide()) { level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, getId(state)); } -@@ -314,13 +_,28 @@ +@@ -313,13 +_,28 @@ } for (int i = toPush.size() - 1; i >= 0; i--) { 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 a7ddf93cc18d..539fac6942f6 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -170,15 +_,22 @@ +@@ -168,15 +_,22 @@ } protected void onPlace(final BlockState state, final Level level, final BlockPos pos, final BlockState oldState, final boolean movedByPiston) { @@ -24,7 +24,7 @@ Block block = state.getBlock(); boolean doDropExperienceHack = explosion.getIndirectSourceEntity() instanceof Player; if (block.dropFromExplosion(explosion)) { -@@ -188,8 +_,10 @@ +@@ -186,8 +_,10 @@ .withParameter(LootContextParams.TOOL, ItemStack.EMPTY) .withOptionalParameter(LootContextParams.BLOCK_ENTITY, blockEntity) .withOptionalParameter(LootContextParams.THIS_ENTITY, explosion.getDirectSourceEntity()); @@ -37,7 +37,7 @@ } state.spawnAfterBreak(level, pos, ItemStack.EMPTY, doDropExperienceHack); -@@ -269,7 +_,7 @@ +@@ -263,7 +_,7 @@ } protected boolean canBeReplaced(final BlockState state, final BlockPlaceContext context) { @@ -46,7 +46,7 @@ } protected boolean canBeReplaced(final BlockState state, final Fluid fluid) { -@@ -484,6 +_,15 @@ +@@ -486,6 +_,15 @@ this.instrument = properties.instrument; this.replaceable = properties.replaceable; } @@ -62,7 +62,7 @@ private boolean calculateSolid() { if (this.owner.properties.forceSolidOn) { -@@ -507,12 +_,14 @@ +@@ -509,12 +_,14 @@ return bounds.getSize() >= 0.7291666666666666 || bounds.getYsize() >= 1.0; } @@ -77,19 +77,20 @@ this.legacySolid = this.calculateSolid(); this.occlusionShape = this.canOcclude ? this.owner.getOcclusionShape(this.asState()) : Shapes.empty(); -@@ -552,6 +_,11 @@ - public boolean isSolid() { +@@ -555,6 +_,12 @@ return this.legacySolid; } + + // Paper start - Protect Bedrock and End Portal/Frames from being destroyed + public final boolean isDestroyable() { -+ return getBlock().isDestroyable(); ++ return this.getBlock().isDestroyable(); + } + // Paper end - Protect Bedrock and End Portal/Frames from being destroyed - ++ public boolean isValidSpawn(final BlockGetter level, final BlockPos pos, final EntityType type) { return this.getBlock().properties.isValidSpawn.test(this.asState(), level, pos, type); -@@ -573,19 +_,19 @@ + } +@@ -575,19 +_,19 @@ return this.occlusionShape; } @@ -114,7 +115,7 @@ return this.isAir; } -@@ -599,7 +_,7 @@ +@@ -601,7 +_,7 @@ } public MapColor getMapColor(final BlockGetter level, final BlockPos pos) { @@ -123,7 +124,7 @@ } public BlockState rotate(final Rotation rotation) { -@@ -655,14 +_,14 @@ +@@ -661,14 +_,14 @@ } public PushReaction getPistonPushReaction() { @@ -140,7 +141,7 @@ return this.canOcclude; } -@@ -753,7 +_,13 @@ +@@ -759,7 +_,13 @@ } public void onPlace(final Level level, final BlockPos pos, final BlockState oldState, final boolean movedByPiston) { @@ -155,7 +156,7 @@ } public void affectNeighborsAfterRemoval(final ServerLevel level, final BlockPos pos, final boolean movedByPiston) { -@@ -780,6 +_,7 @@ +@@ -786,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 +164,7 @@ } public List getDrops(final LootParams.Builder params) { -@@ -864,11 +_,11 @@ +@@ -870,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/border/WorldBorder.java.patch b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch index 3b42c770b6de..d478969f6d4e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch @@ -134,11 +134,18 @@ private interface BorderExtent { double getMinX(final float deltaPartialTick); -@@ -433,6 +_,7 @@ +@@ -433,7 +_,13 @@ this.previousSize = this.size; this.size = this.calculateSize(); - if (this.lerpProgress <= 0L) { -+ if (WorldBorder.this.world != null) new io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent(WorldBorder.this.world.getWorld(), WorldBorder.this.world.getWorld().getWorldBorder(), this.from, this.to, this.lerpDuration).callEvent(); // Paper - Add worldborder events - WorldBorder.this.setDirty(); - return WorldBorder.this.new StaticBorderExtent(this.to); - } else { + WorldBorder.this.setDirty(); +- return this.lerpProgress <= 0L ? WorldBorder.this.new StaticBorderExtent(this.to) : this; ++ // Paper start ++ boolean finished = this.lerpProgress <= 0L; ++ if (finished && WorldBorder.this.world != null) { ++ new io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent(WorldBorder.this.world.getWorld(), WorldBorder.this.world.getWorld().getWorldBorder(), this.from, this.to, this.lerpDuration).callEvent(); // Paper - Add worldborder events ++ } ++ return finished ? WorldBorder.this.new StaticBorderExtent(this.to) : this; ++ // Paper end + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch index e04a19590b68..94e49278a247 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -56,7 +56,7 @@ } public abstract ChunkStatus getPersistedStatus(); -@@ -438,6 +_,23 @@ +@@ -444,6 +_,23 @@ throw new ReportedException(report); } } 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 495df6e567bc..6847ede15a91 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 @@ -11,7 +11,7 @@ } public Optional getTypeNameForDataFixer() { -@@ -127,12 +_,30 @@ +@@ -127,16 +_,34 @@ ); public @Nullable Pair> findNearestMapStructure( @@ -22,6 +22,11 @@ return null; } +- if (!level.getServer().getWorldGenSettings().options().generateStructures()) { ++ if (!level.worldGenSettings.options().generateStructures()) { // CraftBukkit + return null; + } + + // Paper start - StructuresLocateEvent + final org.bukkit.World bukkitWorld = level.getWorld(); + final org.bukkit.Location origin = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); @@ -43,7 +48,7 @@ ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); Map>> placementScans = new Object2ObjectArrayMap<>(); -@@ -227,6 +_,7 @@ +@@ -231,6 +_,7 @@ BlockPos.MutableBlockPos structurePos = new BlockPos.MutableBlockPos(); for (ChunkPos chunkPos : positions) { @@ -51,7 +56,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; -@@ -258,9 +_,12 @@ +@@ -262,9 +_,12 @@ for (int x = -radius; x <= radius; x++) { boolean xEdge = x == -radius || x == radius; @@ -67,7 +72,7 @@ int sectorX = chunkOriginX + spacing * x; int sectorZ = chunkOriginZ + spacing * z; ChunkPos chunkTarget = config.getPotentialStructureChunk(seed, sectorX, sectorZ); -@@ -312,7 +_,7 @@ +@@ -316,7 +_,7 @@ } } @@ -76,7 +81,7 @@ ChunkPos centerPos = chunk.getPos(); if (!SharedConstants.debugVoidTerrain(centerPos)) { SectionPos sectionPos = SectionPos.of(centerPos, level.getMinSectionY()); -@@ -386,7 +_,14 @@ +@@ -390,7 +_,14 @@ Supplier currentlyGenerating = () -> featureRegistry.getResourceKey(feature) .map(Object::toString) .orElseGet(feature::toString); @@ -92,7 +97,7 @@ try { level.setCurrentlyGenerating(currentlyGenerating); -@@ -414,6 +_,34 @@ +@@ -418,6 +_,34 @@ } } } @@ -127,7 +132,7 @@ private static BoundingBox getWritableArea(final ChunkAccess chunk) { ChunkPos chunkPos = chunk.getPos(); -@@ -493,7 +_,7 @@ +@@ -497,7 +_,7 @@ } } @@ -136,7 +141,7 @@ if (structures.size() == 1) { this.tryGenerateStructure( structures.get(0), -@@ -588,6 +_,14 @@ +@@ -592,6 +_,14 @@ biomePredicate ); if (start.isValid()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch index b55910d2927c..65cf9481c5c5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch @@ -12,5 +12,5 @@ + // Paper end + @Override - public @Nullable BlockState setBlockState(final BlockPos pos, final BlockState state, @Block.UpdateFlags final int flags) { + public @Nullable BlockState setBlockState(final BlockPos pos, final BlockState state, final @Block.UpdateFlags int flags) { return null; 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 f95a91639fe4..861648b07f6b 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 @@ -180,7 +180,7 @@ if (removeThis != null) { if (this.level instanceof ServerLevel serverLevel) { this.removeGameEventListener(removeThis, serverLevel); -@@ -513,6 +_,65 @@ +@@ -512,6 +_,65 @@ } } @@ -246,7 +246,7 @@ public boolean isEmpty() { return false; } -@@ -702,6 +_,7 @@ +@@ -700,6 +_,7 @@ } private void updateBlockEntityTicker(final T blockEntity) { @@ -254,7 +254,7 @@ BlockState state = blockEntity.getBlockState(); BlockEntityTicker ticker = state.getTicker(this.level, (BlockEntityType)blockEntity.getType()); if (ticker == null) { -@@ -749,7 +_,11 @@ +@@ -747,7 +_,11 @@ if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; @@ -267,7 +267,7 @@ this.loggedInvalidBlockState = true; LevelChunk.LOGGER .warn( -@@ -758,14 +_,17 @@ +@@ -756,14 +_,17 @@ LogUtils.defer(this::getPos), blockState ); 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 9ee8636b937d..b57440711af9 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,8 +1,8 @@ --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -14,12 +_,12 @@ - public static final int SECTION_HEIGHT = 16; - public static final int SECTION_SIZE = 4096; +@@ -11,12 +_,12 @@ + + public class LevelChunkSection { public static final int BIOME_CONTAINER_BITS = 2; - private short nonEmptyBlockCount; + short nonEmptyBlockCount; // Paper - package private @@ -15,7 +15,7 @@ private LevelChunkSection(final LevelChunkSection source) { this.nonEmptyBlockCount = source.nonEmptyBlockCount; -@@ -30,7 +_,7 @@ +@@ -27,7 +_,7 @@ this.biomes = source.biomes.copy(); } @@ -24,7 +24,7 @@ this.states = states; this.biomes = biomes; this.recalcBlockCounts(); -@@ -46,7 +_,7 @@ +@@ -43,7 +_,7 @@ } public FluidState getFluidState(final int sectionX, final int sectionY, final int sectionZ) { @@ -33,7 +33,7 @@ } public void acquire() { -@@ -197,6 +_,12 @@ +@@ -194,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/storage/RegionFileStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch index da26ce43b89d..623f61986faa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileStorage.java.patch @@ -53,7 +53,7 @@ if (regionChunkInputStream != null) { @@ -67,7 +_,7 @@ - protected void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException { + public void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException { if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { - RegionFile region = this.getRegionFile(pos); + RegionFile region = this.getRegionFile(pos, false); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EnderDragonFight.java.patch b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EnderDragonFight.java.patch index 99f8747f0049..4af4166f8409 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EnderDragonFight.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EnderDragonFight.java.patch @@ -25,7 +25,7 @@ this.dragonUUID = null; } } -@@ -404,13 +_,20 @@ +@@ -403,13 +_,20 @@ this.dragonEvent.setVisible(false); this.spawnExitPortal(true); this.spawnNewGateway(); @@ -53,7 +53,7 @@ this.hasPreviouslyKilledDragon = true; this.dragonKilled = true; -@@ -425,14 +_,26 @@ +@@ -424,14 +_,26 @@ this.setDirty(); } @@ -81,7 +81,7 @@ } public void spawnNewGateway(final BlockPos pos) { -@@ -456,6 +_,12 @@ +@@ -455,6 +_,12 @@ this.exitPortalLocation = this.exitPortalLocation.atY(Math.max(this.level.getMinY() + 1, this.exitPortalLocation.getY())); this.setDirty(); } @@ -94,7 +94,7 @@ if (feature.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.exitPortalLocation)) { int chunkRadius = Mth.positiveCeilDiv(4, 16); -@@ -473,6 +_,7 @@ +@@ -472,6 +_,7 @@ dragon.snapTo(this.origin.getX(), 128 + this.origin.getY(), this.origin.getZ(), this.level.getRandom().nextFloat() * 360.0F, 0.0F); this.level.addFreshEntity(dragon); this.dragonUUID = dragon.getUUID(); @@ -102,7 +102,7 @@ this.setDirty(); } -@@ -485,6 +_,10 @@ +@@ -484,6 +_,10 @@ this.ticksSinceDragonSeen = 0; if (dragon.hasCustomName()) { this.dragonEvent.setName(dragon.getDisplayName()); @@ -113,7 +113,7 @@ } } } -@@ -517,7 +_,13 @@ +@@ -516,7 +_,13 @@ return this.hasPreviouslyKilledDragon; } @@ -128,7 +128,7 @@ if (this.dragonKilled && this.respawnStage == null) { BlockPos location = this.exitPortalLocation; if (location == null) { -@@ -532,6 +_,20 @@ +@@ -531,6 +_,20 @@ location = this.exitPortalLocation; } @@ -149,7 +149,7 @@ List crystals = Lists.newArrayList(); BlockPos center = location.above(1); -@@ -539,18 +_,19 @@ +@@ -538,18 +_,19 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { List found = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(center.relative(direction, 3))); if (found.isEmpty()) { @@ -172,7 +172,7 @@ if (this.dragonKilled && this.respawnStage == null) { for (BlockPattern.BlockPatternMatch portal = this.findExitPortal(); portal != null; portal = this.findExitPortal()) { for (int x = 0; x < this.exitPortalPattern.getWidth(); x++) { -@@ -570,7 +_,9 @@ +@@ -569,7 +_,9 @@ this.spawnExitPortal(false); this.respawnCrystals = crystals.stream().map(EntityReference::of).toList(); this.setDirty(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch index 95139c54f334..126599b9d294 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEvent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/gameevent/GameEvent.java +++ b/net/minecraft/world/level/gameevent/GameEvent.java -@@ -85,7 +_,7 @@ +@@ -86,7 +_,7 @@ } private static Holder.Reference register(final String name, final int notificationRadius) { 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 07db921464da..345fa73e1d86 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 @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java +++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java -@@ -123,7 +_,7 @@ +@@ -124,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) + ExtraCodecs.optionalAlwaysPresentFieldOf(ExtraCodecs.NON_NEGATIVE_INT, "event_delay", 0) + .forGetter(VibrationSystem.Data::getTravelTimeInTicks) ) - .apply( -@@ -223,7 +_,14 @@ +@@ -225,7 +_,14 @@ } Vec3 destination = listenerSourcePos.get(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/DensityFunctions.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/DensityFunctions.java.patch index 03ee533dca7a..7313a5b3900a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/DensityFunctions.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/DensityFunctions.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/DensityFunctions.java +++ b/net/minecraft/world/level/levelgen/DensityFunctions.java -@@ -532,6 +_,16 @@ +@@ -499,6 +_,16 @@ ); private static final float ISLAND_THRESHOLD = -0.9F; private final SimplexNoise islandNoise; @@ -17,7 +17,7 @@ public EndIslandDensityFunction(final long seed) { RandomSource islandRandom = new LegacyRandomSource(seed); -@@ -544,15 +_,31 @@ +@@ -511,15 +_,31 @@ int chunkZ = sectionZ / 2; int subSectionX = sectionX % 2; int subSectionZ = sectionZ % 2; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch index dfd1c2e4d7be..967593bd83b1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -266,7 +_,7 @@ +@@ -265,7 +_,7 @@ @Override public void buildSurface(final WorldGenRegion region, final StructureManager structureManager, final RandomState randomState, final ChunkAccess protoChunk) { if (!SharedConstants.debugVoidTerrain(protoChunk.getPos()) && !SharedConstants.DEBUG_DISABLE_SURFACE) { - WorldGenerationContext context = new WorldGenerationContext(this, region); + WorldGenerationContext context = new WorldGenerationContext(this, region, region.getMinecraftWorld()); // Paper - Flat bedrock generator settings - this.buildSurface( - protoChunk, - context, -@@ -314,7 +_,7 @@ + Set> possibleBiomes = collectPossibleBiomes(region, 1); + this.buildSurface(protoChunk, context, randomState, structureManager, region.getBiomeManager(), Blender.of(region), possibleBiomes); + } +@@ -319,7 +_,7 @@ NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk(c -> this.createNoiseChunk(c, structureManager, Blender.of(region), randomState)); Aquifer aquifer = noiseChunk.aquifer(); CarvingContext context = new CarvingContext( diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch index dab72df27b05..0a78eb7c598a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -47,7 +47,7 @@ + continue; + } + // Paper end - PhantomPreSpawnEvent - Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL); + Phantom phantom = EntityTypes.PHANTOM.create(level, EntitySpawnReason.NATURAL); if (phantom != null) { + phantom.spawningEntity = player.getUUID(); // Paper - PhantomPreSpawnEvent phantom.snapTo(spawnPos, 0.0F, 0.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index e71d18ec3648..16271e4513e0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -188,6 +_,11 @@ +@@ -177,6 +_,11 @@ } level.setBlock(pos, blockState, Block.UPDATE_CLIENTS); @@ -12,7 +12,7 @@ FluidState fluidState = level.getFluidState(pos); if (!fluidState.isEmpty()) { level.scheduleTick(pos, fluidState.getType(), 0); -@@ -200,6 +_,48 @@ +@@ -189,6 +_,48 @@ } } @@ -24,7 +24,7 @@ + } + + boolean result = level.setBlock(pos, craftBlockEntityState.getHandle(), updateFlags); -+ BlockEntity blockEntity = level.getBlockEntity(pos); ++ net.minecraft.world.level.block.entity.BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity != null) { + try (final net.minecraft.util.ProblemReporter.ScopedCollector problemReporter = new net.minecraft.util.ProblemReporter.ScopedCollector( + () -> "StructurePieceTranformers@" + pos.toShortString(), LOGGER @@ -61,20 +61,18 @@ protected boolean canBeReplaced(final LevelReader level, final int x, final int y, final int z, final BoundingBox chunkBB) { return true; } -@@ -471,11 +_,17 @@ +@@ -460,10 +_,16 @@ blockState = reorient(level, pos, Blocks.CHEST.defaultBlockState()); } - level.setBlock(pos, blockState, Block.UPDATE_CLIENTS); -- BlockEntity blockEntity = level.getBlockEntity(pos); -- if (blockEntity instanceof ChestBlockEntity) { -- ((ChestBlockEntity)blockEntity).setLootTable(lootTable, random.nextLong()); +- if (level.getBlockEntity(pos) instanceof ChestBlockEntity chestBlockEntity) { +- chestBlockEntity.setLootTable(lootTable, random.nextLong()); - } + // CraftBukkit start + // level.setBlock(pos, blockState, Block.UPDATE_CLIENTS); -+ // BlockEntity blockEntity = level.getBlockEntity(pos); -+ // if (blockEntity instanceof ChestBlockEntity) { -+ // ((ChestBlockEntity)blockEntity).setLootTable(lootTable, random.nextLong()); ++ // if (level.getBlockEntity(pos) instanceof ChestBlockEntity chestBlockEntity) { ++ // chestBlockEntity.setLootTable(lootTable, random.nextLong()); + // } + org.bukkit.craftbukkit.block.CraftChest chestState = (org.bukkit.craftbukkit.block.CraftChest) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(level, pos, blockState, null); + chestState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(lootTable)); @@ -84,20 +82,18 @@ return true; } else { -@@ -495,11 +_,28 @@ +@@ -483,10 +_,27 @@ ) { BlockPos pos = this.getWorldPos(x, y, z); if (chunkBB.isInside(pos) && !level.getBlockState(pos).is(Blocks.DISPENSER)) { - this.placeBlock(level, Blocks.DISPENSER.defaultBlockState().setValue(DispenserBlock.FACING, facing), x, y, z, chunkBB); -- BlockEntity blockEntity = level.getBlockEntity(pos); -- if (blockEntity instanceof DispenserBlockEntity) { -- ((DispenserBlockEntity)blockEntity).setLootTable(lootTable, random.nextLong()); +- if (level.getBlockEntity(pos) instanceof DispenserBlockEntity dispenserBlockEntity) { +- dispenserBlockEntity.setLootTable(lootTable, random.nextLong()); - } + // CraftBukkit start + // this.placeBlock(level, Blocks.DISPENSER.defaultBlockState().setValue(DispenserBlock.FACING, facing), x, y, z, chunkBB); -+ // BlockEntity blockEntity = level.getBlockEntity(pos); -+ // if (blockEntity instanceof DispenserBlockEntity) { -+ // ((DispenserBlockEntity)blockEntity).setLootTable(lootTable, random.nextLong()); ++ // if (level.getBlockEntity(pos) instanceof DispenserBlockEntity dispenserBlockEntity) { ++ // dispenserBlockEntity.setLootTable(lootTable, random.nextLong()); + // } + if (!this.canBeReplaced(level, x, y, z, this.boundingBox)) { + return true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch index c0e388defb0a..73b3212598b9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch @@ -15,5 +15,5 @@ + } + // CraftBukkit end level.setBlock(blockPos, Blocks.SUSPICIOUS_SAND.defaultBlockState(), Block.UPDATE_CLIENTS); - level.getBlockEntity(blockPos, BlockEntityType.BRUSHABLE_BLOCK) + level.getBlockEntity(blockPos, BlockEntityTypes.BRUSHABLE_BLOCK) .ifPresent(entity -> entity.setLootTable(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY, blockPos.asLong())); 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 087141d8c5ba..4e50a4904907 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 -@@ -411,7 +_,10 @@ +@@ -415,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/IglooPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch index 3054f978e67f..c78d1ad2fc24 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch @@ -1,17 +1,15 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java -@@ -115,10 +_,13 @@ +@@ -114,9 +_,12 @@ ) { if ("chest".equals(markerId)) { level.setBlock(position, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); -- BlockEntity chest = level.getBlockEntity(position.below()); -- if (chest instanceof ChestBlockEntity) { -- ((ChestBlockEntity)chest).setLootTable(BuiltInLootTables.IGLOO_CHEST, random.nextLong()); +- if (level.getBlockEntity(position.below()) instanceof ChestBlockEntity chestBlockEntity) { +- chestBlockEntity.setLootTable(BuiltInLootTables.IGLOO_CHEST, random.nextLong()); - } + // CraftBukkit start - ensure block transformation -+ // BlockEntity blockEntity = level.getBlockEntity(position.below()); -+ // if (blockEntity instanceof ChestBlockEntity) { -+ // ((ChestBlockEntity)blockEntity).setLootTable(BuiltInLootTables.IGLOO_CHEST, random.nextLong()); ++ // if (level.getBlockEntity(position.below()) instanceof ChestBlockEntity chestBlockEntity) { ++ // chestBlockEntity.setLootTable(BuiltInLootTables.IGLOO_CHEST, random.nextLong()); + // } + this.setCraftLootTable(level, position.below(), random, BuiltInLootTables.IGLOO_CHEST); + // CraftBukkit end 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 67381ccb62dc..66c988014404 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 @@ -6,12 +6,12 @@ this.hasPlacedSpider = true; - level.setBlock(pos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); - if (level.getBlockEntity(pos) instanceof SpawnerBlockEntity spawner) { -- spawner.setEntityId(EntityType.CAVE_SPIDER, random); +- spawner.setEntityId(EntityTypes.CAVE_SPIDER, random); - } + // CraftBukkit start + // level.setBlock(pos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); + // if (level.getBlockEntity(pos) instanceof SpawnerBlockEntity spawner) { -+ // spawner.setEntityId(EntityType.CAVE_SPIDER, random); ++ // spawner.setEntityId(EntityTypes.CAVE_SPIDER, random); + // } + this.placeCraftSpawner(level, pos, org.bukkit.entity.EntityType.CAVE_SPIDER, Block.UPDATE_CLIENTS); + // CraftBukkit end 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 760e4631e435..c0b448a2b5d0 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 @@ -6,12 +6,12 @@ this.hasPlacedSpawner = true; - level.setBlock(pos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); - if (level.getBlockEntity(pos) instanceof SpawnerBlockEntity spawner) { -- spawner.setEntityId(EntityType.BLAZE, random); +- spawner.setEntityId(EntityTypes.BLAZE, random); - } + // CraftBukkit start + // level.setBlock(pos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); + // if (level.getBlockEntity(pos) instanceof SpawnerBlockEntity spawner) { -+ // spawner.setEntityId(EntityType.BLAZE, random); ++ // spawner.setEntityId(EntityTypes.BLAZE, random); + // } + this.placeCraftSpawner(level, pos, org.bukkit.entity.EntityType.BLAZE, Block.UPDATE_CLIENTS); + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch index 56eb8a9035a3..4a39a499aa89 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java -@@ -322,16 +_,22 @@ +@@ -321,16 +_,22 @@ final String markerId, final BlockPos position, final ServerLevelAccessor level, final RandomSource random, final BoundingBox chunkBB ) { if ("chest".equals(markerId)) { @@ -9,10 +9,10 @@ - Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(position).is(FluidTags.WATER)), - Block.UPDATE_CLIENTS - ); -- BlockEntity chest = level.getBlockEntity(position); -- if (chest instanceof ChestBlockEntity) { -- ((ChestBlockEntity)chest) -- .setLootTable(this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL, random.nextLong()); +- if (level.getBlockEntity(position) instanceof ChestBlockEntity chestBlockEntity) { +- chestBlockEntity.setLootTable( +- this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL, random.nextLong() +- ); - } + // CraftBukkit start - transform block to ensure loot table is accessible + // level.setBlock( @@ -20,10 +20,10 @@ + // Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(position).is(FluidTags.WATER)), + // Block.UPDATE_CLIENTS + // ); -+ // BlockEntity chest = level.getBlockEntity(position); -+ // if (chest instanceof ChestBlockEntity) { -+ // ((ChestBlockEntity)chest) -+ // .setLootTable(this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL, random.nextLong()); ++ // if (level.getBlockEntity(position) instanceof ChestBlockEntity chestBlockEntity) { ++ // chestBlockEntity.setLootTable( ++ // this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL, random.nextLong() ++ // ); + // } + org.bukkit.craftbukkit.block.CraftChest craftChest = (org.bukkit.craftbukkit.block.CraftChest) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(level, position, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(position).is(FluidTags.WATER)), null); + craftChest.setSeed(random.nextLong()); @@ -31,5 +31,5 @@ + this.placeCraftBlockEntity(level, position, craftChest, Block.UPDATE_CLIENTS); + // CraftBukkit end } else if ("drowned".equals(markerId)) { - Drowned drowned = EntityType.DROWNED.create(level.getLevel(), EntitySpawnReason.STRUCTURE); + Drowned drowned = EntityTypes.DROWNED.create(level.getLevel(), EntitySpawnReason.STRUCTURE); if (drowned != null) { 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 5c5114538c68..ec7926b7331e 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 @@ -6,12 +6,12 @@ this.hasPlacedSpawner = true; - level.setBlock(pos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); - if (level.getBlockEntity(pos) instanceof SpawnerBlockEntity spawner) { -- spawner.setEntityId(EntityType.SILVERFISH, random); +- spawner.setEntityId(EntityTypes.SILVERFISH, random); - } + // CraftBukkit start + // level.setBlock(pos, Blocks.SPAWNER.defaultBlockState(), Block.UPDATE_CLIENTS); + // if (level.getBlockEntity(pos) instanceof SpawnerBlockEntity spawner) { -+ // spawner.setEntityId(EntityType.SILVERFISH, random); ++ // spawner.setEntityId(EntityTypes.SILVERFISH, random); + // } + this.placeCraftSpawner(level, pos, org.bukkit.entity.EntityType.SILVERFISH, Block.UPDATE_CLIENTS); + // CraftBukkit end 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 04b357902949..77b0a4aaa3b1 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -80,6 +_,10 @@ +@@ -81,6 +_,10 @@ public final List entityInfoList = Lists.newArrayList(); private Vec3i size = Vec3i.ZERO; private String author = "?"; @@ -11,7 +11,7 @@ public Vec3i getSize() { return this.size; -@@ -249,7 +_,7 @@ +@@ -250,7 +_,7 @@ } public boolean placeInWorld( @@ -20,7 +20,7 @@ final BlockPos position, final BlockPos referencePos, final StructurePlaceSettings settings, -@@ -260,6 +_,19 @@ +@@ -261,6 +_,19 @@ return false; } @@ -40,7 +40,7 @@ List blockInfoList = settings.getRandomPalette(this.palettes, position).blocks(); if ((!blockInfoList.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 -@@ -287,6 +_,20 @@ +@@ -288,6 +_,20 @@ level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), Block.UPDATE_SKIP_ALL_SIDEEFFECTS | Block.UPDATE_NONE); } @@ -61,7 +61,7 @@ if (level.setBlock(blockPos, state, updateMode)) { minX = Math.min(minX, blockPos.getX()); minY = Math.min(minY, blockPos.getY()); -@@ -298,7 +_,7 @@ +@@ -299,7 +_,7 @@ if (blockInfo.nbt != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos); if (blockEntity != null) { @@ -89,7 +89,7 @@ position, settings.getMirror(), settings.getRotation(), -@@ -510,14 +_,17 @@ +@@ -522,16 +_,17 @@ }); } } @@ -98,13 +98,15 @@ 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); +- return EntityType.create( +- TagValueInput.create(reporter, level.registryAccess(), tag), level.getLevel(), new EntitySpawnRequest(EntitySpawnReason.STRUCTURE, false) +- ); - } 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 ++ return EntityType.create(TagValueInput.create(reporter, level.registryAccess(), tag), level.getLevel(), new EntitySpawnRequest(EntitySpawnReason.STRUCTURE, false), true); // Paper - Don't fire sync event during generation + // } catch (Exception ignored) { + // return Optional.empty(); + // } @@ -112,7 +114,7 @@ } public Vec3i getSize(final Rotation rotation) { -@@ -708,6 +_,11 @@ +@@ -704,6 +_,11 @@ tag.put("entities", entityList); tag.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); @@ -124,7 +126,7 @@ return NbtUtils.addCurrentDataVersion(tag); } -@@ -733,6 +_,11 @@ +@@ -729,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))); }); @@ -136,7 +138,7 @@ } private void loadPalette(final HolderGetter blockLookup, final ListTag paletteList, final ListTag blockList) { -@@ -832,7 +_,7 @@ +@@ -828,7 +_,7 @@ public static final class Palette { private final List blocks; diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch index 5fd5b79ef7ef..8d80a8c758dd 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -@@ -158,7 +_,7 @@ +@@ -160,7 +_,7 @@ orientation = this.orientation.withFront(direction); } 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 92dc79032cc4..cad5725ebad3 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -144,13 +_,14 @@ +@@ -145,13 +_,14 @@ final WorldDataConfiguration dataConfiguration, final Registry datapackDimensions, final HolderLookup.Provider registryAccess @@ -16,7 +16,7 @@ .mapOrElse( Function.identity(), error -> { -@@ -169,13 +_,13 @@ +@@ -170,9 +_,9 @@ } public static DataResult readExistingSavedData( @@ -28,12 +28,7 @@ CompoundTag fileContents; try { -- fileContents = NbtIo.readCompressed(dataLocation, NbtAccounter.defaultQuota()); -+ 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); - } -@@ -386,7 +_,7 @@ +@@ -393,7 +_,7 @@ 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/PrimaryLevelData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index ef7802d8b004..8d73fe52887b 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 @@ -60,7 +60,7 @@ } public static void writeLastPlayed(final CompoundTag tag) { -@@ -322,6 +_,14 @@ +@@ -327,6 +_,14 @@ public LevelSettings getLevelSettings() { return this.settings.copy(); } diff --git a/paper-server/patches/sources/net/minecraft/world/scores/PlayerTeam.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/PlayerTeam.java.patch index dc24bbf1dad6..6925a2098a92 100644 --- a/paper-server/patches/sources/net/minecraft/world/scores/PlayerTeam.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/scores/PlayerTeam.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/scores/PlayerTeam.java +++ b/net/minecraft/world/scores/PlayerTeam.java -@@ -222,7 +_,7 @@ +@@ -223,7 +_,7 @@ i -> i.group( Codec.STRING.fieldOf("Name").forGetter(PlayerTeam.Packed::name), ComponentSerialization.CODEC.optionalFieldOf("DisplayName").forGetter(PlayerTeam.Packed::displayName), -- ChatFormatting.COLOR_CODEC.optionalFieldOf("TeamColor").forGetter(PlayerTeam.Packed::color), -+ io.papermc.paper.util.PaperCodecs.lenientCodec("TeamColor", ChatFormatting.COLOR_CODEC).forGetter(PlayerTeam.Packed::color), // Paper - better fail on decode +- TeamColor.CODEC.optionalFieldOf("TeamColor").forGetter(PlayerTeam.Packed::color), ++ io.papermc.paper.util.PaperCodecs.lenientCodec("TeamColor", TeamColor.CODEC).forGetter(PlayerTeam.Packed::color), // Paper - better fail on decode Codec.BOOL.optionalFieldOf("AllowFriendlyFire", true).forGetter(PlayerTeam.Packed::allowFriendlyFire), Codec.BOOL.optionalFieldOf("SeeFriendlyInvisibles", true).forGetter(PlayerTeam.Packed::seeFriendlyInvisibles), ComponentSerialization.CODEC.optionalFieldOf("MemberNamePrefix", CommonComponents.EMPTY).forGetter(PlayerTeam.Packed::memberNamePrefix), diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java index 7b71c8243307..e3d2e558bbe4 100644 --- a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java @@ -7,17 +7,17 @@ import net.minecraft.world.level.block.PointedDripstoneBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.DripstoneThickness; import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.SpeleothemThickness; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.type.PointedDripstone; +import org.bukkit.block.data.type.Speleothem; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.jspecify.annotations.NullMarked; @NullMarked @GeneratedClass -public class CraftPointedDripstone extends CraftBlockData implements PointedDripstone { - private static final EnumProperty THICKNESS = PointedDripstoneBlock.THICKNESS; +public class CraftPointedDripstone extends CraftBlockData implements Speleothem { + private static final EnumProperty THICKNESS = PointedDripstoneBlock.THICKNESS; private static final EnumProperty TIP_DIRECTION = PointedDripstoneBlock.TIP_DIRECTION; @@ -28,12 +28,12 @@ public CraftPointedDripstone(BlockState state) { } @Override - public PointedDripstone.Thickness getThickness() { - return this.get(THICKNESS, PointedDripstone.Thickness.class); + public Speleothem.Thickness getThickness() { + return this.get(THICKNESS, Speleothem.Thickness.class); } @Override - public void setThickness(final PointedDripstone.Thickness thickness) { + public void setThickness(final Speleothem.Thickness thickness) { Preconditions.checkArgument(thickness != null, "thickness cannot be null!"); this.set(THICKNESS, thickness); } diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotentSulfur.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotentSulfur.java new file mode 100644 index 000000000000..1ec20a23f8d3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotentSulfur.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.annotation.GeneratedClass; +import net.minecraft.world.level.block.PotentSulfurBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.PotentSulfurState; +import org.bukkit.block.data.type.PotentSulfur; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@GeneratedClass +public class CraftPotentSulfur extends CraftBlockData implements PotentSulfur { + private static final EnumProperty STATE = PotentSulfurBlock.STATE; + + public CraftPotentSulfur(BlockState state) { + super(state); + } + + @Override + public PotentSulfur.State getPotentSulfurState() { + return this.get(STATE, PotentSulfur.State.class); + } + + @Override + public void setPotentSulfurState(final PotentSulfur.State state) { + Preconditions.checkArgument(state != null, "state cannot be null!"); + this.set(STATE, state); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSulfurSpike.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSulfurSpike.java new file mode 100644 index 000000000000..36a52e7c030c --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSulfurSpike.java @@ -0,0 +1,67 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.annotation.GeneratedClass; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.SulfurSpikeBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.SpeleothemThickness; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Speleothem; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@GeneratedClass +public class CraftSulfurSpike extends CraftBlockData implements Speleothem { + private static final EnumProperty THICKNESS = SulfurSpikeBlock.THICKNESS; + + private static final EnumProperty TIP_DIRECTION = SulfurSpikeBlock.TIP_DIRECTION; + + private static final BooleanProperty WATERLOGGED = SulfurSpikeBlock.WATERLOGGED; + + public CraftSulfurSpike(BlockState state) { + super(state); + } + + @Override + public Speleothem.Thickness getThickness() { + return this.get(THICKNESS, Speleothem.Thickness.class); + } + + @Override + public void setThickness(final Speleothem.Thickness thickness) { + Preconditions.checkArgument(thickness != null, "thickness cannot be null!"); + this.set(THICKNESS, thickness); + } + + @Override + public BlockFace getVerticalDirection() { + return this.get(TIP_DIRECTION, BlockFace.class); + } + + @Override + public void setVerticalDirection(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.getModY() != 0, "Invalid face, only vertical face are allowed for this property!"); + this.set(TIP_DIRECTION, blockFace); + } + + @Override + public Set getVerticalDirections() { + return this.getValues(TIP_DIRECTION, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java index 602d3ce2cd16..ba32d58c33c6 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -87,7 +87,7 @@ public static void getUpdateStatusStartupMessage() { case 0 -> apiResult.ifPresent(result -> { COMPONENT_LOGGER.warn(text("*************************************************************************************")); COMPONENT_LOGGER.warn(text("You are running the latest build for your Minecraft version (" + BUILD_INFO.minecraftVersionId() + ")")); - COMPONENT_LOGGER.warn(text("However, you are " + result.distance() + " release(s) behind the latest stable release (" + result.latestVersion() + ")!")); + COMPONENT_LOGGER.warn(text("However, you are " + result.distance() + " release" + (result.distance() == 1 ? "" : "s") + " behind the latest stable release (" + result.latestVersion() + ")!")); COMPONENT_LOGGER.warn(text("It is recommended that you update as soon as possible")); COMPONENT_LOGGER.warn(text(DOWNLOAD_PAGE)); COMPONENT_LOGGER.warn(text("*************************************************************************************")); @@ -95,10 +95,11 @@ public static void getUpdateStatusStartupMessage() { case DISTANCE_UNKNOWN -> COMPONENT_LOGGER.warn(text("*** You are running an unknown version! Cannot fetch version info ***")); default -> { if (apiResult.isPresent()) { - COMPONENT_LOGGER.warn(text("*** You are running an outdated version of Minecraft, which is " + apiResult.get().distance() + " release(s) and " + distance + " build(s) behind!")); + final MinecraftVersionFetcher result = apiResult.get(); + COMPONENT_LOGGER.warn(text("*** You are running an outdated version of Minecraft, which is " + result.distance() + " release" + (result.distance() == 1 ? "" : "s") + " and " + distance + " build" + (distance == 1 ? "" : "s") + " behind!")); COMPONENT_LOGGER.warn(text("*** Please update to the latest stable version on " + DOWNLOAD_PAGE + " ***")); } else { - COMPONENT_LOGGER.info(text("*** Currently you are " + distance + " build(s) behind ***")); + COMPONENT_LOGGER.info(text("*** Currently you are " + distance + " build" + (distance == 1 ? "" : "s") + " behind ***")); COMPONENT_LOGGER.info(text("*** It is highly recommended to download the latest build from " + DOWNLOAD_PAGE + " ***")); } } @@ -174,6 +175,11 @@ private static Optional fetchMinecraftVersionList() { final int currentIndex = versionList.indexOf(currentVersion); final int latestIndex = versionList.indexOf(latestVersion); final int distance = currentIndex - latestIndex; + if (distance < 0) { + // Avoid logging warnings for early unpublished snapshot builds + return Optional.empty(); + } + return Optional.of(new MinecraftVersionFetcher(latestVersion, distance)); } } catch (final JsonSyntaxException ex) { diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index b3c7107689f0..077fe6d0f415 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java @@ -68,7 +68,7 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.animal.golem.IronGolem.class, IronGolem.class); map.put(net.minecraft.world.entity.animal.equine.Llama.class, Llama.class); map.put(net.minecraft.world.entity.animal.equine.TraderLlama.class, TraderLlama.class); - map.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class); + map.put(net.minecraft.world.entity.monster.cubemob.MagmaCube.class, MagmaCube.class); map.put(net.minecraft.world.entity.monster.Monster.class, Monster.class); map.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); map.put(net.minecraft.world.entity.animal.cow.MushroomCow.class, MushroomCow.class); @@ -93,7 +93,7 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.monster.skeleton.AbstractSkeleton.class, AbstractSkeleton.class); map.put(net.minecraft.world.entity.monster.skeleton.Stray.class, Stray.class); map.put(net.minecraft.world.entity.monster.skeleton.WitherSkeleton.class, WitherSkeleton.class); - map.put(net.minecraft.world.entity.monster.Slime.class, Slime.class); + map.put(net.minecraft.world.entity.monster.cubemob.Slime.class, Slime.class); map.put(net.minecraft.world.entity.animal.golem.SnowGolem.class, Snowman.class); map.put(net.minecraft.world.entity.monster.spider.Spider.class, Spider.class); map.put(net.minecraft.world.entity.animal.squid.Squid.class, Squid.class); @@ -139,6 +139,8 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.animal.nautilus.ZombieNautilus.class, ZombieNautilus.class); map.put(net.minecraft.world.entity.animal.camel.CamelHusk.class, CamelHusk.class); map.put(net.minecraft.world.entity.monster.skeleton.Parched.class, Parched.class); + map.put(net.minecraft.world.entity.monster.cubemob.SulfurCube.class, SulfurCube.class); + map.put(net.minecraft.world.entity.monster.cubemob.AbstractCubeMob.class, AbstractCubeMob.class); // End generate - MobGoalHelper#BUKKIT_BRIDGE // }); @@ -159,7 +161,8 @@ public class MobGoalHelper { RangedEntity.class, Tameable.class, Monster.class, - PufferFish.class // weird case + PufferFish.class, // weird case + AbstractCubeMob.class ); private static String getPathName(Class type, Class holderClass, String name) { diff --git a/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java index 9863aed2417e..330f14b15cee 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java @@ -15,8 +15,9 @@ import java.util.Vector; public class RAMDetails extends JList { - public static final DecimalFormat DECIMAL_FORMAT = Util.make(new DecimalFormat("########0.000"), (format) - -> format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT))); + public static final DecimalFormat DECIMAL_FORMAT = Util.make( + new DecimalFormat("########0.000"), (format) -> format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT)) + ); private final MinecraftServer server; @@ -63,17 +64,17 @@ public void update() { double[] tps = server.getTPS(); String[] tpsAvg = new String[tps.length]; - for ( int g = 0; g < tps.length; g++) { - tpsAvg[g] = format( tps[g] ); + for (int g = 0; g < tps.length; g++) { + tpsAvg[g] = format(tps[g]); } vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)"); vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb"); - vector.add("Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / (double) TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms"); + vector.add("Avg tick: " + DECIMAL_FORMAT.format((double) this.server.getAverageTickTimeNanos() / (double) TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms"); vector.add("TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg)); setListData(vector); } private static String format(double tps) { - return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); + return ((tps > 21.0) ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, 20.0); } } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/network/PaperLegacyStatusClient.java b/paper-server/src/main/java/com/destroystokyo/paper/network/PaperLegacyStatusClient.java index cc54b1c20798..ebc03a8e4780 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/network/PaperLegacyStatusClient.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/network/PaperLegacyStatusClient.java @@ -46,7 +46,7 @@ public boolean isLegacy() { public static PaperServerListPingEvent processRequest(MinecraftServer server, InetSocketAddress address, int protocolVersion, @Nullable InetSocketAddress virtualHost) { - PaperServerListPingEvent event = new PaperServerListPingEventImpl(server, + PaperServerListPingEvent event = new PaperServerListPingEventImpl(server, new PaperLegacyStatusClient(address, protocolVersion, virtualHost), Byte.MAX_VALUE, null); server.server.getPluginManager().callEvent(event); diff --git a/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java b/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java index 48e774677edf..52a878608271 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java @@ -20,7 +20,7 @@ public PaperAuthenticationService(Proxy proxy) { @Override public MinecraftSessionService createMinecraftSessionService() { - return new PaperMinecraftSessionService(this.getServicesKeySet(), this.getProxy(), this.environment); + return new PaperMinecraftSessionService(this.getServicesKeySet(), this.getProxy(), this.environment); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java index 737c51819110..f4d5123d9488 100644 --- a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java +++ b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java @@ -1,38 +1,74 @@ package io.papermc.paper; import com.destroystokyo.paper.PaperSkinParts; +import com.destroystokyo.paper.PaperVersionFetcher; import com.destroystokyo.paper.SkinParts; +import com.destroystokyo.paper.util.VersionFetcher; +import com.google.common.base.Preconditions; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.attribute.UnmodifiableAttributeMap; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.datacomponent.item.PaperResolvableProfile; import io.papermc.paper.datacomponent.item.ResolvableProfile; +import io.papermc.paper.entity.poi.PaperPoiType; +import io.papermc.paper.entity.poi.PoiType; +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; +import io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEventManager; +import io.papermc.paper.util.MCUtil; import io.papermc.paper.world.damagesource.CombatEntry; import io.papermc.paper.world.damagesource.FallLocationType; import io.papermc.paper.world.damagesource.PaperCombatEntryWrapper; import io.papermc.paper.world.damagesource.PaperCombatTrackerWrapper; +import java.io.IOException; +import java.util.Objects; import java.util.Set; +import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.function.Predicate; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.flattener.ComponentFlattener; import net.minecraft.Optionull; import net.minecraft.commands.Commands; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.chat.ComponentUtils; +import net.minecraft.network.chat.ResolutionContext; import net.minecraft.world.damagesource.FallLocation; +import net.minecraft.world.entity.ai.attributes.DefaultAttributes; +import net.minecraft.world.entity.ai.village.poi.PoiManager; import net.minecraft.world.entity.decoration.Mannequin; import org.bukkit.GameRule; +import org.bukkit.NamespacedKey; +import org.bukkit.Statistic; +import org.bukkit.attribute.Attributable; import org.bukkit.block.Biome; +import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.CraftGameRule; +import org.bukkit.craftbukkit.CraftStatistic; import org.bukkit.craftbukkit.block.CraftBiome; -import io.papermc.paper.entity.poi.PaperPoiType; -import io.papermc.paper.entity.poi.PoiType; -import net.minecraft.world.entity.ai.village.poi.PoiManager; +import org.bukkit.craftbukkit.command.VanillaCommandWrapper; import org.bukkit.craftbukkit.damage.CraftDamageEffect; import org.bukkit.craftbukkit.damage.CraftDamageSource; +import org.bukkit.craftbukkit.damage.CraftDamageSourceBuilder; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.entity.CraftEntityType; import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftMannequin; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.damage.DamageEffect; import org.bukkit.damage.DamageSource; +import org.bukkit.damage.DamageType; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pose; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -40,11 +76,6 @@ public class PaperServerInternalAPIBridge implements InternalAPIBridge { public static final PaperServerInternalAPIBridge INSTANCE = new PaperServerInternalAPIBridge(); - @Override - public DamageEffect getDamageEffect(final String key) { - return CraftDamageEffect.getById(key); - } - @Override public Biome constructLegacyCustomBiome() { class Holder { @@ -65,11 +96,6 @@ public CombatEntry createCombatEntry(final LivingEntity entity, final DamageSour ); } - @Override - public PoiType.Occupancy createOccupancy(final String enumNameEntry) { - return new PaperPoiType.PaperOccupancy(PoiManager.Occupancy.valueOf(enumNameEntry)); - } - @Override public CombatEntry createCombatEntry( final DamageSource damageSource, @@ -124,7 +150,7 @@ public Component defaultMannequinDescription() { } @Override - public GameRule legacyGameRuleBridge(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass) { + public GameRule legacyGameRuleBridge(final GameRule rule, final Function fromLegacyToModern, final Function toLegacyFromModern, final Class legacyClass) { return CraftGameRule.wrap(rule, fromLegacyToModern, toLegacyFromModern, legacyClass); } @@ -132,4 +158,96 @@ public GameRule legacyGameRuleBridge(GameRule r public Set validMannequinPoses() { return CraftMannequin.VALID_POSES; } + + @Override + public PoiType.Occupancy createOccupancy(final String enumNameEntry) { + return new PaperPoiType.PaperOccupancy(PoiManager.Occupancy.valueOf(enumNameEntry)); + } + + @Override + public DamageSource.Builder createDamageSourceBuilder(final DamageType damageType) { + return new CraftDamageSourceBuilder(damageType); + } + + @Override + public DamageEffect getDamageEffect(final String key) { + return Objects.requireNonNull(CraftDamageEffect.getById(key), "No DamageEffect found for " + key + ". This is a bug."); + } + + @Override + public String getTranslationKey(final EntityType entityType) { + return CraftEntityType.bukkitToMinecraft(entityType).getDescriptionId(); + } + + @Override + public VersionFetcher getVersionFetcher() { + return new PaperVersionFetcher(); + } + + @Override + public ItemStack deserializeItem(final byte[] data) { + CompoundTag tag = MCUtil.deserializeTagFromBytes(data); + int dataVersion = NbtUtils.getDataVersion(tag, 0); + Preconditions.checkArgument(dataVersion <= CraftMagicNumbers.INSTANCE.getDataVersion(), "Newer version! Server downgrades are not supported!"); + return MCUtil.deserializeItem(tag); + } + + @Override + public boolean hasDefaultEntityAttributes(final NamespacedKey entityKey) { + return DefaultAttributes.hasSupplier(BuiltInRegistries.ENTITY_TYPE.getValue(CraftNamespacedKey.toMinecraft(entityKey))); + } + + @Override + public Attributable getDefaultEntityAttributes(final NamespacedKey entityKey) { + var supplier = DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType) BuiltInRegistries.ENTITY_TYPE.getValue(CraftNamespacedKey.toMinecraft(entityKey))); + return new UnmodifiableAttributeMap(supplier); + } + + @Override + public String getStatisticCriteriaKey(final Statistic statistic) { + if (statistic.getType() != Statistic.Type.UNTYPED) return "minecraft.custom:minecraft." + statistic.getKey().getKey(); + return CraftStatistic.getNMSStatistic(statistic).getName(); + } + + @Override + public LifecycleEventManager createPluginLifecycleEventManager(final JavaPlugin plugin, final BooleanSupplier registrationCheck) { + return new PaperLifecycleEventManager<>(plugin, registrationCheck); + } + + @Override + public ItemStack createEmptyStack() { + return CraftItemStack.asCraftMirror(null); + } + + @Override + public Component resolveWithContext(final Component component, final @Nullable CommandSender context, final @Nullable Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { + final net.minecraft.commands.CommandSourceStack source = context != null ? VanillaCommandWrapper.getListener(context) : null; + Boolean previous = null; + if (source != null && bypassPermissions) { + previous = source.bypassSelectorPermissions; + source.bypassSelectorPermissions = true; + } + try { + final ResolutionContext.Builder builder = ResolutionContext.builder(); + // order is important here + if (source != null) { + builder.withSource(source); + } + if (scoreboardSubject != null) { + builder.withEntityOverride(((CraftEntity) scoreboardSubject).getHandle()); + } + return PaperAdventure.asAdventure(ComponentUtils.resolve(builder.build(), PaperAdventure.asVanilla(component))); + } catch (final CommandSyntaxException e) { + throw new IOException(e); + } finally { + if (previous != null) { + source.bypassSelectorPermissions = previous; + } + } + } + + @Override + public ComponentFlattener componentFlattener() { + return PaperAdventure.FLATTENER; + } } diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java index d0f87ef856d9..2f4ca0271dab 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java @@ -3,7 +3,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.serialization.JavaOps; import io.netty.util.AttributeKey; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -26,8 +25,8 @@ import net.kyori.adventure.text.event.DataComponentValue; import net.kyori.adventure.text.event.DataComponentValueConverterRegistry; import net.kyori.adventure.text.flattener.ComponentFlattener; +import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.Style; -import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.serializer.ComponentSerializer; import net.kyori.adventure.text.serializer.ansi.ANSIComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; @@ -35,8 +34,6 @@ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.kyori.adventure.translation.GlobalTranslator; import net.kyori.adventure.util.Codec; -import net.minecraft.ChatFormatting; -import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponentType; @@ -46,22 +43,18 @@ import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; import net.minecraft.nbt.TagParser; -import net.minecraft.network.chat.ComponentUtils; -import net.minecraft.network.chat.ResolutionContext; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket; import net.minecraft.network.protocol.game.ClientboundSoundPacket; +import net.minecraft.resources.Identifier; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.world.BossEvent; import net.minecraft.world.entity.Entity; -import org.bukkit.command.CommandSender; +import net.minecraft.world.scores.TeamColor; import org.bukkit.craftbukkit.CraftRegistry; -import org.bukkit.craftbukkit.command.VanillaCommandWrapper; -import org.bukkit.craftbukkit.entity.CraftEntity; import org.intellij.lang.annotations.Subst; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -247,7 +240,6 @@ public static String asPlain(final Component component, final Locale locale) { } private static Component translated(final Component component, final Locale locale) { - //noinspection ConstantValue return GlobalTranslator.render( component, // play it safe @@ -257,25 +249,6 @@ private static Component translated(final Component component, final Locale loca ); } - public static Component resolveWithContext(final @NotNull Component component, final @Nullable CommandSender context, final org.bukkit.entity.@Nullable Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { - final CommandSourceStack css = context != null ? VanillaCommandWrapper.getListener(context) : null; - Boolean previous = null; - if (css != null && bypassPermissions) { - previous = css.bypassSelectorPermissions; - css.bypassSelectorPermissions = true; - } - try { - final ResolutionContext resoutionContext = ResolutionContext.builder().withSource(css).withEntityOverride(scoreboardSubject == null ? null : ((CraftEntity) scoreboardSubject).getHandle()).build(); - return asAdventure(ComponentUtils.resolve(resoutionContext, asVanilla(component), 0)); - } catch (final CommandSyntaxException e) { - throw new IOException(e); - } finally { - if (css != null && previous != null) { - css.bypassSelectorPermissions = previous; - } - } - } - // BossBar public static BossEvent.BossBarColor asVanilla(final BossBar.Color color) { @@ -437,17 +410,12 @@ public record DataComponentValueImpl(com.mojang.serialization.Codec codec, } // Colors - - public static @NotNull TextColor asAdventure(final ChatFormatting formatting) { - final Integer color = formatting.getColor(); - if (color == null) { - throw new IllegalArgumentException("Not a valid color"); - } - return TextColor.color(color); + public static @Nullable NamedTextColor asAdventure(final TeamColor teamColor) { + return NamedTextColor.NAMES.value(teamColor.getSerializedName()); } - public static @Nullable ChatFormatting asVanilla(final TextColor color) { - return ChatFormatting.getByHexValue(color.value()); + public static @Nullable TeamColor asVanilla(final NamedTextColor color) { + return TeamColor.byName(color.toString()); } // Style diff --git a/paper-server/src/main/java/io/papermc/paper/command/PaperVersionCommand.java b/paper-server/src/main/java/io/papermc/paper/command/PaperVersionCommand.java index bfacb856623b..5f17c295e215 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/PaperVersionCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/PaperVersionCommand.java @@ -7,6 +7,7 @@ import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import com.mojang.brigadier.tree.LiteralCommandNode; +import io.papermc.paper.InternalAPIBridge; import io.papermc.paper.command.brigadier.CommandSourceStack; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.plugin.configuration.PluginMeta; @@ -24,7 +25,6 @@ import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.plugin.Plugin; import org.bukkit.util.StringUtil; import org.jspecify.annotations.NullMarked; @@ -45,7 +45,7 @@ public class PaperVersionCommand { private static final Component FAILED_TO_FETCH = Component.text("Could not fetch version information!", NamedTextColor.RED); private static final Component FETCHING = Component.text("Checking version, please wait...", NamedTextColor.WHITE, TextDecoration.ITALIC); - private final VersionFetcher versionFetcher = CraftMagicNumbers.INSTANCE.getVersionFetcher(); + private final VersionFetcher versionFetcher = InternalAPIBridge.get().getVersionFetcher(); private CompletableFuture computedVersion = CompletableFuture.completedFuture(new ComputedVersion(Component.empty(), -1)); // Precompute-- someday move that stuff out of bukkit public static LiteralCommandNode create() { diff --git a/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java index 486fbfd5ef8c..1b383909b47c 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java @@ -47,10 +47,9 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.TextColor; -import net.minecraft.advancements.criterion.MinMaxBounds; +import net.minecraft.advancements.predicates.MinMaxBounds; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.AngleArgument; -import net.minecraft.commands.arguments.ColorArgument; import net.minecraft.commands.arguments.ComponentArgument; import net.minecraft.commands.arguments.DimensionArgument; import net.minecraft.commands.arguments.EntityAnchorArgument; @@ -67,6 +66,7 @@ import net.minecraft.commands.arguments.ResourceKeyArgument; import net.minecraft.commands.arguments.ScoreboardSlotArgument; import net.minecraft.commands.arguments.StyleArgument; +import net.minecraft.commands.arguments.TeamColorArgument; import net.minecraft.commands.arguments.TemplateMirrorArgument; import net.minecraft.commands.arguments.TemplateRotationArgument; import net.minecraft.commands.arguments.TimeArgument; @@ -279,14 +279,8 @@ public ArgumentType itemStackPredicate() { @Override public ArgumentType namedColor() { - return this.wrap(ColorArgument.color(), result -> - requireNonNull( - NamedTextColor.namedColor( - requireNonNull(result.getColor(), () -> result + " didn't have a color") - ), - () -> result.getColor() + " didn't map to an adventure named color" - ) - ); + return this.wrap(TeamColorArgument.teamColor(), result -> + requireNonNull(NamedTextColor.NAMES.value(result.getSerializedName()), () -> result.getSerializedName() + " didn't map to an adventure named color")); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpListenersCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpListenersCommand.java index 9c79d8757f14..2f77462fa779 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpListenersCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpListenersCommand.java @@ -77,7 +77,7 @@ private void dumpToFile(final CommandSender sender) { try { Files.createDirectories(parent); Files.createFile(path); - try (final PrintWriter writer = new PrintWriter(path.toFile())){ + try (final PrintWriter writer = new PrintWriter(path.toFile())) { for (final String eventClass : eventClassNames()) { final HandlerList handlers; try { diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java index 76d4b3ecec1e..86ae93a9cad3 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -43,6 +43,7 @@ import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.ExperienceOrb; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; @@ -196,8 +197,8 @@ public static DespawnRangePair createDefault() { } public @ThrowExceptions Reference2ObjectMap, IntOr.Disabled> despawnTime = Util.make(new Reference2ObjectOpenHashMap<>(), map -> { - map.put(EntityType.SNOWBALL, IntOr.Disabled.DISABLED); - map.put(EntityType.LLAMA_SPIT, IntOr.Disabled.DISABLED); + map.put(EntityTypes.SNOWBALL, IntOr.Disabled.DISABLED); + map.put(EntityTypes.LLAMA_SPIT, IntOr.Disabled.DISABLED); }); @PostProcess @@ -282,13 +283,13 @@ public class Behavior extends ConfigurationPart { public double babyZombieMovementModifier = 0.5; public boolean allowSpiderWorldBorderClimbing = true; - private static final List> ZOMBIE_LIKE = List.of(EntityType.ZOMBIE, EntityType.HUSK, EntityType.ZOMBIE_VILLAGER, EntityType.ZOMBIFIED_PIGLIN); + private static final List> ZOMBIE_LIKE = List.of(EntityTypes.ZOMBIE, EntityTypes.HUSK, EntityTypes.ZOMBIE_VILLAGER, EntityTypes.ZOMBIFIED_PIGLIN); @MergeMap public Map, List> doorBreakingDifficulty = Util.make(new IdentityHashMap<>(), map -> { for (final EntityType type : ZOMBIE_LIKE) { map.put(type, Arrays.stream(Difficulty.values()).filter(Zombie.DOOR_BREAKING_PREDICATE).toList()); } - map.put(EntityType.VINDICATOR, Arrays.stream(Difficulty.values()).filter(Vindicator.DOOR_BREAKING_PREDICATE).toList()); + map.put(EntityTypes.VINDICATOR, Arrays.stream(Difficulty.values()).filter(Vindicator.DOOR_BREAKING_PREDICATE).toList()); }); public boolean disableCreeperLingeringEffect = false; @@ -514,12 +515,12 @@ public class Chunks extends ConfigurationPart { public Duration delayChunkUnloadsBy = Duration.of("10s"); public Reference2IntMap> entityPerChunkSaveLimit = Util.make(new Reference2IntOpenHashMap<>(BuiltInRegistries.ENTITY_TYPE.size()), map -> { map.defaultReturnValue(-1); - map.put(EntityType.EXPERIENCE_ORB, -1); - map.put(EntityType.SNOWBALL, -1); - map.put(EntityType.ENDER_PEARL, -1); - map.put(EntityType.ARROW, -1); - map.put(EntityType.FIREBALL, -1); - map.put(EntityType.SMALL_FIREBALL, -1); + map.put(EntityTypes.EXPERIENCE_ORB, -1); + map.put(EntityTypes.SNOWBALL, -1); + map.put(EntityTypes.ENDER_PEARL, -1); + map.put(EntityTypes.ARROW, -1); + map.put(EntityTypes.FIREBALL, -1); + map.put(EntityTypes.SMALL_FIREBALL, -1); }); public boolean flushRegionsOnSave = false; @@ -544,8 +545,8 @@ public class TickRates extends ConfigurationPart { public int mobSpawner = 1; public int wetFarmland = 1; public int dryFarmland = 1; - public Table, String, Integer> sensor = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "secondarypoisensor", 40)); - public Table, String, Integer> behavior = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "validatenearbypoi", -1)); + public Table, String, Integer> sensor = Util.make(HashBasedTable.create(), table -> table.put(EntityTypes.VILLAGER, "secondarypoisensor", 40)); + public Table, String, Integer> behavior = Util.make(HashBasedTable.create(), table -> table.put(EntityTypes.VILLAGER, "validatenearbypoi", -1)); } @Setting(FeatureSeedsGeneration.FEATURE_SEEDS_KEY) diff --git a/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerGameConnection.java b/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerGameConnection.java index ac252f2f43f1..0b17dc4eb635 100644 --- a/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerGameConnection.java +++ b/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerGameConnection.java @@ -8,8 +8,8 @@ public class PaperPlayerGameConnection extends PaperCommonConnection implements PlayerGameConnection { - public PaperPlayerGameConnection(final ServerGamePacketListenerImpl serverConfigurationPacketListenerImpl) { - super(serverConfigurationPacketListenerImpl); + public PaperPlayerGameConnection(final ServerGamePacketListenerImpl packetListener) { + super(packetListener); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java index 328cc1a7655c..a775db74a447 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/DataComponentAdapters.java @@ -36,6 +36,7 @@ import io.papermc.paper.datacomponent.item.PaperRepairable; import io.papermc.paper.datacomponent.item.PaperResolvableProfile; import io.papermc.paper.datacomponent.item.PaperSeededContainerLoot; +import io.papermc.paper.datacomponent.item.PaperSulfurCubeContent; import io.papermc.paper.datacomponent.item.PaperSuspiciousStewEffects; import io.papermc.paper.datacomponent.item.PaperSwingAnimation; import io.papermc.paper.datacomponent.item.PaperTooltipDisplay; @@ -173,6 +174,7 @@ public static void bootstrap() { register(DataComponents.CONTAINER, PaperItemContainerContents::new); register(DataComponents.BLOCK_STATE, PaperBlockItemDataProperties::new); // bees + register(DataComponents.SULFUR_CUBE_CONTENT, PaperSulfurCubeContent::new); // register(DataComponents.LOCK, PaperLockCode::new); register(DataComponents.CONTAINER_LOOT, PaperSeededContainerLoot::new); register(DataComponents.BREAK_SOUND, nms -> PaperAdventure.asAdventure(nms.value().location()), PaperAdventure::resolveSound); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java index 28670480c48f..c2ccc5a3c418 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridgesImpl.java @@ -183,11 +183,11 @@ public MapId mapId(final int id) { } @Override - public UseRemainder useRemainder(final ItemStack stack) { - Preconditions.checkArgument(stack != null, "Item cannot be null"); - Preconditions.checkArgument(!stack.isEmpty(), "Remaining item cannot be empty!"); + public UseRemainder useRemainder(final ItemStack item) { + Preconditions.checkArgument(item != null, "item cannot be null"); + Preconditions.checkArgument(!item.isEmpty(), "item cannot be empty!"); return new PaperUseRemainder( - new net.minecraft.world.item.component.UseRemainder(CraftItemStack.asTemplate(stack)) + new net.minecraft.world.item.component.UseRemainder(CraftItemStack.asTemplate(item)) ); } @@ -286,4 +286,11 @@ public KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, floa maxDurationTicks, minSpeed, requireNonNegative(minRelativeSpeed, "minRelativeSpeed") )); } + + @Override + public SulfurCubeContent sulfurCubeContent(final ItemStack absorbedItem) { + Preconditions.checkArgument(absorbedItem != null, "absorbedItem cannot be null"); + Preconditions.checkArgument(!absorbedItem.isEmpty(), "absorbedItem cannot be empty"); + return new PaperSulfurCubeContent(new net.minecraft.world.item.component.SulfurCubeContent(CraftItemStack.asTemplate(absorbedItem))); + } } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBundleContents.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBundleContents.java index 2f55228064e8..932a3258171d 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBundleContents.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBundleContents.java @@ -26,16 +26,16 @@ static final class BuilderImpl implements BundleContents.Builder { private final List items = new ObjectArrayList<>(); @Override - public BundleContents.Builder add(final ItemStack stack) { - Preconditions.checkArgument(stack != null, "stack cannot be null"); - Preconditions.checkArgument(!stack.isEmpty(), "stack cannot be empty"); - this.items.add(CraftItemStack.asTemplate(stack)); + public BundleContents.Builder add(final ItemStack item) { + Preconditions.checkArgument(item != null, "item cannot be null"); + Preconditions.checkArgument(!item.isEmpty(), "item cannot be empty"); + this.items.add(CraftItemStack.asTemplate(item)); return this; } @Override - public BundleContents.Builder addAll(final List stacks) { - stacks.forEach(this::add); + public BundleContents.Builder addAll(final List items) { + items.forEach(this::add); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java index 3972d8097e13..19df68577dab 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java @@ -27,16 +27,16 @@ static final class BuilderImpl implements ChargedProjectiles.Builder { private final List items = new ArrayList<>(); @Override - public ChargedProjectiles.Builder add(final ItemStack stack) { - Preconditions.checkArgument(stack != null, "stack cannot be null"); - Preconditions.checkArgument(!stack.isEmpty(), "stack cannot be empty"); - this.items.add(CraftItemStack.asNMSCopy(stack)); + public ChargedProjectiles.Builder add(final ItemStack item) { + Preconditions.checkArgument(item != null, "item cannot be null"); + Preconditions.checkArgument(!item.isEmpty(), "item cannot be empty"); + this.items.add(CraftItemStack.asNMSCopy(item)); return this; } @Override - public ChargedProjectiles.Builder addAll(final List stacks) { - stacks.forEach(this::add); + public ChargedProjectiles.Builder addAll(final List items) { + items.forEach(this::add); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java index c2e2ff3a8c1b..8e658a12032c 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemAdventurePredicate.java @@ -8,7 +8,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; import java.util.Optional; -import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.predicates.DataComponentMatchers; import net.minecraft.core.registries.Registries; import org.bukkit.craftbukkit.util.Handleable; @@ -33,11 +33,11 @@ public List predicates() { static final class BuilderImpl implements ItemAdventurePredicate.Builder { - private final List predicates = new ObjectArrayList<>(); + private final List predicates = new ObjectArrayList<>(); @Override public ItemAdventurePredicate.Builder addPredicate(final BlockPredicate predicate) { - this.predicates.add(new net.minecraft.advancements.criterion.BlockPredicate(Optional.ofNullable(predicate.blocks()).map( + this.predicates.add(new net.minecraft.advancements.predicates.BlockPredicate(Optional.ofNullable(predicate.blocks()).map( blocks -> PaperRegistrySets.convertToNms(Registries.BLOCK, Conversions.global().lookup(), blocks) ), Optional.empty(), Optional.empty(), DataComponentMatchers.ANY)); // TODO DataComponentMatchers return this; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java index e424d8050e09..4f6f45e3d451 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java @@ -27,29 +27,29 @@ static final class BuilderImpl implements ItemContainerContents.Builder { private final List items = new ObjectArrayList<>(); @Override - public ItemContainerContents.Builder add(final ItemStack stack) { - Preconditions.checkArgument(stack != null, "Item cannot be null"); + public ItemContainerContents.Builder add(final ItemStack item) { + Preconditions.checkArgument(item != null, "item cannot be null"); Preconditions.checkArgument( this.items.size() + 1 <= net.minecraft.world.item.component.ItemContainerContents.MAX_SIZE, "Cannot have more than %s items, had %s", net.minecraft.world.item.component.ItemContainerContents.MAX_SIZE, this.items.size() + 1 ); - this.items.add(CraftItemStack.asNMSCopy(stack)); + this.items.add(CraftItemStack.asNMSCopy(item)); return this; } @Override - public ItemContainerContents.Builder addAll(final List stacks) { + public ItemContainerContents.Builder addAll(final List items) { Preconditions.checkArgument( - this.items.size() + stacks.size() <= net.minecraft.world.item.component.ItemContainerContents.MAX_SIZE, + this.items.size() + items.size() <= net.minecraft.world.item.component.ItemContainerContents.MAX_SIZE, "Cannot have more than %s items, had %s", net.minecraft.world.item.component.ItemContainerContents.MAX_SIZE, - this.items.size() + stacks.size() + this.items.size() + items.size() ); - MCUtil.addAndConvert(this.items, stacks, stack -> { - Preconditions.checkArgument(stack != null, "Cannot pass null item!"); - return CraftItemStack.asNMSCopy(stack); + MCUtil.addAndConvert(this.items, items, item -> { + Preconditions.checkArgument(item != null, "Cannot pass null item!"); + return CraftItemStack.asNMSCopy(item); }); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSulfurCubeContent.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSulfurCubeContent.java new file mode 100644 index 000000000000..14e95899546a --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSulfurCubeContent.java @@ -0,0 +1,20 @@ +package io.papermc.paper.datacomponent.item; + +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.Handleable; +import org.bukkit.inventory.ItemStack; + +public record PaperSulfurCubeContent( + net.minecraft.world.item.component.SulfurCubeContent impl +) implements SulfurCubeContent, Handleable { + + @Override + public net.minecraft.world.item.component.SulfurCubeContent getHandle() { + return this.impl; + } + + @Override + public ItemStack absorbedItem() { + return CraftItemStack.asBukkitCopy(this.impl.absorbedBlockItemStack()); + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java index 559343a33bad..5d2fda0ac2da 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java @@ -37,8 +37,8 @@ private static void validatePageLength(final String page) { ); } - private static void validatePageCount(final int current, final int add) { - final int newSize = current + add; + private static void validatePageCount(final int current, final int delta) { + final int newSize = current + delta; Preconditions.checkArgument( newSize <= net.minecraft.world.item.component.WritableBookContent.MAX_PAGES, "Cannot have more than %s pages, had %s", diff --git a/paper-server/src/main/java/io/papermc/paper/entity/PaperBucketable.java b/paper-server/src/main/java/io/papermc/paper/entity/PaperBucketable.java index d3fc2e5db9f3..a75ffe98c492 100644 --- a/paper-server/src/main/java/io/papermc/paper/entity/PaperBucketable.java +++ b/paper-server/src/main/java/io/papermc/paper/entity/PaperBucketable.java @@ -7,7 +7,7 @@ public interface PaperBucketable extends Bucketable { - net.minecraft.world.entity.animal.Bucketable getHandle(); + net.minecraft.world.entity.Bucketable getHandle(); @Override default boolean isFromBucket() { diff --git a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java index 21332259bbb0..4b3fd7f89336 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -21,6 +21,7 @@ import io.papermc.paper.registry.data.PaperPaintingVariantRegistryEntry; import io.papermc.paper.registry.data.PaperPigVariantRegistryEntry; import io.papermc.paper.registry.data.PaperSoundEventRegistryEntry; +import io.papermc.paper.registry.data.PaperSulfurCubeArchetypeRegistryEntry; import io.papermc.paper.registry.data.PaperWolfVariantRegistryEntry; import io.papermc.paper.registry.data.PaperZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.PaperDialogRegistryEntry; @@ -65,6 +66,7 @@ import org.bukkit.craftbukkit.entity.CraftCow; import org.bukkit.craftbukkit.entity.CraftFrog; import org.bukkit.craftbukkit.entity.CraftPig; +import org.bukkit.craftbukkit.entity.CraftSulfurCube; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; import org.bukkit.craftbukkit.entity.CraftZombieNautilus; @@ -85,6 +87,7 @@ import org.bukkit.entity.Cow; import org.bukkit.entity.Frog; import org.bukkit.entity.Pig; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; import org.bukkit.entity.ZombieNautilus; @@ -148,6 +151,7 @@ public final class PaperRegistries { start(Registries.PIG_VARIANT, RegistryKey.PIG_VARIANT).craft(Pig.Variant.class, CraftPig.CraftVariant::new).writable(PaperPigVariantRegistryEntry.PaperBuilder::new), start(Registries.PIG_SOUND_VARIANT, RegistryKey.PIG_SOUND_VARIANT).craft(Pig.SoundVariant.class, CraftPig.CraftSoundVariant::new).build(), start(Registries.ZOMBIE_NAUTILUS_VARIANT, RegistryKey.ZOMBIE_NAUTILUS_VARIANT).craft(ZombieNautilus.Variant.class, CraftZombieNautilus.CraftVariant::new).writable(PaperZombieNautilusVariantRegistryEntry.PaperBuilder::new), + start(Registries.SULFUR_CUBE_ARCHETYPE, RegistryKey.SULFUR_CUBE_ARCHETYPE).craft(SulfurCube.Archetype.class, CraftSulfurCube.CraftArchetype::new).writable(PaperSulfurCubeArchetypeRegistryEntry.PaperBuilder::new), start(Registries.DIALOG, RegistryKey.DIALOG).craft(Dialog.class, PaperDialog::new, true).writable(PaperDialogRegistryEntry.PaperBuilder::new), // api-only diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java index a1d314f722d9..bec275433ea0 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCatTypeRegistryEntry.java @@ -3,6 +3,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.util.MCUtil; import net.minecraft.core.ClientAsset; import net.minecraft.world.entity.animal.feline.CatVariant; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; @@ -18,13 +19,10 @@ public class PaperCatTypeRegistryEntry implements CatTypeRegistryEntry { protected ClientAsset.@Nullable ResourceTexture babyClientTextureAsset; protected SpawnPrioritySelectors spawnConditions; - protected final Conversions conversions; - public PaperCatTypeRegistryEntry( - final Conversions conversions, + final Conversions ignoredConversions, final @Nullable CatVariant internal ) { - this.conversions = conversions; if (internal == null) { this.spawnConditions = SpawnPrioritySelectors.EMPTY; return; @@ -37,12 +35,12 @@ public PaperCatTypeRegistryEntry( @Override public ClientTextureAsset clientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.clientTextureAsset, "clientTextureAsset")); } @Override public ClientTextureAsset babyClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); } public static final class PaperBuilder extends PaperCatTypeRegistryEntry implements Builder, PaperRegistryBuilder { @@ -53,13 +51,13 @@ public PaperBuilder(final Conversions conversions, final @Nullable CatVariant in @Override public Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { - this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + this.clientTextureAsset = MCUtil.toResourceTexture(asArgument(clientTextureAsset, "clientTextureAsset")); return this; } @Override public Builder babyClientTextureAsset(final ClientTextureAsset babyClientTextureAsset) { - this.babyClientTextureAsset = this.conversions.asVanilla(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); + this.babyClientTextureAsset = MCUtil.toResourceTexture(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java index 4809bff29b99..f45810128b7f 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperChickenVariantRegistryEntry.java @@ -3,6 +3,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.util.MCUtil; import net.minecraft.core.ClientAsset; import net.minecraft.world.entity.animal.chicken.ChickenVariant; import net.minecraft.world.entity.variant.ModelAndTexture; @@ -20,13 +21,10 @@ public class PaperChickenVariantRegistryEntry implements ChickenVariantRegistryE protected ClientAsset.@Nullable ResourceTexture babyClientTextureAsset; protected SpawnPrioritySelectors spawnConditions; - protected final Conversions conversions; - public PaperChickenVariantRegistryEntry( - final Conversions conversions, + final Conversions ignoredConversions, final @Nullable ChickenVariant internal ) { - this.conversions = conversions; if (internal == null) { this.spawnConditions = SpawnPrioritySelectors.EMPTY; return; @@ -40,12 +38,12 @@ public PaperChickenVariantRegistryEntry( @Override public ClientTextureAsset clientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.clientTextureAsset, "clientTextureAsset")); } @Override public ClientTextureAsset babyClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); } @Override @@ -64,13 +62,13 @@ public PaperBuilder(final Conversions conversions, final @Nullable ChickenVarian @Override public Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { - this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + this.clientTextureAsset = MCUtil.toResourceTexture(asArgument(clientTextureAsset, "clientTextureAsset")); return this; } @Override public Builder babyClientTextureAsset(final ClientTextureAsset babyClientTextureAsset) { - this.babyClientTextureAsset = this.conversions.asVanilla(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); + this.babyClientTextureAsset = MCUtil.toResourceTexture(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java index 8d526716ea43..f6a057465e5d 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperCowVariantRegistryEntry.java @@ -3,6 +3,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.util.MCUtil; import net.minecraft.core.ClientAsset; import net.minecraft.world.entity.animal.cow.CowVariant; import net.minecraft.world.entity.variant.ModelAndTexture; @@ -20,13 +21,10 @@ public class PaperCowVariantRegistryEntry implements CowVariantRegistryEntry { protected ClientAsset.@Nullable ResourceTexture babyClientTextureAsset = null; protected SpawnPrioritySelectors spawnConditions; - protected final Conversions conversions; - public PaperCowVariantRegistryEntry( - final Conversions conversions, + final Conversions ignoredConversions, final @Nullable CowVariant internal ) { - this.conversions = conversions; if (internal == null) { this.spawnConditions = SpawnPrioritySelectors.EMPTY; return; @@ -40,12 +38,12 @@ public PaperCowVariantRegistryEntry( @Override public ClientTextureAsset clientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.clientTextureAsset, "clientTextureAsset")); } @Override public ClientTextureAsset babyClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); } @Override @@ -65,13 +63,13 @@ public PaperBuilder(final Conversions conversions, final @Nullable CowVariant in @Override public Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { - this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + this.clientTextureAsset = MCUtil.toResourceTexture(asArgument(clientTextureAsset, "clientTextureAsset")); return this; } @Override public Builder babyClientTextureAsset(final ClientTextureAsset babyClientTextureAsset) { - this.babyClientTextureAsset = this.conversions.asVanilla(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); + this.babyClientTextureAsset = MCUtil.toResourceTexture(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperDamageTypeRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperDamageTypeRegistryEntry.java index 519b66de023c..d294bcb916b0 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperDamageTypeRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperDamageTypeRegistryEntry.java @@ -16,14 +16,13 @@ public class PaperDamageTypeRegistryEntry implements DamageTypeRegistryEntry { + protected final Conversions conversions; protected @Nullable String messageId; protected @Nullable DamageScaling scaling; protected @Nullable Float exhaustion; protected DamageEffects effects = DamageEffects.HURT; protected DeathMessageType deathMessageType = DeathMessageType.DEFAULT; - protected final Conversions conversions; - public PaperDamageTypeRegistryEntry( final Conversions conversions, final @Nullable DamageType internal diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java index 53559e6041a7..5617be78a54d 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperEnchantmentRegistryEntry.java @@ -7,6 +7,7 @@ import io.papermc.paper.registry.data.util.Conversions; import io.papermc.paper.registry.set.PaperRegistrySets; import io.papermc.paper.registry.set.RegistryKeySet; +import io.papermc.paper.util.MCUtil; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -127,7 +128,7 @@ public EnchantmentCost maximumCost() { @Override public List activeSlots() { - return Collections.unmodifiableList(Lists.transform(asConfigured(this.activeSlots, "activeSlots"), CraftEquipmentSlot::getSlotGroup)); + return MCUtil.transformUnmodifiable(asConfigured(this.activeSlots, "activeSlots"), CraftEquipmentSlot::getSlotGroup); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperFrogVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperFrogVariantRegistryEntry.java index bd6a9b51c169..e42ba94512bd 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperFrogVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperFrogVariantRegistryEntry.java @@ -3,6 +3,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.util.MCUtil; import net.minecraft.core.ClientAsset; import net.minecraft.world.entity.animal.frog.FrogVariant; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; @@ -17,13 +18,10 @@ public class PaperFrogVariantRegistryEntry implements FrogVariantRegistryEntry { protected ClientAsset.@Nullable ResourceTexture clientTextureAsset; protected SpawnPrioritySelectors spawnConditions; - protected final Conversions conversions; - public PaperFrogVariantRegistryEntry( - final Conversions conversions, + final Conversions ignoredConversions, final @Nullable FrogVariant internal ) { - this.conversions = conversions; if (internal == null) { spawnConditions = SpawnPrioritySelectors.EMPTY; return; @@ -35,7 +33,7 @@ public PaperFrogVariantRegistryEntry( @Override public ClientTextureAsset clientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.clientTextureAsset, "clientTextureAsset")); } public static final class PaperBuilder extends PaperFrogVariantRegistryEntry implements Builder, PaperRegistryBuilder { @@ -46,7 +44,7 @@ public PaperBuilder(final Conversions conversions, final @Nullable FrogVariant i @Override public Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { - this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + this.clientTextureAsset = MCUtil.toResourceTexture(asArgument(clientTextureAsset, "clientTextureAsset")); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java index 3eed052976cc..dbb709466a6e 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPaintingVariantRegistryEntry.java @@ -19,14 +19,13 @@ public class PaperPaintingVariantRegistryEntry implements PaintingVariantRegistryEntry { + protected final Conversions conversions; protected OptionalInt width = OptionalInt.empty(); protected OptionalInt height = OptionalInt.empty(); protected @Nullable Component title; protected @Nullable Component author; protected @Nullable Identifier assetId; - protected final Conversions conversions; - public PaperPaintingVariantRegistryEntry( final Conversions conversions, final @Nullable PaintingVariant internal diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java index fe9e5889b819..7e439e44e50d 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperPigVariantRegistryEntry.java @@ -3,6 +3,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.util.MCUtil; import net.minecraft.core.ClientAsset; import net.minecraft.world.entity.animal.pig.PigVariant; import net.minecraft.world.entity.variant.ModelAndTexture; @@ -20,13 +21,10 @@ public class PaperPigVariantRegistryEntry implements PigVariantRegistryEntry { protected ClientAsset.@Nullable ResourceTexture babyClientTextureAsset; protected SpawnPrioritySelectors spawnConditions; - protected final Conversions conversions; - public PaperPigVariantRegistryEntry( - final Conversions conversions, + final Conversions ignoredConversions, final @Nullable PigVariant internal ) { - this.conversions = conversions; if (internal == null) { spawnConditions = SpawnPrioritySelectors.EMPTY; return; @@ -40,12 +38,12 @@ public PaperPigVariantRegistryEntry( @Override public ClientTextureAsset clientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.clientTextureAsset, "clientTextureAsset")); } @Override public ClientTextureAsset babyClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.babyClientTextureAsset, "babyClientTextureAsset")); } @Override @@ -64,13 +62,13 @@ public PaperBuilder(final Conversions conversions, final @Nullable PigVariant in @Override public Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { - this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + this.clientTextureAsset = MCUtil.toResourceTexture(asArgument(clientTextureAsset, "clientTextureAsset")); return this; } @Override public Builder babyClientTextureAsset(final ClientTextureAsset babyClientTextureAsset) { - this.babyClientTextureAsset = this.conversions.asVanilla(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); + this.babyClientTextureAsset = MCUtil.toResourceTexture(asArgument(babyClientTextureAsset, "babyClientTextureAsset")); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSulfurCubeArchetypeRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSulfurCubeArchetypeRegistryEntry.java new file mode 100644 index 000000000000..922d09622aa5 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSulfurCubeArchetypeRegistryEntry.java @@ -0,0 +1,205 @@ +package io.papermc.paper.registry.data; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import io.papermc.paper.registry.PaperRegistries; +import io.papermc.paper.registry.PaperRegistryBuilder; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.registry.set.PaperRegistrySets; +import io.papermc.paper.registry.set.RegistryKeySet; +import io.papermc.paper.util.MCUtil; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Random; +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.Registries; +import net.minecraft.util.valueproviders.ConstantFloat; +import net.minecraft.world.entity.SulfurCubeArchetype; +import net.minecraft.world.item.Item; +import org.bukkit.craftbukkit.attribute.CraftAttributeInstance; +import org.bukkit.craftbukkit.util.RandomSourceWrapper; +import org.bukkit.entity.SulfurCube; +import org.bukkit.inventory.ItemType; +import org.jspecify.annotations.Nullable; + +import static io.papermc.paper.registry.data.util.Checks.asArgument; +import static io.papermc.paper.registry.data.util.Checks.asConfigured; + +public class PaperSulfurCubeArchetypeRegistryEntry implements SulfurCubeArchetypeRegistryEntry { + + protected final Conversions conversions; + protected @Nullable HolderSet items; + protected List attributeModifiers; + protected boolean buoyant; + protected SulfurCubeArchetype.@Nullable ExplosionData explosion; + protected SulfurCubeArchetype.@Nullable ContactDamage contactDamage; + protected SulfurCubeArchetype.@Nullable KnockbackModifiers knockbackModifiers; + protected SulfurCubeArchetype.@Nullable SoundSettings soundSettings; + + public PaperSulfurCubeArchetypeRegistryEntry(final Conversions conversions, final @Nullable SulfurCubeArchetype archetype) { + this.conversions = conversions; + if (archetype == null) { + this.attributeModifiers = List.of(); + return; + } + + this.items = archetype.items(); + this.attributeModifiers = archetype.attributeModifiers(); + this.buoyant = archetype.buoyant(); + this.explosion = archetype.explosion().orElse(null); + this.contactDamage = archetype.contactDamage().orElse(null); + this.knockbackModifiers = archetype.knockbackModifiers(); + this.soundSettings = archetype.soundSettings(); + } + + @Override + public RegistryKeySet items() { + return PaperRegistrySets.convertToApi(RegistryKey.ITEM, asConfigured(this.items, "items")); + } + + @Override + public List attributeModifiers() { + return MCUtil.transformUnmodifiable(this.attributeModifiers, entry -> { + return AttributeEntry.of( + PaperRegistries.fromNms(entry.attribute().unwrapKey().orElseThrow()), + CraftAttributeInstance.convert(entry.modifier()) + ); + }); + } + + @Override + public boolean buoyant() { + return this.buoyant; + } + + @Override + public @Nullable ExplosionSettings explosion() { + if (this.explosion == null) { + return null; + } + + return ExplosionSettings.of( + this.explosion.power(), + this.explosion.causesFire(), + this.explosion.fuse() + ); + } + + @Override + public @Nullable ContactDamage contactDamage() { + if (this.contactDamage == null) { + return null; + } + + return ContactDamage.of( + PaperRegistries.fromNms(this.contactDamage.damageType().unwrapKey().orElseThrow()), + this.contactDamage.amount().sample(new RandomSourceWrapper(new Random())), + this.contactDamage.attributeToSource() + ); + } + + @Override + public KnockbackModifiers knockbackModifiers() { + asConfigured(this.knockbackModifiers, "knockbackModifiers"); + return KnockbackModifiers.of( + this.knockbackModifiers.horizontalPower(), + this.knockbackModifiers.verticalPower() + ); + } + + @Override + public SoundSettings soundSettings() { + asConfigured(this.soundSettings, "soundSettings"); + return SoundSettings.of( + PaperRegistries.fromNms(this.soundSettings.hitSound().unwrapKey().orElseThrow()), + PaperRegistries.fromNms(this.soundSettings.pushSound().unwrapKey().orElseThrow()), + this.soundSettings.pushSoundImpulseThreshold(), + this.soundSettings.pushSoundCooldown() + ); + } + + public static final class PaperBuilder extends PaperSulfurCubeArchetypeRegistryEntry implements Builder, PaperRegistryBuilder { + + public PaperBuilder(final Conversions conversions, final @Nullable SulfurCubeArchetype archetype) { + super(conversions, archetype); + } + + @Override + public Builder items(final RegistryKeySet items) { + this.items = PaperRegistrySets.convertToNms(Registries.ITEM, this.conversions.lookup(), asArgument(items, "items")); + return this; + } + + @Override + public Builder attributeModifiers(final Iterable entries) { + this.attributeModifiers = Lists.newArrayList(Iterables.transform(asArgument(entries, "entries"), entry -> { + return new SulfurCubeArchetype.AttributeEntry( + this.conversions.getReferenceHolder(PaperRegistries.toNms(entry.attribute())), + CraftAttributeInstance.convert(entry.modifier()) + ); + })); + return this; + } + + @Override + public Builder buoyant(final boolean buoyant) { + this.buoyant = buoyant; + return this; + } + + @Override + public Builder explosion(final @Nullable ExplosionSettings settings) { + this.explosion = settings == null ? null : new SulfurCubeArchetype.ExplosionData( + settings.power(), + settings.incendiary(), + settings.fuseTicks() + ); + return this; + } + + @Override + public Builder contactDamage(final @Nullable ContactDamage damage) { + this.contactDamage = damage == null ? null : new SulfurCubeArchetype.ContactDamage( + this.conversions.getReferenceHolder(PaperRegistries.toNms(damage.damageType())), + ConstantFloat.of(damage.amount()), + damage.attributeToSource() + ); + return this; + } + + @Override + public Builder knockbackModifiers(final KnockbackModifiers modifiers) { + this.knockbackModifiers = new SulfurCubeArchetype.KnockbackModifiers( + modifiers.horizontalPower(), + modifiers.verticalPower() + ); + return this; + } + + @Override + public Builder soundSettings(final SoundSettings settings) { + this.soundSettings = new SulfurCubeArchetype.SoundSettings( + this.conversions.getReferenceHolder(PaperRegistries.toNms(settings.hitSound())), + this.conversions.getReferenceHolder(PaperRegistries.toNms(settings.pushSound())), + settings.pushSoundImpulseThreshold(), + settings.pushSoundCooldown() + ); + return this; + } + + @Override + public SulfurCubeArchetype build() { + return new SulfurCubeArchetype( + asConfigured(this.items, "items"), + Collections.unmodifiableList(this.attributeModifiers), + this.buoyant, + Optional.ofNullable(this.explosion), + Optional.ofNullable(this.contactDamage), + asConfigured(this.knockbackModifiers, "knockbackModifiers"), + asConfigured(this.soundSettings, "soundSettings") + ); + } + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperWolfVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperWolfVariantRegistryEntry.java index 4c33b3ecd8a2..2f8fb1cd213a 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperWolfVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperWolfVariantRegistryEntry.java @@ -3,6 +3,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.util.MCUtil; import net.minecraft.core.ClientAsset; import net.minecraft.world.entity.animal.wolf.WolfVariant; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; @@ -22,13 +23,10 @@ public class PaperWolfVariantRegistryEntry implements WolfVariantRegistryEntry { protected ClientAsset.@Nullable ResourceTexture babyTameClientTextureAsset; protected SpawnPrioritySelectors spawnConditions; - protected final Conversions conversions; - public PaperWolfVariantRegistryEntry( - final Conversions conversions, + final Conversions ignoredConversions, final @Nullable WolfVariant internal ) { - this.conversions = conversions; if (internal == null) { this.spawnConditions = SpawnPrioritySelectors.EMPTY; return; @@ -45,32 +43,32 @@ public PaperWolfVariantRegistryEntry( @Override public ClientTextureAsset angryClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.angryClientTextureAsset, "angryClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.angryClientTextureAsset, "angryClientTextureAsset")); } @Override public ClientTextureAsset wildClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.wildClientTextureAsset, "wildClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.wildClientTextureAsset, "wildClientTextureAsset")); } @Override public ClientTextureAsset tameClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.tameClientTextureAsset, "tameClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.tameClientTextureAsset, "tameClientTextureAsset")); } @Override public ClientTextureAsset babyAngryClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.babyAngryClientTextureAsset, "babyAngryClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.babyAngryClientTextureAsset, "babyAngryClientTextureAsset")); } @Override public ClientTextureAsset babyWildClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.babyWildClientTextureAsset, "babyWildClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.babyWildClientTextureAsset, "babyWildClientTextureAsset")); } @Override public ClientTextureAsset babyTameClientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.babyTameClientTextureAsset, "babyTameClientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.babyTameClientTextureAsset, "babyTameClientTextureAsset")); } public static final class PaperBuilder extends PaperWolfVariantRegistryEntry implements Builder, PaperRegistryBuilder { @@ -81,37 +79,37 @@ public PaperBuilder(final Conversions conversions, final @Nullable WolfVariant i @Override public Builder angryClientTextureAsset(final ClientTextureAsset angryClientTextureAsset) { - this.angryClientTextureAsset = this.conversions.asVanilla(asArgument(angryClientTextureAsset, "angryClientTextureAsset")); + this.angryClientTextureAsset = MCUtil.toResourceTexture(asArgument(angryClientTextureAsset, "angryClientTextureAsset")); return this; } @Override public Builder wildClientTextureAsset(final ClientTextureAsset wildClientTextureAsset) { - this.wildClientTextureAsset = this.conversions.asVanilla(asArgument(wildClientTextureAsset, "wildClientTextureAsset")); + this.wildClientTextureAsset = MCUtil.toResourceTexture(asArgument(wildClientTextureAsset, "wildClientTextureAsset")); return this; } @Override public Builder tameClientTextureAsset(final ClientTextureAsset tameClientTextureAsset) { - this.tameClientTextureAsset = this.conversions.asVanilla(asArgument(tameClientTextureAsset, "tameClientTextureAsset")); + this.tameClientTextureAsset = MCUtil.toResourceTexture(asArgument(tameClientTextureAsset, "tameClientTextureAsset")); return this; } @Override public Builder babyAngryClientTextureAsset(final ClientTextureAsset babyAngryClientTextureAsset) { - this.babyAngryClientTextureAsset = this.conversions.asVanilla(asArgument(babyAngryClientTextureAsset, "babyAngryClientTextureAsset")); + this.babyAngryClientTextureAsset = MCUtil.toResourceTexture(asArgument(babyAngryClientTextureAsset, "babyAngryClientTextureAsset")); return this; } @Override public Builder babyWildClientTextureAsset(final ClientTextureAsset babyWildClientTextureAsset) { - this.babyWildClientTextureAsset = this.conversions.asVanilla(asArgument(babyWildClientTextureAsset, "babyWildClientTextureAsset")); + this.babyWildClientTextureAsset = MCUtil.toResourceTexture(asArgument(babyWildClientTextureAsset, "babyWildClientTextureAsset")); return this; } @Override public Builder babyTameClientTextureAsset(final ClientTextureAsset babyTameClientTextureAsset) { - this.babyTameClientTextureAsset = this.conversions.asVanilla(asArgument(babyTameClientTextureAsset, "babyTameClientTextureAsset")); + this.babyTameClientTextureAsset = MCUtil.toResourceTexture(asArgument(babyTameClientTextureAsset, "babyTameClientTextureAsset")); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java index c9938e7772e0..fe473bb8fcec 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java @@ -3,6 +3,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; +import io.papermc.paper.util.MCUtil; import net.minecraft.core.ClientAsset; import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant; import net.minecraft.world.entity.variant.ModelAndTexture; @@ -19,13 +20,10 @@ public class PaperZombieNautilusVariantRegistryEntry implements ZombieNautilusVa protected ClientAsset.@Nullable ResourceTexture clientTextureAsset; protected SpawnPrioritySelectors spawnConditions; - protected final Conversions conversions; - public PaperZombieNautilusVariantRegistryEntry( - final Conversions conversions, + final Conversions ignoredConversions, final @Nullable ZombieNautilusVariant internal ) { - this.conversions = conversions; if (internal == null) { this.spawnConditions = SpawnPrioritySelectors.EMPTY; return; @@ -38,14 +36,14 @@ public PaperZombieNautilusVariantRegistryEntry( @Override public ClientTextureAsset clientTextureAsset() { - return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + return MCUtil.toTextureAsset(asConfigured(this.clientTextureAsset, "clientTextureAsset")); } @Override - public ZombieNautilusVariantRegistryEntry.Model model() { + public Model model() { return switch (asConfigured(this.model, "model")) { - case NORMAL -> ZombieNautilusVariantRegistryEntry.Model.NORMAL; - case WARM -> ZombieNautilusVariantRegistryEntry.Model.WARM; + case NORMAL -> Model.NORMAL; + case WARM -> Model.WARM; }; } @@ -56,13 +54,13 @@ public PaperBuilder(final Conversions conversions, final @Nullable ZombieNautilu } @Override - public ZombieNautilusVariantRegistryEntry.Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { - this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + public Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { + this.clientTextureAsset = MCUtil.toResourceTexture(asArgument(clientTextureAsset, "clientTextureAsset")); return this; } @Override - public ZombieNautilusVariantRegistryEntry.Builder model(final ZombieNautilusVariantRegistryEntry.Model model) { + public Builder model(final Model model) { this.model = switch (asArgument(model, "model")) { case NORMAL -> ZombieNautilusVariant.ModelType.NORMAL; case WARM -> ZombieNautilusVariant.ModelType.WARM; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java b/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java index 8d2272967ab8..a183a58751d7 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/PaperDialogCodecs.java @@ -22,17 +22,17 @@ import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; -import net.minecraft.util.Util; import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.dialog.CommonButtonData; import net.minecraft.server.dialog.Dialog; import net.minecraft.server.dialog.action.ParsedTemplate; import net.minecraft.server.dialog.body.PlainMessage; import net.minecraft.server.dialog.input.TextInput; import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.Util; import net.minecraft.world.item.ItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/body/ItemDialogBodyImpl.java b/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/body/ItemDialogBodyImpl.java index c935e0619a3d..6ba651149865 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/body/ItemDialogBodyImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/dialog/body/ItemDialogBodyImpl.java @@ -51,7 +51,7 @@ public ItemDialogBody.Builder width(final @Range(from = 1, to = 256) int width) @Override public ItemDialogBody.Builder height(final @Range(from = 1, to = 256) int height) { - this.height = requireRange(height, "height", 1, 256); + this.height = requireRange(height, "height", 1, 256); return this; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/util/Conversions.java b/paper-server/src/main/java/io/papermc/paper/registry/data/util/Conversions.java index e4124cc4bc06..4625d82e6514 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/util/Conversions.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/util/Conversions.java @@ -3,17 +3,14 @@ import com.google.common.base.Preconditions; import com.mojang.serialization.Codec; import com.mojang.serialization.JavaOps; -import io.papermc.paper.adventure.PaperAdventure; import io.papermc.paper.adventure.WrapperAwareSerializer; import io.papermc.paper.registry.PaperRegistries; import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.PaperRegistryBuilderFactory; import io.papermc.paper.registry.RegistryKey; -import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.entry.RegistryEntryMeta; import java.util.function.Consumer; import net.kyori.adventure.text.Component; -import net.minecraft.core.ClientAsset; import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; import net.minecraft.core.Registry; @@ -38,13 +35,13 @@ public static Conversions global() { } private final RegistryOps.RegistryInfoLookup lookup; - private final WrapperAwareSerializer serializer; private final RegistryOps javaOps; + private final WrapperAwareSerializer serializer; public Conversions(final RegistryOps.RegistryInfoLookup lookup) { this.lookup = lookup; - this.serializer = new WrapperAwareSerializer(() -> RegistryOps.create(JavaOps.INSTANCE, lookup)); this.javaOps = RegistryOps.create(JavaOps.INSTANCE, lookup); + this.serializer = new WrapperAwareSerializer(() -> this.javaOps); } public OUT convert(final IN in, final Codec outCodec, final Codec inCodec) { @@ -73,20 +70,6 @@ public Component asAdventure(final net.minecraft.network.chat.@Nullable Componen return vanilla == null ? Component.empty() : this.serializer.deserialize(vanilla); } - public ClientTextureAsset asBukkit(final ClientAsset.@Nullable Texture clientTextureAsset) { - return clientTextureAsset == null ? null : ClientTextureAsset.clientTextureAsset( - PaperAdventure.asAdventure(clientTextureAsset.id()), - PaperAdventure.asAdventure(clientTextureAsset.texturePath()) - ); - } - - public ClientAsset.ResourceTexture asVanilla(final @Nullable ClientTextureAsset clientTextureAsset) { - return clientTextureAsset == null ? null : new ClientAsset.ResourceTexture( - PaperAdventure.asVanilla(clientTextureAsset.identifier()), - PaperAdventure.asVanilla(clientTextureAsset.texturePath()) - ); - } - private static > RegistryEntryMeta.Buildable getDirectHolderBuildableMeta(final RegistryKey registryKey) { final RegistryEntryMeta.Buildable buildableMeta = PaperRegistries.getBuildableMeta(registryKey); Preconditions.checkArgument(buildableMeta.registryTypeMapper().supportsDirectHolders(), "Registry type mapper must support direct holders"); diff --git a/paper-server/src/main/java/io/papermc/paper/registry/holder/InlinedRegistryHolderImpl.java b/paper-server/src/main/java/io/papermc/paper/registry/holder/InlinedRegistryHolderImpl.java index 4a3c017adebb..fbb61b2d9aa4 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/holder/InlinedRegistryHolderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/holder/InlinedRegistryHolderImpl.java @@ -1,8 +1,6 @@ package io.papermc.paper.registry.holder; import net.minecraft.core.Holder; -import org.jetbrains.annotations.ApiStatus; -@ApiStatus.Internal record InlinedRegistryHolderImpl(ENTRY entry, Holder.Direct holder) implements RegistryHolder.Inlined { } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/holder/ReferenceRegistryHolderImpl.java b/paper-server/src/main/java/io/papermc/paper/registry/holder/ReferenceRegistryHolderImpl.java index 976907d2726a..ee2c2d4d962a 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/holder/ReferenceRegistryHolderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/holder/ReferenceRegistryHolderImpl.java @@ -1,8 +1,6 @@ package io.papermc.paper.registry.holder; import io.papermc.paper.registry.TypedKey; -import org.jetbrains.annotations.ApiStatus; -@ApiStatus.Internal record ReferenceRegistryHolderImpl(TypedKey key) implements RegistryHolder.Reference { } diff --git a/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java b/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java index 229543e88182..292ea89a5a5b 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java @@ -3,15 +3,14 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import io.papermc.paper.adventure.PaperAdventure; import io.papermc.paper.plugin.bootstrap.BootstrapContext; import io.papermc.paper.plugin.lifecycle.event.registrar.PaperRegistrar; import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.tag.TagKey; +import io.papermc.paper.util.MCUtil; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -61,7 +60,7 @@ public Map, Collection>> getAllTags() { } private static List> convert(final List nmsEntries) { - return Collections.unmodifiableList(Lists.transform(nmsEntries, PaperPreFlattenTagRegistrar::convert)); + return MCUtil.transformUnmodifiable(nmsEntries, PaperPreFlattenTagRegistrar::convert); } private static io.papermc.paper.tag.TagEntry convert(final TagLoader.EntryWithSource nmsEntry) { diff --git a/paper-server/src/main/java/io/papermc/paper/util/CountingOps.java b/paper-server/src/main/java/io/papermc/paper/util/CountingOps.java index 2cb103bce7a3..1081e24e4c0a 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/CountingOps.java +++ b/paper-server/src/main/java/io/papermc/paper/util/CountingOps.java @@ -56,6 +56,11 @@ public Value createString(final String value) { return Value.PRIMITIVE; } + @Override + public Value createBoolean(final boolean value) { + return Value.PRIMITIVE; + } + @Override public DataResult getNumberValue(final Value input) { throw new UnsupportedOperationException(); @@ -66,6 +71,11 @@ public DataResult getStringValue(final Value input) { throw new UnsupportedOperationException(); } + @Override + public DataResult getBooleanValue(final Value input) { + throw new UnsupportedOperationException(); + } + @Override public DataResult mergeToList(final Value input, final Value value) { final Accumulator accumulator = new Accumulator(); diff --git a/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java b/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java index ae3e03fe01f0..f659aba1587d 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/paper-server/src/main/java/io/papermc/paper/util/MCUtil.java @@ -1,11 +1,17 @@ package io.papermc.paper.util; +import ca.spottedleaf.moonrise.common.PlatformHooks; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.google.common.util.concurrent.ThreadFactoryBuilder; +import io.papermc.paper.adventure.PaperAdventure; import io.papermc.paper.math.BlockPosition; import io.papermc.paper.math.FinePosition; import io.papermc.paper.math.Position; +import io.papermc.paper.registry.data.client.ClientTextureAsset; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -18,13 +24,20 @@ import java.util.function.Function; import java.util.function.Supplier; import net.minecraft.core.BlockPos; +import net.minecraft.core.ClientAsset; import net.minecraft.core.Vec3i; import net.minecraft.core.component.DataComponents; -import net.minecraft.resources.ResourceKey; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtAccounter; +import net.minecraft.nbt.NbtIo; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.NbtUtils; import net.minecraft.server.MinecraftServer; import net.minecraft.tags.BlockTags; +import net.minecraft.util.datafix.DataFixers; +import net.minecraft.util.datafix.fixes.References; +import net.minecraft.world.entity.Bucketable; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.animal.Bucketable; import net.minecraft.world.entity.animal.cow.AbstractCow; import net.minecraft.world.entity.animal.cow.MushroomCow; import net.minecraft.world.entity.player.Player; @@ -41,10 +54,12 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import org.bukkit.Location; -import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftLocation; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.Waitable; +import org.jspecify.annotations.Nullable; public final class MCUtil { public static final java.util.concurrent.Executor MAIN_EXECUTOR = (run) -> { @@ -254,4 +269,50 @@ public static boolean clientPredictsInteraction(final Player player, final Entit public static String getLevelName(Level level) { return level.dimension().identifier().toString(); } + + public static @Nullable ClientTextureAsset toTextureAsset(final ClientAsset.@Nullable Texture clientTextureAsset) { + return clientTextureAsset == null ? null : ClientTextureAsset.clientTextureAsset( + PaperAdventure.asAdventure(clientTextureAsset.id()), + PaperAdventure.asAdventure(clientTextureAsset.texturePath()) + ); + } + + public static ClientAsset.@Nullable ResourceTexture toResourceTexture(final @Nullable ClientTextureAsset clientTextureAsset) { + return clientTextureAsset == null ? null : new ClientAsset.ResourceTexture( + PaperAdventure.asVanilla(clientTextureAsset.identifier()), + PaperAdventure.asVanilla(clientTextureAsset.texturePath()) + ); + } + + public static org.bukkit.inventory.ItemStack deserializeItem(CompoundTag tag) { + final int dataVersion = NbtUtils.getDataVersion(tag, 0); + tag = PlatformHooks.get().convertNBT(References.ITEM_STACK, DataFixers.getDataFixer(), tag, dataVersion, CraftMagicNumbers.INSTANCE.getDataVersion()); + if (tag.getStringOr("id", "minecraft:air").equals("minecraft:air")) { + return CraftItemStack.asCraftMirror(ItemStack.EMPTY); + } + return CraftItemStack.asCraftMirror(ItemStack.CODEC.parse( + CraftRegistry.getMinecraftRegistry().createSerializationContext(NbtOps.INSTANCE), tag + ).getOrThrow()); + } + + public static byte[] serializeTagToBytes(final CompoundTag tag) { + NbtUtils.addCurrentDataVersion(tag); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + try { + NbtIo.writeCompressed(tag, outputStream); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + return outputStream.toByteArray(); + } + + public static CompoundTag deserializeTagFromBytes(final byte[] data) { + CompoundTag tag; + try { + tag = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtAccounter.unlimitedHeap()); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + return tag; + } } diff --git a/paper-server/src/main/java/io/papermc/paper/util/StackWalkerUtil.java b/paper-server/src/main/java/io/papermc/paper/util/StackWalkerUtil.java index 8bf0630c0e06..faae65bef7ae 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/StackWalkerUtil.java +++ b/paper-server/src/main/java/io/papermc/paper/util/StackWalkerUtil.java @@ -14,7 +14,7 @@ public static JavaPlugin getFirstPluginCaller() { Optional foundFrame = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE) .walk(stream -> stream .map((frame) -> { - ClassLoader classLoader = frame.getDeclaringClass().getClassLoader(); + ClassLoader classLoader = frame.getDeclaringClass().getClassLoader(); JavaPlugin plugin; if (classLoader instanceof ConfiguredPluginClassLoader configuredPluginClassLoader) { plugin = configuredPluginClassLoader.getPlugin(); diff --git a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/OversizedItemComponentSanitizer.java b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/OversizedItemComponentSanitizer.java index 02579074b70a..8a2c224d6b1d 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/OversizedItemComponentSanitizer.java +++ b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/OversizedItemComponentSanitizer.java @@ -40,7 +40,7 @@ public void encode(final RegistryFriendlyByteBuf buffer, final BundleContents va } // Disable further obfuscation to skip e.g. count. - try (final SafeAutoClosable ignored = ItemObfuscationSession.withContext(c -> c.level(ItemObfuscationSession.ObfuscationLevel.OVERSIZED))){ + try (final SafeAutoClosable ignored = ItemObfuscationSession.withContext(c -> c.level(ItemObfuscationSession.ObfuscationLevel.OVERSIZED))) { BundleContents.STREAM_CODEC.encode(buffer, sanitizeBundleContents(value)); } } diff --git a/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java b/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java index cd3e7cc8cf08..1bf392bacadd 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java +++ b/paper-server/src/main/java/io/papermc/paper/world/PaperWorldLoader.java @@ -8,7 +8,6 @@ import java.util.Locale; import java.util.UUID; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.Identifier; import net.minecraft.resources.ResourceKey; import net.minecraft.server.Main; import net.minecraft.server.MinecraftServer; @@ -22,7 +21,6 @@ import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.PrimaryLevelData; import net.minecraft.world.level.storage.SavedDataStorage; -import org.bukkit.NamespacedKey; import org.bukkit.World; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @@ -74,17 +72,9 @@ public record WorldLoadingInfoAndData(WorldLoadingInfo info, LoadedWorldData dat return new WorldLoadingInfoAndData(info, loadedWorldData); } - public static ResourceKey dimensionKey(final ResourceKey stemKey) { - return ResourceKey.create(Registries.DIMENSION, stemKey.identifier()); - } - - public static ResourceKey dimensionKey(final NamespacedKey key) { - return ResourceKey.create(Registries.DIMENSION, Identifier.fromNamespaceAndPath(key.namespace(), key.value())); - } - private WorldLoadingInfo getWorldInfo(final LevelStem stem) { final ResourceKey stemKey = this.server.registryAccess().lookupOrThrow(Registries.LEVEL_STEM).getResourceKey(stem).orElseThrow(); - final ResourceKey dimensionKey = dimensionKey(stemKey); + final ResourceKey dimensionKey = Registries.levelStemToLevel(stemKey); boolean enabled = true; final World.Environment environment; if (stemKey == LevelStem.NETHER) { diff --git a/paper-server/src/main/java/io/papermc/paper/world/saveddata/PaperLevelOverrides.java b/paper-server/src/main/java/io/papermc/paper/world/saveddata/PaperLevelOverrides.java index fb575b634de6..0aba139ace05 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/saveddata/PaperLevelOverrides.java +++ b/paper-server/src/main/java/io/papermc/paper/world/saveddata/PaperLevelOverrides.java @@ -77,6 +77,7 @@ public static PaperLevelOverrides createFromRawLevelData(final @Nullable Dynamic if (levelData == null) { return new PaperLevelOverrides(); } + return new PaperLevelOverrides( RespawnData.fromVanilla(levelData.get("spawn").read(LevelData.RespawnData.CODEC).result().orElse(LevelData.RespawnData.DEFAULT)), levelData.get("Time").asLong(0L), @@ -172,6 +173,13 @@ public boolean isAllowCommands() { return this.rootDataOrThrow().isAllowCommands(); } + @Override + public void setAllowCommands(final boolean allowCommands) { + if (this.isAllowCommands() != allowCommands) { + this.syncRootData(rootData -> rootData.setAllowCommands(allowCommands)); + } + } + @Override public boolean isInitialized() { return this.initialized; @@ -235,7 +243,7 @@ public RespawnData normalized() { public LevelData.RespawnData toVanilla(final ResourceKey dimension) { final RespawnData normalized = this.normalized(); - return LevelData.RespawnData.of(dimension, normalized.pos, normalized.yaw, normalized.pitch); + return LevelData.RespawnData.of(dimension, normalized.pos(), normalized.yaw(), normalized.pitch()); } public static RespawnData fromVanilla(final LevelData.RespawnData respawnData) { diff --git a/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java b/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java index 1e7ef9a34e3b..f1b9de16b801 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java +++ b/paper-server/src/main/java/io/papermc/paper/world/worldgen/OptionallyFlatBedrockConditionSource.java @@ -8,7 +8,6 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.Identifier; -import net.minecraft.util.KeyDispatchDataCodec; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.level.levelgen.PositionalRandomFactory; @@ -26,19 +25,19 @@ public record OptionallyFlatBedrockConditionSource(Identifier randomName, Vertic Registries.MATERIAL_CONDITION, Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "optionally_flat_bedrock_condition_source") ); - private static final KeyDispatchDataCodec CODEC = KeyDispatchDataCodec.of(RecordCodecBuilder.mapCodec(i -> i.group( + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group( Identifier.CODEC.fieldOf("random_name").forGetter(OptionallyFlatBedrockConditionSource::randomName), VerticalAnchor.CODEC.fieldOf("true_at_and_below").forGetter(OptionallyFlatBedrockConditionSource::trueAtAndBelow), VerticalAnchor.CODEC.fieldOf("false_at_and_above").forGetter(OptionallyFlatBedrockConditionSource::falseAtAndAbove), Codec.BOOL.fieldOf("is_roof").forGetter(OptionallyFlatBedrockConditionSource::isRoof) - ).apply(i, OptionallyFlatBedrockConditionSource::new))); + ).apply(i, OptionallyFlatBedrockConditionSource::new)); public static void bootstrap() { - Registry.register(BuiltInRegistries.MATERIAL_CONDITION, CODEC_RESOURCE_KEY, CODEC.codec()); + Registry.register(BuiltInRegistries.MATERIAL_CONDITION, CODEC_RESOURCE_KEY, CODEC); } @Override - public KeyDispatchDataCodec codec() { + public MapCodec codec() { return CODEC; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java index 578ad15a29b9..b568f90116dc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java @@ -5,7 +5,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Map; -import java.util.function.Supplier; +import net.minecraft.CrashReportDetail; import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -14,10 +14,10 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; -public class CraftCrashReport implements Supplier { +public class CraftCrashReport implements CrashReportDetail { @Override - public String get() { + public String call() { final io.papermc.paper.ServerBuildInfo build = io.papermc.paper.ServerBuildInfo.buildInfo(); StringWriter value = new StringWriter(); try { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index c994b2aafdb1..d91961f17a39 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -8,6 +8,8 @@ import net.minecraft.core.particles.ColorParticleOption; import net.minecraft.core.particles.DustColorTransitionOptions; import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.core.particles.GeyserBaseParticleOptions; +import net.minecraft.core.particles.GeyserParticleOptions; import net.minecraft.core.particles.ItemParticleOption; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.PowerParticleOption; @@ -214,6 +216,23 @@ public ParticleOptions createParticleParam(Particle.Spell data) { } }; + BiFunction, CraftParticle> geyser = (name, particle) -> new CraftParticle<>(name, particle, Particle.Geyser.class) { + @Override + public ParticleOptions createParticleParam(Particle.Geyser data) { + int waterBlocks = data.getWaterBlocks(); + return new GeyserParticleOptions((net.minecraft.core.particles.ParticleType) particle, waterBlocks); + } + }; + + BiFunction, CraftParticle> geyserBase = (name, particle) -> new CraftParticle<>(name, particle, Particle.GeyserBase.class) { + @Override + public ParticleOptions createParticleParam(Particle.GeyserBase data) { + int waterBlocks = data.getWaterBlocks(); + float burstImpulse = data.getBurstImpulse(); + return new GeyserBaseParticleOptions((net.minecraft.core.particles.ParticleType) particle, waterBlocks, burstImpulse); + } + }; + add("dust", dustOptionsFunction); add("item", itemStackFunction); add("block", blockDataFunction); @@ -232,6 +251,11 @@ public ParticleOptions createParticleParam(Particle.Spell data) { add("trail", trailFunction); add("effect", spellFunction); add("instant_effect", spellFunction); + add("geyser", geyser); + add("geyser_plume", geyser); + add("geyser", geyser); + add("geyser_base", geyserBase); + add("geyser_poof", geyserBase); } private static void add(String name, BiFunction, CraftParticle> function) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index ab2224ecebc5..622d023bf1e0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1,7 +1,6 @@ package org.bukkit.craftbukkit; import ca.spottedleaf.moonrise.common.time.TickData; -import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -10,12 +9,13 @@ import com.google.common.collect.MapMaker; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.serialization.JsonOps; import io.papermc.paper.configuration.GlobalConfiguration; import io.papermc.paper.configuration.PaperServerConfiguration; import io.papermc.paper.configuration.ServerConfiguration; +import io.papermc.paper.util.MCUtil; import io.papermc.paper.world.PaperWorldLoader; import io.papermc.paper.world.migration.WorldFolderMigration; -import io.papermc.paper.world.saveddata.PaperLevelOverrides; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; @@ -105,6 +105,7 @@ import net.minecraft.world.level.levelgen.WorldDimensions; import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldOptions; +import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.saveddata.maps.MapId; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; @@ -397,12 +398,7 @@ public final boolean isGlobalTickThread() { public CraftServer(DedicatedServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; - this.playerView = Collections.unmodifiableList(Lists.transform(playerList.players, new Function() { - @Override - public CraftPlayer apply(ServerPlayer player) { - return player.getBukkitEntity(); - } - })); + this.playerView = MCUtil.transformUnmodifiable(playerList.players, ServerPlayer::getBukkitEntity); this.serverVersion = io.papermc.paper.ServerBuildInfo.buildInfo().asString(io.papermc.paper.ServerBuildInfo.StringRepresentation.VERSION_SIMPLE); // Paper - improve version this.structureManager = new CraftStructureManager(console.getStructureManager(), console.registryAccess()); this.serverTickManager = new CraftServerTickManager(console.tickRateManager()); @@ -692,7 +688,6 @@ public Player getPlayer(final String name) { } @Override - @Deprecated public Player getPlayerExact(String name) { Preconditions.checkArgument(name != null, "name cannot be null"); @@ -1202,18 +1197,17 @@ public World createWorld(WorldCreator creator) { default -> throw new IllegalArgumentException("Illegal dimension (" + creator.environment() + ")"); }; - final ResourceKey dimensionKey = PaperWorldLoader.dimensionKey(creator.key()); - WorldLoader.DataLoadContext context = this.console.worldLoaderContext; - RegistryAccess.Frozen registryAccess = context.datapackDimensions(); - net.minecraft.core.Registry contextLevelStemRegistry = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); - final LevelStem configuredStem = this.console.registryAccess().lookupOrThrow(Registries.LEVEL_STEM).getValue(actualDimension); + RegistryAccess registryAccess = this.console.registryAccess(); + final ResourceKey dimensionKey = CraftNamespacedKey.toResourceKey(Registries.DIMENSION, creator.key()); + net.minecraft.core.Registry levelStemRegistry = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); + final LevelStem configuredStem = levelStemRegistry.getValue(actualDimension); if (configuredStem == null) { throw new IllegalStateException("Missing configured level stem " + actualDimension); } try { WorldFolderMigration.migrateApiWorld( this.console.storageSource, - this.console.registryAccess(), + registryAccess, name, actualDimension, dimensionKey @@ -1227,22 +1221,31 @@ public World createWorld(WorldCreator creator) { name ); final PrimaryLevelData primaryLevelData = (PrimaryLevelData) this.console.getWorldData(); - WorldGenSettings worldGenSettings = LevelStorageSource.readExistingSavedData(this.console.storageSource, dimensionKey, this.console.registryAccess(), WorldGenSettings.TYPE) + WorldGenSettings worldGenSettings = LevelStorageSource.readExistingSavedData(this.console.storageSource, dimensionKey, registryAccess, WorldGenSettings.TYPE) .result() .orElse(null); + RegistryAccess contextRegistryAccess = registryAccess; if (worldGenSettings == null) { WorldOptions worldOptions = new WorldOptions(creator.seed(), creator.generateStructures(), creator.bonusChest()); - DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(GsonHelper.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT)); - WorldDimensions worldDimensions = properties.create(context.datapackWorldgen()); + String flatGenSettings = creator.generatorSettings(); + if (flatGenSettings.isEmpty()) { + flatGenSettings = FlatLevelGeneratorSettings.CODEC.encodeStart(registryAccess.createSerializationContext(JsonOps.INSTANCE), FlatLevelGeneratorSettings.getDefault( + registryAccess.lookupOrThrow(Registries.BIOME), + registryAccess.lookupOrThrow(Registries.STRUCTURE_SET), + registryAccess.lookupOrThrow(Registries.PLACED_FEATURE) + )).getOrThrow().toString(); + } + DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(GsonHelper.parse(flatGenSettings), creator.type().name().toLowerCase(Locale.ROOT)); + WorldDimensions worldDimensions = properties.create(registryAccess); - WorldDimensions.Complete complete = worldDimensions.bake(contextLevelStemRegistry); + WorldDimensions.Complete complete = worldDimensions.bake(levelStemRegistry); if (complete.dimensions().getValue(actualDimension) == null) { throw new IllegalStateException("Missing generated level stem " + actualDimension + " for world " + name); } worldGenSettings = new WorldGenSettings(worldOptions, worldDimensions); - registryAccess = complete.dimensionsRegistryAccess(); + contextRegistryAccess = complete.dimensionsRegistryAccess(); loadedWorldData.levelOverrides().setHardcore(creator.hardcore()); loadedWorldData = new PaperWorldLoader.LoadedWorldData( loadedWorldData.bukkitName(), @@ -1253,27 +1256,27 @@ public World createWorld(WorldCreator creator) { } final WorldGenSettings genSettingsFinal = worldGenSettings; - contextLevelStemRegistry = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); + levelStemRegistry = contextRegistryAccess.lookupOrThrow(Registries.LEVEL_STEM); if (this.console.options.has("forceUpgrade")) { - net.minecraft.server.Main.forceUpgrade(this.console.storageSource, DataFixers.getDataFixer(), this.console.options.has("eraseCache"), () -> true, registryAccess, this.console.options.has("recreateRegionFiles")); + net.minecraft.server.Main.forceUpgrade(this.console.storageSource, DataFixers.getDataFixer(), this.console.options.has("eraseCache"), () -> true, contextRegistryAccess, this.console.options.has("recreateRegionFiles")); } long biomeZoomSeed = BiomeManager.obfuscateSeed(genSettingsFinal.options().seed()); LevelStem customStem = genSettingsFinal.dimensions().get(actualDimension).orElse(null); if (customStem == null) { - customStem = contextLevelStemRegistry.getValue(actualDimension); + customStem = levelStemRegistry.getValue(actualDimension); } if (customStem == null) { throw new IllegalStateException("Missing level stem for world " + name + " using key " + actualDimension); } - WorldInfo worldInfo = new CraftWorldInfo(loadedWorldData.bukkitName(), CraftNamespacedKey.fromMinecraft(dimensionKey.identifier()), genSettingsFinal.options().seed(), primaryLevelData.enabledFeatures(), creator.environment(), customStem.type().value(), customStem.generator(), this.getHandle().getServer().registryAccess(), loadedWorldData.uuid()); + WorldInfo worldInfo = new CraftWorldInfo(loadedWorldData.bukkitName(), CraftNamespacedKey.fromMinecraft(dimensionKey.identifier()), genSettingsFinal.options().seed(), primaryLevelData.enabledFeatures(), creator.environment(), customStem.type().value(), customStem.generator(), registryAccess, loadedWorldData.uuid()); if (biomeProvider == null && chunkGenerator != null) { biomeProvider = chunkGenerator.getDefaultBiomeProvider(worldInfo); } - final SavedDataStorage savedDataStorage = new SavedDataStorage(this.console.storageSource.getDimensionPath(dimensionKey).resolve(LevelResource.DATA.id()), this.console.getFixerUpper(), this.console.registryAccess()); + final SavedDataStorage savedDataStorage = new SavedDataStorage(this.console.storageSource.getDimensionPath(dimensionKey).resolve(LevelResource.DATA.id()), this.console.getFixerUpper(), registryAccess); savedDataStorage.set(WorldGenSettings.TYPE, new WorldGenSettings(genSettingsFinal.options(), genSettingsFinal.dimensions())); List list = ImmutableList.of( new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(savedDataStorage) @@ -1928,7 +1931,6 @@ public UUID getPlayerUniqueId(String name) { } @Override - @Deprecated public OfflinePlayer getOfflinePlayer(String name) { Preconditions.checkArgument(name != null, "name cannot be null"); Preconditions.checkArgument(!name.isBlank(), "name cannot be empty"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index f77cb6d85c89..6fe05d7ab465 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -63,10 +63,9 @@ import net.minecraft.world.attribute.BedRule; import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.EntitySpawnReason; -import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.LightningBolt; import net.minecraft.world.entity.ai.village.poi.PoiManager; -import net.minecraft.world.entity.ai.village.poi.PoiRecord; import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.raid.Raids; @@ -658,7 +657,7 @@ public org.bukkit.entity.Item dropItem(Location location, ItemStack item, Consum ItemEntity entity = new ItemEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftItemStack.asNMSCopy(item)); org.bukkit.entity.Item itemEntity = (org.bukkit.entity.Item) entity.getBukkitEntity(); - entity.pickupDelay = 10; + entity.setDefaultPickUpDelay(); if (function != null) { function.accept(itemEntity); } @@ -672,7 +671,7 @@ public org.bukkit.entity.Item dropItemNaturally(Location location, ItemStack ite Preconditions.checkArgument(item != null, "ItemStack cannot be null"); double xs = Mth.nextDouble(this.world.getRandom(), -0.25, 0.25); - double ys = Mth.nextDouble(this.world.getRandom(), -0.25, 0.25) - ((double) EntityType.ITEM.getHeight() / 2.0); + double ys = Mth.nextDouble(this.world.getRandom(), -0.25, 0.25) - ((double) EntityTypes.ITEM.getHeight() / 2.0); double zs = Mth.nextDouble(this.world.getRandom(), -0.25, 0.25); location = location.clone().add(xs, ys, zs); return this.dropItem(location, item, function); @@ -686,14 +685,14 @@ public T spawnArrow(Location location, Vector directio net.minecraft.world.entity.projectile.arrow.AbstractArrow arrow; if (TippedArrow.class.isAssignableFrom(clazz)) { - arrow = EntityType.ARROW.create(this.world, EntitySpawnReason.COMMAND); + arrow = EntityTypes.ARROW.create(this.world, EntitySpawnReason.COMMAND); ((Arrow) arrow.getBukkitEntity()).setBasePotionType(PotionType.WATER); } else if (SpectralArrow.class.isAssignableFrom(clazz)) { - arrow = EntityType.SPECTRAL_ARROW.create(this.world, EntitySpawnReason.COMMAND); + arrow = EntityTypes.SPECTRAL_ARROW.create(this.world, EntitySpawnReason.COMMAND); } else if (Trident.class.isAssignableFrom(clazz)) { - arrow = EntityType.TRIDENT.create(this.world, EntitySpawnReason.COMMAND); + arrow = EntityTypes.TRIDENT.create(this.world, EntitySpawnReason.COMMAND); } else { - arrow = EntityType.ARROW.create(this.world, EntitySpawnReason.COMMAND); + arrow = EntityTypes.ARROW.create(this.world, EntitySpawnReason.COMMAND); } arrow.snapTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); @@ -715,7 +714,7 @@ public LightningStrike strikeLightningEffect(Location loc) { private LightningStrike strikeLightning0(Location loc, boolean isVisual) { Preconditions.checkArgument(loc != null, "Location cannot be null"); - LightningBolt lightning = EntityType.LIGHTNING_BOLT.create(this.world, EntitySpawnReason.COMMAND); + LightningBolt lightning = EntityTypes.LIGHTNING_BOLT.create(this.world, EntitySpawnReason.COMMAND); lightning.snapTo(loc.getX(), loc.getY(), loc.getZ()); lightning.isEffect = isVisual; // Paper - Properly handle lightning effects api this.world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM); @@ -748,24 +747,28 @@ public boolean generateTree(Location loc, TreeType type) { public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { this.world.captureTreeGeneration = true; this.world.captureBlockStates = true; - boolean grownTree = this.generateTree(loc, type); - this.world.captureBlockStates = false; - this.world.captureTreeGeneration = false; + List capturedBlockStates; + boolean grownTree; + try { + grownTree = this.generateTree(loc, type); + } finally { + this.world.captureTreeGeneration = false; + this.world.captureBlockStates = false; + + capturedBlockStates = new ArrayList<>(this.world.capturedBlockStates.values()); + this.world.capturedBlockStates.clear(); + } if (grownTree) { // Copy block data to delegate - for (BlockState blockstate : this.world.capturedBlockStates.values()) { - BlockPos position = ((CraftBlockState) blockstate).getPosition(); + for (CraftBlockState snapshot : capturedBlockStates) { + BlockPos position = snapshot.getPosition(); net.minecraft.world.level.block.state.BlockState oldBlock = this.world.getBlockState(position); - int flags = ((CraftBlockState) blockstate).getFlags(); - delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData()); + int flags = snapshot.getFlags(); + delegate.setBlockData(snapshot.getX(), snapshot.getY(), snapshot.getZ(), snapshot.getBlockData()); net.minecraft.world.level.block.state.BlockState newBlock = this.world.getBlockState(position); this.world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flags, net.minecraft.world.level.block.Block.UPDATE_LIMIT); } - this.world.capturedBlockStates.clear(); - return true; - } else { - this.world.capturedBlockStates.clear(); - return false; } + return grownTree; } @Override @@ -1857,7 +1860,7 @@ public boolean isFixedTime() { @Override public Collection getInfiniburn() { - return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(net.minecraft.core.registries.BuiltInRegistries.BLOCK.getTagOrEmpty(this.getHandle().dimensionType().infiniburn()).iterator(), blockHolder -> CraftBlockType.minecraftToBukkit(blockHolder.value()))); + return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(this.getHandle().dimensionType().infiniburn().iterator(), blockHolder -> CraftBlockType.minecraftToBukkit(blockHolder.value()))); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java index efbc098faa4c..1dcfc5d715bb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java @@ -5,7 +5,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.entity.BeehiveBlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.BlockEntityTypes; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -53,7 +53,7 @@ private void addBees() { RandomSource random = level.getRandom(); // copied from BeehiveDecorator - level.getBlockEntity(pos, BlockEntityType.BEEHIVE).ifPresent(beehive -> { + level.getBlockEntity(pos, BlockEntityTypes.BEEHIVE).ifPresent(beehive -> { int numBees = 2 + random.nextInt(2); for (int count = 0; count < numBees; count++) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index 90c8deade7dc..daf00bcb98b4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -2,8 +2,8 @@ import java.util.ArrayList; import java.util.Collection; -import net.minecraft.advancements.criterion.DataComponentMatchers; -import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.predicates.DataComponentMatchers; +import net.minecraft.advancements.predicates.ItemPredicate; import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponents; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java deleted file mode 100644 index 473dfc398782..000000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.bukkit.craftbukkit.block; - -import net.minecraft.world.level.block.entity.BedBlockEntity; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Bed; - -public class CraftBed extends CraftBlockEntityState implements Bed { - - public CraftBed(World world, BedBlockEntity blockEntity) { - super(world, blockEntity); - } - - protected CraftBed(CraftBed state, Location location) { - super(state, location); - } - - @Override - public DyeColor getColor() { - return switch (this.getType()) { - case BLACK_BED -> DyeColor.BLACK; - case BLUE_BED -> DyeColor.BLUE; - case BROWN_BED -> DyeColor.BROWN; - case CYAN_BED -> DyeColor.CYAN; - case GRAY_BED -> DyeColor.GRAY; - case GREEN_BED -> DyeColor.GREEN; - case LIGHT_BLUE_BED -> DyeColor.LIGHT_BLUE; - case LIGHT_GRAY_BED -> DyeColor.LIGHT_GRAY; - case LIME_BED -> DyeColor.LIME; - case MAGENTA_BED -> DyeColor.MAGENTA; - case ORANGE_BED -> DyeColor.ORANGE; - case PINK_BED -> DyeColor.PINK; - case PURPLE_BED -> DyeColor.PURPLE; - case RED_BED -> DyeColor.RED; - case WHITE_BED -> DyeColor.WHITE; - case YELLOW_BED -> DyeColor.YELLOW; - default -> throw new IllegalArgumentException("Unknown DyeColor for " + this.getType()); - }; - } - - @Override - public void setColor(DyeColor color) { - throw new UnsupportedOperationException("Must set block type to appropriate bed colour"); - } - - @Override - public CraftBed copy() { - return new CraftBed(this, null); - } - - @Override - public CraftBed copy(Location location) { - return new CraftBed(this, location); - } -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 5d6116c55072..51b9dbde5688 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -526,31 +526,38 @@ public boolean applyBoneMeal(BlockFace face) { UseOnContext context = new UseOnContext(world, null, InteractionHand.MAIN_HAND, Items.BONE_MEAL.getDefaultInstance(), new BlockHitResult(Vec3.ZERO, direction, this.getPosition(), false)); // SPIGOT-6895: Call StructureGrowEvent and BlockFertilizeEvent + List capturedBlockStates; world.captureTreeGeneration = true; - InteractionResult result = BoneMealItem.applyBonemeal(context); - world.captureTreeGeneration = false; + TreeType treeType; + InteractionResult result; + try { + result = BoneMealItem.applyBonemeal(context); + } finally { + world.captureTreeGeneration = false; + + capturedBlockStates = new ArrayList<>(world.capturedBlockStates.values()); + world.capturedBlockStates.clear(); - if (!world.capturedBlockStates.isEmpty()) { - TreeType treeType = SaplingBlock.treeType; + treeType = SaplingBlock.treeType; SaplingBlock.treeType = null; - List states = new ArrayList<>(world.capturedBlockStates.values()); - world.capturedBlockStates.clear(); + } + + if (!capturedBlockStates.isEmpty()) { StructureGrowEvent structureEvent = null; if (treeType != null) { - structureEvent = new StructureGrowEvent(this.getLocation(), treeType, true, null, states); + structureEvent = new StructureGrowEvent(this.getLocation(), treeType, true, null, (List) (List) capturedBlockStates); Bukkit.getPluginManager().callEvent(structureEvent); } - event = new BlockFertilizeEvent(CraftBlock.at(world, this.getPosition()), null, states); + event = new BlockFertilizeEvent(CraftBlock.at(world, this.getPosition()), null, (List) (List) capturedBlockStates); event.setCancelled(structureEvent != null && structureEvent.isCancelled()); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - for (org.bukkit.block.BlockState state : states) { - CraftBlockState craftBlockState = (CraftBlockState) state; - craftBlockState.place(craftBlockState.getFlags()); - world.checkCapturedTreeStateForObserverNotify(this.position, craftBlockState); + for (CraftBlockState snapshot : capturedBlockStates) { + snapshot.place(snapshot.getFlags()); + world.checkCapturedTreeStateForObserverNotify(this.position, snapshot); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index b8a3660a13b9..8380df946b0e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -252,13 +252,15 @@ public boolean place(@net.minecraft.world.level.block.Block.UpdateFlags int flag } // used to revert a block placement due to an event being cancelled for example - public boolean revertPlace() { + public boolean revertPlace(boolean ignorePoi) { + int extraFlags = ignorePoi ? net.minecraft.world.level.block.Block.UPDATE_SKIP_POI : 0; return this.place( net.minecraft.world.level.block.Block.UPDATE_CLIENTS | net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE | net.minecraft.world.level.block.Block.UPDATE_SUPPRESS_DROPS | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE | - net.minecraft.world.level.block.Block.UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS + net.minecraft.world.level.block.Block.UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS | + extraFlags ); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java index e3fbe9d9a4fd..6dcfe2cea0ac 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java @@ -12,6 +12,7 @@ import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.BlockEntityTypes; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; @@ -85,55 +86,55 @@ private static void register(BlockEntityType type, BlockStateFactory facto static { // Start generate - CraftBlockEntityStates - register(BlockEntityType.BANNER, CraftBanner.class, CraftBanner::new); - register(BlockEntityType.BARREL, CraftBarrel.class, CraftBarrel::new); - register(BlockEntityType.BEACON, CraftBeacon.class, CraftBeacon::new); - register(BlockEntityType.BED, CraftBed.class, CraftBed::new); - register(BlockEntityType.BEEHIVE, CraftBeehive.class, CraftBeehive::new); - register(BlockEntityType.BELL, CraftBell.class, CraftBell::new); - register(BlockEntityType.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new); - register(BlockEntityType.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new); - register(BlockEntityType.BRUSHABLE_BLOCK, CraftBrushableBlock.class, CraftBrushableBlock::new); - register(BlockEntityType.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new); - register(BlockEntityType.CAMPFIRE, CraftCampfire.class, CraftCampfire::new); - register(BlockEntityType.CHEST, CraftChest.class, CraftChest::new); - register(BlockEntityType.CHISELED_BOOKSHELF, CraftChiseledBookshelf.class, CraftChiseledBookshelf::new); - register(BlockEntityType.COMMAND_BLOCK, CraftCommandBlock.class, CraftCommandBlock::new); - register(BlockEntityType.COMPARATOR, CraftComparator.class, CraftComparator::new); - register(BlockEntityType.CONDUIT, CraftConduit.class, CraftConduit::new); - register(BlockEntityType.COPPER_GOLEM_STATUE, CraftCopperGolemStatue.class, CraftCopperGolemStatue::new); - register(BlockEntityType.CRAFTER, CraftCrafter.class, CraftCrafter::new); - register(BlockEntityType.CREAKING_HEART, CraftCreakingHeart.class, CraftCreakingHeart::new); - register(BlockEntityType.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new); - register(BlockEntityType.DECORATED_POT, CraftDecoratedPot.class, CraftDecoratedPot::new); - register(BlockEntityType.DISPENSER, CraftDispenser.class, CraftDispenser::new); - register(BlockEntityType.DROPPER, CraftDropper.class, CraftDropper::new); - register(BlockEntityType.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new); - register(BlockEntityType.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new); - register(BlockEntityType.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new); - register(BlockEntityType.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new); - register(BlockEntityType.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new); - register(BlockEntityType.HANGING_SIGN, CraftHangingSign.class, CraftHangingSign::new); - register(BlockEntityType.HOPPER, CraftHopper.class, CraftHopper::new); - register(BlockEntityType.JIGSAW, CraftJigsaw.class, CraftJigsaw::new); - register(BlockEntityType.JUKEBOX, CraftJukebox.class, CraftJukebox::new); - register(BlockEntityType.LECTERN, CraftLectern.class, CraftLectern::new); - register(BlockEntityType.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new); - register(BlockEntityType.PISTON, CraftMovingPiston.class, CraftMovingPiston::new); - register(BlockEntityType.SCULK_CATALYST, CraftSculkCatalyst.class, CraftSculkCatalyst::new); - register(BlockEntityType.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new); - register(BlockEntityType.SCULK_SHRIEKER, CraftSculkShrieker.class, CraftSculkShrieker::new); - register(BlockEntityType.SHELF, CraftShelf.class, CraftShelf::new); - register(BlockEntityType.SHULKER_BOX, CraftShulkerBox.class, CraftShulkerBox::new); - register(BlockEntityType.SIGN, CraftSign.class, CraftSign::new); - register(BlockEntityType.SKULL, CraftSkull.class, CraftSkull::new); - register(BlockEntityType.SMOKER, CraftSmoker.class, CraftSmoker::new); - register(BlockEntityType.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new); - register(BlockEntityType.TEST_BLOCK, CraftTestBlock.class, CraftTestBlock::new); - register(BlockEntityType.TEST_INSTANCE_BLOCK, CraftTestInstanceBlock.class, CraftTestInstanceBlock::new); - register(BlockEntityType.TRAPPED_CHEST, CraftChest.class, CraftChest::new); - register(BlockEntityType.TRIAL_SPAWNER, CraftTrialSpawner.class, CraftTrialSpawner::new); - register(BlockEntityType.VAULT, CraftVault.class, CraftVault::new); + register(BlockEntityTypes.BANNER, CraftBanner.class, CraftBanner::new); + register(BlockEntityTypes.BARREL, CraftBarrel.class, CraftBarrel::new); + register(BlockEntityTypes.BEACON, CraftBeacon.class, CraftBeacon::new); + register(BlockEntityTypes.BEEHIVE, CraftBeehive.class, CraftBeehive::new); + register(BlockEntityTypes.BELL, CraftBell.class, CraftBell::new); + register(BlockEntityTypes.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new); + register(BlockEntityTypes.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new); + register(BlockEntityTypes.BRUSHABLE_BLOCK, CraftBrushableBlock.class, CraftBrushableBlock::new); + register(BlockEntityTypes.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new); + register(BlockEntityTypes.CAMPFIRE, CraftCampfire.class, CraftCampfire::new); + register(BlockEntityTypes.CHEST, CraftChest.class, CraftChest::new); + register(BlockEntityTypes.CHISELED_BOOKSHELF, CraftChiseledBookshelf.class, CraftChiseledBookshelf::new); + register(BlockEntityTypes.COMMAND_BLOCK, CraftCommandBlock.class, CraftCommandBlock::new); + register(BlockEntityTypes.COMPARATOR, CraftComparator.class, CraftComparator::new); + register(BlockEntityTypes.CONDUIT, CraftConduit.class, CraftConduit::new); + register(BlockEntityTypes.COPPER_GOLEM_STATUE, CraftCopperGolemStatue.class, CraftCopperGolemStatue::new); + register(BlockEntityTypes.CRAFTER, CraftCrafter.class, CraftCrafter::new); + register(BlockEntityTypes.CREAKING_HEART, CraftCreakingHeart.class, CraftCreakingHeart::new); + register(BlockEntityTypes.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new); + register(BlockEntityTypes.DECORATED_POT, CraftDecoratedPot.class, CraftDecoratedPot::new); + register(BlockEntityTypes.DISPENSER, CraftDispenser.class, CraftDispenser::new); + register(BlockEntityTypes.DROPPER, CraftDropper.class, CraftDropper::new); + register(BlockEntityTypes.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new); + register(BlockEntityTypes.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new); + register(BlockEntityTypes.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new); + register(BlockEntityTypes.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new); + register(BlockEntityTypes.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new); + register(BlockEntityTypes.HANGING_SIGN, CraftHangingSign.class, CraftHangingSign::new); + register(BlockEntityTypes.HOPPER, CraftHopper.class, CraftHopper::new); + register(BlockEntityTypes.JIGSAW, CraftJigsaw.class, CraftJigsaw::new); + register(BlockEntityTypes.JUKEBOX, CraftJukebox.class, CraftJukebox::new); + register(BlockEntityTypes.LECTERN, CraftLectern.class, CraftLectern::new); + register(BlockEntityTypes.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new); + register(BlockEntityTypes.PISTON, CraftMovingPiston.class, CraftMovingPiston::new); + register(BlockEntityTypes.POTENT_SULFUR, CraftPotentSulfur.class, CraftPotentSulfur::new); + register(BlockEntityTypes.SCULK_CATALYST, CraftSculkCatalyst.class, CraftSculkCatalyst::new); + register(BlockEntityTypes.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new); + register(BlockEntityTypes.SCULK_SHRIEKER, CraftSculkShrieker.class, CraftSculkShrieker::new); + register(BlockEntityTypes.SHELF, CraftShelf.class, CraftShelf::new); + register(BlockEntityTypes.SHULKER_BOX, CraftShulkerBox.class, CraftShulkerBox::new); + register(BlockEntityTypes.SIGN, CraftSign.class, CraftSign::new); + register(BlockEntityTypes.SKULL, CraftSkull.class, CraftSkull::new); + register(BlockEntityTypes.SMOKER, CraftSmoker.class, CraftSmoker::new); + register(BlockEntityTypes.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new); + register(BlockEntityTypes.TEST_BLOCK, CraftTestBlock.class, CraftTestBlock::new); + register(BlockEntityTypes.TEST_INSTANCE_BLOCK, CraftTestInstanceBlock.class, CraftTestInstanceBlock::new); + register(BlockEntityTypes.TRAPPED_CHEST, CraftChest.class, CraftChest::new); + register(BlockEntityTypes.TRIAL_SPAWNER, CraftTrialSpawner.class, CraftTrialSpawner::new); + register(BlockEntityTypes.VAULT, CraftVault.class, CraftVault::new); // End generate - CraftBlockEntityStates } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index ad3da82fa35e..c6ef79a3f0fd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.block; -import net.minecraft.advancements.criterion.DataComponentMatchers; -import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.predicates.DataComponentMatchers; +import net.minecraft.advancements.predicates.ItemPredicate; import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponents; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftPotentSulfur.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftPotentSulfur.java new file mode 100644 index 000000000000..d27f4bb9f793 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftPotentSulfur.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.world.level.block.entity.PotentSulfurBlockEntity; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.PotentSulfur; + +public class CraftPotentSulfur extends CraftBlockEntityState implements PotentSulfur { + + public CraftPotentSulfur(World world, PotentSulfurBlockEntity blockEntity) { + super(world, blockEntity); + } + + protected CraftPotentSulfur(CraftPotentSulfur state, Location location) { + super(state, location); + } + + @Override + public CraftPotentSulfur copy() { + return new CraftPotentSulfur(this, null); + } + + @Override + public CraftPotentSulfur copy(Location location) { + return new CraftPotentSulfur(this, location); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 944acb68a5e5..f4e3f9b27ede 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -356,6 +356,7 @@ public int hashCode() { register(net.minecraft.world.level.block.PlayerWallHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPlayerWallHead::new); register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new); register(net.minecraft.world.level.block.PotatoBlock.class, org.bukkit.craftbukkit.block.impl.CraftPotato::new); + register(net.minecraft.world.level.block.PotentSulfurBlock.class, org.bukkit.craftbukkit.block.impl.CraftPotentSulfur::new); register(net.minecraft.world.level.block.PoweredRailBlock.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail::new); register(net.minecraft.world.level.block.PressurePlateBlock.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlate::new); register(net.minecraft.world.level.block.RailBlock.class, org.bukkit.craftbukkit.block.impl.CraftRail::new); @@ -390,6 +391,7 @@ public int hashCode() { register(net.minecraft.world.level.block.StonecutterBlock.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new); register(net.minecraft.world.level.block.StructureBlock.class, org.bukkit.craftbukkit.block.impl.CraftStructureBlock::new); register(net.minecraft.world.level.block.SugarCaneBlock.class, org.bukkit.craftbukkit.block.impl.CraftSugarCane::new); + register(net.minecraft.world.level.block.SulfurSpikeBlock.class, org.bukkit.craftbukkit.block.impl.CraftSulfurSpike::new); register(net.minecraft.world.level.block.SweetBerryBushBlock.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new); register(net.minecraft.world.level.block.TallFlowerBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallFlower::new); register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCubeMob.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCubeMob.java new file mode 100644 index 000000000000..cdc00e62610b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCubeMob.java @@ -0,0 +1,35 @@ +package org.bukkit.craftbukkit.entity; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.AbstractCubeMob; + +public abstract class CraftAbstractCubeMob extends CraftMob implements AbstractCubeMob { + public CraftAbstractCubeMob(final CraftServer server, final net.minecraft.world.entity.monster.cubemob.AbstractCubeMob entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.monster.cubemob.AbstractCubeMob getHandle() { + return (net.minecraft.world.entity.monster.cubemob.AbstractCubeMob) this.entity; + } + + @Override + public int getSize() { + return this.getHandle().getSize(); + } + + @Override + public void setSize(int size) { + this.getHandle().setSize(size, this.getHandle().isAlive()); + } + + @Override + public boolean canWander() { + return this.getHandle().canWander(); + } + + @Override + public void setWander(boolean canWander) { + this.getHandle().setWander(canWander); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index e4a0df348522..e445d377fa34 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.TreeSpecies; import org.bukkit.craftbukkit.CraftServer; @@ -103,39 +104,39 @@ public Status getStatus() { } public static Boat.Type boatTypeFromNms(EntityType boatType) { - if (boatType == EntityType.OAK_BOAT || boatType == EntityType.OAK_CHEST_BOAT) { + if (boatType == EntityTypes.OAK_BOAT || boatType == EntityTypes.OAK_CHEST_BOAT) { return Type.OAK; } - if (boatType == EntityType.BIRCH_BOAT || boatType == EntityType.BIRCH_CHEST_BOAT) { + if (boatType == EntityTypes.BIRCH_BOAT || boatType == EntityTypes.BIRCH_CHEST_BOAT) { return Type.BIRCH; } - if (boatType == EntityType.ACACIA_BOAT || boatType == EntityType.ACACIA_CHEST_BOAT) { + if (boatType == EntityTypes.ACACIA_BOAT || boatType == EntityTypes.ACACIA_CHEST_BOAT) { return Type.ACACIA; } - if (boatType == EntityType.CHERRY_BOAT || boatType == EntityType.CHERRY_CHEST_BOAT) { + if (boatType == EntityTypes.CHERRY_BOAT || boatType == EntityTypes.CHERRY_CHEST_BOAT) { return Type.CHERRY; } - if (boatType == EntityType.JUNGLE_BOAT || boatType == EntityType.JUNGLE_CHEST_BOAT) { + if (boatType == EntityTypes.JUNGLE_BOAT || boatType == EntityTypes.JUNGLE_CHEST_BOAT) { return Type.JUNGLE; } - if (boatType == EntityType.SPRUCE_BOAT || boatType == EntityType.SPRUCE_CHEST_BOAT) { + if (boatType == EntityTypes.SPRUCE_BOAT || boatType == EntityTypes.SPRUCE_CHEST_BOAT) { return Type.SPRUCE; } - if (boatType == EntityType.DARK_OAK_BOAT || boatType == EntityType.DARK_OAK_CHEST_BOAT) { + if (boatType == EntityTypes.DARK_OAK_BOAT || boatType == EntityTypes.DARK_OAK_CHEST_BOAT) { return Type.DARK_OAK; } - if (boatType == EntityType.MANGROVE_BOAT || boatType == EntityType.MANGROVE_CHEST_BOAT) { + if (boatType == EntityTypes.MANGROVE_BOAT || boatType == EntityTypes.MANGROVE_CHEST_BOAT) { return Type.MANGROVE; } - if (boatType == EntityType.BAMBOO_RAFT || boatType == EntityType.BAMBOO_CHEST_RAFT) { + if (boatType == EntityTypes.BAMBOO_RAFT || boatType == EntityTypes.BAMBOO_CHEST_RAFT) { return Type.BAMBOO; } @@ -155,23 +156,23 @@ public static Status boatStatusFromNms(net.minecraft.world.entity.vehicle.boat.A @Deprecated public static TreeSpecies getTreeSpecies(EntityType boatType) { - if (boatType == EntityType.SPRUCE_BOAT || boatType == EntityType.SPRUCE_CHEST_BOAT) { + if (boatType == EntityTypes.SPRUCE_BOAT || boatType == EntityTypes.SPRUCE_CHEST_BOAT) { return TreeSpecies.REDWOOD; } - if (boatType == EntityType.BIRCH_BOAT || boatType == EntityType.BIRCH_CHEST_BOAT) { + if (boatType == EntityTypes.BIRCH_BOAT || boatType == EntityTypes.BIRCH_CHEST_BOAT) { return TreeSpecies.BIRCH; } - if (boatType == EntityType.JUNGLE_BOAT || boatType == EntityType.JUNGLE_CHEST_BOAT) { + if (boatType == EntityTypes.JUNGLE_BOAT || boatType == EntityTypes.JUNGLE_CHEST_BOAT) { return TreeSpecies.JUNGLE; } - if (boatType == EntityType.ACACIA_BOAT || boatType == EntityType.ACACIA_CHEST_BOAT) { + if (boatType == EntityTypes.ACACIA_BOAT || boatType == EntityTypes.ACACIA_CHEST_BOAT) { return TreeSpecies.ACACIA; } - if (boatType == EntityType.DARK_OAK_BOAT || boatType == EntityType.DARK_OAK_CHEST_BOAT) { + if (boatType == EntityTypes.DARK_OAK_BOAT || boatType == EntityTypes.DARK_OAK_CHEST_BOAT) { return TreeSpecies.DARK_OAK; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java index f61abf0ecad0..2beb9348f17a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java @@ -61,8 +61,8 @@ public Oxidizing getOxidizing() { public void setOxidizing(final Oxidizing oxidizing) { Preconditions.checkArgument(oxidizing != null, "oxidizing cannot be null"); switch (oxidizing) { - case Oxidizing.Waxed waxed -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.golem.CopperGolem.IGNORE_WEATHERING_TICK; - case Oxidizing.Unset unset -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.golem.CopperGolem.UNSET_WEATHERING_TICK; + case Oxidizing.Waxed _ -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.golem.CopperGolem.IGNORE_WEATHERING_TICK; + case Oxidizing.Unset _ -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.golem.CopperGolem.UNSET_WEATHERING_TICK; case Oxidizing.AtTime atTime -> this.getHandle().nextWeatheringTick = atTime.time(); default -> throw new IllegalStateException("Unexpected value: " + oxidizing); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 2f40476da09c..30f012468eb6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -31,6 +31,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityProcessor; import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntitySpawnRequest; import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.projectile.arrow.AbstractArrow; @@ -1029,7 +1030,7 @@ private Entity copy(net.minecraft.world.level.Level level) { final TagValueOutput output = TagValueOutput.createWithContext(problemReporter, level.registryAccess()); this.getHandle().saveAsPassenger(output, false, true, true); - return net.minecraft.world.entity.EntityType.loadEntityRecursive(output.buildResult(), level, EntitySpawnReason.LOAD, EntityProcessor.NOP); + return net.minecraft.world.entity.EntityType.loadEntityRecursive(output.buildResult(), level, new EntitySpawnRequest(EntitySpawnReason.LOAD, false), EntityProcessor.NOP); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java index 3df77f98529a..40ac5542e828 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntitySnapshot.java @@ -7,6 +7,7 @@ import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.EntityProcessor; import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntitySpawnRequest; import net.minecraft.world.level.storage.TagValueInput; import net.minecraft.world.level.storage.TagValueOutput; import org.bukkit.Location; @@ -59,7 +60,7 @@ public String getAsString() { private net.minecraft.world.entity.Entity createInternal(World world) { net.minecraft.world.level.Level level = ((CraftWorld) world).getHandle(); - net.minecraft.world.entity.Entity internal = net.minecraft.world.entity.EntityType.loadEntityRecursive(this.data, level, EntitySpawnReason.LOAD, EntityProcessor.NOP); + net.minecraft.world.entity.Entity internal = net.minecraft.world.entity.EntityType.loadEntityRecursive(this.data, level, new EntitySpawnRequest(EntitySpawnReason.LOAD, false), EntityProcessor.NOP); if (internal == null) { // Try creating by type internal = CraftEntityType.bukkitToMinecraft(this.type).create(level, EntitySpawnReason.LOAD); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java index bf59ea6025ab..5b2a126779cc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java @@ -18,11 +18,8 @@ public class CraftEntityType { public static EntityType minecraftToBukkit(net.minecraft.world.entity.EntityType minecraft) { Preconditions.checkArgument(minecraft != null); - net.minecraft.core.Registry> registry = CraftRegistry.getMinecraftRegistry(Registries.ENTITY_TYPE); - EntityType bukkit = Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); - + EntityType bukkit = Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(net.minecraft.world.entity.EntityType.getKey(minecraft))); Preconditions.checkArgument(bukkit != null); - return bukkit; } @@ -30,7 +27,7 @@ public static EntityType minecraftToBukkit(net.minecraft.world.entity.EntityType public static net.minecraft.world.entity.EntityType bukkitToMinecraft(EntityType bukkit) { Preconditions.checkArgument(bukkit != null); return CraftRegistry.getMinecraftRegistry(Registries.ENTITY_TYPE) - .getOptional(KEY_CACHE.computeIfAbsent(bukkit, type -> net.minecraft.resources.ResourceKey.create(Registries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(type.getKey())))).orElseThrow(); + .getOptional(KEY_CACHE.computeIfAbsent(bukkit, type -> CraftNamespacedKey.toResourceKey(Registries.ENTITY_TYPE, type.getKey()))).orElseThrow(); } @Deprecated // for now until this is a proper registry type diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java index 148de096f809..1449c73e4310 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java @@ -165,6 +165,7 @@ import org.bukkit.entity.Squid; import org.bukkit.entity.Stray; import org.bukkit.entity.Strider; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.Tadpole; import org.bukkit.entity.TextDisplay; @@ -276,110 +277,111 @@ Level minecraftWorld() { static { // Living - register(new EntityTypeData<>(EntityType.ELDER_GUARDIAN, ElderGuardian.class, CraftElderGuardian::new, createLiving(net.minecraft.world.entity.EntityType.ELDER_GUARDIAN))); - register(new EntityTypeData<>(EntityType.WITHER_SKELETON, WitherSkeleton.class, CraftWitherSkeleton::new, createLiving(net.minecraft.world.entity.EntityType.WITHER_SKELETON))); - register(new EntityTypeData<>(EntityType.STRAY, Stray.class, CraftStray::new, createLiving(net.minecraft.world.entity.EntityType.STRAY))); - register(new EntityTypeData<>(EntityType.BOGGED, Bogged.class, CraftBogged::new, createLiving(net.minecraft.world.entity.EntityType.BOGGED))); - register(new EntityTypeData<>(EntityType.HUSK, Husk.class, CraftHusk::new, createLiving(net.minecraft.world.entity.EntityType.HUSK))); - register(new EntityTypeData<>(EntityType.ZOMBIE_VILLAGER, ZombieVillager.class, CraftVillagerZombie::new, createLiving(net.minecraft.world.entity.EntityType.ZOMBIE_VILLAGER))); - register(new EntityTypeData<>(EntityType.SKELETON_HORSE, SkeletonHorse.class, CraftSkeletonHorse::new, createLiving(net.minecraft.world.entity.EntityType.SKELETON_HORSE))); - register(new EntityTypeData<>(EntityType.ZOMBIE_HORSE, ZombieHorse.class, CraftZombieHorse::new, createLiving(net.minecraft.world.entity.EntityType.ZOMBIE_HORSE))); - register(new EntityTypeData<>(EntityType.ARMOR_STAND, ArmorStand.class, CraftArmorStand::new, createLiving(net.minecraft.world.entity.EntityType.ARMOR_STAND))); - register(new EntityTypeData<>(EntityType.DONKEY, Donkey.class, CraftDonkey::new, createLiving(net.minecraft.world.entity.EntityType.DONKEY))); - register(new EntityTypeData<>(EntityType.MULE, Mule.class, CraftMule::new, createLiving(net.minecraft.world.entity.EntityType.MULE))); - register(new EntityTypeData<>(EntityType.EVOKER, Evoker.class, CraftEvoker::new, createLiving(net.minecraft.world.entity.EntityType.EVOKER))); - register(new EntityTypeData<>(EntityType.VEX, Vex.class, CraftVex::new, createLiving(net.minecraft.world.entity.EntityType.VEX))); - register(new EntityTypeData<>(EntityType.VINDICATOR, Vindicator.class, CraftVindicator::new, createLiving(net.minecraft.world.entity.EntityType.VINDICATOR))); - register(new EntityTypeData<>(EntityType.ILLUSIONER, Illusioner.class, CraftIllusioner::new, createLiving(net.minecraft.world.entity.EntityType.ILLUSIONER))); - register(new EntityTypeData<>(EntityType.CREEPER, Creeper.class, CraftCreeper::new, createLiving(net.minecraft.world.entity.EntityType.CREEPER))); - register(new EntityTypeData<>(EntityType.SKELETON, Skeleton.class, CraftSkeleton::new, createLiving(net.minecraft.world.entity.EntityType.SKELETON))); - register(new EntityTypeData<>(EntityType.SPIDER, Spider.class, CraftSpider::new, createLiving(net.minecraft.world.entity.EntityType.SPIDER))); - register(new EntityTypeData<>(EntityType.GIANT, Giant.class, CraftGiant::new, createLiving(net.minecraft.world.entity.EntityType.GIANT))); - register(new EntityTypeData<>(EntityType.ZOMBIE, Zombie.class, CraftZombie::new, createLiving(net.minecraft.world.entity.EntityType.ZOMBIE))); - register(new EntityTypeData<>(EntityType.SLIME, Slime.class, CraftSlime::new, createLiving(net.minecraft.world.entity.EntityType.SLIME))); - register(new EntityTypeData<>(EntityType.GHAST, Ghast.class, CraftGhast::new, createLiving(net.minecraft.world.entity.EntityType.GHAST))); - register(new EntityTypeData<>(EntityType.ZOMBIFIED_PIGLIN, PigZombie.class, CraftPigZombie::new, createLiving(net.minecraft.world.entity.EntityType.ZOMBIFIED_PIGLIN))); - register(new EntityTypeData<>(EntityType.ENDERMAN, Enderman.class, CraftEnderman::new, createLiving(net.minecraft.world.entity.EntityType.ENDERMAN))); - register(new EntityTypeData<>(EntityType.CAVE_SPIDER, CaveSpider.class, CraftCaveSpider::new, createLiving(net.minecraft.world.entity.EntityType.CAVE_SPIDER))); - register(new EntityTypeData<>(EntityType.SILVERFISH, Silverfish.class, CraftSilverfish::new, createLiving(net.minecraft.world.entity.EntityType.SILVERFISH))); - register(new EntityTypeData<>(EntityType.BLAZE, Blaze.class, CraftBlaze::new, createLiving(net.minecraft.world.entity.EntityType.BLAZE))); - register(new EntityTypeData<>(EntityType.MAGMA_CUBE, MagmaCube.class, CraftMagmaCube::new, createLiving(net.minecraft.world.entity.EntityType.MAGMA_CUBE))); - register(new EntityTypeData<>(EntityType.WITHER, Wither.class, CraftWither::new, createLiving(net.minecraft.world.entity.EntityType.WITHER))); - register(new EntityTypeData<>(EntityType.BAT, Bat.class, CraftBat::new, createLiving(net.minecraft.world.entity.EntityType.BAT))); - register(new EntityTypeData<>(EntityType.WITCH, Witch.class, CraftWitch::new, createLiving(net.minecraft.world.entity.EntityType.WITCH))); - register(new EntityTypeData<>(EntityType.ENDERMITE, Endermite.class, CraftEndermite::new, createLiving(net.minecraft.world.entity.EntityType.ENDERMITE))); - register(new EntityTypeData<>(EntityType.GUARDIAN, Guardian.class, CraftGuardian::new, createLiving(net.minecraft.world.entity.EntityType.GUARDIAN))); - register(new EntityTypeData<>(EntityType.SHULKER, Shulker.class, CraftShulker::new, createLiving(net.minecraft.world.entity.EntityType.SHULKER))); - register(new EntityTypeData<>(EntityType.PIG, Pig.class, CraftPig::new, createLiving(net.minecraft.world.entity.EntityType.PIG))); - register(new EntityTypeData<>(EntityType.SHEEP, Sheep.class, CraftSheep::new, createLiving(net.minecraft.world.entity.EntityType.SHEEP))); - register(new EntityTypeData<>(EntityType.COW, Cow.class, CraftCow::new, createLiving(net.minecraft.world.entity.EntityType.COW))); - register(new EntityTypeData<>(EntityType.CHICKEN, Chicken.class, CraftChicken::new, createLiving(net.minecraft.world.entity.EntityType.CHICKEN))); - register(new EntityTypeData<>(EntityType.SQUID, Squid.class, CraftSquid::new, createLiving(net.minecraft.world.entity.EntityType.SQUID))); - register(new EntityTypeData<>(EntityType.WOLF, Wolf.class, CraftWolf::new, createLiving(net.minecraft.world.entity.EntityType.WOLF))); - register(new EntityTypeData<>(EntityType.MOOSHROOM, MushroomCow.class, CraftMushroomCow::new, createLiving(net.minecraft.world.entity.EntityType.MOOSHROOM))); - register(new EntityTypeData<>(EntityType.SNOW_GOLEM, Snowman.class, CraftSnowman::new, createLiving(net.minecraft.world.entity.EntityType.SNOW_GOLEM))); - register(new EntityTypeData<>(EntityType.OCELOT, Ocelot.class, CraftOcelot::new, createLiving(net.minecraft.world.entity.EntityType.OCELOT))); - register(new EntityTypeData<>(EntityType.IRON_GOLEM, IronGolem.class, CraftIronGolem::new, createLiving(net.minecraft.world.entity.EntityType.IRON_GOLEM))); - register(new EntityTypeData<>(EntityType.HORSE, Horse.class, CraftHorse::new, createLiving(net.minecraft.world.entity.EntityType.HORSE))); - register(new EntityTypeData<>(EntityType.RABBIT, Rabbit.class, CraftRabbit::new, createLiving(net.minecraft.world.entity.EntityType.RABBIT))); - register(new EntityTypeData<>(EntityType.POLAR_BEAR, PolarBear.class, CraftPolarBear::new, createLiving(net.minecraft.world.entity.EntityType.POLAR_BEAR))); - register(new EntityTypeData<>(EntityType.LLAMA, Llama.class, CraftLlama::new, createLiving(net.minecraft.world.entity.EntityType.LLAMA))); - register(new EntityTypeData<>(EntityType.PARROT, Parrot.class, CraftParrot::new, createLiving(net.minecraft.world.entity.EntityType.PARROT))); - register(new EntityTypeData<>(EntityType.VILLAGER, Villager.class, CraftVillager::new, createLiving(net.minecraft.world.entity.EntityType.VILLAGER))); - register(new EntityTypeData<>(EntityType.TURTLE, Turtle.class, CraftTurtle::new, createLiving(net.minecraft.world.entity.EntityType.TURTLE))); - register(new EntityTypeData<>(EntityType.PHANTOM, Phantom.class, CraftPhantom::new, createLiving(net.minecraft.world.entity.EntityType.PHANTOM))); - register(new EntityTypeData<>(EntityType.COD, Cod.class, CraftCod::new, createLiving(net.minecraft.world.entity.EntityType.COD))); - register(new EntityTypeData<>(EntityType.SALMON, Salmon.class, CraftSalmon::new, createLiving(net.minecraft.world.entity.EntityType.SALMON))); - register(new EntityTypeData<>(EntityType.PUFFERFISH, PufferFish.class, CraftPufferFish::new, createLiving(net.minecraft.world.entity.EntityType.PUFFERFISH))); - register(new EntityTypeData<>(EntityType.TROPICAL_FISH, TropicalFish.class, CraftTropicalFish::new, createLiving(net.minecraft.world.entity.EntityType.TROPICAL_FISH))); - register(new EntityTypeData<>(EntityType.DROWNED, Drowned.class, CraftDrowned::new, createLiving(net.minecraft.world.entity.EntityType.DROWNED))); - register(new EntityTypeData<>(EntityType.DOLPHIN, Dolphin.class, CraftDolphin::new, createLiving(net.minecraft.world.entity.EntityType.DOLPHIN))); - register(new EntityTypeData<>(EntityType.CAT, Cat.class, CraftCat::new, createLiving(net.minecraft.world.entity.EntityType.CAT))); - register(new EntityTypeData<>(EntityType.PANDA, Panda.class, CraftPanda::new, createLiving(net.minecraft.world.entity.EntityType.PANDA))); - register(new EntityTypeData<>(EntityType.PILLAGER, Pillager.class, CraftPillager::new, createLiving(net.minecraft.world.entity.EntityType.PILLAGER))); - register(new EntityTypeData<>(EntityType.RAVAGER, Ravager.class, CraftRavager::new, createLiving(net.minecraft.world.entity.EntityType.RAVAGER))); - register(new EntityTypeData<>(EntityType.TRADER_LLAMA, TraderLlama.class, CraftTraderLlama::new, createLiving(net.minecraft.world.entity.EntityType.TRADER_LLAMA))); - register(new EntityTypeData<>(EntityType.WANDERING_TRADER, WanderingTrader.class, CraftWanderingTrader::new, createLiving(net.minecraft.world.entity.EntityType.WANDERING_TRADER))); - register(new EntityTypeData<>(EntityType.FOX, Fox.class, CraftFox::new, createLiving(net.minecraft.world.entity.EntityType.FOX))); - register(new EntityTypeData<>(EntityType.BEE, Bee.class, CraftBee::new, createLiving(net.minecraft.world.entity.EntityType.BEE))); - register(new EntityTypeData<>(EntityType.HOGLIN, Hoglin.class, CraftHoglin::new, createLiving(net.minecraft.world.entity.EntityType.HOGLIN))); - register(new EntityTypeData<>(EntityType.PIGLIN, Piglin.class, CraftPiglin::new, createLiving(net.minecraft.world.entity.EntityType.PIGLIN))); - register(new EntityTypeData<>(EntityType.STRIDER, Strider.class, CraftStrider::new, createLiving(net.minecraft.world.entity.EntityType.STRIDER))); - register(new EntityTypeData<>(EntityType.ZOGLIN, Zoglin.class, CraftZoglin::new, createLiving(net.minecraft.world.entity.EntityType.ZOGLIN))); - register(new EntityTypeData<>(EntityType.PIGLIN_BRUTE, PiglinBrute.class, CraftPiglinBrute::new, createLiving(net.minecraft.world.entity.EntityType.PIGLIN_BRUTE))); - register(new EntityTypeData<>(EntityType.AXOLOTL, Axolotl.class, CraftAxolotl::new, createLiving(net.minecraft.world.entity.EntityType.AXOLOTL))); - register(new EntityTypeData<>(EntityType.GLOW_SQUID, GlowSquid.class, CraftGlowSquid::new, createLiving(net.minecraft.world.entity.EntityType.GLOW_SQUID))); - register(new EntityTypeData<>(EntityType.GOAT, Goat.class, CraftGoat::new, createLiving(net.minecraft.world.entity.EntityType.GOAT))); - register(new EntityTypeData<>(EntityType.ALLAY, Allay.class, CraftAllay::new, createLiving(net.minecraft.world.entity.EntityType.ALLAY))); - register(new EntityTypeData<>(EntityType.FROG, Frog.class, CraftFrog::new, createLiving(net.minecraft.world.entity.EntityType.FROG))); - register(new EntityTypeData<>(EntityType.TADPOLE, Tadpole.class, CraftTadpole::new, createLiving(net.minecraft.world.entity.EntityType.TADPOLE))); - register(new EntityTypeData<>(EntityType.WARDEN, Warden.class, CraftWarden::new, createLiving(net.minecraft.world.entity.EntityType.WARDEN))); - register(new EntityTypeData<>(EntityType.CAMEL, Camel.class, CraftCamel::new, createLiving(net.minecraft.world.entity.EntityType.CAMEL))); - register(new EntityTypeData<>(EntityType.SNIFFER, Sniffer.class, CraftSniffer::new, createLiving(net.minecraft.world.entity.EntityType.SNIFFER))); - register(new EntityTypeData<>(EntityType.BREEZE, Breeze.class, CraftBreeze::new, createLiving(net.minecraft.world.entity.EntityType.BREEZE))); - register(new EntityTypeData<>(EntityType.ARMADILLO, Armadillo.class, CraftArmadillo::new, createLiving(net.minecraft.world.entity.EntityType.ARMADILLO))); - register(new EntityTypeData<>(EntityType.CREAKING, Creaking.class, CraftCreaking::new, createLiving(net.minecraft.world.entity.EntityType.CREAKING))); - register(new EntityTypeData<>(EntityType.HAPPY_GHAST, HappyGhast.class, CraftHappyGhast::new, createLiving(net.minecraft.world.entity.EntityType.HAPPY_GHAST))); - register(new EntityTypeData<>(EntityType.COPPER_GOLEM, CopperGolem.class, CraftCopperGolem::new, createLiving(net.minecraft.world.entity.EntityType.COPPER_GOLEM))); - register(new EntityTypeData<>(EntityType.MANNEQUIN, Mannequin.class, CraftMannequin::new, createLiving(net.minecraft.world.entity.EntityType.MANNEQUIN))); - register(new EntityTypeData<>(EntityType.NAUTILUS, Nautilus.class, CraftNautilus::new, createLiving(net.minecraft.world.entity.EntityType.NAUTILUS))); - register(new EntityTypeData<>(EntityType.ZOMBIE_NAUTILUS, ZombieNautilus.class, CraftZombieNautilus::new, createLiving(net.minecraft.world.entity.EntityType.ZOMBIE_NAUTILUS))); - register(new EntityTypeData<>(EntityType.CAMEL_HUSK, CamelHusk.class, CraftCamelHusk::new, createLiving(net.minecraft.world.entity.EntityType.CAMEL_HUSK))); - register(new EntityTypeData<>(EntityType.PARCHED, Parched.class, CraftParched::new, createLiving(net.minecraft.world.entity.EntityType.PARCHED))); - - Function dragonFunction = createLiving(net.minecraft.world.entity.EntityType.ENDER_DRAGON); + register(new EntityTypeData<>(EntityType.ELDER_GUARDIAN, ElderGuardian.class, CraftElderGuardian::new, createLiving(net.minecraft.world.entity.EntityTypes.ELDER_GUARDIAN))); + register(new EntityTypeData<>(EntityType.WITHER_SKELETON, WitherSkeleton.class, CraftWitherSkeleton::new, createLiving(net.minecraft.world.entity.EntityTypes.WITHER_SKELETON))); + register(new EntityTypeData<>(EntityType.STRAY, Stray.class, CraftStray::new, createLiving(net.minecraft.world.entity.EntityTypes.STRAY))); + register(new EntityTypeData<>(EntityType.BOGGED, Bogged.class, CraftBogged::new, createLiving(net.minecraft.world.entity.EntityTypes.BOGGED))); + register(new EntityTypeData<>(EntityType.HUSK, Husk.class, CraftHusk::new, createLiving(net.minecraft.world.entity.EntityTypes.HUSK))); + register(new EntityTypeData<>(EntityType.ZOMBIE_VILLAGER, ZombieVillager.class, CraftVillagerZombie::new, createLiving(net.minecraft.world.entity.EntityTypes.ZOMBIE_VILLAGER))); + register(new EntityTypeData<>(EntityType.SKELETON_HORSE, SkeletonHorse.class, CraftSkeletonHorse::new, createLiving(net.minecraft.world.entity.EntityTypes.SKELETON_HORSE))); + register(new EntityTypeData<>(EntityType.ZOMBIE_HORSE, ZombieHorse.class, CraftZombieHorse::new, createLiving(net.minecraft.world.entity.EntityTypes.ZOMBIE_HORSE))); + register(new EntityTypeData<>(EntityType.ARMOR_STAND, ArmorStand.class, CraftArmorStand::new, createLiving(net.minecraft.world.entity.EntityTypes.ARMOR_STAND))); + register(new EntityTypeData<>(EntityType.DONKEY, Donkey.class, CraftDonkey::new, createLiving(net.minecraft.world.entity.EntityTypes.DONKEY))); + register(new EntityTypeData<>(EntityType.MULE, Mule.class, CraftMule::new, createLiving(net.minecraft.world.entity.EntityTypes.MULE))); + register(new EntityTypeData<>(EntityType.EVOKER, Evoker.class, CraftEvoker::new, createLiving(net.minecraft.world.entity.EntityTypes.EVOKER))); + register(new EntityTypeData<>(EntityType.VEX, Vex.class, CraftVex::new, createLiving(net.minecraft.world.entity.EntityTypes.VEX))); + register(new EntityTypeData<>(EntityType.VINDICATOR, Vindicator.class, CraftVindicator::new, createLiving(net.minecraft.world.entity.EntityTypes.VINDICATOR))); + register(new EntityTypeData<>(EntityType.ILLUSIONER, Illusioner.class, CraftIllusioner::new, createLiving(net.minecraft.world.entity.EntityTypes.ILLUSIONER))); + register(new EntityTypeData<>(EntityType.CREEPER, Creeper.class, CraftCreeper::new, createLiving(net.minecraft.world.entity.EntityTypes.CREEPER))); + register(new EntityTypeData<>(EntityType.SKELETON, Skeleton.class, CraftSkeleton::new, createLiving(net.minecraft.world.entity.EntityTypes.SKELETON))); + register(new EntityTypeData<>(EntityType.SPIDER, Spider.class, CraftSpider::new, createLiving(net.minecraft.world.entity.EntityTypes.SPIDER))); + register(new EntityTypeData<>(EntityType.GIANT, Giant.class, CraftGiant::new, createLiving(net.minecraft.world.entity.EntityTypes.GIANT))); + register(new EntityTypeData<>(EntityType.ZOMBIE, Zombie.class, CraftZombie::new, createLiving(net.minecraft.world.entity.EntityTypes.ZOMBIE))); + register(new EntityTypeData<>(EntityType.SLIME, Slime.class, CraftSlime::new, createLiving(net.minecraft.world.entity.EntityTypes.SLIME))); + register(new EntityTypeData<>(EntityType.GHAST, Ghast.class, CraftGhast::new, createLiving(net.minecraft.world.entity.EntityTypes.GHAST))); + register(new EntityTypeData<>(EntityType.ZOMBIFIED_PIGLIN, PigZombie.class, CraftPigZombie::new, createLiving(net.minecraft.world.entity.EntityTypes.ZOMBIFIED_PIGLIN))); + register(new EntityTypeData<>(EntityType.ENDERMAN, Enderman.class, CraftEnderman::new, createLiving(net.minecraft.world.entity.EntityTypes.ENDERMAN))); + register(new EntityTypeData<>(EntityType.CAVE_SPIDER, CaveSpider.class, CraftCaveSpider::new, createLiving(net.minecraft.world.entity.EntityTypes.CAVE_SPIDER))); + register(new EntityTypeData<>(EntityType.SILVERFISH, Silverfish.class, CraftSilverfish::new, createLiving(net.minecraft.world.entity.EntityTypes.SILVERFISH))); + register(new EntityTypeData<>(EntityType.BLAZE, Blaze.class, CraftBlaze::new, createLiving(net.minecraft.world.entity.EntityTypes.BLAZE))); + register(new EntityTypeData<>(EntityType.MAGMA_CUBE, MagmaCube.class, CraftMagmaCube::new, createLiving(net.minecraft.world.entity.EntityTypes.MAGMA_CUBE))); + register(new EntityTypeData<>(EntityType.WITHER, Wither.class, CraftWither::new, createLiving(net.minecraft.world.entity.EntityTypes.WITHER))); + register(new EntityTypeData<>(EntityType.BAT, Bat.class, CraftBat::new, createLiving(net.minecraft.world.entity.EntityTypes.BAT))); + register(new EntityTypeData<>(EntityType.WITCH, Witch.class, CraftWitch::new, createLiving(net.minecraft.world.entity.EntityTypes.WITCH))); + register(new EntityTypeData<>(EntityType.ENDERMITE, Endermite.class, CraftEndermite::new, createLiving(net.minecraft.world.entity.EntityTypes.ENDERMITE))); + register(new EntityTypeData<>(EntityType.GUARDIAN, Guardian.class, CraftGuardian::new, createLiving(net.minecraft.world.entity.EntityTypes.GUARDIAN))); + register(new EntityTypeData<>(EntityType.SHULKER, Shulker.class, CraftShulker::new, createLiving(net.minecraft.world.entity.EntityTypes.SHULKER))); + register(new EntityTypeData<>(EntityType.PIG, Pig.class, CraftPig::new, createLiving(net.minecraft.world.entity.EntityTypes.PIG))); + register(new EntityTypeData<>(EntityType.SHEEP, Sheep.class, CraftSheep::new, createLiving(net.minecraft.world.entity.EntityTypes.SHEEP))); + register(new EntityTypeData<>(EntityType.COW, Cow.class, CraftCow::new, createLiving(net.minecraft.world.entity.EntityTypes.COW))); + register(new EntityTypeData<>(EntityType.CHICKEN, Chicken.class, CraftChicken::new, createLiving(net.minecraft.world.entity.EntityTypes.CHICKEN))); + register(new EntityTypeData<>(EntityType.SQUID, Squid.class, CraftSquid::new, createLiving(net.minecraft.world.entity.EntityTypes.SQUID))); + register(new EntityTypeData<>(EntityType.WOLF, Wolf.class, CraftWolf::new, createLiving(net.minecraft.world.entity.EntityTypes.WOLF))); + register(new EntityTypeData<>(EntityType.MOOSHROOM, MushroomCow.class, CraftMushroomCow::new, createLiving(net.minecraft.world.entity.EntityTypes.MOOSHROOM))); + register(new EntityTypeData<>(EntityType.SNOW_GOLEM, Snowman.class, CraftSnowman::new, createLiving(net.minecraft.world.entity.EntityTypes.SNOW_GOLEM))); + register(new EntityTypeData<>(EntityType.OCELOT, Ocelot.class, CraftOcelot::new, createLiving(net.minecraft.world.entity.EntityTypes.OCELOT))); + register(new EntityTypeData<>(EntityType.IRON_GOLEM, IronGolem.class, CraftIronGolem::new, createLiving(net.minecraft.world.entity.EntityTypes.IRON_GOLEM))); + register(new EntityTypeData<>(EntityType.HORSE, Horse.class, CraftHorse::new, createLiving(net.minecraft.world.entity.EntityTypes.HORSE))); + register(new EntityTypeData<>(EntityType.RABBIT, Rabbit.class, CraftRabbit::new, createLiving(net.minecraft.world.entity.EntityTypes.RABBIT))); + register(new EntityTypeData<>(EntityType.POLAR_BEAR, PolarBear.class, CraftPolarBear::new, createLiving(net.minecraft.world.entity.EntityTypes.POLAR_BEAR))); + register(new EntityTypeData<>(EntityType.LLAMA, Llama.class, CraftLlama::new, createLiving(net.minecraft.world.entity.EntityTypes.LLAMA))); + register(new EntityTypeData<>(EntityType.PARROT, Parrot.class, CraftParrot::new, createLiving(net.minecraft.world.entity.EntityTypes.PARROT))); + register(new EntityTypeData<>(EntityType.VILLAGER, Villager.class, CraftVillager::new, createLiving(net.minecraft.world.entity.EntityTypes.VILLAGER))); + register(new EntityTypeData<>(EntityType.TURTLE, Turtle.class, CraftTurtle::new, createLiving(net.minecraft.world.entity.EntityTypes.TURTLE))); + register(new EntityTypeData<>(EntityType.PHANTOM, Phantom.class, CraftPhantom::new, createLiving(net.minecraft.world.entity.EntityTypes.PHANTOM))); + register(new EntityTypeData<>(EntityType.COD, Cod.class, CraftCod::new, createLiving(net.minecraft.world.entity.EntityTypes.COD))); + register(new EntityTypeData<>(EntityType.SALMON, Salmon.class, CraftSalmon::new, createLiving(net.minecraft.world.entity.EntityTypes.SALMON))); + register(new EntityTypeData<>(EntityType.PUFFERFISH, PufferFish.class, CraftPufferFish::new, createLiving(net.minecraft.world.entity.EntityTypes.PUFFERFISH))); + register(new EntityTypeData<>(EntityType.TROPICAL_FISH, TropicalFish.class, CraftTropicalFish::new, createLiving(net.minecraft.world.entity.EntityTypes.TROPICAL_FISH))); + register(new EntityTypeData<>(EntityType.DROWNED, Drowned.class, CraftDrowned::new, createLiving(net.minecraft.world.entity.EntityTypes.DROWNED))); + register(new EntityTypeData<>(EntityType.DOLPHIN, Dolphin.class, CraftDolphin::new, createLiving(net.minecraft.world.entity.EntityTypes.DOLPHIN))); + register(new EntityTypeData<>(EntityType.CAT, Cat.class, CraftCat::new, createLiving(net.minecraft.world.entity.EntityTypes.CAT))); + register(new EntityTypeData<>(EntityType.PANDA, Panda.class, CraftPanda::new, createLiving(net.minecraft.world.entity.EntityTypes.PANDA))); + register(new EntityTypeData<>(EntityType.PILLAGER, Pillager.class, CraftPillager::new, createLiving(net.minecraft.world.entity.EntityTypes.PILLAGER))); + register(new EntityTypeData<>(EntityType.RAVAGER, Ravager.class, CraftRavager::new, createLiving(net.minecraft.world.entity.EntityTypes.RAVAGER))); + register(new EntityTypeData<>(EntityType.TRADER_LLAMA, TraderLlama.class, CraftTraderLlama::new, createLiving(net.minecraft.world.entity.EntityTypes.TRADER_LLAMA))); + register(new EntityTypeData<>(EntityType.WANDERING_TRADER, WanderingTrader.class, CraftWanderingTrader::new, createLiving(net.minecraft.world.entity.EntityTypes.WANDERING_TRADER))); + register(new EntityTypeData<>(EntityType.FOX, Fox.class, CraftFox::new, createLiving(net.minecraft.world.entity.EntityTypes.FOX))); + register(new EntityTypeData<>(EntityType.BEE, Bee.class, CraftBee::new, createLiving(net.minecraft.world.entity.EntityTypes.BEE))); + register(new EntityTypeData<>(EntityType.HOGLIN, Hoglin.class, CraftHoglin::new, createLiving(net.minecraft.world.entity.EntityTypes.HOGLIN))); + register(new EntityTypeData<>(EntityType.PIGLIN, Piglin.class, CraftPiglin::new, createLiving(net.minecraft.world.entity.EntityTypes.PIGLIN))); + register(new EntityTypeData<>(EntityType.STRIDER, Strider.class, CraftStrider::new, createLiving(net.minecraft.world.entity.EntityTypes.STRIDER))); + register(new EntityTypeData<>(EntityType.ZOGLIN, Zoglin.class, CraftZoglin::new, createLiving(net.minecraft.world.entity.EntityTypes.ZOGLIN))); + register(new EntityTypeData<>(EntityType.PIGLIN_BRUTE, PiglinBrute.class, CraftPiglinBrute::new, createLiving(net.minecraft.world.entity.EntityTypes.PIGLIN_BRUTE))); + register(new EntityTypeData<>(EntityType.AXOLOTL, Axolotl.class, CraftAxolotl::new, createLiving(net.minecraft.world.entity.EntityTypes.AXOLOTL))); + register(new EntityTypeData<>(EntityType.GLOW_SQUID, GlowSquid.class, CraftGlowSquid::new, createLiving(net.minecraft.world.entity.EntityTypes.GLOW_SQUID))); + register(new EntityTypeData<>(EntityType.GOAT, Goat.class, CraftGoat::new, createLiving(net.minecraft.world.entity.EntityTypes.GOAT))); + register(new EntityTypeData<>(EntityType.ALLAY, Allay.class, CraftAllay::new, createLiving(net.minecraft.world.entity.EntityTypes.ALLAY))); + register(new EntityTypeData<>(EntityType.FROG, Frog.class, CraftFrog::new, createLiving(net.minecraft.world.entity.EntityTypes.FROG))); + register(new EntityTypeData<>(EntityType.TADPOLE, Tadpole.class, CraftTadpole::new, createLiving(net.minecraft.world.entity.EntityTypes.TADPOLE))); + register(new EntityTypeData<>(EntityType.WARDEN, Warden.class, CraftWarden::new, createLiving(net.minecraft.world.entity.EntityTypes.WARDEN))); + register(new EntityTypeData<>(EntityType.CAMEL, Camel.class, CraftCamel::new, createLiving(net.minecraft.world.entity.EntityTypes.CAMEL))); + register(new EntityTypeData<>(EntityType.SNIFFER, Sniffer.class, CraftSniffer::new, createLiving(net.minecraft.world.entity.EntityTypes.SNIFFER))); + register(new EntityTypeData<>(EntityType.BREEZE, Breeze.class, CraftBreeze::new, createLiving(net.minecraft.world.entity.EntityTypes.BREEZE))); + register(new EntityTypeData<>(EntityType.ARMADILLO, Armadillo.class, CraftArmadillo::new, createLiving(net.minecraft.world.entity.EntityTypes.ARMADILLO))); + register(new EntityTypeData<>(EntityType.CREAKING, Creaking.class, CraftCreaking::new, createLiving(net.minecraft.world.entity.EntityTypes.CREAKING))); + register(new EntityTypeData<>(EntityType.HAPPY_GHAST, HappyGhast.class, CraftHappyGhast::new, createLiving(net.minecraft.world.entity.EntityTypes.HAPPY_GHAST))); + register(new EntityTypeData<>(EntityType.COPPER_GOLEM, CopperGolem.class, CraftCopperGolem::new, createLiving(net.minecraft.world.entity.EntityTypes.COPPER_GOLEM))); + register(new EntityTypeData<>(EntityType.MANNEQUIN, Mannequin.class, CraftMannequin::new, createLiving(net.minecraft.world.entity.EntityTypes.MANNEQUIN))); + register(new EntityTypeData<>(EntityType.NAUTILUS, Nautilus.class, CraftNautilus::new, createLiving(net.minecraft.world.entity.EntityTypes.NAUTILUS))); + register(new EntityTypeData<>(EntityType.ZOMBIE_NAUTILUS, ZombieNautilus.class, CraftZombieNautilus::new, createLiving(net.minecraft.world.entity.EntityTypes.ZOMBIE_NAUTILUS))); + register(new EntityTypeData<>(EntityType.CAMEL_HUSK, CamelHusk.class, CraftCamelHusk::new, createLiving(net.minecraft.world.entity.EntityTypes.CAMEL_HUSK))); + register(new EntityTypeData<>(EntityType.PARCHED, Parched.class, CraftParched::new, createLiving(net.minecraft.world.entity.EntityTypes.PARCHED))); + register(new EntityTypeData<>(EntityType.SULFUR_CUBE, SulfurCube.class, CraftSulfurCube::new, createLiving(net.minecraft.world.entity.EntityTypes.SULFUR_CUBE))); + + Function dragonFunction = createLiving(net.minecraft.world.entity.EntityTypes.ENDER_DRAGON); register(new EntityTypeData<>(EntityType.ENDER_DRAGON, EnderDragon.class, CraftEnderDragon::new, spawnData -> { Preconditions.checkArgument(spawnData.normalWorld(), "Cannot spawn entity %s during world generation", EnderDragon.class.getName()); return dragonFunction.apply(spawnData); })); // Fireball - register(new EntityTypeData<>(EntityType.FIREBALL, LargeFireball.class, CraftLargeFireball::new, createFireball(net.minecraft.world.entity.EntityType.FIREBALL))); - register(new EntityTypeData<>(EntityType.SMALL_FIREBALL, SmallFireball.class, CraftSmallFireball::new, createFireball(net.minecraft.world.entity.EntityType.SMALL_FIREBALL))); - register(new EntityTypeData<>(EntityType.WITHER_SKULL, WitherSkull.class, CraftWitherSkull::new, createFireball(net.minecraft.world.entity.EntityType.WITHER_SKULL))); - register(new EntityTypeData<>(EntityType.DRAGON_FIREBALL, DragonFireball.class, CraftDragonFireball::new, createFireball(net.minecraft.world.entity.EntityType.DRAGON_FIREBALL))); - register(new EntityTypeData<>(EntityType.WIND_CHARGE, WindCharge.class, CraftWindCharge::new, createFireball(net.minecraft.world.entity.EntityType.WIND_CHARGE))); - register(new EntityTypeData<>(EntityType.BREEZE_WIND_CHARGE, BreezeWindCharge.class, CraftBreezeWindCharge::new, createFireball(net.minecraft.world.entity.EntityType.BREEZE_WIND_CHARGE))); + register(new EntityTypeData<>(EntityType.FIREBALL, LargeFireball.class, CraftLargeFireball::new, createFireball(net.minecraft.world.entity.EntityTypes.FIREBALL))); + register(new EntityTypeData<>(EntityType.SMALL_FIREBALL, SmallFireball.class, CraftSmallFireball::new, createFireball(net.minecraft.world.entity.EntityTypes.SMALL_FIREBALL))); + register(new EntityTypeData<>(EntityType.WITHER_SKULL, WitherSkull.class, CraftWitherSkull::new, createFireball(net.minecraft.world.entity.EntityTypes.WITHER_SKULL))); + register(new EntityTypeData<>(EntityType.DRAGON_FIREBALL, DragonFireball.class, CraftDragonFireball::new, createFireball(net.minecraft.world.entity.EntityTypes.DRAGON_FIREBALL))); + register(new EntityTypeData<>(EntityType.WIND_CHARGE, WindCharge.class, CraftWindCharge::new, createFireball(net.minecraft.world.entity.EntityTypes.WIND_CHARGE))); + register(new EntityTypeData<>(EntityType.BREEZE_WIND_CHARGE, BreezeWindCharge.class, CraftBreezeWindCharge::new, createFireball(net.minecraft.world.entity.EntityTypes.BREEZE_WIND_CHARGE))); // Hanging register(new EntityTypeData<>(EntityType.PAINTING, Painting.class, CraftPainting::new, createHanging(Painting.class, (spawnData, hangingData) -> { @@ -390,7 +392,7 @@ Level minecraftWorld() { } } - net.minecraft.world.entity.decoration.painting.Painting entity = new net.minecraft.world.entity.decoration.painting.Painting(net.minecraft.world.entity.EntityType.PAINTING, spawnData.minecraftWorld()); + net.minecraft.world.entity.decoration.painting.Painting entity = new net.minecraft.world.entity.decoration.painting.Painting(net.minecraft.world.entity.EntityTypes.PAINTING, spawnData.minecraftWorld()); entity.absSnapTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); entity.setDirection(hangingData.direction()); return entity; @@ -399,46 +401,46 @@ Level minecraftWorld() { register(new EntityTypeData<>(EntityType.GLOW_ITEM_FRAME, GlowItemFrame.class, CraftGlowItemFrame::new, createHanging(GlowItemFrame.class, (spawnData, hangingData) -> new net.minecraft.world.entity.decoration.GlowItemFrame(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction())))); // Move no rotation - register(new EntityTypeData<>(EntityType.ARROW, Arrow.class, CraftArrow::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityType.ARROW))); - register(new EntityTypeData<>(EntityType.ENDER_PEARL, EnderPearl.class, CraftEnderPearl::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityType.ENDER_PEARL))); - register(new EntityTypeData<>(EntityType.EXPERIENCE_BOTTLE, ThrownExpBottle.class, CraftThrownExpBottle::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityType.EXPERIENCE_BOTTLE))); - register(new EntityTypeData<>(EntityType.SPECTRAL_ARROW, SpectralArrow.class, CraftSpectralArrow::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityType.SPECTRAL_ARROW))); - register(new EntityTypeData<>(EntityType.END_CRYSTAL, EnderCrystal.class, CraftEnderCrystal::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityType.END_CRYSTAL))); - register(new EntityTypeData<>(EntityType.TRIDENT, Trident.class, CraftTrident::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityType.TRIDENT))); - register(new EntityTypeData<>(EntityType.LIGHTNING_BOLT, LightningStrike.class, CraftLightningStrike::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityType.LIGHTNING_BOLT))); + register(new EntityTypeData<>(EntityType.ARROW, Arrow.class, CraftArrow::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityTypes.ARROW))); + register(new EntityTypeData<>(EntityType.ENDER_PEARL, EnderPearl.class, CraftEnderPearl::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityTypes.ENDER_PEARL))); + register(new EntityTypeData<>(EntityType.EXPERIENCE_BOTTLE, ThrownExpBottle.class, CraftThrownExpBottle::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityTypes.EXPERIENCE_BOTTLE))); + register(new EntityTypeData<>(EntityType.SPECTRAL_ARROW, SpectralArrow.class, CraftSpectralArrow::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityTypes.SPECTRAL_ARROW))); + register(new EntityTypeData<>(EntityType.END_CRYSTAL, EnderCrystal.class, CraftEnderCrystal::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityTypes.END_CRYSTAL))); + register(new EntityTypeData<>(EntityType.TRIDENT, Trident.class, CraftTrident::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityTypes.TRIDENT))); + register(new EntityTypeData<>(EntityType.LIGHTNING_BOLT, LightningStrike.class, CraftLightningStrike::new, createAndMoveEmptyRot(net.minecraft.world.entity.EntityTypes.LIGHTNING_BOLT))); // Move - register(new EntityTypeData<>(EntityType.SHULKER_BULLET, ShulkerBullet.class, CraftShulkerBullet::new, createAndMove(net.minecraft.world.entity.EntityType.SHULKER_BULLET))); - register(new EntityTypeData<>(EntityType.LLAMA_SPIT, LlamaSpit.class, CraftLlamaSpit::new, createAndMove(net.minecraft.world.entity.EntityType.LLAMA_SPIT))); - register(new EntityTypeData<>(EntityType.OMINOUS_ITEM_SPAWNER, OminousItemSpawner.class, CraftOminousItemSpawner::new, createAndMove(net.minecraft.world.entity.EntityType.OMINOUS_ITEM_SPAWNER))); + register(new EntityTypeData<>(EntityType.SHULKER_BULLET, ShulkerBullet.class, CraftShulkerBullet::new, createAndMove(net.minecraft.world.entity.EntityTypes.SHULKER_BULLET))); + register(new EntityTypeData<>(EntityType.LLAMA_SPIT, LlamaSpit.class, CraftLlamaSpit::new, createAndMove(net.minecraft.world.entity.EntityTypes.LLAMA_SPIT))); + register(new EntityTypeData<>(EntityType.OMINOUS_ITEM_SPAWNER, OminousItemSpawner.class, CraftOminousItemSpawner::new, createAndMove(net.minecraft.world.entity.EntityTypes.OMINOUS_ITEM_SPAWNER))); // Move (boats) - register(new EntityTypeData<>(EntityType.ACACIA_BOAT, AcaciaBoat.class, CraftAcaciaBoat::new, createAndMove(net.minecraft.world.entity.EntityType.ACACIA_BOAT))); - register(new EntityTypeData<>(EntityType.ACACIA_CHEST_BOAT, AcaciaChestBoat.class, CraftAcaciaChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.ACACIA_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.BAMBOO_RAFT, BambooRaft.class, CraftBambooRaft::new, createAndMove(net.minecraft.world.entity.EntityType.BAMBOO_RAFT))); - register(new EntityTypeData<>(EntityType.BAMBOO_CHEST_RAFT, BambooChestRaft.class, CraftBambooChestRaft::new, createAndMove(net.minecraft.world.entity.EntityType.BAMBOO_CHEST_RAFT))); - register(new EntityTypeData<>(EntityType.BIRCH_BOAT, BirchBoat.class, CraftBirchBoat::new, createAndMove(net.minecraft.world.entity.EntityType.BIRCH_BOAT))); - register(new EntityTypeData<>(EntityType.BIRCH_CHEST_BOAT, BirchChestBoat.class, CraftBirchChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.BIRCH_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.CHERRY_BOAT, CherryBoat.class, CraftCherryBoat::new, createAndMove(net.minecraft.world.entity.EntityType.CHERRY_BOAT))); - register(new EntityTypeData<>(EntityType.CHERRY_CHEST_BOAT, CherryChestBoat.class, CraftCherryChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.CHERRY_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.DARK_OAK_BOAT, DarkOakBoat.class, CraftDarkOakBoat::new, createAndMove(net.minecraft.world.entity.EntityType.DARK_OAK_BOAT))); - register(new EntityTypeData<>(EntityType.DARK_OAK_CHEST_BOAT, DarkOakChestBoat.class, CraftDarkOakChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.DARK_OAK_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.JUNGLE_BOAT, JungleBoat.class, CraftJungleBoat::new, createAndMove(net.minecraft.world.entity.EntityType.JUNGLE_BOAT))); - register(new EntityTypeData<>(EntityType.JUNGLE_CHEST_BOAT, JungleChestBoat.class, CraftJungleChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.JUNGLE_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.MANGROVE_BOAT, MangroveBoat.class, CraftMangroveBoat::new, createAndMove(net.minecraft.world.entity.EntityType.MANGROVE_BOAT))); - register(new EntityTypeData<>(EntityType.MANGROVE_CHEST_BOAT, MangroveChestBoat.class, CraftMangroveChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.MANGROVE_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.OAK_BOAT, OakBoat.class, CraftOakBoat::new, createAndMove(net.minecraft.world.entity.EntityType.OAK_BOAT))); - register(new EntityTypeData<>(EntityType.OAK_CHEST_BOAT, OakChestBoat.class, CraftOakChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.OAK_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.PALE_OAK_BOAT, PaleOakBoat.class, CraftPaleOakBoat::new, createAndMove(net.minecraft.world.entity.EntityType.PALE_OAK_BOAT))); - register(new EntityTypeData<>(EntityType.PALE_OAK_CHEST_BOAT, PaleOakChestBoat.class, CraftPaleOakChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.PALE_OAK_CHEST_BOAT))); - register(new EntityTypeData<>(EntityType.SPRUCE_BOAT, SpruceBoat.class, CraftSpruceBoat::new, createAndMove(net.minecraft.world.entity.EntityType.SPRUCE_BOAT))); - register(new EntityTypeData<>(EntityType.SPRUCE_CHEST_BOAT, SpruceChestBoat.class, CraftSpruceChestBoat::new, createAndMove(net.minecraft.world.entity.EntityType.SPRUCE_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.ACACIA_BOAT, AcaciaBoat.class, CraftAcaciaBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.ACACIA_BOAT))); + register(new EntityTypeData<>(EntityType.ACACIA_CHEST_BOAT, AcaciaChestBoat.class, CraftAcaciaChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.ACACIA_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.BAMBOO_RAFT, BambooRaft.class, CraftBambooRaft::new, createAndMove(net.minecraft.world.entity.EntityTypes.BAMBOO_RAFT))); + register(new EntityTypeData<>(EntityType.BAMBOO_CHEST_RAFT, BambooChestRaft.class, CraftBambooChestRaft::new, createAndMove(net.minecraft.world.entity.EntityTypes.BAMBOO_CHEST_RAFT))); + register(new EntityTypeData<>(EntityType.BIRCH_BOAT, BirchBoat.class, CraftBirchBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.BIRCH_BOAT))); + register(new EntityTypeData<>(EntityType.BIRCH_CHEST_BOAT, BirchChestBoat.class, CraftBirchChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.BIRCH_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.CHERRY_BOAT, CherryBoat.class, CraftCherryBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.CHERRY_BOAT))); + register(new EntityTypeData<>(EntityType.CHERRY_CHEST_BOAT, CherryChestBoat.class, CraftCherryChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.CHERRY_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.DARK_OAK_BOAT, DarkOakBoat.class, CraftDarkOakBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.DARK_OAK_BOAT))); + register(new EntityTypeData<>(EntityType.DARK_OAK_CHEST_BOAT, DarkOakChestBoat.class, CraftDarkOakChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.DARK_OAK_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.JUNGLE_BOAT, JungleBoat.class, CraftJungleBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.JUNGLE_BOAT))); + register(new EntityTypeData<>(EntityType.JUNGLE_CHEST_BOAT, JungleChestBoat.class, CraftJungleChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.JUNGLE_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.MANGROVE_BOAT, MangroveBoat.class, CraftMangroveBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.MANGROVE_BOAT))); + register(new EntityTypeData<>(EntityType.MANGROVE_CHEST_BOAT, MangroveChestBoat.class, CraftMangroveChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.MANGROVE_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.OAK_BOAT, OakBoat.class, CraftOakBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.OAK_BOAT))); + register(new EntityTypeData<>(EntityType.OAK_CHEST_BOAT, OakChestBoat.class, CraftOakChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.OAK_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.PALE_OAK_BOAT, PaleOakBoat.class, CraftPaleOakBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.PALE_OAK_BOAT))); + register(new EntityTypeData<>(EntityType.PALE_OAK_CHEST_BOAT, PaleOakChestBoat.class, CraftPaleOakChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.PALE_OAK_CHEST_BOAT))); + register(new EntityTypeData<>(EntityType.SPRUCE_BOAT, SpruceBoat.class, CraftSpruceBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.SPRUCE_BOAT))); + register(new EntityTypeData<>(EntityType.SPRUCE_CHEST_BOAT, SpruceChestBoat.class, CraftSpruceChestBoat::new, createAndMove(net.minecraft.world.entity.EntityTypes.SPRUCE_CHEST_BOAT))); // Set pos - register(new EntityTypeData<>(EntityType.MARKER, Marker.class, CraftMarker::new, createAndSetPos(net.minecraft.world.entity.EntityType.MARKER))); - register(new EntityTypeData<>(EntityType.BLOCK_DISPLAY, BlockDisplay.class, CraftBlockDisplay::new, combine(createAndSetPos(net.minecraft.world.entity.EntityType.BLOCK_DISPLAY), ROT))); // Paper - register(new EntityTypeData<>(EntityType.INTERACTION, Interaction.class, CraftInteraction::new, createAndSetPos(net.minecraft.world.entity.EntityType.INTERACTION))); - register(new EntityTypeData<>(EntityType.ITEM_DISPLAY, ItemDisplay.class, CraftItemDisplay::new, combine(createAndSetPos(net.minecraft.world.entity.EntityType.ITEM_DISPLAY), ROT))); // Paper - register(new EntityTypeData<>(EntityType.TEXT_DISPLAY, TextDisplay.class, CraftTextDisplay::new, combine(createAndSetPos(net.minecraft.world.entity.EntityType.TEXT_DISPLAY), ROT))); // Paper + register(new EntityTypeData<>(EntityType.MARKER, Marker.class, CraftMarker::new, createAndSetPos(net.minecraft.world.entity.EntityTypes.MARKER))); + register(new EntityTypeData<>(EntityType.BLOCK_DISPLAY, BlockDisplay.class, CraftBlockDisplay::new, combine(createAndSetPos(net.minecraft.world.entity.EntityTypes.BLOCK_DISPLAY), ROT))); // Paper + register(new EntityTypeData<>(EntityType.INTERACTION, Interaction.class, CraftInteraction::new, createAndSetPos(net.minecraft.world.entity.EntityTypes.INTERACTION))); + register(new EntityTypeData<>(EntityType.ITEM_DISPLAY, ItemDisplay.class, CraftItemDisplay::new, combine(createAndSetPos(net.minecraft.world.entity.EntityTypes.ITEM_DISPLAY), ROT))); // Paper + register(new EntityTypeData<>(EntityType.TEXT_DISPLAY, TextDisplay.class, CraftTextDisplay::new, combine(createAndSetPos(net.minecraft.world.entity.EntityTypes.TEXT_DISPLAY), ROT))); // Paper // MISC register(new EntityTypeData<>(EntityType.ITEM, Item.class, CraftItem::new, spawnData -> { @@ -454,7 +456,7 @@ Level minecraftWorld() { register(new EntityTypeData<>(EntityType.EXPERIENCE_ORB, ExperienceOrb.class, CraftExperienceOrb::new, combine(combine(spawnData -> new net.minecraft.world.entity.ExperienceOrb(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), 0, org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM, null, null), CLEAR_MOVE_IF_NOT_RANDOMIZED), (spawnData, experienceOrb) -> { if (!spawnData.randomizeData()) { experienceOrb.setYRot(0); } }) // Paper - respect randomizeData )); - register(new EntityTypeData<>(EntityType.AREA_EFFECT_CLOUD, AreaEffectCloud.class, CraftAreaEffectCloud::new, createAndMove(net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD))); // Paper - set area effect cloud rotation + register(new EntityTypeData<>(EntityType.AREA_EFFECT_CLOUD, AreaEffectCloud.class, CraftAreaEffectCloud::new, createAndMove(net.minecraft.world.entity.EntityTypes.AREA_EFFECT_CLOUD))); // Paper - set area effect cloud rotation register(new EntityTypeData<>(EntityType.EGG, Egg.class, CraftEgg::new, spawnData -> new ThrownEgg(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.EGG)))); register(new EntityTypeData<>(EntityType.LEASH_KNOT, LeashHitch.class, CraftLeash::new, spawnData -> new LeashFenceKnotEntity(spawnData.minecraftWorld(), BlockPos.containing(spawnData.x(), spawnData.y(), spawnData.z())))); // SPIGOT-5732: LeashHitch has no direction and is always centered at a block register(new EntityTypeData<>(EntityType.SNOWBALL, Snowball.class, CraftSnowball::new, spawnData -> new net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.SNOWBALL)))); @@ -479,13 +481,13 @@ Level minecraftWorld() { })); // Paper end - respect randomizeData register(new EntityTypeData<>(EntityType.EVOKER_FANGS, EvokerFangs.class, CraftEvokerFangs::new, spawnData -> new net.minecraft.world.entity.projectile.EvokerFangs(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), (float) Math.toRadians(spawnData.yaw()), 0, null))); - register(new EntityTypeData<>(EntityType.COMMAND_BLOCK_MINECART, CommandMinecart.class, CraftMinecartCommand::new, createMinecart(net.minecraft.world.entity.EntityType.COMMAND_BLOCK_MINECART))); - register(new EntityTypeData<>(EntityType.MINECART, RideableMinecart.class, CraftMinecartRideable::new, createMinecart(net.minecraft.world.entity.EntityType.MINECART))); - register(new EntityTypeData<>(EntityType.CHEST_MINECART, StorageMinecart.class, CraftMinecartChest::new, createMinecart(net.minecraft.world.entity.EntityType.CHEST_MINECART))); - register(new EntityTypeData<>(EntityType.FURNACE_MINECART, PoweredMinecart.class, CraftMinecartFurnace::new, createMinecart(net.minecraft.world.entity.EntityType.FURNACE_MINECART))); - register(new EntityTypeData<>(EntityType.TNT_MINECART, ExplosiveMinecart.class, CraftMinecartTNT::new, createMinecart(net.minecraft.world.entity.EntityType.TNT_MINECART))); - register(new EntityTypeData<>(EntityType.HOPPER_MINECART, HopperMinecart.class, CraftMinecartHopper::new, createMinecart(net.minecraft.world.entity.EntityType.HOPPER_MINECART))); - register(new EntityTypeData<>(EntityType.SPAWNER_MINECART, SpawnerMinecart.class, CraftMinecartMobSpawner::new, createMinecart(net.minecraft.world.entity.EntityType.SPAWNER_MINECART))); + register(new EntityTypeData<>(EntityType.COMMAND_BLOCK_MINECART, CommandMinecart.class, CraftMinecartCommand::new, createMinecart(net.minecraft.world.entity.EntityTypes.COMMAND_BLOCK_MINECART))); + register(new EntityTypeData<>(EntityType.MINECART, RideableMinecart.class, CraftMinecartRideable::new, createMinecart(net.minecraft.world.entity.EntityTypes.MINECART))); + register(new EntityTypeData<>(EntityType.CHEST_MINECART, StorageMinecart.class, CraftMinecartChest::new, createMinecart(net.minecraft.world.entity.EntityTypes.CHEST_MINECART))); + register(new EntityTypeData<>(EntityType.FURNACE_MINECART, PoweredMinecart.class, CraftMinecartFurnace::new, createMinecart(net.minecraft.world.entity.EntityTypes.FURNACE_MINECART))); + register(new EntityTypeData<>(EntityType.TNT_MINECART, ExplosiveMinecart.class, CraftMinecartTNT::new, createMinecart(net.minecraft.world.entity.EntityTypes.TNT_MINECART))); + register(new EntityTypeData<>(EntityType.HOPPER_MINECART, HopperMinecart.class, CraftMinecartHopper::new, createMinecart(net.minecraft.world.entity.EntityTypes.HOPPER_MINECART))); + register(new EntityTypeData<>(EntityType.SPAWNER_MINECART, SpawnerMinecart.class, CraftMinecartMobSpawner::new, createMinecart(net.minecraft.world.entity.EntityTypes.SPAWNER_MINECART))); // None spawn able register(new EntityTypeData<>(EntityType.FISHING_BOBBER, FishHook.class, CraftFishHook::new, null)); // Cannot spawn a fish hook diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index aefc65543fc1..d1448cf50f15 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -2,6 +2,8 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Sets; +import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.world.damagesource.CombatTracker; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -10,10 +12,8 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; -import io.papermc.paper.adventure.PaperAdventure; import net.kyori.adventure.key.Key; import net.minecraft.Optionull; -import io.papermc.paper.world.damagesource.CombatTracker; import net.minecraft.core.component.DataComponents; import net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket; import net.minecraft.resources.ResourceKey; @@ -26,19 +26,19 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.EntitySpawnReason; -import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.decoration.ArmorStand; import net.minecraft.world.entity.decoration.Mannequin; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball; import net.minecraft.world.entity.projectile.ThrowableProjectile; +import net.minecraft.world.entity.projectile.arrow.ThrownTrident; +import net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball; import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg; import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownExperienceBottle; -import net.minecraft.world.entity.projectile.arrow.ThrownTrident; import net.minecraft.world.item.Items; import net.minecraft.world.item.component.Consumable; import net.minecraft.world.phys.Vec3; @@ -74,7 +74,6 @@ import org.bukkit.entity.Fireball; import org.bukkit.entity.Firework; import org.bukkit.entity.FishHook; -import org.bukkit.entity.HumanEntity; import org.bukkit.entity.LingeringPotion; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LlamaSpit; @@ -416,12 +415,11 @@ public void damage(double amount) { @Override public void damage(double amount, org.bukkit.entity.Entity source) { - DamageSource reason = this.getHandle().damageSources().generic(); - - if (source instanceof HumanEntity) { - reason = this.getHandle().damageSources().playerAttack(((CraftHumanEntity) source).getHandle()); - } else if (source instanceof LivingEntity) { - reason = this.getHandle().damageSources().mobAttack(((CraftLivingEntity) source).getHandle()); + final DamageSource reason; + if (source instanceof LivingEntity) { + reason = ((CraftLivingEntity) source).getHandle().createDamageSource(); + } else { + reason = this.getHandle().damageSources().generic(); } this.damage(amount, reason); @@ -435,10 +433,9 @@ public void damage(double amount, org.bukkit.damage.DamageSource damageSource) { } private void damage(double amount, DamageSource damageSource) { - Preconditions.checkArgument(damageSource != null, "damageSource cannot be null"); Preconditions.checkState(!this.getHandle().generation, "Cannot damage entity during world generation"); - this.entity.hurt(damageSource, (float) amount); + this.entity.hurtServer((ServerLevel) this.getHandle().level(), damageSource, (float) amount); } @Override @@ -606,9 +603,9 @@ public T launchProjectile(Class projectile, launch = new net.minecraft.world.entity.projectile.hurtingprojectile.DragonFireball(world, this.getHandle(), vec); } else if (AbstractWindCharge.class.isAssignableFrom(projectile)) { if (BreezeWindCharge.class.isAssignableFrom(projectile)) { - launch = EntityType.BREEZE_WIND_CHARGE.create(world, EntitySpawnReason.TRIGGERED); + launch = EntityTypes.BREEZE_WIND_CHARGE.create(world, EntitySpawnReason.TRIGGERED); } else { - launch = EntityType.WIND_CHARGE.create(world, EntitySpawnReason.TRIGGERED); + launch = EntityTypes.WIND_CHARGE.create(world, EntitySpawnReason.TRIGGERED); } ((net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle()); @@ -623,7 +620,7 @@ public T launchProjectile(Class projectile, Location location = this.getEyeLocation(); Vector direction = location.getDirection(); - launch = EntityType.LLAMA_SPIT.create(world, EntitySpawnReason.TRIGGERED); + launch = EntityTypes.LLAMA_SPIT.create(world, EntitySpawnReason.TRIGGERED); ((net.minecraft.world.entity.projectile.LlamaSpit) launch).setOwner(this.getHandle()); ((net.minecraft.world.entity.projectile.LlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F); // EntityLlama @@ -1029,7 +1026,7 @@ public void setHurtDirection(final float hurtDirection) { @Override public void knockback(final double strength, final double directionX, final double directionZ) { Preconditions.checkArgument(strength > 0, "Knockback strength must be > 0"); - this.getHandle().knockback(strength, directionX, directionZ); + this.getHandle().knockback(strength, directionX, directionZ, this.getHandle().damageSources().generic(), 0.0F); // todo - snapshot - api - expose damage source and/or damage } public void broadcastSlotBreak(final org.bukkit.inventory.EquipmentSlot slot) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java index 8720425ea9f9..4e51bd14f84a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java @@ -3,14 +3,14 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.MagmaCube; -public class CraftMagmaCube extends CraftSlime implements MagmaCube { +public class CraftMagmaCube extends CraftAbstractCubeMob implements MagmaCube { - public CraftMagmaCube(CraftServer server, net.minecraft.world.entity.monster.MagmaCube entity) { + public CraftMagmaCube(CraftServer server, net.minecraft.world.entity.monster.cubemob.MagmaCube entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.MagmaCube getHandle() { - return (net.minecraft.world.entity.monster.MagmaCube) this.entity; + public net.minecraft.world.entity.monster.cubemob.MagmaCube getHandle() { + return (net.minecraft.world.entity.monster.cubemob.MagmaCube) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java index cb6a367deb2a..c2faff9b6910 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java @@ -97,6 +97,6 @@ public boolean canBreed() { } @Override - public void setBreed(boolean b) { + public void setBreed(boolean breed) { } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 2e95fee39986..b47a215db4b1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -119,6 +119,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntitySpawnRequest; import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.item.ItemEntity; @@ -1687,7 +1688,7 @@ public int applyMending(int amount) { .getRandomItemWith(net.minecraft.world.item.enchantment.EnchantmentEffectComponents.REPAIR_WITH_XP, handle, net.minecraft.world.item.ItemStack::isDamaged); final net.minecraft.world.item.ItemStack itemstack = selected.map(net.minecraft.world.item.enchantment.EnchantedItemInUse::itemStack).orElse(net.minecraft.world.item.ItemStack.EMPTY); if (!itemstack.isEmpty() && itemstack.getItem().components().has(net.minecraft.core.component.DataComponents.MAX_DAMAGE)) { - net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level(), net.minecraft.world.entity.EntitySpawnReason.COMMAND); + net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityTypes.EXPERIENCE_ORB.create(handle.level(), net.minecraft.world.entity.EntitySpawnReason.COMMAND); orb.setValue(amount); orb.spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM; orb.setPosRaw(handle.getX(), handle.getY(), handle.getZ()); @@ -3317,7 +3318,7 @@ public org.bukkit.entity.Entity getShoulderEntityLeft() { return net.minecraft.world.entity.EntityType.create( TagValueInput.create(scopedCollector.forChild(() -> ".shoulder"), this.getHandle().registryAccess(), this.getHandle().getShoulderEntityLeft()), this.getHandle().level(), - EntitySpawnReason.LOAD + new EntitySpawnRequest(EntitySpawnReason.LOAD, false) ).map(Entity::getBukkitEntity).orElse(null); } } @@ -3343,7 +3344,7 @@ public org.bukkit.entity.Entity getShoulderEntityRight() { return net.minecraft.world.entity.EntityType.create( TagValueInput.create(scopedCollector.forChild(() -> ".shoulder"), this.getHandle().registryAccess(), this.getHandle().getShoulderEntityRight()), this.getHandle().level(), - EntitySpawnReason.LOAD + new EntitySpawnRequest(EntitySpawnReason.LOAD, false) ).map(Entity::getBukkitEntity).orElse(null); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java index 214e636701a5..28a5ad75e01b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java @@ -3,34 +3,13 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Slime; -public class CraftSlime extends CraftMob implements Slime, CraftEnemy { - - public CraftSlime(CraftServer server, net.minecraft.world.entity.monster.Slime entity) { +public class CraftSlime extends CraftAbstractCubeMob implements Slime, CraftEnemy { + public CraftSlime(final CraftServer server, final net.minecraft.world.entity.monster.cubemob.Slime entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Slime getHandle() { - return (net.minecraft.world.entity.monster.Slime) this.entity; - } - - @Override - public int getSize() { - return this.getHandle().getSize(); - } - - @Override - public void setSize(int size) { - this.getHandle().setSize(size, /* true */ getHandle().isAlive()); // Paper - fix dead slime setSize invincibility - } - - @Override - public boolean canWander() { - return this.getHandle().canWander(); - } - - @Override - public void setWander(boolean canWander) { - this.getHandle().setWander(canWander); + public net.minecraft.world.entity.monster.cubemob.Slime getHandle() { + return (net.minecraft.world.entity.monster.cubemob.Slime) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSulfurCube.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSulfurCube.java new file mode 100644 index 000000000000..7a2e9c8d693c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSulfurCube.java @@ -0,0 +1,105 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import io.papermc.paper.entity.PaperBucketable; +import io.papermc.paper.entity.PaperShearable; +import io.papermc.paper.registry.HolderableBase; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.SulfurCubeArchetype; +import net.minecraft.world.entity.item.PrimedTnt; +import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.SulfurCube; + +public class CraftSulfurCube extends CraftAbstractCubeMob implements SulfurCube, PaperShearable, PaperBucketable { + public CraftSulfurCube(final CraftServer server, final net.minecraft.world.entity.monster.cubemob.SulfurCube entity) { + super(server, entity); + } + + @Override + public net.minecraft.world.entity.monster.cubemob.SulfurCube getHandle() { + return (net.minecraft.world.entity.monster.cubemob.SulfurCube) this.entity; + } + + @Override + public int getFuseTicks() { + return this.getHandle().getFuse(); + } + + @Override + public void setFuseTicks(final int ticks) { + Preconditions.checkArgument(ticks == PrimedTnt.NO_FUSE || ticks > 0, "ticks must be positive or %s", PrimedTnt.NO_FUSE); + this.getHandle().setFuse(ticks); + this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.cubemob.SulfurCube.MAX_FUSE, ticks); + } + + @Override + public boolean canExplode() { + return this.getHandle().canExplode(); + } + + @Override + public boolean ignite(final boolean imminent) { + return this.getHandle().primeTime(imminent); + } + + @Override + public int getAge() { + return this.getHandle().getAge(); + } + + @Override + public void setAge(final int age) { + this.getHandle().setAge(age); + } + + @Override + public void setAgeLock(final boolean lock) { + this.getHandle().setAgeLocked(lock); + } + + @Override + public boolean getAgeLock() { + return this.getHandle().isAgeLocked(); + } + + @Override + public void setBaby() { + CraftAgeable.setBaby(this.getHandle(), true); + } + + @Override + public void setAdult() { + CraftAgeable.setBaby(this.getHandle(), false); + } + + @Override + public boolean isAdult() { + return !this.getHandle().isBaby(); + } + + @Override + public boolean canBreed() { + return false; + } + + @Override + public void setBreed(final boolean breed) { + } + + public static class CraftArchetype extends HolderableBase implements Archetype { + + public static Archetype minecraftHolderToBukkit(Holder minecraft) { + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.SULFUR_CUBE_ARCHETYPE); + } + + public static Holder bukkitToMinecraftHolder(Archetype bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); + } + + public CraftArchetype(final Holder holder) { + super(holder); + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index 80cc06f91f80..e9dc62fa360f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -6,6 +6,7 @@ import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.entity.Mob; import org.bukkit.entity.Vex; public class CraftVex extends CraftMonster implements Vex { @@ -21,8 +22,8 @@ public net.minecraft.world.entity.monster.Vex getHandle() { @Override public org.bukkit.entity.Mob getSummoner() { - net.minecraft.world.entity.Mob owner = this.getHandle().getOwner(); - return owner != null ? (org.bukkit.entity.Mob) owner.getBukkitEntity() : null; + net.minecraft.world.entity.LivingEntity owner = this.getHandle().getOwner(); + return owner instanceof net.minecraft.world.entity.Mob mob ? (Mob) mob.getBukkitEntity() : null; // todo - snapshot - the summoner/owner can be any LivingEntity now } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index d37de00e5b9a..8184b397fc3b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -176,7 +176,7 @@ public static Holder bukkitToMinecraftHolder(Type bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } - public CraftType(final Holder holder){ + public CraftType(final Holder holder) { super(holder, count++); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java index 442d5fa7bc34..bf96258e19f5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java @@ -64,6 +64,6 @@ public boolean canBreed() { } @Override - public void setBreed(boolean b) { + public void setBreed(boolean breed) { } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index def476715af2..08c549628e17 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -144,7 +144,7 @@ public boolean canBreed() { } @Override - public void setBreed(boolean b) { + public void setBreed(boolean breed) { } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 7a42d1810f74..72bc687efb64 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -12,6 +12,7 @@ import io.papermc.paper.connection.PlayerConnection; import io.papermc.paper.event.block.BlockLockCheckEvent; import io.papermc.paper.event.connection.PlayerConnectionValidateLoginEvent; +import io.papermc.paper.event.entity.EntityIgniteEvent; import io.papermc.paper.event.entity.ItemTransportingEntityValidateTargetEvent; import io.papermc.paper.event.player.PlayerBedFailEnterEvent; import io.papermc.paper.event.player.PlayerToggleEntityAgeLockEvent; @@ -21,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; import net.minecraft.commands.CommandSourceStack; @@ -47,9 +49,11 @@ import net.minecraft.world.entity.Leashable; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.PathfinderMob; +import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.fish.AbstractFish; import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.item.PrimedTnt; import net.minecraft.world.entity.monster.illager.SpellcasterIllager; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.entity.raid.Raid; @@ -951,49 +955,51 @@ public static boolean handleBlockSpreadEvent(LevelAccessor level, BlockPos sourc return false; } - public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, DamageSource damageSource) { - return CraftEventFactory.callEntityDeathEvent(victim, damageSource, new ArrayList<>(0)); // Paper - Restore vanilla drops behavior - } - - public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, DamageSource damageSource, List drops) { // Paper - Restore vanilla drops behavior - // Paper start - return CraftEventFactory.callEntityDeathEvent(victim, damageSource, drops, com.google.common.util.concurrent.Runnables.doNothing()); - } - private static final java.util.function.Function FROM_FUNCTION = stack -> { if (stack == null) return null; return new Entity.DefaultDrop(CraftItemType.bukkitToMinecraft(stack.getType()), stack, null); }; - public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, DamageSource damageSource, List drops, Runnable lootCheck) { // Paper - Restore vanilla drops behavior - // Paper end + public static boolean callEntityDeathEvent(ServerLevel level, net.minecraft.world.entity.LivingEntity victim, DamageSource damageSource) { + EntityDeathEvent event = callEntityDeathEvent(level, victim, damageSource, new ArrayList<>(0), false); + return !event.isCancelled(); + } + + public static EntityDeathEvent callEntityDeathEvent(ServerLevel level, net.minecraft.world.entity.LivingEntity victim, DamageSource damageSource, List drops, boolean delayedDrops) { // Paper - Restore vanilla drops behavior CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); - CraftWorld world = (CraftWorld) entity.getWorld(); - EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(world.getHandle(), damageSource.getEntity())); // Paper - Restore vanilla drops behavior + EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(level, damageSource.getEntity())); // Paper - Restore vanilla drops behavior populateFields(victim, event); // Paper - make cancellable - Bukkit.getServer().getPluginManager().callEvent(event); + event.callEvent(); - // Paper start - make cancellable if (event.isCancelled()) { return event; } + playDeathSound(victim, event, damageSource); - // Paper end victim.expToDrop = event.getDroppedExp(); - lootCheck.run(); // Paper - advancement triggers before destroying items - // Paper start - Restore vanilla drops behavior + Runnable dropAll = () -> { + dropAllItems(drops, item -> victim.spawnAtLocation(level, item)); + }; + + if (delayedDrops) { + victim.postDeathEventTasks.add(dropAll); + } else { + dropAll.run(); + } + + return event; + } + + private static void dropAllItems(List drops, Consumer fallback) { for (Entity.DefaultDrop drop : drops) { if (drop == null) continue; final org.bukkit.inventory.ItemStack stack = drop.stack(); - // Paper end - Restore vanilla drops behavior - if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue; + if (stack.isEmpty()) continue; - drop.runConsumer(s -> world.dropItem(entity.getLocation(), s)); // Paper - Restore vanilla drops behavior + drop.runConsumer(item -> fallback.accept(CraftItemStack.unwrap(item))); } - - return event; } public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, DamageSource damageSource, List drops, net.kyori.adventure.text.Component deathMessage, boolean showDeathMessages, boolean keepInventory) { @@ -1017,15 +1023,7 @@ public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, DamageS victim.expToDrop = event.getDroppedExp(); victim.newExp = event.getNewExp(); - // Paper start - Restore vanilla drops behavior - for (Entity.DefaultDrop drop : drops) { - if (drop == null) continue; - final org.bukkit.inventory.ItemStack stack = drop.stack(); - // Paper end - Restore vanilla drops behavior - if (stack == null || stack.getType() == Material.AIR) continue; - - drop.runConsumer(s -> victim.drop(CraftItemStack.unwrap(s), true, false)); // Paper - Restore vanilla drops behavior - } + dropAllItems(drops, item -> victim.drop(item, true, false)); return event; } @@ -1033,9 +1031,10 @@ public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, DamageS // Paper start - helper methods for making death event cancellable // Add information to death event private static void populateFields(net.minecraft.world.entity.LivingEntity victim, EntityDeathEvent event) { - event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.MAX_HEALTH).getValue()); + event.setReviveHealth(victim.getAttribute(Attributes.MAX_HEALTH).getValue()); event.setShouldPlayDeathSound(!victim.silentDeath && !victim.isSilent()); net.minecraft.sounds.SoundEvent soundEffect = victim.getDeathSound(); + // todo this feels overblown better to just provide a way to cancel the sound and plugins play their own sound event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.minecraftToBukkit(soundEffect) : null); event.setDeathSoundCategory(org.bukkit.SoundCategory.valueOf(victim.getSoundSource().name())); event.setDeathSoundVolume(victim.getSoundVolume()); @@ -1063,18 +1062,14 @@ private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSo private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map modifiers, Map> modifierFunctions, boolean cancelled) { CraftDamageSource bukkitDamageSource = new CraftDamageSource(source); - final Entity damager = source.eventEntityDamager() != null ? source.eventEntityDamager() : source.getDirectEntity(); // Paper - fix DamageSource API - if (source.is(DamageTypeTags.IS_EXPLOSION)) { - if (damager == null) { - return CraftEventFactory.callEntityDamageEvent(source.eventBlockDamager(), source.causingBlockSnapshot(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled); - } - DamageCause damageCause = (damager.getBukkitEntity() instanceof org.bukkit.entity.TNTPrimed) ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION; - return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API - } else if (damager != null || source.getDirectEntity() != null) { + final Entity damager = source.eventEntityDamager() != null ? source.eventEntityDamager() : source.getDirectEntity(); + if (damager != null) { DamageCause cause = DamageCause.ENTITY_ATTACK; if (source.knownCause() != null) { cause = source.knownCause(); + } else if (source.is(DamageTypes.FIREWORKS) || source.is(DamageTypes.EXPLOSION) || source.is(DamageTypes.PLAYER_EXPLOSION)) { // look at relevant items in #is_explosion tag + cause = damager instanceof PrimedTnt ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION; } else if (damager instanceof net.minecraft.world.entity.projectile.Projectile) { if (damager.getBukkitEntity() instanceof ThrownPotion) { cause = DamageCause.MAGIC; @@ -1089,33 +1084,30 @@ private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSo cause = DamageCause.FALLING_BLOCK; } else if (source.is(DamageTypes.LIGHTNING_BOLT)) { cause = DamageCause.LIGHTNING; - } else if (source.is(DamageTypes.FALL)) { - cause = DamageCause.FALL; } else if (source.is(DamageTypes.DRAGON_BREATH)) { - cause = DamageCause.DRAGON_BREATH; + cause = DamageCause.DRAGON_BREATH; // never used } else if (source.is(DamageTypes.MAGIC)) { cause = DamageCause.MAGIC; } return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API - } else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) { + } else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) { // why this is a block event, damager is always null and no snapshot either return CraftEventFactory.callEntityDamageEvent(source.eventBlockDamager(), source.causingBlockSnapshot(), entity, DamageCause.VOID, bukkitDamageSource, modifiers, modifierFunctions, cancelled); - } else if (source.is(DamageTypes.LAVA)) { + } else if (source.is(DamageTypes.LAVA)) { // todo move below once lastLavaContact is defined return CraftEventFactory.callEntityDamageEvent(source.eventBlockDamager(), source.causingBlockSnapshot(), entity, DamageCause.LAVA, bukkitDamageSource, modifiers, modifierFunctions, cancelled); - } else if (source.eventBlockDamager() != null) { + } else if (source.eventBlockDamager() != null || source.causingBlockSnapshot() != null) { DamageCause cause; if (source.knownCause() != null) { cause = source.knownCause(); - } else if (source.is(DamageTypes.CACTUS) || source.is(DamageTypes.SWEET_BERRY_BUSH) || source.is(DamageTypes.STALAGMITE) || source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_ANVIL)) { + } else if (source.is(DamageTypes.CACTUS) || source.is(DamageTypes.SWEET_BERRY_BUSH) || source.is(DamageTypes.STALAGMITE) || + source.is(DamageTypes.HOT_FLOOR) || source.is(DamageTypes.CAMPFIRE)) { cause = DamageCause.CONTACT; - } else if (source.is(DamageTypes.HOT_FLOOR)) { - cause = DamageCause.HOT_FLOOR; } else if (source.is(DamageTypes.MAGIC)) { cause = DamageCause.MAGIC; } else if (source.is(DamageTypes.IN_FIRE)) { cause = DamageCause.FIRE; - } else if (source.is(DamageTypes.CAMPFIRE)) { - cause = DamageCause.CAMPFIRE; + } else if (source.is(DamageTypes.BAD_RESPAWN_POINT)) { + cause = DamageCause.BLOCK_EXPLOSION; } else { cause = DamageCause.CUSTOM; } @@ -1125,7 +1117,7 @@ private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSo DamageCause cause; if (source.knownCause() != null) { cause = source.knownCause(); - } else if (source.is(DamageTypes.IN_FIRE)) { + } else if (source.is(DamageTypes.IN_FIRE)) { // todo could be called above cause = DamageCause.FIRE; } else if (source.is(DamageTypes.STARVE)) { cause = DamageCause.STARVATION; @@ -1326,8 +1318,8 @@ public static FoodLevelChangeEvent callFoodLevelChangeEvent(net.minecraft.world. return event; } - public static PigZapEvent callPigZapEvent(Entity pig, Entity lightning, Entity pigzombie) { - PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity()); + public static PigZapEvent callPigZapEvent(Entity pig, Entity lightning, Entity zombifiedPiglin) { + PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) zombifiedPiglin.getBukkitEntity()); pig.getBukkitEntity().getServer().getPluginManager().callEvent(event); return event; } @@ -1700,20 +1692,16 @@ public static boolean callPlayerRiptideEvent(net.minecraft.world.entity.player.P return event.callEvent(); } - public static BlockShearEntityEvent callBlockShearEntityEvent(Entity animal, org.bukkit.block.Block dispenser, CraftItemStack is, List drops) { // Paper - custom shear drops - BlockShearEntityEvent bse = new BlockShearEntityEvent(dispenser, animal.getBukkitEntity(), is, Lists.transform(drops, CraftItemStack::asCraftMirror)); // Paper - custom shear drops - Bukkit.getPluginManager().callEvent(bse); - return bse; + public static BlockShearEntityEvent callBlockShearEntityEvent(Entity animal, org.bukkit.block.Block dispenser, CraftItemStack is, List drops) { + BlockShearEntityEvent event = new BlockShearEntityEvent(dispenser, animal.getBukkitEntity(), is, Lists.transform(drops, CraftItemStack::asCraftMirror)); + Bukkit.getPluginManager().callEvent(event); + return event; } - public static PlayerShearEntityEvent handlePlayerShearEntityEvent(net.minecraft.world.entity.player.Player player, Entity sheared, ItemStack shears, InteractionHand hand, List drops) { // Paper - custom shear drops - if (!(player instanceof ServerPlayer)) { - return null; // Paper - custom shear drops - } - - PlayerShearEntityEvent event = new PlayerShearEntityEvent((Player) player.getBukkitEntity(), sheared.getBukkitEntity(), CraftItemStack.asCraftMirror(shears), (hand == InteractionHand.OFF_HAND ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND), Lists.transform(drops, CraftItemStack::asCraftMirror)); // Paper - custom shear drops + public static PlayerShearEntityEvent handlePlayerShearEntityEvent(net.minecraft.world.entity.player.Player player, Entity sheared, ItemStack shears, InteractionHand hand, List drops) { + PlayerShearEntityEvent event = new PlayerShearEntityEvent(((ServerPlayer) player).getBukkitEntity(), sheared.getBukkitEntity(), CraftItemStack.asCraftMirror(shears), CraftEquipmentSlot.getHand(hand), Lists.transform(drops, CraftItemStack::asCraftMirror)); Bukkit.getPluginManager().callEvent(event); - return event; // Paper - custom shear drops + return event; } public static Cancellable handleStatisticsIncrease(net.minecraft.world.entity.player.Player entityHuman, net.minecraft.stats.Stat statistic, int current, int newValue) { @@ -1811,7 +1799,7 @@ public static void callPrepareResultEvent(AbstractContainerMenu container, int r } event.callEvent(); event.getInventory().setItem(resultSlot, event.getResult()); - container.broadcastChanges();; + container.broadcastChanges(); } public static SpawnerSpawnEvent callSpawnerSpawnEvent(Entity spawnee, BlockPos pos) { @@ -2253,20 +2241,19 @@ public static boolean handleBlockFailedDispenseEvent(ServerLevel serverLevel, Bl return event.callEvent(); } - public static boolean handleBlockPreDispenseEvent(ServerLevel serverLevel, BlockPos pos, ItemStack itemStack, int slot) { - org.bukkit.block.Block block = CraftBlock.at(serverLevel, pos); + public static boolean handleBlockPreDispenseEvent(ServerLevel level, BlockPos pos, ItemStack itemStack, int slot) { + org.bukkit.block.Block block = CraftBlock.at(level, pos); io.papermc.paper.event.block.BlockPreDispenseEvent event = new io.papermc.paper.event.block.BlockPreDispenseEvent(block, org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), slot); return event.callEvent(); } - @Nullable - public static ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.BlockSource pointer, BlockPos to, ItemStack itemStack, net.minecraft.core.dispenser.DispenseItemBehavior instance) { + public static @Nullable ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.BlockSource pointer, BlockPos to, ItemStack dispensed, net.minecraft.core.dispenser.DispenseItemBehavior instance) { org.bukkit.block.Block bukkitBlock = CraftBlock.at(pointer.level(), pointer.pos()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.isDamageableItem() ? itemStack : itemStack.copyWithCount(1)); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(dispensed.isDamageableItem() ? dispensed : dispensed.copyWithCount(1)); org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to)); if (!event.callEvent()) { - return itemStack; + return dispensed; } if (!event.getItem().equals(craftItem)) { @@ -2275,7 +2262,7 @@ public static ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.Bl net.minecraft.core.dispenser.DispenseItemBehavior itemBehavior = net.minecraft.world.level.block.DispenserBlock.getDispenseBehavior(pointer, eventStack); if (itemBehavior != net.minecraft.core.dispenser.DispenseItemBehavior.NOOP && itemBehavior != instance) { itemBehavior.dispense(pointer, eventStack); - return itemStack; + return dispensed; } } return null; @@ -2427,4 +2414,16 @@ public static ClockTimeSkipEvent createTimeSkipEvent(final CommandSourceStack so } return new TimeSkipEvent(source.getLevel().getWorld(), ClockTimeSkipEvent.SkipReason.COMMAND, skipAmount); } + + public static int callEntityIgniteEvent(Entity entity, int fuseTime) { + if (EntityIgniteEvent.getHandlerList().getRegisteredListeners().length == 0) { + return fuseTime; // No listeners, skip event creation + } + + EntityIgniteEvent event = new EntityIgniteEvent(entity.getBukkitEntity(), fuseTime); + if (!event.callEvent()) { + return PrimedTnt.NO_FUSE; + } + return event.getFuseTime(); + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java index 9e6cf5abc55c..2ea5c7310bdd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java @@ -15,6 +15,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntitySpawnRequest; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.WorldGenLevel; @@ -91,7 +92,7 @@ public void loadEntities() { for (int z = -(this.buffer >> 4); z <= (this.buffer >> 4); z++) { ProtoChunk chunk = (ProtoChunk) access.getChunk(this.centerChunkX + x, this.centerChunkZ + z); for (CompoundTag compound : chunk.getEntities()) { - EntityType.loadEntityRecursive(compound, access.getMinecraftWorld(), EntitySpawnReason.LOAD, (entity) -> { + EntityType.loadEntityRecursive(compound, access.getMinecraftWorld(), new EntitySpawnRequest(EntitySpawnReason.LOAD, false), (entity) -> { if (this.region.contains(entity.getX(), entity.getY(), entity.getZ())) { entity.generation = true; this.entities.add(entity); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java index 91beb5ff7715..f92a9daafb05 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftWorldInfo.java @@ -22,7 +22,7 @@ public class CraftWorldInfo implements WorldInfo { private final int maxHeight; private final FeatureFlagSet enabledFeatures; private final ChunkGenerator vanillaChunkGenerator; - private final RegistryAccess.Frozen registryAccess; + private final RegistryAccess registryAccess; public CraftWorldInfo( String name, @@ -32,7 +32,7 @@ public CraftWorldInfo( World.Environment environment, DimensionType dimensionType, ChunkGenerator vanillaChunkGenerator, - RegistryAccess.Frozen registryAccess, + RegistryAccess registryAccess, UUID uuid ) { this.name = name; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java index 546b7aa1055c..bf8d61d5fa8f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java @@ -245,7 +245,7 @@ public static ItemMetaData getItemMetaData(CraftItemType return CraftItemMetas.asType(CraftItemMetas.SUSPICIOUS_STEW_META_DATA); } if (itemType == ItemType.COD_BUCKET || itemType == ItemType.PUFFERFISH_BUCKET || itemType == ItemType.TADPOLE_BUCKET - || itemType == ItemType.SALMON_BUCKET || itemType == ItemType.ITEM_FRAME + || itemType == ItemType.SALMON_BUCKET || itemType == ItemType.SULFUR_CUBE_BUCKET || itemType == ItemType.ITEM_FRAME || itemType == ItemType.GLOW_ITEM_FRAME || itemType == ItemType.PAINTING) { return CraftItemMetas.asType(CraftItemMetas.ENTITY_TAG_META_DATA); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 22f2a8c1ee40..de0e88caf608 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -2,12 +2,27 @@ import com.google.common.base.Preconditions; import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.datacomponent.DataComponentTypes; +import io.papermc.paper.datacomponent.PaperDataComponentType; +import io.papermc.paper.inventory.tooltip.TooltipContext; +import io.papermc.paper.persistence.PaperPersistentDataContainerView; +import io.papermc.paper.persistence.PersistentDataContainerView; +import io.papermc.paper.util.MCUtil; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; import net.kyori.adventure.text.Component; -import net.minecraft.advancements.criterion.DataComponentMatchers; -import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.SharedConstants; +import net.minecraft.advancements.predicates.DataComponentMatchers; +import net.minecraft.advancements.predicates.ItemPredicate; import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponentMap; @@ -17,35 +32,48 @@ import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.nbt.Tag; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemInstance; import net.minecraft.world.item.ItemStackTemplate; +import net.minecraft.world.item.Items; import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.item.component.ResolvableProfile; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.ItemEnchantments; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; +import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemType; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.MaterialData; import org.bukkit.persistence.PersistentDataContainer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; @DelegateDeserialization(ItemStack.class) public final class CraftItemStack extends ItemStack { // Paper start - delegate api-ItemStack to CraftItemStack - private static final java.lang.invoke.VarHandle API_ITEM_STACK_CRAFT_DELEGATE_FIELD; + private static final VarHandle API_ITEM_STACK_CRAFT_DELEGATE_FIELD; static { try { - API_ITEM_STACK_CRAFT_DELEGATE_FIELD = java.lang.invoke.MethodHandles.privateLookupIn( + API_ITEM_STACK_CRAFT_DELEGATE_FIELD = MethodHandles.privateLookupIn( ItemStack.class, - java.lang.invoke.MethodHandles.lookup() + MethodHandles.lookup() ).findVarHandle(ItemStack.class, "craftDelegate", ItemStack.class); } catch (final IllegalAccessException | NoSuchFieldException exception) { throw new RuntimeException(exception); @@ -112,8 +140,8 @@ public static net.minecraft.world.item.ItemStack asNMSCopy(@Nullable ItemStack o // Paper end - re-implement after delegating all api ItemStack calls to CraftItemStack } - public static java.util.List asNMSCopy(java.util.List originals) { - final java.util.List items = new java.util.ArrayList<>(originals.size()); + public static List asNMSCopy(List originals) { + final List items = new ArrayList<>(originals.size()); for (final ItemStack original : originals) { items.add(asNMSCopy(original)); } @@ -121,7 +149,7 @@ public static java.util.List asNMSCopy(java. } public static ItemStackTemplate asTemplate(ItemStack bukkit) { - return net.minecraft.world.item.ItemStackTemplate.fromNonEmptyStack(asNMSCopy(bukkit)); + return ItemStackTemplate.fromNonEmptyStack(asNMSCopy(bukkit)); } public static net.minecraft.world.item.ItemStack copyNMSStack(net.minecraft.world.item.ItemStack original, int amount) { @@ -133,14 +161,18 @@ public static net.minecraft.world.item.ItemStack copyNMSStack(net.minecraft.worl /** * Copies the NMS stack to return as a strictly-Bukkit stack */ - public static ItemStack asBukkitCopy(net.minecraft.world.item.ItemStack original) { + private static ItemStack asBukkitCopy(net.minecraft.world.item.ItemStack original) { // no such thing as a "strictly-Bukkit stack" anymore // we copy the stack since it should be a complete copy not a mirror return asCraftMirror(original.copy()); } - public static ItemStack asBukkitCopy(net.minecraft.world.item.ItemStackTemplate original) { - return asBukkitCopy(original.create()); + public static ItemStack asBukkitCopy(ItemInstance original) { + return switch (original) { + case ItemStackTemplate template -> asBukkitCopy(template.create()); + case net.minecraft.world.item.ItemStack item -> asBukkitCopy(item); + default -> throw new AssertionError(); + }; } public static CraftItemStack asCraftMirror(net.minecraft.world.item.ItemStack original) { @@ -261,16 +293,24 @@ public int getMaxStackSize() { } @Override - public int getMaxItemUseDuration(final org.bukkit.entity.LivingEntity entity) { + public byte @NotNull [] serializeAsBytes() { + Preconditions.checkArgument(!this.isEmpty(), "Empty item cannot be serialized"); + + return MCUtil.serializeTagToBytes( + (CompoundTag) net.minecraft.world.item.ItemStack.CODEC.encodeStart( + CraftRegistry.getMinecraftRegistry().createSerializationContext(NbtOps.INSTANCE), + this.handle + ).getOrThrow() + ); + } + + @Override + public int getMaxItemUseDuration(final LivingEntity entity) { if (this.handle == null) { return 0; } - // Make sure plugins calling the old method don't blow up - if (entity == null && (this.handle.is(net.minecraft.world.item.Items.CROSSBOW) || this.handle.is(net.minecraft.world.item.Items.GOAT_HORN))) { - throw new UnsupportedOperationException("This item requires an entity to determine the max use duration"); - } - return this.handle.getUseDuration(entity != null ? ((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity).getHandle() : null); + return this.handle.getUseDuration(entity != null ? ((CraftLivingEntity) entity).getHandle() : null); // TODO - check on each update if passing null is fine } @Override @@ -333,18 +373,58 @@ public void removeEnchantments() { } } + @Override + public @NotNull Map serialize() { + if (this.isEmpty()) { + return Map.of("id", "minecraft:air", SharedConstants.DATA_VERSION_TAG, Bukkit.getUnsafe().getDataVersion(), "schema_version", 1); + } + final CompoundTag tag = (CompoundTag) net.minecraft.world.item.ItemStack.CODEC.encodeStart( + CraftRegistry.getMinecraftRegistry().createSerializationContext(NbtOps.INSTANCE), + CraftItemStack.asNMSCopy(this) + ).getOrThrow(); + NbtUtils.addCurrentDataVersion(tag); + + final Map ret = new LinkedHashMap<>(); + tag.asCompound().get().forEach((key, value) -> { + switch (key) { + case "id" -> { + ret.put("id", value.asString().get()); + } + case "count" -> { + ret.put("count", value.asInt().get()); + } + case "components" -> { + final Map components = new LinkedHashMap<>(); + value.asCompound().ifPresent((compoundTag) -> { + compoundTag.forEach((componentKey, componentTag) -> { + final String serializedComponent = componentTag.toString(); + components.put(componentKey, serializedComponent); + }); + }); + ret.put("components", components); + } + case SharedConstants.DATA_VERSION_TAG -> { + ret.put(SharedConstants.DATA_VERSION_TAG, value.asInt().get()); + } + default -> throw new IllegalStateException("Unexpected value: " + key); + } + }); + ret.put("schema_version", 1); + return ret; + } + @Override public Map getEnchantments() { - io.papermc.paper.datacomponent.item.ItemEnchantments itemEnchantments = this.getData(io.papermc.paper.datacomponent.DataComponentTypes.ENCHANTMENTS); // empty constant might be useful here + io.papermc.paper.datacomponent.item.ItemEnchantments itemEnchantments = this.getData(DataComponentTypes.ENCHANTMENTS); // empty constant might be useful here if (itemEnchantments == null) { - return java.util.Collections.emptyMap(); + return Collections.emptyMap(); } return itemEnchantments.enchantments(); } @Override public CraftItemStack clone() { - return new org.bukkit.craftbukkit.inventory.CraftItemStack(this.handle != null ? this.handle.copy() : null); // Paper + return new CraftItemStack(this.handle != null ? this.handle.copy() : null); // Paper } @Override @@ -358,7 +438,7 @@ public void adjustTagForItemMeta(final Material oldType) { if (oldMeta == null) { newMeta = getItemMeta(this.handle); } else { - final java.util.Set> extraHandledComponents = new java.util.HashSet<>(CraftMetaItem.getTopLevelHandledComponents(oldMeta.getClass())); + final Set> extraHandledComponents = new HashSet<>(CraftMetaItem.getTopLevelHandledComponents(oldMeta.getClass())); newMeta = getItemMeta(this.handle, CraftItemType.minecraftToBukkitNew(this.handle.getItem()), extraHandledComponents); } this.setItemMeta(newMeta); @@ -369,7 +449,7 @@ public static void applyMetaToItem(net.minecraft.world.item.ItemStack itemStack, // Paper start - support updating profile after resolving it final CraftMetaItem.Applicator tag = new CraftMetaItem.Applicator() { @Override - void skullCallback(final net.minecraft.world.item.component.ResolvableProfile profile) { + void skullCallback(final ResolvableProfile profile) { itemStack.set(DataComponents.PROFILE, profile); } }; @@ -382,11 +462,11 @@ public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item) { return getItemMeta(item, null); } - public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, org.bukkit.inventory.ItemType metaForType) { + public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, ItemType metaForType) { // Paper start - handled tags on type change return getItemMeta(item, metaForType, null); } - public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, org.bukkit.inventory.ItemType metaForType, final java.util.Set> extraHandledComponents) { + public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, ItemType metaForType, final Set> extraHandledComponents) { // Paper end - handled tags on type change if (!CraftItemStack.hasItemMeta(item)) { return CraftItemFactory.instance().getItemMeta(CraftItemStack.getType(item)); @@ -424,7 +504,7 @@ public static boolean setItemMeta(net.minecraft.world.item.ItemStack item, ItemM // Paper start - support updating profile after resolving it CraftMetaItem.Applicator tag = new CraftMetaItem.Applicator() { @Override - void skullCallback(final net.minecraft.world.item.component.ResolvableProfile resolvableProfile) { + void skullCallback(final ResolvableProfile resolvableProfile) { item.set(DataComponents.PROFILE, resolvableProfile); } }; @@ -439,6 +519,14 @@ void skullCallback(final net.minecraft.world.item.component.ResolvableProfile re return true; } + @Override + public @NotNull String translationKey() { + if (this.handle == null) { + return Items.AIR.getDescriptionId(); + } + return this.handle.getItem().getDescriptionId(); + } + @Override public @NotNull Component effectiveName() { return this.handle == null ? Component.empty() : PaperAdventure.asAdventure(this.handle.getStyledHoverName()); @@ -491,19 +579,41 @@ public ItemStack withType(final Material type) { } // Paper end + @Override + public boolean isRepairableBy(@NotNull final ItemStack repairMaterial) { + if (this.handle == null) { + return false; + } + return this.handle.isValidRepairItem(CraftItemStack.unwrap(repairMaterial)); + } + + @Override + public @NotNull @Unmodifiable List computeTooltipLines(final TooltipContext tooltipContext, final Player player) { + Preconditions.checkArgument(tooltipContext != null, "tooltipContext cannot be null"); + net.minecraft.world.item.ItemStack item = this.handle == null ? net.minecraft.world.item.ItemStack.EMPTY : this.handle; + net.minecraft.world.item.TooltipFlag.Default flag = tooltipContext.isAdvanced() ? net.minecraft.world.item.TooltipFlag.ADVANCED : net.minecraft.world.item.TooltipFlag.NORMAL; + if (tooltipContext.isCreative()) { + flag = flag.asCreative(); + } + final List lines = item.getTooltipLines( + net.minecraft.world.item.Item.TooltipContext.of(player == null ? CraftRegistry.getMinecraftRegistry() : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle().level().registryAccess()), + player == null ? null : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle(), flag); + return lines.stream().map(PaperAdventure::asAdventure).toList(); + } + public static final String PDC_CUSTOM_DATA_KEY = "PublicBukkitValues"; - private net.minecraft.nbt.CompoundTag getPdcTag() { + private CompoundTag getPdcTag() { if (this.handle == null) { - return new net.minecraft.nbt.CompoundTag(); + return new CompoundTag(); } - final net.minecraft.world.item.component.CustomData customData = this.handle.getOrDefault(DataComponents.CUSTOM_DATA, net.minecraft.world.item.component.CustomData.EMPTY); + final CustomData customData = this.handle.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY); // getUnsafe is OK here because we are only ever *reading* the data so immutability is preserved //noinspection deprecation return customData.getUnsafe().getCompoundOrEmpty(PDC_CUSTOM_DATA_KEY); } - private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); - private final io.papermc.paper.persistence.PaperPersistentDataContainerView pdcView = new io.papermc.paper.persistence.PaperPersistentDataContainerView(REGISTRY) { + private static final CraftPersistentDataTypeRegistry REGISTRY = new CraftPersistentDataTypeRegistry(); + private final PaperPersistentDataContainerView pdcView = new PaperPersistentDataContainerView(REGISTRY) { @Override public int getSize() { @@ -511,17 +621,17 @@ public int getSize() { } @Override - public net.minecraft.nbt.CompoundTag toTagCompound() { + public CompoundTag toTagCompound() { return CraftItemStack.this.getPdcTag(); } @Override - public net.minecraft.nbt.Tag getTag(final String key) { + public Tag getTag(final String key) { return CraftItemStack.this.getPdcTag().get(key); } }; @Override - public io.papermc.paper.persistence.PersistentDataContainerView getPersistentDataContainer() { + public PersistentDataContainerView getPersistentDataContainer() { return this.pdcView; } @@ -554,7 +664,7 @@ public T getData(final io.papermc.paper.datacomponent.DataComponentType.Valu if (this.isEmpty()) { return null; } - return io.papermc.paper.datacomponent.PaperDataComponentType.convertDataComponentValue(this.handle.getComponents(), (io.papermc.paper.datacomponent.PaperDataComponentType.ValuedImpl) type); + return PaperDataComponentType.convertDataComponentValue(this.handle.getComponents(), (PaperDataComponentType.ValuedImpl) type); } @Override @@ -562,15 +672,15 @@ public boolean hasData(final io.papermc.paper.datacomponent.DataComponentType ty if (this.isEmpty()) { return false; } - return this.handle.has(io.papermc.paper.datacomponent.PaperDataComponentType.bukkitToMinecraft(type)); + return this.handle.has(PaperDataComponentType.bukkitToMinecraft(type)); } @Override - public java.util.Set getDataTypes() { + public Set getDataTypes() { if (this.isEmpty()) { - return java.util.Collections.emptySet(); + return Collections.emptySet(); } - return io.papermc.paper.datacomponent.PaperDataComponentType.minecraftToBukkit(this.handle.getComponents().keySet()); + return PaperDataComponentType.minecraftToBukkit(this.handle.getComponents().keySet()); } @Override @@ -579,7 +689,7 @@ public void setData(final io.papermc.paper.datacomponent.DataComponentType.V if (this.isEmpty()) { return; } - this.setDataInternal((io.papermc.paper.datacomponent.PaperDataComponentType.ValuedImpl) type, value); + this.setDataInternal((PaperDataComponentType.ValuedImpl) type, value); } @Override @@ -587,10 +697,10 @@ public void setData(final io.papermc.paper.datacomponent.DataComponentType.NonVa if (this.isEmpty()) { return; } - this.setDataInternal((io.papermc.paper.datacomponent.PaperDataComponentType.NonValuedImpl) type, null); + this.setDataInternal((PaperDataComponentType.NonValuedImpl) type, null); } - private void setDataInternal(final io.papermc.paper.datacomponent.PaperDataComponentType type, final A value) { + private void setDataInternal(final PaperDataComponentType type, final A value) { this.handle.set(type.getHandle(), type.getAdapter().toVanilla(value, type.getHolder())); } @@ -599,7 +709,7 @@ public void unsetData(final io.papermc.paper.datacomponent.DataComponentType typ if (this.isEmpty()) { return; } - this.handle.remove(io.papermc.paper.datacomponent.PaperDataComponentType.bukkitToMinecraft(type)); + this.handle.remove(PaperDataComponentType.bukkitToMinecraft(type)); } @Override @@ -607,11 +717,11 @@ public void resetData(final io.papermc.paper.datacomponent.DataComponentType typ if (this.isEmpty()) { return; } - this.resetData((io.papermc.paper.datacomponent.PaperDataComponentType) type); + this.resetData((PaperDataComponentType) type); } - private void resetData(final io.papermc.paper.datacomponent.PaperDataComponentType type) { - final net.minecraft.core.component.DataComponentType nms = io.papermc.paper.datacomponent.PaperDataComponentType.bukkitToMinecraft(type); + private void resetData(final PaperDataComponentType type) { + final DataComponentType nms = PaperDataComponentType.bukkitToMinecraft(type); final M nmsValue = this.handle.getItem().components().get(nms); // if nmsValue is null, it will clear any set patch // if nmsValue is not null, it will still clear any set patch because it will equal the default value @@ -626,7 +736,7 @@ public void copyDataFrom(final ItemStack source, final Predicate> nmsFilter = nms -> filter.test(io.papermc.paper.datacomponent.PaperDataComponentType.minecraftToBukkit(nms)); + final Predicate> nmsFilter = nms -> filter.test(PaperDataComponentType.minecraftToBukkit(nms)); net.minecraft.world.item.ItemStack sourceNmsStack = getCraftStack(source).handle; this.handle.applyComponents(sourceNmsStack.getPrototype().filter(nmsType -> { return !sourceNmsStack.hasNonDefault(nmsType) && nmsFilter.test(nmsType); @@ -642,12 +752,12 @@ public boolean isDataOverridden(final io.papermc.paper.datacomponent.DataCompone if (this.isEmpty()) { return false; } - final net.minecraft.core.component.DataComponentType nms = io.papermc.paper.datacomponent.PaperDataComponentType.bukkitToMinecraft(type); + final DataComponentType nms = PaperDataComponentType.bukkitToMinecraft(type); return this.handle.hasNonDefault(nms); } @Override - public boolean matchesWithoutData(final ItemStack item, final java.util.Set exclude, final boolean ignoreCount) { + public boolean matchesWithoutData(final ItemStack item, final Set exclude, final boolean ignoreCount) { // Extracted from base equals final CraftItemStack craftStack = getCraftStack(item); if (this.handle == craftStack.handle) return true; @@ -671,9 +781,9 @@ public boolean matchesWithoutData(final ItemStack item, final java.util.Set> skippingTypes = new java.util.HashSet<>(exclude.size()); + Set> skippingTypes = new HashSet<>(exclude.size()); for (io.papermc.paper.datacomponent.DataComponentType api : exclude) { - skippingTypes.add(io.papermc.paper.datacomponent.PaperDataComponentType.bukkitToMinecraft(api)); + skippingTypes.add(PaperDataComponentType.bukkitToMinecraft(api)); } // Check the patch by first stripping excluded types and then compare the trimmed patches diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java index 045613845bcc..b1f7fbf5f534 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java @@ -196,7 +196,7 @@ public float getCompostChance() { @Override public Multimap getDefaultAttributeModifiers() { - return this.getDefaultAttributeModifiers(sg -> true); + return this.getDefaultAttributeModifiers(_ -> true); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 6f8f42d359ff..7a9c63b327bb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -4,7 +4,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; -import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.trading.Merchant; @@ -58,7 +58,7 @@ public MinecraftMerchant(net.kyori.adventure.text.Component title) { } public MinecraftMerchant() { - this.title = EntityType.VILLAGER.getDescription(); + this.title = EntityTypes.VILLAGER.getDescription(); } // Paper end diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java index 72e7092dfd7c..e7e084e0ed32 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java @@ -7,6 +7,7 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.item.component.TypedEntityData; import org.bukkit.Material; import org.bukkit.configuration.serialization.DelegateDeserialization; @@ -88,7 +89,7 @@ void deserializeInternal(CompoundTag tag, Object context) { super.deserializeInternal(tag, context); tag.getCompound(CraftMetaArmorStand.ENTITY_TAG.NBT).ifPresent(entityTag -> { - if (!entityTag.contains(ENTITY_ID.NBT)) entityTag.putString(ENTITY_ID.NBT, EntityType.getKey(EntityType.ARMOR_STAND).toString()); // fixup legacy armorstand metas that did not include this. + if (!entityTag.contains(ENTITY_ID.NBT)) entityTag.putString(ENTITY_ID.NBT, EntityType.getKey(EntityTypes.ARMOR_STAND).toString()); // fixup legacy armorstand metas that did not include this. this.entityTag = entityTag; }); } @@ -175,7 +176,7 @@ public CraftMetaArmorStand clone() { private void populateTagIfNull() { if (this.entityTag == null) { this.entityTag = new CompoundTag(); - this.entityTag.putString(ENTITY_ID.NBT, EntityType.getKey(EntityType.ARMOR_STAND).toString()); + this.entityTag.putString(ENTITY_ID.NBT, EntityType.getKey(EntityTypes.ARMOR_STAND).toString()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index e8aa3f1100e2..3fe7674e0acc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -309,8 +309,8 @@ DataComponentPatch build() { private CraftJukeboxComponent jukebox; private Integer damage; private Integer maxDamage; - private List canPlaceOnPredicates; - private List canBreakPredicates; + private List canPlaceOnPredicates; + private List canBreakPredicates; // hide_additional_tooltip backward compatibility based on TooltipDisplayComponentFix#CONVERTED_ADDITIONAL_TOOLTIP_TYPES private static final Set> HIDDEN_COMPONENTS_PREVIOUSLY = Set.of( @@ -2537,14 +2537,14 @@ public void setCanPlaceOn(final Set canPlaceOn) { this.canPlaceOnPredicates = convertFromLegacyMaterial(canPlaceOn); } - private static List convertFromLegacyMaterial(final Collection materials) { + private static List convertFromLegacyMaterial(final Collection materials) { final net.minecraft.core.Registry blockRegistry = CraftRegistry.getMinecraftRegistry().lookupOrThrow(net.minecraft.core.registries.Registries.BLOCK); return materials.stream().map(m -> { - return net.minecraft.advancements.criterion.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(m)).build(); + return net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(m)).build(); }).toList(); } - private static Set convertToLegacyMaterial(final List predicates) { + private static Set convertToLegacyMaterial(final List predicates) { return predicates.stream() .flatMap(p -> p.blocks().map(net.minecraft.core.HolderSet::stream).orElse(java.util.stream.Stream.empty())) .map(holder -> CraftBlockType.minecraftToBukkit(holder.value())) @@ -2575,22 +2575,22 @@ public void setPlaceableKeys(final Collection convertFromLegacyNamespaced(final Collection namespaceds) { - final List predicates = new ArrayList<>(); + private static List convertFromLegacyNamespaced(final Collection namespaceds) { + final List predicates = new ArrayList<>(); final net.minecraft.core.Registry blockRegistry = CraftRegistry.getMinecraftRegistry().lookupOrThrow(net.minecraft.core.registries.Registries.BLOCK); for (final com.destroystokyo.paper.Namespaced namespaced : namespaceds) { if (namespaced instanceof final org.bukkit.NamespacedKey key) { - predicates.add(net.minecraft.advancements.criterion.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(requireNonNull(org.bukkit.Registry.MATERIAL.get(key)))).build()); + predicates.add(net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(requireNonNull(org.bukkit.Registry.MATERIAL.get(key)))).build()); } else if (namespaced instanceof final com.destroystokyo.paper.NamespacedTag tag) { - predicates.add(net.minecraft.advancements.criterion.BlockPredicate.Builder.block().of(blockRegistry, net.minecraft.tags.TagKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(tag.getNamespace(), tag.getKey()))).build()); + predicates.add(net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blockRegistry, net.minecraft.tags.TagKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(tag.getNamespace(), tag.getKey()))).build()); } } return predicates; } - private static Set convertToLegacyNamespaced(final Collection predicates) { + private static Set convertToLegacyNamespaced(final Collection predicates) { final Set namespaceds = Sets.newHashSet(); - for (final net.minecraft.advancements.criterion.BlockPredicate predicate : predicates) { + for (final net.minecraft.advancements.predicates.BlockPredicate predicate : predicates) { if (predicate.blocks().isEmpty()) { continue; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java index 6748e1b45b5e..362486f47d65 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java @@ -116,7 +116,7 @@ public PotionEffect createEffect(int duration, int amplifier) { @Override public boolean isInstant() { - return this.getHandle().isInstantenous(); + return this.getHandle().isInstantaneous(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java index 6058d219f31c..4a1e98623109 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -5,10 +5,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; +import io.papermc.paper.adventure.PaperAdventure; import net.kyori.adventure.audience.Audience; +import net.minecraft.network.chat.TextColor; import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.Team.Visibility; +import net.minecraft.world.scores.TeamColor; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; @@ -73,25 +77,19 @@ public void suffix(net.kyori.adventure.text.Component suffix) throws IllegalStat @Override public boolean hasColor() { this.checkState(); - return this.team.getColor().getColor() != null; + return this.team.getColor().isPresent(); } @Override public net.kyori.adventure.text.format.TextColor color() throws IllegalStateException { - Preconditions.checkState(this.team.getColor().getColor() != null, "Team colors must have hex values"); this.checkState(); - - net.kyori.adventure.text.format.TextColor color = net.kyori.adventure.text.format.TextColor.color(this.team.getColor().getColor()); - if (!(color instanceof net.kyori.adventure.text.format.NamedTextColor)) { - throw new IllegalStateException("Team doesn't have a NamedTextColor"); - } - return color; + return this.team.getColor().map(PaperAdventure::asAdventure).orElseThrow(() -> new IllegalStateException("Team does not have a color!")); } @Override public void color(net.kyori.adventure.text.format.NamedTextColor color) { this.checkState(); - this.team.setColor(color == null ? net.minecraft.ChatFormatting.RESET : io.papermc.paper.adventure.PaperAdventure.asVanilla(color)); + this.team.setColor(Optional.ofNullable(color).map(PaperAdventure::asVanilla)); } @Override @@ -143,7 +141,7 @@ public void setSuffix(String suffix) { public ChatColor getColor() { this.checkState(); - return CraftChatMessage.getColor(this.team.getColor()); + return this.team.getColor().map(t -> CraftChatMessage.toLegacyFormat(t.textColor())).map(CraftChatMessage::getColor).orElse(ChatColor.RESET); } @Override @@ -152,7 +150,14 @@ public void setColor(ChatColor color) { Preconditions.checkArgument(!color.isFormat(), "Color must be a color not a format"); this.checkState(); - this.team.setColor(CraftChatMessage.getColor(color)); + this.team.setColor( + Optional.of(color) + .filter(c -> c != ChatColor.RESET) + .map(CraftChatMessage::getColor) + .map(TextColor::fromLegacyFormat) + .map(TextColor::serialize) + .map(TeamColor::byName) + ); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java index 13807ed9458b..47e85f78552c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java @@ -6,17 +6,12 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.NbtUtils; import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.level.BaseSpawner; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.SpawnData; -import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.storage.TagValueOutput; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; @@ -56,7 +51,7 @@ default void setSpawnedItem(final ItemStack itemStack) { try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(() -> getSpawner().toString(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, this.getInternalWorld().registryAccess()); - tagValueOutput.putString(Entity.TAG_ID, BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.ITEM).toString()); + tagValueOutput.putString(Entity.TAG_ID, BuiltInRegistries.ENTITY_TYPE.getKey(EntityTypes.ITEM).toString()); tagValueOutput.store("Item", net.minecraft.world.item.ItemStack.CODEC, item); this.setNextSpawnData( diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java index c54c45c3323b..2184aa82229e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructure.java @@ -13,6 +13,7 @@ import net.minecraft.util.ProblemReporter; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntitySpawnRequest; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.WorldGenLevel; @@ -146,7 +147,7 @@ public List getEntities() { EntityType.create( TagValueInput.createGlobal(problemReporter, entity.nbt), ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(), - EntitySpawnReason.STRUCTURE + new EntitySpawnRequest(EntitySpawnReason.STRUCTURE, false) ).ifPresent(dummyEntity -> { dummyEntity.setPos(entity.pos.x, entity.pos.y, entity.pos.z); entities.add(dummyEntity.getBukkitEntity()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java index 4a1b8038a144..c9ebf985ea6d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ApiVersion.java @@ -11,6 +11,7 @@ public final class ApiVersion implements Comparable, Serializable { public static final ApiVersion FLATTENING; public static final ApiVersion FIELD_NAME_PARITY; public static final ApiVersion ABSTRACT_COW; + public static final ApiVersion ABSTRACT_CUBE_MOB; public static final ApiVersion NONE; private static final Map versions; @@ -21,6 +22,7 @@ public final class ApiVersion implements Comparable, Serializable { FLATTENING = getOrCreateVersion("1.13"); FIELD_NAME_PARITY = getOrCreateVersion("1.20.5"); ABSTRACT_COW = getOrCreateVersion("1.21.5"); + ABSTRACT_CUBE_MOB = getOrCreateVersion("26.2"); NONE = getOrCreateVersion("none"); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index c103a31c14b8..30cf868faa93 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -82,7 +82,10 @@ public class Commodore { "org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent", "org/bukkit/block/data/type/Crafter$Orientation", "org/bukkit/block/Orientation", "org/bukkit/block/data/type/Jigsaw$Orientation", "org/bukkit/block/Orientation", - "org/bukkit/block/data/type/MossyCarpet$Height", "org/bukkit/block/data/type/Wall$Height" + "org/bukkit/block/data/type/MossyCarpet$Height", "org/bukkit/block/data/type/Wall$Height", + "org/bukkit/block/data/type/PinkPetals", "org/bukkit/block/data/type/FlowerBed", + "org/bukkit/block/data/type/PointedDripstone", "org/bukkit/block/data/type/Speleothem", + "org/bukkit/block/data/type/PointedDripstone$Thickness", "org/bukkit/block/data/type/Speleothem$Thickness" ); private static final Map CLASS_TO_INTERFACE = Map.ofEntries( @@ -219,6 +222,9 @@ public byte[] convert(byte[] b, final String pluginName, final ApiVersion plugin if (pluginVersion.isOlderThan(ApiVersion.ABSTRACT_COW)) { renames.put("org/bukkit/entity/Cow", "org/bukkit/entity/AbstractCow"); } + if (pluginVersion.isOlderThan(ApiVersion.ABSTRACT_CUBE_MOB)) { + renames.put("org/bukkit/entity/Slime", "org/bukkit/entity/AbstractCubeMob"); + } cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, cw) { final Set rerouteMethodData = new HashSet<>(); @@ -444,7 +450,7 @@ private void handleMethod(MethodPrinter visitor, int opcode, String owner, Strin } // Paper start - Rewrite plugins - owner = getOriginalOrRewrite(owner) ; + owner = getOriginalOrRewrite(owner); if (desc != null) { desc = getOriginalOrRewrite(desc); } @@ -667,7 +673,7 @@ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, Str public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) { // Paper start - Rewrite plugins descriptor = getOriginalOrRewrite(descriptor); - if ( signature != null ) { + if (signature != null) { signature = getOriginalOrRewrite(signature); } // Paper end diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index 3f115c561f34..02a9d052cbcd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -30,6 +30,7 @@ import net.minecraft.util.ExtraCodecs; import org.bukkit.ChatColor; import org.bukkit.craftbukkit.CraftRegistry; +import org.jspecify.annotations.Nullable; public final class CraftChatMessage { @@ -104,7 +105,7 @@ private StringMessage(String message, boolean keepNewlines, boolean plain) { this.modifier = StringMessage.RESET.withColor(TextColor.parseColor(this.hex.toString()).result().orElse(null)); // Paper this.hex = null; } - } else if (format.isFormat() && format != ChatFormatting.RESET) { + } else if (isFormat(format) && format != ChatFormatting.RESET) { switch (format) { case BOLD: this.modifier = this.modifier.withBold(Boolean.TRUE); @@ -310,8 +311,9 @@ public static String fromComponent(Component component) { TextColor color = modi.getColor(); if (c.getContents() != PlainTextContents.EMPTY || color != null) { if (color != null) { - if (color.format != null) { - out.append(color.format); + final ChatFormatting format = toLegacyFormat(color); + if (format != null) { + out.append(format); } else { out.append(ChatColor.COLOR_CHAR).append("x"); for (char magic : color.serialize().substring(1).toCharArray()) { @@ -367,6 +369,36 @@ public static BaseComponent[] vanillaToBungee(Component component) { return jsonToBungee(toJSON(component)); } + public static @Nullable ChatFormatting toLegacyFormat(final TextColor color) { + // rgb values of the named text colors mapped to the legacy chat formatting enum + return switch (color.getValue()) { + case 0 -> ChatFormatting.BLACK; + case 170 -> ChatFormatting.DARK_BLUE; + case 43520 -> ChatFormatting.DARK_GREEN; + case 43690 -> ChatFormatting.DARK_AQUA; + case 11141120 -> ChatFormatting.DARK_RED; + case 11141290 -> ChatFormatting.DARK_PURPLE; + case 16755200 -> ChatFormatting.GOLD; + case 11184810 -> ChatFormatting.GRAY; + case 5592405 -> ChatFormatting.DARK_GRAY; + case 5592575 -> ChatFormatting.BLUE; + case 5635925 -> ChatFormatting.GREEN; + case 5636095 -> ChatFormatting.AQUA; + case 16733525 -> ChatFormatting.RED; + case 16733695 -> ChatFormatting.LIGHT_PURPLE; + case 16777045 -> ChatFormatting.YELLOW; + case 16777215 -> ChatFormatting.WHITE; + default -> null; + }; + } + + private static boolean isFormat(final ChatFormatting formatting) { + return switch (formatting) { + case OBFUSCATED, BOLD, STRIKETHROUGH, UNDERLINE, ITALIC -> true; + default -> false; + }; + } + private CraftChatMessage() { } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 3f903315d3c0..14b99f9fdc19 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -2,7 +2,6 @@ import ca.spottedleaf.moonrise.common.PlatformHooks; import com.google.common.base.Preconditions; -import com.google.common.collect.Multimap; import com.google.common.io.Files; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; @@ -16,16 +15,15 @@ import io.papermc.paper.adventure.AdventureCodecs; import io.papermc.paper.entity.EntitySerializationFlag; import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.util.MCUtil; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.logging.Level; import java.util.stream.Stream; @@ -33,7 +31,6 @@ import net.minecraft.SharedConstants; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.commands.arguments.item.ItemParser; -import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; @@ -49,6 +46,9 @@ import net.minecraft.util.ProblemReporter; import net.minecraft.util.datafix.DataFixers; import net.minecraft.util.datafix.fixes.References; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntitySpawnRequest; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.alchemy.Potion; @@ -64,25 +64,17 @@ import org.bukkit.UnsafeValues; import org.bukkit.World; import org.bukkit.advancement.Advancement; -import org.bukkit.attribute.Attribute; -import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.data.BlockData; import org.bukkit.configuration.MemorySection; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.damage.CraftDamageSourceBuilder; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.legacy.CraftLegacy; import org.bukkit.craftbukkit.legacy.FieldRename; import org.bukkit.craftbukkit.potion.CraftPotionType; -import org.bukkit.damage.DamageSource; -import org.bukkit.damage.DamageType; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.CreativeCategory; -import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.plugin.InvalidPluginException; @@ -102,41 +94,11 @@ public final class CraftMagicNumbers implements UnsafeValues { private CraftMagicNumbers() {} - @Override - public net.kyori.adventure.text.flattener.ComponentFlattener componentFlattener() { - return io.papermc.paper.adventure.PaperAdventure.FLATTENER; - } - - @Override - public net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer() { - return net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.colorDownsamplingGson(); - } - - @Override - public net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer() { - return net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson(); - } - @Override public net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer() { return io.papermc.paper.adventure.PaperAdventure.PLAIN; } - @Override - public net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer() { - return net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText(); - } - - @Override - public net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection(); - } - - @Override - public net.kyori.adventure.text.Component resolveWithContext(final net.kyori.adventure.text.Component component, final org.bukkit.command.CommandSender context, final org.bukkit.entity.Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { - return io.papermc.paper.adventure.PaperAdventure.resolveWithContext(component, context, scoreboardSubject, bypassPermissions); - } - public static BlockState getBlock(MaterialData material) { return CraftMagicNumbers.getBlock(material.getItemType(), material.getData()); } @@ -269,16 +231,6 @@ public Material getMaterial(String material, int version) { return Material.matchMaterial(converted.asString("")); } - /** - * @deprecated in favor of {@link io.papermc.paper.ServerBuildInfo#minecraftVersionId()} - * Paper has used Mojang mappings since 1.20.5 and now in 26.1 the server is not obfuscated anymore, - * so this method no longer returns a useful value. - */ - @Deprecated(forRemoval = true, since = "1.21.6") - public String getMappingsVersion() { - throw new UnsupportedOperationException("Use ServerBuildInfo#minecraftVersionId instead."); - } - @Override public int getDataVersion() { return SharedConstants.getCurrentVersion().dataVersion().version(); @@ -409,42 +361,6 @@ public byte[] processClass(PluginDescriptionFile pdf, String path, byte[] clazz) return clazz; } - @Override - public Multimap getDefaultAttributeModifiers(Material material, EquipmentSlot slot) { - // Paper start - delegate to method on ItemType - final org.bukkit.inventory.ItemType item = material.asItemType(); - Preconditions.checkArgument(item != null, material + " is not an item and does not have default attributes"); - return item.getDefaultAttributeModifiers(slot); - // Paper end - delegate to method on ItemType - } - - @Override - public CreativeCategory getCreativeCategory(Material material) { - return material.getCreativeCategory(); - } - - @Override - public String getBlockTranslationKey(Material material) { - return material.getBlockTranslationKey(); - } - - @Override - public String getItemTranslationKey(Material material) { - return material.getItemTranslationKey(); - } - - @Override - public String getTranslationKey(EntityType entityType) { - Preconditions.checkArgument(entityType.getName() != null, "Invalid name of EntityType %s for translation key", entityType); - return net.minecraft.world.entity.EntityType.byString(entityType.getName()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElseThrow(); - } - - @Override - public String getTranslationKey(ItemStack itemStack) { - net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack); - return nmsItemStack.getItem().getDescriptionId(); - } - @Override public boolean isSupportedApiVersion(String apiVersion) { if (apiVersion == null) return false; @@ -454,11 +370,6 @@ public boolean isSupportedApiVersion(String apiVersion) { return !toCheck.isNewerThan(ApiVersion.CURRENT) && !toCheck.isOlderThan(minimumVersion); } - @Override - public String getTranslationKey(final Attribute attribute) { - return attribute.getTranslationKey(); - } - @Override public PotionType.InternalPotionData getInternalPotionData(NamespacedKey namespacedKey) { Potion potionRegistry = CraftRegistry.getMinecraftRegistry(Registries.POTION) @@ -468,17 +379,12 @@ public PotionType.InternalPotionData getInternalPotionData(NamespacedKey namespa } @Override - public DamageSource.Builder createDamageSourceBuilder(DamageType damageType) { - return new CraftDamageSourceBuilder(damageType); - } - - @Override - public String get(Class aClass, String s) { - if (aClass == Enchantment.class) { + public String get(Class elementClass, String value) { + if (elementClass == Enchantment.class) { // We currently do not have any version-dependent remapping, so we can use current version - return FieldRename.convertEnchantmentName(ApiVersion.CURRENT, s); + return FieldRename.convertEnchantmentName(ApiVersion.CURRENT, value); } - return s; + return value; } @Override @@ -487,84 +393,6 @@ public B get(RegistryKey registry, NamespacedKey namespaced return CraftRegistry.get(registry, namespacedKey, ApiVersion.CURRENT); } - @Override - public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { - return new com.destroystokyo.paper.PaperVersionFetcher(); - } - - @Override - public byte[] serializeItem(ItemStack item) { - Preconditions.checkNotNull(item, "null cannot be serialized"); - Preconditions.checkArgument(!item.isEmpty(), "Empty itemstack cannot be serialized"); - - return serializeNbtToBytes( - (CompoundTag) net.minecraft.world.item.ItemStack.CODEC.encodeStart( - MinecraftServer.getServer().registryAccess().createSerializationContext(NbtOps.INSTANCE), - CraftItemStack.unwrap(item) - ).getOrThrow() - ); - } - - @Override - public ItemStack deserializeItem(byte[] data) { - Preconditions.checkNotNull(data, "null cannot be deserialized"); - Preconditions.checkArgument(data.length > 0, "cannot deserialize nothing"); - - CompoundTag compound = deserializeNbtFromBytes(data); - return deserializeItem(compound); - } - - private ItemStack deserializeItem(CompoundTag compound) { - final int dataVersion = compound.getIntOr("DataVersion", 0); - compound = PlatformHooks.get().convertNBT(References.ITEM_STACK, DataFixers.getDataFixer(), compound, dataVersion, this.getDataVersion()); // Paper - possibly use dataconverter - if (compound.getStringOr("id", "minecraft:air").equals("minecraft:air")) { - return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.EMPTY); - } - return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.CODEC.parse( - CraftRegistry.getMinecraftRegistry().createSerializationContext(NbtOps.INSTANCE), compound - ).getOrThrow()); - } - - @Override - public @org.jetbrains.annotations.NotNull Map serializeStack(final ItemStack itemStack) { - if (itemStack.isEmpty()) { - return Map.of("id", "minecraft:air", SharedConstants.DATA_VERSION_TAG, this.getDataVersion(), "schema_version", 1); - } - final CompoundTag tag = (CompoundTag) net.minecraft.world.item.ItemStack.CODEC.encodeStart( - CraftRegistry.getMinecraftRegistry().createSerializationContext(NbtOps.INSTANCE), - CraftItemStack.asNMSCopy(itemStack) - ).getOrThrow(); - NbtUtils.addCurrentDataVersion(tag); - - final Map ret = new LinkedHashMap<>(); - tag.asCompound().get().forEach((key, value) -> { - switch (key) { - case "id" -> { - ret.put("id", value.asString().get()); - } - case "count" -> { - ret.put("count", value.asInt().get()); - } - case "components" -> { - final Map components = new LinkedHashMap<>(); - value.asCompound().ifPresent((compoundTag) -> { - compoundTag.forEach((componentKey, componentTag) -> { - final String serializedComponent = componentTag.toString(); - components.put(componentKey, serializedComponent); - }); - }); - ret.put("components", components); - } - case SharedConstants.DATA_VERSION_TAG -> { - ret.put(SharedConstants.DATA_VERSION_TAG, value.asInt().get()); - } - default -> throw new IllegalStateException("Unexpected value: " + key); - } - }); - ret.put("schema_version", 1); - return ret; - } - private static final TagParser SNBT_REGISTRY_UNAWARE_PARSER = TagParser.create(NbtOps.INSTANCE); @Override public @org.jetbrains.annotations.NotNull ItemStack deserializeStack(@org.jetbrains.annotations.NotNull final Map args) { @@ -584,10 +412,10 @@ private ItemStack deserializeItem(CompoundTag compound) { Map componentMap; if (value instanceof Map) { componentMap = (Map) value; - } else if (value instanceof MemorySection memory) { + } else if (value instanceof MemorySection section) { componentMap = new HashMap<>(); - for (final String memoryKey : memory.getKeys(false)) { - componentMap.put(memoryKey, memory.getString(memoryKey)); + for (final String sectionKey : section.getKeys(false)) { + componentMap.put(sectionKey, section.getString(sectionKey)); } } else { throw new IllegalArgumentException("components must be a Map"); @@ -604,7 +432,7 @@ private ItemStack deserializeItem(CompoundTag compound) { }); tag.put("components", componentsTag); - } else { + } else { throw new IllegalStateException("Unexpected version: " + version); } } @@ -618,7 +446,7 @@ private ItemStack deserializeItem(CompoundTag compound) { } }); - return deserializeItem(tag); + return MCUtil.deserializeItem(tag); } @Override @@ -626,8 +454,8 @@ public com.google.gson.JsonObject serializeItemAsJson(ItemStack itemStack) { Preconditions.checkNotNull(itemStack, "Cannot serialize empty ItemStack"); Preconditions.checkArgument(!itemStack.isEmpty(), "Cannot serialize empty ItemStack"); - net.minecraft.core.RegistryAccess.Frozen reg = net.minecraft.server.MinecraftServer.getServer().registryAccess(); - com.mojang.serialization.DynamicOps ops = reg.createSerializationContext(com.mojang.serialization.JsonOps.INSTANCE); + net.minecraft.core.RegistryAccess registryAccess = CraftRegistry.getMinecraftRegistry(); + com.mojang.serialization.DynamicOps ops = registryAccess.createSerializationContext(com.mojang.serialization.JsonOps.INSTANCE); com.google.gson.JsonObject item; // Serialize as SNBT to preserve exact NBT types; vanilla codecs already can handle such deserialization. net.minecraft.world.item.component.CustomData.SERIALIZE_CUSTOM_AS_SNBT.set(true); @@ -636,7 +464,7 @@ public com.google.gson.JsonObject serializeItemAsJson(ItemStack itemStack) { } finally { net.minecraft.world.item.component.CustomData.SERIALIZE_CUSTOM_AS_SNBT.set(false); } - item.addProperty("DataVersion", this.getDataVersion()); + item.addProperty(SharedConstants.DATA_VERSION_TAG, this.getDataVersion()); return item; } @@ -644,10 +472,10 @@ public com.google.gson.JsonObject serializeItemAsJson(ItemStack itemStack) { public ItemStack deserializeItemFromJson(com.google.gson.JsonObject data) throws IllegalArgumentException { Preconditions.checkNotNull(data, "null cannot be deserialized"); - final int dataVersion = data.get("DataVersion").getAsInt(); - final int currentVersion = org.bukkit.craftbukkit.util.CraftMagicNumbers.INSTANCE.getDataVersion(); + final int dataVersion = data.get(SharedConstants.DATA_VERSION_TAG).getAsInt(); + final int currentVersion = this.getDataVersion(); data = (com.google.gson.JsonObject) MinecraftServer.getServer().fixerUpper.update(References.ITEM_STACK, new Dynamic<>(com.mojang.serialization.JsonOps.INSTANCE, data), dataVersion, currentVersion).getValue(); - com.mojang.serialization.DynamicOps ops = MinecraftServer.getServer().registryAccess().createSerializationContext(com.mojang.serialization.JsonOps.INSTANCE); + com.mojang.serialization.DynamicOps ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(com.mojang.serialization.JsonOps.INSTANCE); return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.CODEC.parse(ops, data).getOrThrow(IllegalArgumentException::new)); } @@ -708,7 +536,7 @@ public byte[] serializeEntity(org.bukkit.entity.Entity entity, EntitySerializati throw new IllegalArgumentException("Couldn't serialize entity"); } } - return serializeNbtToBytes(output.buildResult()); + return MCUtil.serializeTagToBytes(output.buildResult()); } } @@ -717,20 +545,21 @@ public org.bukkit.entity.Entity deserializeEntity(byte[] data, World world, bool Preconditions.checkNotNull(data, "null cannot be deserialized"); Preconditions.checkArgument(data.length > 0, "Cannot deserialize empty data"); - CompoundTag compound = deserializeNbtFromBytes(data); - int dataVersion = compound.getIntOr("DataVersion", 0); - compound = PlatformHooks.get().convertNBT(References.ENTITY, MinecraftServer.getServer().fixerUpper, compound, dataVersion, this.getDataVersion()); // Paper - possibly use dataconverter + CompoundTag tag = MCUtil.deserializeTagFromBytes(data); + int dataVersion = NbtUtils.getDataVersion(tag, 0); + Preconditions.checkArgument(dataVersion <= Bukkit.getUnsafe().getDataVersion(), "Newer version! Server downgrades are not supported!"); + tag = PlatformHooks.get().convertNBT(References.ENTITY, MinecraftServer.getServer().fixerUpper, tag, dataVersion, this.getDataVersion()); // Paper - possibly use dataconverter if (!preservePassengers) { - compound.remove("Passengers"); + tag.remove(Entity.TAG_PASSENGERS); } - net.minecraft.world.entity.Entity nmsEntity = deserializeEntity(compound, ((CraftWorld) world).getHandle(), preserveUUID); + net.minecraft.world.entity.Entity nmsEntity = deserializeEntity(tag, ((CraftWorld) world).getHandle(), preserveUUID); return nmsEntity.getBukkitEntity(); } - private net.minecraft.world.entity.Entity deserializeEntity(CompoundTag compound, ServerLevel world, boolean preserveUUID) { + private net.minecraft.world.entity.Entity deserializeEntity(CompoundTag tag, ServerLevel world, boolean preserveUUID) { if (!preserveUUID) { // Generate a new UUID, so we don't have to worry about deserializing the same entity twice - compound.remove("UUID"); + tag.remove(Entity.TAG_UUID); } final net.minecraft.world.entity.Entity nmsEntity; @@ -738,15 +567,15 @@ private net.minecraft.world.entity.Entity deserializeEntity(CompoundTag compound () -> "deserialiseEntity", LOGGER )) { nmsEntity = net.minecraft.world.entity.EntityType.create( - TagValueInput.create(problemReporter, world.registryAccess(), compound), + TagValueInput.create(problemReporter, world.registryAccess(), tag), world, - net.minecraft.world.entity.EntitySpawnReason.LOAD + new EntitySpawnRequest(EntitySpawnReason.LOAD, false) ).orElseThrow(() -> new IllegalArgumentException("An ID was not found for the data. Did you downgrade?")); } - compound.getList("Passengers").ifPresent(passengers -> { - for (final Tag tag : passengers) { - if (!(tag instanceof final CompoundTag serializedPassenger)) { + tag.getList(Entity.TAG_PASSENGERS).ifPresent(passengers -> { + for (final Tag passenger : passengers) { + if (!(passenger instanceof final CompoundTag serializedPassenger)) { continue; } final net.minecraft.world.entity.Entity passengerEntity = deserializeEntity(serializedPassenger, world, preserveUUID); @@ -756,37 +585,9 @@ private net.minecraft.world.entity.Entity deserializeEntity(CompoundTag compound return nmsEntity; } - private byte[] serializeNbtToBytes(CompoundTag compound) { - compound.putInt("DataVersion", getDataVersion()); - java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream(); - try { - net.minecraft.nbt.NbtIo.writeCompressed( - compound, - outputStream - ); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - return outputStream.toByteArray(); - } - - private CompoundTag deserializeNbtFromBytes(byte[] data) { - CompoundTag compound; - try { - compound = net.minecraft.nbt.NbtIo.readCompressed( - new java.io.ByteArrayInputStream(data), net.minecraft.nbt.NbtAccounter.unlimitedHeap() - ); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - int dataVersion = compound.getIntOr("DataVersion", 0); - Preconditions.checkArgument(dataVersion <= getDataVersion(), "Newer version! Server downgrades are not supported!"); - return compound; - } - @Override - public int nextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); + public int nextEntityId(final World world) { + return ((CraftWorld) world).getHandle().getNextEntityId(); } @Override @@ -798,77 +599,8 @@ public String getMainLevelName() { public int getProtocolVersion() { return net.minecraft.SharedConstants.getCurrentVersion().protocolVersion(); } - - @Override - public boolean isValidRepairItemStack(org.bukkit.inventory.ItemStack itemToBeRepaired, org.bukkit.inventory.ItemStack repairMaterial) { - if (!itemToBeRepaired.getType().isItem() || !repairMaterial.getType().isItem()) { - return false; - } - return CraftItemStack.unwrap(itemToBeRepaired).isValidRepairItem(CraftItemStack.unwrap(repairMaterial)); - } - - @Override - public boolean hasDefaultEntityAttributes(NamespacedKey entityKey) { - return net.minecraft.world.entity.ai.attributes.DefaultAttributes.hasSupplier(net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.getValue(CraftNamespacedKey.toMinecraft(entityKey))); - } - - @Override - public org.bukkit.attribute.Attributable getDefaultEntityAttributes(NamespacedKey entityKey) { - Preconditions.checkArgument(hasDefaultEntityAttributes(entityKey), entityKey + " doesn't have default attributes"); - var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType) net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.getValue(CraftNamespacedKey.toMinecraft(entityKey))); - return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier); - } - - @Override - public org.bukkit.NamespacedKey getBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z) { - return accessor.getBiome(x, y, z).getKey(); - } - - @Override - public void setBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z, org.bukkit.NamespacedKey biomeKey) { - accessor.setBiome(x, y, z, io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(RegistryKey.BIOME).getOrThrow(biomeKey)); - } - - @Override - public String getStatisticCriteriaKey(org.bukkit.Statistic statistic) { - if (statistic.getType() != org.bukkit.Statistic.Type.UNTYPED) return "minecraft.custom:minecraft." + statistic.getKey().getKey(); - return org.bukkit.craftbukkit.CraftStatistic.getNMSStatistic(statistic).getName(); - } - - @Override - public List computeTooltipLines(final ItemStack itemStack, final io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, final org.bukkit.entity.Player player) { - Preconditions.checkArgument(tooltipContext != null, "tooltipContext cannot be null"); - net.minecraft.world.item.TooltipFlag.Default flag = tooltipContext.isAdvanced() ? net.minecraft.world.item.TooltipFlag.ADVANCED : net.minecraft.world.item.TooltipFlag.NORMAL; - if (tooltipContext.isCreative()) { - flag = flag.asCreative(); - } - final List lines = CraftItemStack.asNMSCopy(itemStack).getTooltipLines( - net.minecraft.world.item.Item.TooltipContext.of(player == null ? CraftRegistry.getMinecraftRegistry() : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle().level().registryAccess()), - player == null ? null : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle(), flag); - return lines.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).toList(); - } // Paper end - @Override - public org.bukkit.Color getSpawnEggLayerColor(final EntityType entityType, final int layer) { - final net.minecraft.world.entity.EntityType type = org.bukkit.craftbukkit.entity.CraftEntityType.bukkitToMinecraft(entityType); - final Optional> eggItem = net.minecraft.world.item.SpawnEggItem.byId(type); - if (eggItem.isPresent()) { - throw new UnsupportedOperationException(); - } - return null; - } - - @Override - public io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager createPluginLifecycleEventManager(final org.bukkit.plugin.java.JavaPlugin plugin, final java.util.function.BooleanSupplier registrationCheck) { - return new io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEventManager<>(plugin, registrationCheck); - } - - @Override - public org.bukkit.inventory.ItemStack createEmptyStack() { - return CraftItemStack.asCraftMirror(null); - } - @Override public ItemStack deserializeItemHover(final HoverEvent.ShowItem itemHover) { final RegistryOps ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JavaOps.INSTANCE); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerLevelAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerLevelAccessor.java index 23b5a09cf5f4..f037b5134bcd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerLevelAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerLevelAccessor.java @@ -62,7 +62,7 @@ public boolean setCraftBlock(BlockPos pos, CraftBlockState craftBlockState, @Blo this.scheduleTick(pos, fluidState.getType(), 0); } if (StructurePiece.SHAPE_CHECK_BLOCKS.contains(snapshot.getBlock())) { - this.getChunk(pos).markPosForPostprocessing(pos); + this.getChunk(pos).markPosForPostProcessing(pos); } BlockEntity blockEntity = this.getBlockEntity(pos); if (blockEntity != null && craftBlockState instanceof CraftBlockEntityState craftEntityState) { diff --git a/paper-server/src/main/resources/data/minecraft/datapacks/paper/pack.mcmeta b/paper-server/src/main/resources/data/minecraft/datapacks/paper/pack.mcmeta index bcccdca454e0..efb85362435a 100644 --- a/paper-server/src/main/resources/data/minecraft/datapacks/paper/pack.mcmeta +++ b/paper-server/src/main/resources/data/minecraft/datapacks/paper/pack.mcmeta @@ -1,9 +1,9 @@ { "pack": { "description": "Built-in Paper Datapack", - "max_format": 101, + "max_format": 107, "min_format": [ - 101, + 107, 1 ] } diff --git a/paper-server/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java b/paper-server/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java index 6fe9c10ffd1d..0b621f0e3386 100644 --- a/paper-server/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java +++ b/paper-server/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java @@ -1,7 +1,6 @@ package io.papermc.paper.advancement; -import io.papermc.paper.adventure.PaperAdventure; -import net.kyori.adventure.text.format.TextColor; +import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.advancements.AdvancementType; import net.minecraft.network.chat.contents.TranslatableContents; import org.bukkit.support.environment.Normal; @@ -15,7 +14,7 @@ public class AdvancementFrameTest { @Test public void test() { for (final AdvancementType advancementType : AdvancementType.values()) { - final TextColor expectedColor = PaperAdventure.asAdventure(advancementType.getChatColor()); + final NamedTextColor expectedColor = NamedTextColor.NAMES.value(net.minecraft.network.chat.TextColor.fromLegacyFormat(advancementType.getChatColor()).toString()); final String expectedTranslationKey = ((TranslatableContents) advancementType.getDisplayName().getContents()).getKey(); final var frame = PaperAdvancementDisplay.asPaperFrame(advancementType); assertEquals(expectedTranslationKey, frame.translationKey(), "The translation keys should be the same"); diff --git a/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java b/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java index 7524ee0de782..4649f0e8e302 100644 --- a/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java +++ b/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java @@ -30,7 +30,7 @@ private CommandSender getSender() { public void test() throws CommandSyntaxException { CommandSender sender = this.getSender(); CommandSourceStack object = Mockito.mock(CommandSourceStack.class); - Mockito.when(object.getLocation()).thenReturn(new Location(null, 0, 0, 0));; + Mockito.when(object.getLocation()).thenReturn(new Location(null, 0, 0, 0)); CommandDispatcher dispatcher = RegistryHelper.context().datapack().commands.getDispatcher(); dispatcher.setConsumer((context, success, result) -> {}); diff --git a/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java b/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java index 1beaa37015e0..79bb235af2f2 100644 --- a/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java +++ b/paper-server/src/test/java/io/papermc/paper/effects/EffectCategoryTest.java @@ -1,6 +1,6 @@ package io.papermc.paper.effects; -import io.papermc.paper.adventure.PaperAdventure; +import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.world.effect.MobEffectCategory; import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.potion.PotionEffectType; @@ -24,7 +24,7 @@ public void testEffectCategoriesExist() { public void testCategoryHasEquivalentColors() { for (MobEffectCategory mobEffectInfo : MobEffectCategory.values()) { PotionEffectType.Category bukkitEffectCategory = CraftPotionEffectType.fromNMS(mobEffectInfo); - assertEquals(bukkitEffectCategory.getColor(), PaperAdventure.asAdventure(mobEffectInfo.getTooltipFormatting()), mobEffectInfo.getTooltipFormatting().name() + " doesn't equal " + bukkitEffectCategory.getColor()); + assertEquals(bukkitEffectCategory.getColor(), NamedTextColor.NAMES.value(net.minecraft.network.chat.TextColor.fromLegacyFormat(mobEffectInfo.getTooltipFormatting()).toString()), mobEffectInfo.getTooltipFormatting().name() + " doesn't equal " + bukkitEffectCategory.getColor()); } } } diff --git a/paper-server/src/test/java/org/bukkit/ParticleTest.java b/paper-server/src/test/java/org/bukkit/ParticleTest.java index b04339c4aa47..e294f6239a01 100644 --- a/paper-server/src/test/java/org/bukkit/ParticleTest.java +++ b/paper-server/src/test/java/org/bukkit/ParticleTest.java @@ -7,6 +7,8 @@ import net.minecraft.core.particles.ColorParticleOption; import net.minecraft.core.particles.DustColorTransitionOptions; import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.core.particles.GeyserBaseParticleOptions; +import net.minecraft.core.particles.GeyserParticleOptions; import net.minecraft.core.particles.ItemParticleOption; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.PowerParticleOption; @@ -129,6 +131,16 @@ public void testRightParticleParamCreation(Particle bukkit) { return; } + if (bukkit.getDataType().equals(Particle.Geyser.class)) { + this.testGeyser(bukkit, minecraft); + return; + } + + if (bukkit.getDataType().equals(Particle.GeyserBase.class)) { + this.testGeyserBase(bukkit, minecraft); + return; + } + fail(String.format(""" No test found for particle %s. Please add a test case for it here. @@ -314,6 +326,41 @@ private void testSpell(Particle bukkit, net.minecraf """, bukkit.getKey(), power, param.getPower())); } + private void testGeyser(Particle bukkit, net.minecraft.core.particles.ParticleType minecraft) { + int waterBlocks = 3; + Particle.Geyser geyser = new Particle.Geyser(waterBlocks); + + GeyserParticleOptions param = this.createAndTest(bukkit, minecraft, geyser, GeyserParticleOptions.class); + + assertEquals(waterBlocks, param.waterBlocks(), String.format(""" + Geyser water blocks for particle %s do not match. + Did something change in the implementation or minecraft? + Expected: %s. + Got: %s. + """, bukkit.getKey(), waterBlocks, param.waterBlocks())); + } + + private void testGeyserBase(Particle bukkit, net.minecraft.core.particles.ParticleType minecraft) { + int waterBlocks = 3; + float burstImpulse = 2.0F; + Particle.GeyserBase geyser = new Particle.GeyserBase(waterBlocks, burstImpulse); + + GeyserBaseParticleOptions param = this.createAndTest(bukkit, minecraft, geyser, GeyserBaseParticleOptions.class); + + assertEquals(waterBlocks, param.waterBlocks(), String.format(""" + Geyser base water blocks for particle %s do not match. + Did something change in the implementation or minecraft? + Expected: %s. + Got: %s. + """, bukkit.getKey(), waterBlocks, param.waterBlocks())); + assertEquals(burstImpulse, param.burstImpulseBase(), 0.001, String.format(""" + Geyser base burst impulse for particle %s do not match. + Did something change in the implementation or minecraft? + Expected: %s. + Got: %s. + """, bukkit.getKey(), burstImpulse, param.burstImpulseBase())); + } + private D createAndTest(Particle bukkit, net.minecraft.core.particles.ParticleType minecraft, Object data, Class paramClass) { @SuppressWarnings("unchecked") T particleParam = (T) assertDoesNotThrow(() -> CraftParticle.createParticleParam(bukkit, data), String.format(""" diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java index 38fdc3dfcb09..b02217053a41 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/entity/EntityTypesTest.java @@ -11,6 +11,7 @@ import java.util.zip.ZipEntry; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractCow; +import org.bukkit.entity.AbstractCubeMob; import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.AbstractNautilus; import org.bukkit.entity.AbstractSkeleton; @@ -79,6 +80,7 @@ public class EntityTypesTest { private static final List> EXCLUDE = Arrays.asList( AbstractArrow.class, AbstractCow.class, + AbstractCubeMob.class, AbstractHorse.class, AbstractNautilus.class, AbstractSkeleton.class, diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index f375aea89cf9..63dd2d1ecf37 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -2,10 +2,10 @@ import java.util.Arrays; import java.util.List; -import java.util.UUID; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.item.Item; import org.bukkit.Bukkit; import org.bukkit.Color; @@ -331,7 +331,7 @@ public void testEachExtraData() { @Override ItemStack operate(ItemStack cleanStack) { final CraftMetaArmorStand meta = (CraftMetaArmorStand) cleanStack.getItemMeta(); meta.entityTag = new CompoundTag(); - meta.entityTag.putString("id", EntityType.getKey(EntityType.ARMOR_STAND).toString()); + meta.entityTag.putString("id", EntityType.getKey(EntityTypes.ARMOR_STAND).toString()); meta.entityTag.putBoolean("Small", true); meta.setInvisible(true); // Paper cleanStack.setItemMeta(meta); @@ -350,7 +350,7 @@ public void testEachExtraData() { @Override ItemStack operate(ItemStack cleanStack) { final CraftMetaEntityTag meta = ((CraftMetaEntityTag) cleanStack.getItemMeta()); meta.entityTag = new CompoundTag(); - meta.entityTag.putString("id", EntityType.getKey(EntityType.ITEM_FRAME).toString()); + meta.entityTag.putString("id", EntityType.getKey(EntityTypes.ITEM_FRAME).toString()); meta.entityTag.putBoolean("Invisible", true); cleanStack.setItemMeta(meta); return cleanStack; @@ -408,20 +408,20 @@ public void testEachExtraData() { @Test public void testAttributeModifiers() { - UUID sameUUID = UUID.randomUUID(); ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); - itemMeta.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 10, AttributeModifier.Operation.ADD_NUMBER)); + NamespacedKey sameKey = NamespacedKey.minecraft("abc"); + itemMeta.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameKey, 10, AttributeModifier.Operation.ADD_NUMBER)); ItemMeta equalMeta = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); - equalMeta.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 10, AttributeModifier.Operation.ADD_NUMBER)); + equalMeta.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameKey, 10, AttributeModifier.Operation.ADD_NUMBER)); assertThat(itemMeta.equals(equalMeta), is(true)); ItemMeta itemMeta2 = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); - itemMeta2.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 10, AttributeModifier.Operation.ADD_NUMBER)); + itemMeta2.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameKey, 10, AttributeModifier.Operation.ADD_NUMBER)); ItemMeta notEqualMeta2 = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); - notEqualMeta2.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 11, AttributeModifier.Operation.ADD_NUMBER)); + notEqualMeta2.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(sameKey, 11, AttributeModifier.Operation.ADD_NUMBER)); assertThat(itemMeta2.equals(notEqualMeta2), is(false)); } diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemTypeTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemTypeTest.java index f4932f175575..5dea4d7ac6d9 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemTypeTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemTypeTest.java @@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemType; @@ -24,11 +25,12 @@ public class ItemTypeTest { @Test public void testItemMetaClasses() throws Exception { for (Field f : ItemType.class.getDeclaredFields()) { - ItemType type = (ItemType) f.get(null); - if (type == ItemType.AIR) { + if (!ItemType.Typed.class.isAssignableFrom(f.getType())) { continue; } + ItemType type = (ItemType) f.get(null); + ItemMeta meta = new ItemStack(type.asMaterial()).getItemMeta(); Class internal = meta == null ? CraftMetaItem.class : meta.getClass(); Class[] interfaces = internal.getInterfaces(); @@ -40,10 +42,13 @@ public void testItemMetaClasses() throws Exception { } Class actual = type.getItemMetaClass(); - assertThat(actual, is(expected)); + assertThat(actual, is(expected), "Bad registered item meta class for item type " + type.getKey()); + if (f.getGenericType() instanceof ParameterizedType paramType) { + assertThat(paramType.getActualTypeArguments()[0], is(expected), "Bad generic type for item type " + type.getKey()); + } } - assertThrows(UnsupportedOperationException.class, () -> ItemType.AIR.getItemMetaClass()); + assertThrows(UnsupportedOperationException.class, ItemType.AIR::getItemMetaClass); } @Test diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 62f41aa7e711..3b5438bebf79 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -158,6 +158,11 @@ public class LegacyTest { Material.NETHERITE_NAUTILUS_ARMOR, Material.NETHERITE_SPEAR, Material.STONE_SPEAR, Material.WOODEN_SPEAR, Material.ZOMBIE_NAUTILUS_SPAWN_EGG, Material.CAMEL_HUSK_SPAWN_EGG, Material.PARCHED_SPAWN_EGG, Material.NETHERITE_HORSE_ARMOR, // 26.1 Material.GOLDEN_DANDELION, Material.POTTED_GOLDEN_DANDELION, + // 26.2 + Material.CHISELED_CINNABAR, Material.CHISELED_SULFUR, Material.CINNABAR, Material.CINNABAR_BRICKS, Material.CINNABAR_BRICK_SLAB, Material.CINNABAR_BRICK_STAIRS, Material.CINNABAR_BRICK_WALL, Material.CINNABAR_SLAB, Material.CINNABAR_STAIRS, Material.CINNABAR_WALL, + Material.MUSIC_DISC_BOUNCE, Material.POLISHED_CINNABAR, Material.POLISHED_CINNABAR_SLAB, Material.POLISHED_CINNABAR_STAIRS, Material.POLISHED_CINNABAR_WALL, Material.POLISHED_SULFUR, Material.POLISHED_SULFUR_SLAB, Material.POLISHED_SULFUR_STAIRS, Material.POLISHED_SULFUR_WALL, + Material.POTENT_SULFUR, Material.SULFUR, Material.SULFUR_BRICKS, Material.SULFUR_BRICK_SLAB, Material.SULFUR_BRICK_STAIRS, Material.SULFUR_BRICK_WALL, Material.SULFUR_CUBE_BUCKET, Material.SULFUR_CUBE_SPAWN_EGG, Material.SULFUR_SLAB, Material.SULFUR_SPIKE, Material.SULFUR_STAIRS, + Material.SULFUR_WALL, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java b/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java index 5811a3bbde12..09d1c69f9200 100644 --- a/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java +++ b/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java @@ -95,7 +95,7 @@ public static Server setup() { // Paper start - testing additions final Thread currentThread = Thread.currentThread(); when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread)); - final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance, new java.util.HashMap<>()), null); + final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance, new java.util.HashMap<>()), null); when(instance.getPluginManager()).thenReturn(pluginManager); // Paper end - testing additions diff --git a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java index 9d7f92967dcf..c22227c4cf24 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/RegistriesArgumentProvider.java @@ -16,6 +16,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.SulfurCubeArchetype; import net.minecraft.world.entity.animal.chicken.ChickenSoundVariant; import net.minecraft.world.entity.animal.chicken.ChickenVariant; import net.minecraft.world.entity.animal.cow.CowSoundVariant; @@ -65,6 +66,7 @@ import org.bukkit.craftbukkit.entity.CraftCow; import org.bukkit.craftbukkit.entity.CraftFrog; import org.bukkit.craftbukkit.entity.CraftPig; +import org.bukkit.craftbukkit.entity.CraftSulfurCube; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; import org.bukkit.craftbukkit.entity.CraftZombieNautilus; @@ -83,6 +85,7 @@ import org.bukkit.entity.Cow; import org.bukkit.entity.Frog; import org.bukkit.entity.Pig; +import org.bukkit.entity.SulfurCube; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; import org.bukkit.entity.ZombieNautilus; @@ -161,6 +164,7 @@ public Object[] get() { register(Registries.DIALOG, Dialog.class, PaperDialog.class, net.minecraft.server.dialog.Dialog.class); register(Registries.GAME_RULE, GameRule.class, GameRules.class, CraftGameRule.class, net.minecraft.world.level.gamerules.GameRule.class); register(Registries.POINT_OF_INTEREST_TYPE, PoiType.class, PoiTypes.class, PaperPoiType.class, net.minecraft.world.entity.ai.village.poi.PoiType.class); + register(Registries.SULFUR_CUBE_ARCHETYPE, SulfurCube.Archetype.class, CraftSulfurCube.CraftArchetype.class, SulfurCubeArchetype.class); } private static void register(ResourceKey> registryKey, Class api, Class impl, Class internal) { diff --git a/snapshot-todos.txt b/snapshot-todos.txt new file mode 100644 index 000000000000..250bffe6365d --- /dev/null +++ b/snapshot-todos.txt @@ -0,0 +1 @@ +Vex summoner can be any LivingEntity now, Vex#getSummoner currently returns Mob From bb676e22673112127df4130b4b5b4115c094d153 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 12 Jun 2026 19:37:14 +0200 Subject: [PATCH 02/30] actual 26.2-rc-2 --- README.md | 4 +- gradle.properties | 2 +- paper-server/build.gradle.kts | 2 +- ...015-Optimise-EntityScheduler-ticking.patch | 4 +- .../network/codec/ByteBufCodecs.java.patch | 2 +- .../server/level/ChunkMap.java.patch | 28 ++--- .../ServerGamePacketListenerImpl.java.patch | 40 +++---- .../util/datafix/DataFixers.java.patch | 2 +- .../minecraft/world/entity/Entity.java.patch | 108 +++++++++--------- .../monster/cubemob/SulfurCube.java.patch | 2 +- 10 files changed, 96 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 59445d9decdd..b53f8180aead 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ repositories { } dependencies { - compileOnly("io.papermc.paper:paper-api:26.1.2.build.+") + compileOnly("io.papermc.paper:paper-api:26.2.build.+") } java { @@ -59,7 +59,7 @@ java { io.papermc.paper paper-api - [26.1.2.build,) + [26.2.build,) provided ``` diff --git a/gradle.properties b/gradle.properties index 1dbdbe4ad184..adce5e88685f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=io.papermc.paper -mcVersion=26.2-pre-5 +mcVersion=26.2-rc-2 # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=26.2 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index cd251009c842..93fb6d33ed45 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:26.2-pre-5+build.1") + mache("io.papermc:mache:26.2-rc-2+build.2") paperclip("io.papermc:paperclip:3.0.4") } diff --git a/paper-server/patches/features/0015-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features/0015-Optimise-EntityScheduler-ticking.patch index 359d182dae1c..6c2a8b37dd35 100644 --- a/paper-server/patches/features/0015-Optimise-EntityScheduler-ticking.patch +++ b/paper-server/patches/features/0015-Optimise-EntityScheduler-ticking.patch @@ -54,10 +54,10 @@ index 0f41295186f7dbcdf3c496c97b70b9732ce1ca23..ea91ac77929db3eb73efa0377f223cb0 io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.handleQueue(this.tickCount); // Paper io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue(this.tickCount); // Paper diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 4837708576725decc0fad19cf92e52341fffe034..28779f4eb561b31c6fa3586cf86019244ca48c15 100644 +index b117729e21c98a4480484320222eaccdb1be5ada..dd4f8d4b26240974a6c5147dd1ee1d686b0e13d1 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -4965,6 +4965,11 @@ public abstract class Entity +@@ -4969,6 +4969,11 @@ public abstract class Entity this.getBukkitEntity().taskScheduler.retire(); } // Paper end - Folia schedulers diff --git a/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch b/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch index c6eed07a1593..9621f4197ed1 100644 --- a/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch @@ -64,7 +64,7 @@ static StreamCodec> optional(final StreamCodec original) { return new StreamCodec>() { @Override -@@ -594,7 +_,7 @@ +@@ -598,7 +_,7 @@ } static StreamCodec.CodecOperation registryFriendlyLengthPrefixed(final int maxSize) { 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 4e018ac9d134..d139327fc816 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 @@ -141,7 +141,7 @@ } }, this.unloadQueue::add).whenComplete((ignored, throwable) -> { if (throwable != null) { -@@ -840,7 +_,7 @@ +@@ -843,7 +_,7 @@ } public int size() { @@ -150,7 +150,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -867,10 +_,10 @@ +@@ -870,10 +_,10 @@ .addColumn("fluid_ticks") .build(output); @@ -165,7 +165,7 @@ Optional chunk = Optional.ofNullable(holder.getLatestChunk()); Optional fullChunk = chunk.flatMap( chunkAccess -> chunkAccess instanceof LevelChunk levelChunk ? Optional.of(levelChunk) : Optional.empty() -@@ -919,14 +_,14 @@ +@@ -922,14 +_,14 @@ return this.upgradeChunkTag( tag, -1, @@ -183,7 +183,7 @@ generatorIdentifier.ifPresent(identifier -> contextTag.putString("generator", identifier.toString())); return contextTag; } -@@ -938,7 +_,7 @@ +@@ -941,7 +_,7 @@ ChunkHolder holder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (holder != null) { LevelChunk chunk = holder.getTickingChunk(); @@ -192,7 +192,7 @@ output.add(chunk); } } -@@ -958,8 +_,14 @@ +@@ -961,8 +_,14 @@ } public boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos) { @@ -208,7 +208,7 @@ } public boolean anyPlayerCloseEnoughTo(final BlockPos pos, final int maxDistance) { -@@ -975,8 +_,24 @@ +@@ -978,8 +_,24 @@ } private boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos) { @@ -234,7 +234,7 @@ return true; } } -@@ -993,7 +_,7 @@ +@@ -996,7 +_,7 @@ Builder builder = ImmutableList.builder(); for (ServerPlayer player : this.playerMap.getAllPlayers()) { @@ -243,7 +243,7 @@ builder.add(player); } } -@@ -1001,13 +_,13 @@ +@@ -1004,13 +_,13 @@ return builder.build(); } @@ -259,7 +259,7 @@ } private boolean playerIsCloseEnoughTo(final ServerPlayer player, final Vec3 pos, final int maxDistance) { -@@ -1139,9 +_,19 @@ +@@ -1142,9 +_,19 @@ } public void addEntity(final Entity entity) { @@ -279,7 +279,7 @@ if (range != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1165,6 +_,7 @@ +@@ -1168,6 +_,7 @@ } protected void removeEntity(final Entity entity) { @@ -287,7 +287,7 @@ if (entity instanceof ServerPlayer player) { this.updatePlayerStatus(player, false); -@@ -1325,10 +_,10 @@ +@@ -1328,10 +_,10 @@ private final Entity entity; private final int range; private SectionPos lastSectionPos; @@ -300,7 +300,7 @@ this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1375,6 +_,7 @@ +@@ -1378,6 +_,7 @@ } public void removePlayer(final ServerPlayer player) { @@ -308,7 +308,7 @@ if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); if (this.seenBy.isEmpty()) { -@@ -1384,23 +_,47 @@ +@@ -1387,23 +_,47 @@ } public void updatePlayer(final ServerPlayer player) { @@ -359,7 +359,7 @@ } } else { this.removePlayer(player); -@@ -1417,6 +_,7 @@ +@@ -1420,6 +_,7 @@ for (Entity passenger : this.entity.getIndirectPassengers()) { int passengerRange = passenger.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 9ca09ea04b97..48204d3eeaee 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1947,7 +1947,7 @@ this.resetPosition(); this.restartClientLoadTimerAfterRespawn(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); -@@ -1905,12 +_,12 @@ +@@ -1905,11 +_,11 @@ return; } @@ -1957,13 +1957,11 @@ this.restartClientLoadTimerAfterRespawn(); if (this.server.isHardcore()) { - this.player.setGameMode(GameType.SPECTATOR); -- this.player.level().getGameRules().set(GameRules.SPECTATORS_GENERATE_CHUNKS, false, this.server); + this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - Expand PlayerGameModeChangeEvent -+ this.player.level().getGameRules().set(GameRules.SPECTATORS_GENERATE_CHUNKS, false, this.player.level()); // CraftBukkit - per-world } } break; -@@ -1923,7 +_,7 @@ +@@ -1922,7 +_,7 @@ } private void sendGameRuleValues() { @@ -1972,7 +1970,7 @@ LOGGER.warn("Player {} tried to request game rule values without required permissions", this.player.getGameProfile().name()); } else { GameRules gameRules = this.player.level().getGameRules(); -@@ -1939,16 +_,27 @@ +@@ -1938,16 +_,27 @@ @Override public void handleContainerClose(final ServerboundContainerClosePacket packet) { @@ -2002,7 +2000,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); -@@ -1964,7 +_,298 @@ +@@ -1963,7 +_,298 @@ } else { boolean fullResyncNeeded = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2302,7 +2300,7 @@ for (Entry e : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(e.getIntKey(), e.getValue()); -@@ -1977,6 +_,8 @@ +@@ -1976,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2311,7 +2309,7 @@ } } } -@@ -1984,6 +_,14 @@ +@@ -1983,6 +_,14 @@ @Override public void handlePlaceRecipe(final ServerboundPlaceRecipePacket packet) { @@ -2326,7 +2324,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -2000,9 +_,44 @@ +@@ -1999,9 +_,44 @@ return; } @@ -2372,7 +2370,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, displayInfo.display().display())); } -@@ -2016,6 +_,7 @@ +@@ -2015,6 +_,7 @@ @Override public void handleContainerButtonClick(final ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2380,7 +2378,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -2025,6 +_,7 @@ +@@ -2024,6 +_,7 @@ if (clickAccepted) { this.player.containerMenu.broadcastChanges(); } @@ -2388,7 +2386,7 @@ } } } -@@ -2041,10 +_,48 @@ +@@ -2040,10 +_,48 @@ boolean validSlot = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean validData = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2437,7 +2435,7 @@ } else if (drop && validData) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -2058,15 +_,38 @@ +@@ -2057,15 +_,38 @@ @Override public void handleSignUpdate(final ServerboundSignUpdatePacket packet) { @@ -2477,7 +2475,7 @@ if (!(level.getBlockEntity(pos) instanceof SignBlockEntity sign)) { return; } -@@ -2078,14 +_,32 @@ +@@ -2077,14 +_,32 @@ @Override public void handlePlayerAbilities(final ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2511,7 +2509,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != wasHatShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -2101,21 +_,21 @@ +@@ -2100,21 +_,21 @@ packet.difficulty().getDisplayName() ); } else { @@ -2536,7 +2534,7 @@ } } -@@ -2135,7 +_,7 @@ +@@ -2134,7 +_,7 @@ ProfilePublicKey.Data newProfileKey = newChatSession.profilePublicKey(); if (!Objects.equals(oldProfileKey, newProfileKey)) { if (oldProfileKey != null && newProfileKey.expiresAt().isBefore(oldProfileKey.expiresAt())) { @@ -2545,7 +2543,7 @@ } else { try { SignatureValidator profileKeySignatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2146,8 +_,8 @@ +@@ -2145,8 +_,8 @@ this.resetPlayerChatState(newChatSession.validate(this.player.getGameProfile(), profileKeySignatureValidator)); } catch (ProfilePublicKey.ValidationException e) { @@ -2556,7 +2554,7 @@ } } } -@@ -2159,11 +_,13 @@ +@@ -2158,11 +_,13 @@ throw new IllegalStateException("Client acknowledged config, but none was requested"); } @@ -2571,7 +2569,7 @@ } @Override -@@ -2180,27 +_,32 @@ +@@ -2179,27 +_,32 @@ private void resetPlayerChatState(final RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2605,7 +2603,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2232,12 +_,23 @@ +@@ -2231,12 +_,23 @@ } public void tickClientLoadTimeout() { @@ -2631,7 +2629,7 @@ this.clientLoadedTimeoutTimer = 0; } -@@ -2249,4 +_,80 @@ +@@ -2248,4 +_,80 @@ this.waitingForRespawn = false; this.clientLoadedTimeoutTimer = 60; } diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch index 50dfd448498c..9e1646eaf619 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -553,6 +_,24 @@ +@@ -554,6 +_,24 @@ Schema v1456 = fixerUpper.addSchema(1456, SAME_NAMESPACED); fixerUpper.addFixer(new EntityItemFrameDirectionFix(v1456, false)); Schema v1458 = fixerUpper.addSchema(1458, V1458::new); 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 88794037c6eb..5ce895506263 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 @@ -647,7 +647,7 @@ this.needsSync = true; } } -@@ -2020,8 +_,20 @@ +@@ -2024,8 +_,20 @@ } public boolean isPushable() { @@ -668,7 +668,7 @@ public void awardKillScore(final Entity victim, final DamageSource killingBlow) { if (victim instanceof ServerPlayer serverPlayer) { -@@ -2048,17 +_,25 @@ +@@ -2052,17 +_,25 @@ } public boolean saveAsPassenger(final ValueOutput output) { @@ -698,7 +698,7 @@ return true; } -@@ -2067,14 +_,34 @@ +@@ -2071,14 +_,34 @@ } public void saveWithoutId(final ValueOutput output) { @@ -733,7 +733,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -2082,7 +_,29 @@ +@@ -2086,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -763,7 +763,7 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -2105,9 +_,14 @@ +@@ -2109,9 +_,14 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } @@ -781,7 +781,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -2117,13 +_,13 @@ +@@ -2121,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -797,7 +797,7 @@ passengersList.discardLast(); } } -@@ -2132,6 +_,33 @@ +@@ -2136,6 +_,33 @@ output.discard("Passengers"); } } @@ -831,7 +831,7 @@ } catch (Throwable t) { CrashReport report = CrashReport.forThrowable(t, "Saving entity NBT"); CrashReportCategory category = report.addCategory("Entity being saved"); -@@ -2179,7 +_,20 @@ +@@ -2183,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -853,7 +853,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2190,6 +_,58 @@ +@@ -2194,6 +_,58 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -912,7 +912,7 @@ } catch (Throwable t) { CrashReport report = CrashReport.forThrowable(t, "Loading entity NBT"); CrashReportCategory category = report.addCategory("Entity being loaded"); -@@ -2203,7 +_,13 @@ +@@ -2207,7 +_,13 @@ } public final @Nullable String getEncodeId() { @@ -927,7 +927,7 @@ return null; } -@@ -2213,6 +_,12 @@ +@@ -2217,6 +_,12 @@ protected abstract void readAdditionalSaveData(ValueInput input); @@ -940,7 +940,7 @@ protected abstract void addAdditionalSaveData(ValueOutput output); public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemLike resource) { -@@ -2224,12 +_,57 @@ +@@ -2228,12 +_,57 @@ } public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final ItemStack itemStack, final Vec3 offset) { @@ -1000,7 +1000,7 @@ level.addFreshEntity(entity); return entity; } -@@ -2273,6 +_,15 @@ +@@ -2277,6 +_,15 @@ for (Leashable mob : mobsToLeash) { if (mob.canHaveALeashAttachedTo(this)) { @@ -1016,7 +1016,7 @@ mob.setLeashedTo(this, true); anyLeashed = true; } -@@ -2287,7 +_,7 @@ +@@ -2291,7 +_,7 @@ } ItemStack heldItem = player.getItemInHand(hand); @@ -1025,7 +1025,7 @@ heldItem.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob target -@@ -2300,11 +_,13 @@ +@@ -2304,11 +_,13 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1043,7 +1043,7 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2321,9 +_,22 @@ +@@ -2325,9 +_,22 @@ if (leashable.canHaveALeashAttachedTo(player)) { if (leashable.isLeashed()) { @@ -1067,7 +1067,7 @@ leashable.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemStack.shrink(1); -@@ -2337,7 +_,13 @@ +@@ -2341,7 +_,13 @@ } public boolean shearOffAllLeashConnections(final @Nullable Player player) { @@ -1082,7 +1082,7 @@ if (dropped && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2346,15 +_,39 @@ +@@ -2350,15 +_,39 @@ } public boolean dropAllLeashConnections(final @Nullable Player player) { @@ -1126,7 +1126,7 @@ } if (dropped) { -@@ -2422,7 +_,7 @@ +@@ -2426,7 +_,7 @@ } public boolean startRiding(final Entity entityToRide, final boolean force, final boolean sendEventAndTriggers) { @@ -1135,7 +1135,7 @@ return false; } -@@ -2430,7 +_,7 @@ +@@ -2434,7 +_,7 @@ return false; } @@ -1144,7 +1144,7 @@ return false; } -@@ -2441,6 +_,27 @@ +@@ -2445,6 +_,27 @@ } if (force || this.canRide(entityToRide) && entityToRide.canAddPassenger(this)) { @@ -1172,7 +1172,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2472,10 +_,16 @@ +@@ -2476,10 +_,16 @@ } public void removeVehicle() { @@ -1190,7 +1190,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, oldVehicle.position); -@@ -2484,7 +_,13 @@ +@@ -2488,7 +_,13 @@ } public void stopRiding() { @@ -1205,7 +1205,7 @@ } protected void addPassenger(final Entity passenger) { -@@ -2506,11 +_,44 @@ +@@ -2510,11 +_,44 @@ } } @@ -1251,7 +1251,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2518,6 +_,7 @@ +@@ -2522,6 +_,7 @@ } passenger.boardingCooldown = 60; @@ -1259,7 +1259,7 @@ } protected boolean canAddPassenger(final Entity passenger) { -@@ -2700,7 +_,7 @@ +@@ -2704,7 +_,7 @@ } public boolean isCrouching() { @@ -1268,7 +1268,7 @@ } public boolean isSprinting() { -@@ -2716,7 +_,7 @@ +@@ -2720,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1277,7 +1277,7 @@ } public boolean isVisuallyCrawling() { -@@ -2724,6 +_,13 @@ +@@ -2728,6 +_,13 @@ } public void setSwimming(final boolean swimming) { @@ -1291,7 +1291,7 @@ this.setSharedFlag(FLAG_SWIMMING, swimming); } -@@ -2761,6 +_,7 @@ +@@ -2765,6 +_,7 @@ } public @Nullable PlayerTeam getTeam() { @@ -1299,7 +1299,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2777,7 +_,11 @@ +@@ -2781,7 +_,11 @@ } public void setInvisible(final boolean invisible) { @@ -1312,7 +1312,7 @@ } public boolean getSharedFlag(final @Entity.Flags int flag) { -@@ -2794,7 +_,7 @@ +@@ -2798,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1321,7 +1321,7 @@ } public int getAirSupply() { -@@ -2802,10 +_,24 @@ +@@ -2806,10 +_,24 @@ } public void setAirSupply(final int supply) { @@ -1347,7 +1347,7 @@ this.setTicksFrozen(0); } -@@ -2832,11 +_,42 @@ +@@ -2836,11 +_,42 @@ public void thunderHit(final ServerLevel level, final LightningBolt lightningBolt) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1394,7 +1394,7 @@ } public void onAboveBubbleColumn(final boolean dragDown, final BlockPos pos) { -@@ -2888,6 +_,12 @@ +@@ -2892,6 +_,12 @@ entity.resetFallDistance(); } @@ -1407,7 +1407,7 @@ public boolean killedEntity(final ServerLevel level, final LivingEntity entity, final DamageSource source) { return true; } -@@ -2986,26 +_,30 @@ +@@ -2990,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1441,7 +1441,7 @@ ); } -@@ -3033,6 +_,13 @@ +@@ -3037,6 +_,13 @@ } public void restoreFrom(final Entity oldEntity) { @@ -1455,7 +1455,7 @@ try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput entityData = TagValueOutput.createWithContext(reporter, oldEntity.registryAccess()); oldEntity.saveWithoutId(entityData); -@@ -3043,8 +_,66 @@ +@@ -3047,8 +_,66 @@ this.portalProcess = oldEntity.portalProcess; } @@ -1523,7 +1523,7 @@ ServerLevel newLevel = transition.newLevel(); boolean otherDimension = newLevel.dimension() != serverLevel.dimension(); if (!transition.asPassenger()) { -@@ -3094,10 +_,15 @@ +@@ -3098,10 +_,15 @@ return null; } @@ -1540,7 +1540,7 @@ for (Entity newPassenger : newPassengers) { newPassenger.startRiding(newEntity, true, false); -@@ -3183,9 +_,17 @@ +@@ -3187,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1561,7 +1561,7 @@ } if (this instanceof WaypointTransmitter waypoint && this.level instanceof ServerLevel serverLevel) { -@@ -3202,6 +_,7 @@ +@@ -3206,6 +_,7 @@ } public boolean canTeleport(final Level from, final Level to) { @@ -1569,7 +1569,7 @@ if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { for (Entity passenger : this.getPassengers()) { if (passenger instanceof ServerPlayer player && !player.seenCredits) { -@@ -3322,7 +_,7 @@ +@@ -3326,7 +_,7 @@ return null; } @@ -1578,7 +1578,7 @@ final ServerLevel level, final double x, final double y, -@@ -3332,14 +_,30 @@ +@@ -3336,14 +_,30 @@ final float newXRot, final boolean resetCamera ) { @@ -1611,7 +1611,7 @@ } public void teleportTo(final double x, final double y, final double z) { -@@ -3450,7 +_,26 @@ +@@ -3454,7 +_,26 @@ } public final void setBoundingBox(final AABB bb) { @@ -1639,7 +1639,7 @@ } public final float getEyeHeight(final Pose pose) { -@@ -3474,6 +_,12 @@ +@@ -3478,6 +_,12 @@ } public void stopSeenByPlayer(final ServerPlayer player) { @@ -1652,7 +1652,7 @@ } public float rotate(final Rotation rotation) { -@@ -3532,21 +_,32 @@ +@@ -3536,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1686,7 +1686,7 @@ } public int countPlayerPassengers() { -@@ -3554,6 +_,7 @@ +@@ -3558,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1694,7 +1694,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3634,9 +_,38 @@ +@@ -3638,9 +_,38 @@ return 0; } @@ -1734,7 +1734,7 @@ this.position(), this.getRotationVector(), level, -@@ -3734,7 +_,9 @@ +@@ -3738,7 +_,9 @@ public void setDeltaMovement(final Vec3 deltaMovement) { if (deltaMovement.isFinite()) { @@ -1744,7 +1744,7 @@ } } -@@ -3805,8 +_,34 @@ +@@ -3809,8 +_,34 @@ } public final void setPosRaw(final double x, final double y, final double z) { @@ -1779,7 +1779,7 @@ int fx = Mth.floor(x); int fy = Mth.floor(y); int fz = Mth.floor(z); -@@ -3828,7 +_,18 @@ +@@ -3832,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(player); } } @@ -1799,7 +1799,7 @@ } public void checkDespawn() { -@@ -3880,6 +_,12 @@ +@@ -3884,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1812,7 +1812,7 @@ public float getYRot() { return this.yRot; } -@@ -3930,7 +_,9 @@ +@@ -3934,7 +_,9 @@ } @Override @@ -1823,7 +1823,7 @@ if (this.removalReason == null) { this.removalReason = reason; } -@@ -3942,12 +_,28 @@ +@@ -3946,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(reason); this.onRemoval(reason); @@ -1852,7 +1852,7 @@ @Override public void setLevelCallback(final EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4169,4 +_,10 @@ +@@ -4173,4 +_,10 @@ return this.save; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch index 944fc58fcafb..96138dbdbf09 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch @@ -142,7 +142,7 @@ } } -@@ -1006,7 +_,7 @@ +@@ -1011,7 +_,7 @@ } @Override From a737972b75f16f6656cf1db675ef1a88b05c149a Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 12 Jun 2026 20:20:34 +0200 Subject: [PATCH 03/30] Fix isAllowedInPeaceful call --- .../minecraft/world/entity/SpawnPlacements.java.patch | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/SpawnPlacements.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/entity/SpawnPlacements.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/SpawnPlacements.java.patch new file mode 100644 index 000000000000..5fd7e1ad910c --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/SpawnPlacements.java ++++ b/net/minecraft/world/entity/SpawnPlacements.java +@@ -79,7 +_,7 @@ + public static boolean checkSpawnRules( + final EntityType type, final ServerLevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random + ) { +- if (!type.isAllowedInPeaceful() && level.getDifficulty() == Difficulty.PEACEFUL) { ++ if (!type.isTypeAllowedInPeaceful() && level.getDifficulty() == Difficulty.PEACEFUL) { // Paper - allow changing despawnInPeaceful + return false; + } + From c35810c3fcf74bd41c2e83e113fbf36340ce6e53 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 12 Jun 2026 20:46:15 +0200 Subject: [PATCH 04/30] Update deps to match Vanilla --- paper-api/build.gradle.kts | 8 ++++---- paper-server/build.gradle.kts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index 53a03ae8b9b3..4d100bf54a1f 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -42,8 +42,8 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider { dependencies { // api dependencies are listed transitively to API consumers - api("com.google.guava:guava:33.5.0-jre") - api("com.google.code.gson:gson:2.13.2") + api("com.google.guava:guava:33.6.0-jre") + api("com.google.code.gson:gson:2.14.0") api("org.yaml:snakeyaml:2.2") api("org.joml:joml:1.10.8") { isTransitive = false // https://github.com/JOML-CI/JOML/issues/352 @@ -187,11 +187,11 @@ tasks.withType().configureEach { options.use() options.isDocFilesSubDirs = true options.links( - "https://guava.dev/releases/33.5.0-jre/api/docs/", + "https://guava.dev/releases/33.6.0-jre/api/docs/", "https://www.javadocs.dev/org.yaml/snakeyaml/2.2/", "https://www.javadocs.dev/org.jetbrains/annotations/$annotationsVersion/", "https://www.javadocs.dev/org.joml/joml/1.10.8/", - "https://www.javadocs.dev/com.google.code.gson/gson/2.13.2", + "https://www.javadocs.dev/com.google.code.gson/gson/2.14.0", "https://jspecify.dev/docs/api/", "https://jd.advntr.dev/api/$adventureVersion/", "https://jd.advntr.dev/key/$adventureVersion/", diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 93fb6d33ed45..5a2c1f62d368 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -122,16 +122,16 @@ dependencies { all its classes to check if they are plugins. Scanning takes about 1-2 seconds so adding this speeds up the server start. */ - implementation("org.apache.logging.log4j:log4j-core:2.25.2") - log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.25.2") // Needed to generate meta for our Log4j plugins + implementation("org.apache.logging.log4j:log4j-core:2.26.0") + log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.26.0") // Needed to generate meta for our Log4j plugins runtimeOnly(log4jPlugins.output) alsoShade(log4jPlugins.output) implementation("com.velocitypowered:velocity-native:3.4.0-SNAPSHOT") { isTransitive = false } - implementation("io.netty:netty-codec-haproxy:4.2.7.Final") // Add support for proxy protocol - implementation("org.apache.logging.log4j:log4j-iostreams:2.25.2") + implementation("io.netty:netty-codec-haproxy:4.2.15.Final") // Add support for proxy protocol + implementation("org.apache.logging.log4j:log4j-iostreams:2.26.0") implementation("org.ow2.asm:asm-commons:9.9.1") implementation("org.spongepowered:configurate-yaml:4.2.0") From e5643cd4d7cf18a2f6ce255a7a4c681f5d0cefe0 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 12 Jun 2026 20:51:06 +0200 Subject: [PATCH 05/30] Update Vex#getSummoner return type --- .../src/main/java/org/bukkit/entity/Vex.java | 19 +++++++++++++++---- .../bukkit/craftbukkit/entity/CraftVex.java | 9 ++++----- snapshot-todos.txt | 1 - 3 files changed, 19 insertions(+), 10 deletions(-) delete mode 100644 snapshot-todos.txt diff --git a/paper-api/src/main/java/org/bukkit/entity/Vex.java b/paper-api/src/main/java/org/bukkit/entity/Vex.java index 45140384af90..83cea1a1d542 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Vex.java +++ b/paper-api/src/main/java/org/bukkit/entity/Vex.java @@ -85,19 +85,30 @@ public interface Vex extends Monster { // Paper start /** - * Get the Mob that summoned this vex + * Get the living entity that summoned this vex * - * @return Mob that summoned this vex + * @return Living entity that summoned this vex */ @Nullable - Mob getSummoner(); + LivingEntity getSummoner(); /** * Set the summoner of this vex * * @param summoner New summoner */ - void setSummoner(@Nullable Mob summoner); + void setSummoner(@Nullable LivingEntity summoner); + + /** + * Set the summoner of this vex + * + * @param summoner New summoner + * @deprecated Use {@link #setSummoner(LivingEntity)} + */ + @Deprecated(forRemoval = true, since = "26.2") + default void setSummoner(@Nullable Mob summoner) { + this.setSummoner((LivingEntity) summoner); + } /** * Gets if this vex should start to take damage diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index e9dc62fa360f..3b6a1bf12f4b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -6,7 +6,6 @@ import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.CraftLocation; -import org.bukkit.entity.Mob; import org.bukkit.entity.Vex; public class CraftVex extends CraftMonster implements Vex { @@ -21,14 +20,14 @@ public net.minecraft.world.entity.monster.Vex getHandle() { } @Override - public org.bukkit.entity.Mob getSummoner() { + public org.bukkit.entity.LivingEntity getSummoner() { net.minecraft.world.entity.LivingEntity owner = this.getHandle().getOwner(); - return owner instanceof net.minecraft.world.entity.Mob mob ? (Mob) mob.getBukkitEntity() : null; // todo - snapshot - the summoner/owner can be any LivingEntity now + return owner instanceof net.minecraft.world.entity.LivingEntity livingEntity ? livingEntity.getBukkitLivingEntity() : null; } @Override - public void setSummoner(org.bukkit.entity.Mob summoner) { - this.getHandle().owner = summoner == null ? null : EntityReference.of(((CraftMob) summoner).getHandle()); + public void setSummoner(org.bukkit.entity.LivingEntity summoner) { + this.getHandle().owner = summoner == null ? null : EntityReference.of(((CraftLivingEntity) summoner).getHandle()); } @Override diff --git a/snapshot-todos.txt b/snapshot-todos.txt deleted file mode 100644 index 250bffe6365d..000000000000 --- a/snapshot-todos.txt +++ /dev/null @@ -1 +0,0 @@ -Vex summoner can be any LivingEntity now, Vex#getSummoner currently returns Mob From e00936a32e6fd819e86b88831f62a9ae7a862ecb Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 12 Jun 2026 21:12:41 +0200 Subject: [PATCH 06/30] [ci skip] update log4j for the api --- paper-api/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index 4d100bf54a1f..7a6c3a388315 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -15,7 +15,7 @@ val annotationsVersion = "26.0.2" val adventureVersion = "4.26.1" val bungeeCordChatVersion = "1.21-R0.2-deprecated+build.21" val slf4jVersion = "2.0.17" -val log4jVersion = "2.25.2" +val log4jVersion = "2.26.0" val apiAndDocs: Configuration by configurations.creating { attributes { From eb5df78ffa996c447f4d507d59264c0035f5cf3e Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 12 Jun 2026 21:49:36 +0200 Subject: [PATCH 07/30] fix wither spawning parity and remove openSign var The wither now spawn again when the last placed skull replace a block such as a snow layer. --- .../minecraft/world/item/ItemStack.java.patch | 43 ++++++------------- .../minecraft/world/item/SignItem.java.patch | 15 +------ .../level/block/WitherSkullBlock.java.patch | 13 +++--- 3 files changed, 23 insertions(+), 48 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index 7d038d8d3e55..ee0187c96c86 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -32,7 +32,7 @@ ItemStack.CODEC.encodeStart(ops, itemStack).getOrThrow(DecoderException::new); } -@@ -368,10 +_,156 @@ +@@ -368,10 +_,141 @@ } Item usedItem = this.getItem(); @@ -72,6 +72,7 @@ + int newCount = this.getCount(); + this.setCount(previousCount); + this.restorePatch(previousPatch); ++ + if (result.consumesAction() && isBonemeal && !capturedBlockStates.isEmpty()) { + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); + org.bukkit.event.world.StructureGrowEvent structureEvent = null; @@ -97,10 +98,9 @@ + } + player.awardStat(Stats.ITEM_USED.get(usedItem)); // SPIGOT-7236 - award stat + } -+ -+ SignItem.openSign = null; // SPIGOT-6758 - Reset on early return + return result; + } ++ if (player != null && result instanceof InteractionResult.Success success && success.wasItemInteraction()) { - player.awardStat(Stats.ITEM_USED.get(usedItem)); + InteractionHand hand = context.getHand(); @@ -119,8 +119,6 @@ + for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : capturedBlockStates) { + snapshot.revertPlace(true); // poi updates needs to be skipped since the poi were never registered as part of the capture + } -+ -+ 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)) { @@ -145,40 +143,27 @@ + 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); -+ } ++ BlockPos placedPos = success.paperSuccessContext().placedPos(); ++ if (usedItem == Items.WITHER_SKELETON_SKULL && placedPos != null) { // Special case skulls to allow wither spawns to be cancelled ++ net.minecraft.world.level.block.entity.BlockEntity blockEntity = level.getBlockEntity(placedPos); ++ if (blockEntity instanceof net.minecraft.world.level.block.entity.SkullBlockEntity skull) { ++ net.minecraft.world.level.block.WitherSkullBlock.checkSpawn(level, placedPos, skull); + } + } + + // 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 -+ } ++ if (usedItem instanceof SignItem && placedPos != null) { ++ if (level.getBlockEntity(placedPos) instanceof net.minecraft.world.level.block.entity.SignBlockEntity sign) { ++ if (level.getBlockState(placedPos).getBlock() instanceof net.minecraft.world.level.block.SignBlock signBlock) { ++ signBlock.openTextEdit(player, sign, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // CraftBukkit // Paper - Add PlayerOpenSignEvent + } -+ } finally { -+ SignItem.openSign = null; + } + } + + // SPIGOT-1288 - play sound stripped from BlockItem -+ if (usedItem instanceof BlockItem && success.paperSuccessContext().placedPos() != null) { ++ if (usedItem instanceof BlockItem && placedPos != null) { + // Paper start - Fix spigot sound playing for BlockItem ItemStacks -+ net.minecraft.world.level.block.state.BlockState state = level.getBlockState(success.paperSuccessContext().placedPos()); ++ BlockState state = level.getBlockState(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); diff --git a/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch index 55d79b84c5e4..a3e8972c8ce9 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SignItem.java.patch @@ -1,22 +1,11 @@ --- a/net/minecraft/world/item/SignItem.java +++ b/net/minecraft/world/item/SignItem.java -@@ -11,6 +_,7 @@ - import org.jspecify.annotations.Nullable; - - public class SignItem extends StandingAndWallBlockItem { -+ public static BlockPos openSign; // CraftBukkit - public SignItem(final Block sign, final Block wallSign, final Item.Properties properties) { - super(sign, wallSign, Direction.DOWN, properties); - } -@@ -29,7 +_,10 @@ +@@ -29,7 +_,7 @@ && player != null && level.getBlockEntity(pos) instanceof SignBlockEntity signEntity && level.getBlockState(pos).getBlock() instanceof SignBlock sign) { - sign.openTextEdit(player, signEntity, true); -+ // CraftBukkit start - SPIGOT-4678 -+ // sign.openTextEdit(player, signEntity, true); -+ SignItem.openSign = pos; -+ // CraftBukkit end ++ // sign.openTextEdit(player, signEntity, true); // CraftBukkit - SPIGOT-4678 - handled later in ItemStack#useOn } return success; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch index efdf2890169b..4c0acb575d7a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch @@ -1,13 +1,14 @@ --- a/net/minecraft/world/level/block/WitherSkullBlock.java +++ b/net/minecraft/world/level/block/WitherSkullBlock.java -@@ -49,6 +_,7 @@ +@@ -43,7 +_,7 @@ } - public static void checkSpawn(final Level level, final BlockPos pos, final SkullBlockEntity placedSkull) { -+ if (level.captureBlockStates) return; // CraftBukkit - if (!level.isClientSide()) { - BlockState blockState = placedSkull.getBlockState(); - boolean correctBlock = blockState.is(Blocks.WITHER_SKELETON_SKULL) || blockState.is(Blocks.WITHER_SKELETON_WALL_SKULL); + public static void checkSpawn(final Level level, final BlockPos pos) { +- if (level.getBlockEntity(pos) instanceof SkullBlockEntity placedSkull) { ++ if (!level.captureBlockStates && level.getBlockEntity(pos) instanceof SkullBlockEntity placedSkull) { // CraftBukkit + checkSpawn(level, pos, placedSkull); + } + } @@ -57,7 +_,7 @@ if (match != null) { WitherBoss witherBoss = EntityTypes.WITHER.create(level, EntitySpawnReason.TRIGGERED); From d1aca9a6c1057bd291255d3e2252dbf04992e410 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 12 Jun 2026 21:31:05 +0200 Subject: [PATCH 08/30] Apply most remaining feature patches --- .../0001-Moonrise-optimisation-patches.patch | 365 +++++++++--------- ...ion-and-add-advanced-packet-support.patch} | 2 +- ...=> 0003-Entity-Activation-Range-2.0.patch} | 26 +- ...> 0004-Optimize-Voxel-Shape-Merging.patch} | 6 +- ...05-optimize-dirt-and-snow-spreading.patch} | 0 ...city-compression-and-cipher-natives.patch} | 4 +- ...-Oversized-block-entities-in-chunks.patch} | 0 ...Optimize-Bit-Operations-by-inlining.patch} | 0 ...> 0009-Remove-streams-from-hot-code.patch} | 0 ...er-Remove-Streams-Optimized-collect.patch} | 0 ...-Eigencraft-redstone-implementation.patch} | 0 ...ate-Current-redstone-implementation.patch} | 8 +- ...Incremental-chunk-and-player-saving.patch} | 28 +- ...lush-support-to-Log4j-AsyncAppender.patch} | 0 ... 0015-Improve-keepalive-ping-system.patch} | 2 +- ...16-Optimise-EntityScheduler-ticking.patch} | 8 +- ...6-Anti-Xray.patch => 0017-Anti-Xray.patch} | 74 ++-- ...lay-open-close-callbacks-for-chests.patch} | 0 ...ove-exact-choice-recipe-ingredients.patch} | 0 ...20-Allow-Saving-of-Oversized-Chunks.patch} | 4 +- ...alSelector-Goal.Flag-Set-operations.patch} | 4 +- ...r-desync-when-new-players-are-added.patch} | 14 +- ...data-to-disk-if-it-serializes-witho.patch} | 4 +- ...24-Entity-load-save-limit-per-chunk.patch} | 4 +- ...ulate-regionfile-header-if-it-is-co.patch} | 14 +- ...nfiles-on-save-configuration-option.patch} | 0 ...n-checking-in-player-move-packet-ha.patch} | 18 +- ...0028-Optional-per-player-mob-spawns.patch} | 34 +- ...g-PreCreatureSpawnEvent-with-per-pl.patch} | 12 +- .../0030-Optimize-Hoppers.patch} | 20 +- 30 files changed, 327 insertions(+), 324 deletions(-) rename paper-server/patches/{features_unapplied => features}/0001-Moonrise-optimisation-patches.patch (99%) rename paper-server/patches/features/{0001-Optimize-Connection-and-add-advanced-packet-support.patch => 0002-Optimize-Connection-and-add-advanced-packet-support.patch} (99%) rename paper-server/patches/features/{0002-Entity-Activation-Range-2.0.patch => 0003-Entity-Activation-Range-2.0.patch} (97%) rename paper-server/patches/features/{0003-Optimize-Voxel-Shape-Merging.patch => 0004-Optimize-Voxel-Shape-Merging.patch} (96%) rename paper-server/patches/features/{0004-optimize-dirt-and-snow-spreading.patch => 0005-optimize-dirt-and-snow-spreading.patch} (100%) rename paper-server/patches/features/{0005-Use-Velocity-compression-and-cipher-natives.patch => 0006-Use-Velocity-compression-and-cipher-natives.patch} (98%) rename paper-server/patches/features/{0006-Handle-Oversized-block-entities-in-chunks.patch => 0007-Handle-Oversized-block-entities-in-chunks.patch} (100%) rename paper-server/patches/features/{0007-Optimize-Bit-Operations-by-inlining.patch => 0008-Optimize-Bit-Operations-by-inlining.patch} (100%) rename paper-server/patches/features/{0008-Remove-streams-from-hot-code.patch => 0009-Remove-streams-from-hot-code.patch} (100%) rename paper-server/patches/features/{0009-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch => 0010-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch} (100%) rename paper-server/patches/features/{0010-Eigencraft-redstone-implementation.patch => 0011-Eigencraft-redstone-implementation.patch} (100%) rename paper-server/patches/features/{0011-Add-Alternate-Current-redstone-implementation.patch => 0012-Add-Alternate-Current-redstone-implementation.patch} (99%) rename paper-server/patches/features/{0012-Incremental-chunk-and-player-saving.patch => 0013-Incremental-chunk-and-player-saving.patch} (87%) rename paper-server/patches/features/{0013-Add-explicit-flush-support-to-Log4j-AsyncAppender.patch => 0014-Add-explicit-flush-support-to-Log4j-AsyncAppender.patch} (100%) rename paper-server/patches/features/{0014-Improve-keepalive-ping-system.patch => 0015-Improve-keepalive-ping-system.patch} (99%) rename paper-server/patches/features/{0015-Optimise-EntityScheduler-ticking.patch => 0016-Optimise-EntityScheduler-ticking.patch} (92%) rename paper-server/patches/features/{0016-Anti-Xray.patch => 0017-Anti-Xray.patch} (91%) rename paper-server/patches/features/{0017-Delay-open-close-callbacks-for-chests.patch => 0018-Delay-open-close-callbacks-for-chests.patch} (100%) rename paper-server/patches/features/{0018-Improve-exact-choice-recipe-ingredients.patch => 0019-Improve-exact-choice-recipe-ingredients.patch} (100%) rename paper-server/patches/{features_unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch => features/0020-Allow-Saving-of-Oversized-Chunks.patch} (98%) rename paper-server/patches/{features_unapplied/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch => features/0021-Optimize-GoalSelector-Goal.Flag-Set-operations.patch} (97%) rename paper-server/patches/{features_unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch => features/0022-Fix-entity-tracker-desync-when-new-players-are-added.patch} (92%) rename paper-server/patches/{features_unapplied/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch => features/0023-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch} (96%) rename paper-server/patches/{features_unapplied/0018-Entity-load-save-limit-per-chunk.patch => features/0024-Entity-load-save-limit-per-chunk.patch} (96%) rename paper-server/patches/{features_unapplied/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch => features/0025-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch} (98%) rename paper-server/patches/{features_unapplied/0021-Flush-regionfiles-on-save-configuration-option.patch => features/0026-Flush-regionfiles-on-save-configuration-option.patch} (100%) rename paper-server/patches/{features_unapplied/0022-Optimise-collision-checking-in-player-move-packet-ha.patch => features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch} (93%) rename paper-server/patches/{features_unapplied/0027-Optional-per-player-mob-spawns.patch => features/0028-Optional-per-player-mob-spawns.patch} (89%) rename paper-server/patches/{features_unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch => features/0029-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch} (90%) rename paper-server/patches/{features_unapplied/0029-Optimize-Hoppers.patch => features/0030-Optimize-Hoppers.patch} (97%) diff --git a/paper-server/patches/features_unapplied/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch similarity index 99% rename from paper-server/patches/features_unapplied/0001-Moonrise-optimisation-patches.patch rename to paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index 4e807f088d17..3d498b6bc64e 100644 --- a/paper-server/patches/features_unapplied/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -23830,10 +23830,10 @@ index 9d9fa99ff7694a3356421df711c7b1443047b057..c79206e0eb455081f63cf4de2c974136 } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index f18001d368d74b987b21521ac2ffe75479ba3a87..c809ea1f2620c543d9bc80afdd64489f2fb98744 100644 +index 7b2a078c11cc5e7b9770ee3811e2b04479d20b37..7ebfe2acac0fe980320386de9574b0600c9e3e97 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -191,7 +191,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; +@@ -189,7 +189,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -23842,7 +23842,7 @@ index f18001d368d74b987b21521ac2ffe75479ba3a87..c809ea1f2620c543d9bc80afdd64489f private static MinecraftServer SERVER; // Paper public static final Logger LOGGER = LogUtils.getLogger(); public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper -@@ -425,6 +425,92 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop output) { + public void collectSpawningChunks(final List output) { - LongIterator spawnCandidateChunks = this.distanceManager.getSpawnCandidateChunks(); + // Paper start - optimise chunk tick iteration + final ca.spottedleaf.moonrise.common.list.ReferenceList tickingChunks = ((ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel)this.level).moonrise$getPlayerTickingChunks(); @@ -25406,7 +25406,7 @@ index 7b41d955038e457faf66d2c1d89437d29f45fbc5..7f879bc44354c9fac0238208db12b55a + // Paper end - optimise chunk tick iteration } - void forEachBlockTickingChunk(final Consumer tickingChunkConsumer) { + public void forEachBlockTickingChunk(final Consumer tickingChunkConsumer) { this.distanceManager.forEachEntityTickingChunk(chunkPos -> { - ChunkHolder holder = this.visibleChunkMap.get(chunkPos); + ChunkHolder holder = this.getVisibleChunkIfPresent(chunkPos); // Paper - rewrite chunk system @@ -25601,8 +25601,8 @@ index 7b41d955038e457faf66d2c1d89437d29f45fbc5..7f879bc44354c9fac0238208db12b55a + // Paper end - rewrite chunk system } - public void addEntity(final Entity entity) { -@@ -1228,6 +963,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + public boolean hasEntityWithId(final int id) { +@@ -1232,6 +967,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); @@ -25615,7 +25615,7 @@ index 7b41d955038e457faf66d2c1d89437d29f45fbc5..7f879bc44354c9fac0238208db12b55a 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 +@@ -1260,12 +1001,38 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP if (trackedEntity != null) { trackedEntity.broadcastRemoved(); } @@ -25656,7 +25656,7 @@ index 7b41d955038e457faf66d2c1d89437d29f45fbc5..7f879bc44354c9fac0238208db12b55a List movedPlayers = Lists.newArrayList(); List players = this.level.players(); -@@ -1361,17 +1128,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1364,17 +1131,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void waitForLightBeforeSending(final ChunkPos centerChunk, final int chunkRadius) { @@ -25676,7 +25676,7 @@ index 7b41d955038e457faf66d2c1d89437d29f45fbc5..7f879bc44354c9fac0238208db12b55a LevelChunk chunk = chunkHolder.getChunkToSend(); if (chunk != null) { consumer.accept(chunk); -@@ -1379,14 +1140,21 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1382,14 +1143,21 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -25700,7 +25700,7 @@ index 7b41d955038e457faf66d2c1d89437d29f45fbc5..7f879bc44354c9fac0238208db12b55a } @Override -@@ -1400,13 +1168,96 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1403,13 +1171,96 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -25798,7 +25798,7 @@ index 7b41d955038e457faf66d2c1d89437d29f45fbc5..7f879bc44354c9fac0238208db12b55a public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { 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 +@@ -1521,17 +1372,24 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } private int getEffectiveRange() { @@ -26431,10 +26431,10 @@ index bd140f2d39307d4f909b11cc78da84e03aa4c3ca..75686eb990d7275b442e16df39b7b2e1 } } diff --git a/net/minecraft/server/level/LoadingChunkTracker.java b/net/minecraft/server/level/LoadingChunkTracker.java -index b107715893fc5329ae4a27967780d3587166b6dd..15cd107d347ee01c809938684bf90cc24d0b4caf 100644 +index 1cd13461a4229eae64ea11f7a5711ce044432719..36defbdc77c0d2b04729e9a69241046f575a3209 100644 --- a/net/minecraft/server/level/LoadingChunkTracker.java +++ b/net/minecraft/server/level/LoadingChunkTracker.java -@@ -38,7 +38,7 @@ class LoadingChunkTracker extends ChunkTracker { +@@ -38,7 +38,7 @@ public class LoadingChunkTracker extends ChunkTracker { if (oldLevel != level) { chunk = this.distanceManager.updateChunkScheduling(node, level, chunk, oldLevel); if (chunk != null) { @@ -26444,7 +26444,7 @@ index b107715893fc5329ae4a27967780d3587166b6dd..15cd107d347ee01c809938684bf90cc2 } } diff --git a/net/minecraft/server/level/PlayerSpawnFinder.java b/net/minecraft/server/level/PlayerSpawnFinder.java -index 8e02980d29a15086805a93f1f1a416f0308c70b9..a7799e8c12713e00124f2caf69f74a616b1af3e7 100644 +index a701288146a1d7cd258faae69f959edf466ec71c..2608ee822cc205a7d101915fd6773d037cadce21 100644 --- a/net/minecraft/server/level/PlayerSpawnFinder.java +++ b/net/minecraft/server/level/PlayerSpawnFinder.java @@ -115,9 +115,9 @@ public class PlayerSpawnFinder { @@ -26470,7 +26470,7 @@ index 8e02980d29a15086805a93f1f1a416f0308c70b9..a7799e8c12713e00124f2caf69f74a61 } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475bd54789b 100644 +index e9f26ac2ceef63c7dcb041c161ebf1529976a72e..9618c6f7adbfc0ab65c221dba6bdb7266cf3baa6 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; @@ -26603,7 +26603,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 @Nullable public ChunkAccess getChunkAtImmediately(int x, int z) { -@@ -212,66 +305,41 @@ public class ServerChunkCache extends ChunkSource { +@@ -212,65 +305,41 @@ public class ServerChunkCache extends ChunkSource { @Override public @Nullable ChunkAccess getChunk(final int x, final int z, final ChunkStatus targetStatus, final boolean loadOrGenerate) { @@ -26660,8 +26660,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 - - 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; +- return this.lastChunk[i] instanceof LevelChunk levelChunk ? levelChunk : null; - } + if (ret != null || !ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()) { + return ret; @@ -26675,8 +26674,8 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 - ChunkAccess chunk = chunkHolder.getChunkIfPresent(ChunkStatus.FULL); - if (chunk != null) { - this.storeInCache(pos, chunk, ChunkStatus.FULL); -- if (chunk instanceof LevelChunk) { -- return (LevelChunk)chunk; +- if (chunk instanceof LevelChunk levelChunk) { +- return levelChunk; - } + 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); @@ -26690,7 +26689,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 } private void clearCache() { -@@ -299,53 +367,62 @@ public class ServerChunkCache extends ChunkSource { +@@ -298,53 +367,62 @@ public class ServerChunkCache extends ChunkSource { private CompletableFuture> getChunkFutureMainThread( final int x, final int z, final ChunkStatus targetStatus, final boolean loadOrGenerate ) { @@ -26787,7 +26786,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 } @Override -@@ -358,28 +435,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -357,28 +435,18 @@ public class ServerChunkCache extends ChunkSource { } public boolean runDistanceManagerUpdates() { @@ -26822,7 +26821,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 this.chunkMap.saveAllChunks(flushStorage); } -@@ -390,17 +457,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -389,17 +457,15 @@ public class ServerChunkCache extends ChunkSource { } public void close(boolean save) throws IOException { @@ -26843,7 +26842,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 ProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("purge"); -@@ -424,6 +489,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -423,6 +489,7 @@ public class ServerChunkCache extends ChunkSource { this.runDistanceManagerUpdates(); profiler.popPush("chunks"); if (tickChunks) { @@ -26851,7 +26850,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 this.tickChunks(); this.chunkMap.tick(); } -@@ -456,7 +522,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -455,7 +522,7 @@ public class ServerChunkCache extends ChunkSource { profiler.push("broadcast"); for (ChunkHolder chunkHolder : this.chunkHoldersToBroadcast) { @@ -26860,7 +26859,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 if (chunk != null) { chunkHolder.broadcastChanges(chunk); } -@@ -497,7 +563,10 @@ public class ServerChunkCache extends ChunkSource { +@@ -496,7 +563,10 @@ public class ServerChunkCache extends ChunkSource { profiler.popPush("filteringSpawningChunks"); this.chunkMap.collectSpawningChunks(spawningChunks); profiler.popPush("shuffleSpawningChunks"); @@ -26871,7 +26870,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 profiler.popPush("tickSpawningChunks"); for (LevelChunk chunk : spawningChunks) { -@@ -508,7 +577,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -507,7 +577,7 @@ public class ServerChunkCache extends ChunkSource { } profiler.popPush("tickTickingChunks"); @@ -26880,7 +26879,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 if (doMobSpawning) { profiler.popPush("customSpawners"); this.level.tickCustomSpawners(this.spawnEnemies); -@@ -522,22 +591,25 @@ public class ServerChunkCache extends ChunkSource { +@@ -521,22 +591,25 @@ public class ServerChunkCache extends ChunkSource { ) { ChunkPos chunkPos = chunk.getPos(); chunk.incrementInhabitedTime(timeDiff); @@ -26911,7 +26910,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 } @Override -@@ -595,19 +667,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -594,19 +667,11 @@ public class ServerChunkCache extends ChunkSource { } public CompletableFuture addTicketAndLoadWithRadius(final TicketType type, final ChunkPos pos, final int radius) { @@ -26936,7 +26935,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 } public void addTicketWithRadius(final TicketType type, final ChunkPos pos, final int radius) { -@@ -657,6 +721,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -660,6 +725,12 @@ public class ServerChunkCache extends ChunkSource { this.chunkMap.setServerViewDistance(newDistance); } @@ -26949,7 +26948,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 public void setSimulationDistance(final int simulationDistance) { this.distanceManager.updateSimulationDistance(simulationDistance); } -@@ -736,18 +806,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -739,18 +810,12 @@ public class ServerChunkCache extends ChunkSource { @Override protected boolean pollTask() { @@ -26971,7 +26970,7 @@ index ca9e965a200ae4e9e5e8d53823918a24a56cb742..a5685e0b50610cc8213f34c5db62b475 } } diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 160eeda06cd6bfcec60bac43235760d92fe8d63d..a62ec41b1319857f0d6cd223d013a92b1e2c2b0d 100644 +index 60e89fbbd09ada8a48527ebac43340a58aa6d001..70daec14be69c0e02759489a5ddeda8718a288cc 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -90,6 +90,11 @@ public class ServerEntity { @@ -26987,7 +26986,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 d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580358b8b82 100644 +index 594d22edfaeee1097304478d09f33a3d5e0dd51d..4b67719f536fcf1d3d0f416c395b603aaf471c82 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; @@ -26999,7 +26998,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 public static final BlockPos END_SPAWN_POINT = new BlockPos(100, 50, 0); public static final IntProvider RAIN_DELAY = UniformInt.of(12000, 180000); public static final IntProvider RAIN_DURATION = UniformInt.of(12000, 24000); -@@ -198,7 +198,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -199,7 +199,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet private final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; private EnvironmentAttributeSystem environmentAttributes; @@ -27008,7 +27007,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 private final GameEventDispatcher gameEventDispatcher; public boolean noSave; private final SleepStatus sleepStatus; -@@ -276,12 +276,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -277,12 +277,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public final void loadChunksForMoveAsync(AABB box, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -27022,7 +27021,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 int minBlockX = Mth.floor(box.minX - 1.0E-7) - 3; int minBlockZ = Mth.floor(box.minZ - 1.0E-7) - 3; -@@ -300,30 +295,171 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -301,30 +296,171 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public final void loadChunks(int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -27210,7 +27209,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } } } -@@ -337,16 +473,135 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -338,16 +474,135 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } } } @@ -27353,7 +27352,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 public ServerLevel( final MinecraftServer server, -@@ -416,18 +671,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -417,18 +672,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet // CraftBukkit end boolean syncWrites = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); @@ -27373,7 +27372,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 this.chunkSource = new ServerChunkCache( this, levelStorage, -@@ -438,7 +682,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -439,7 +683,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.spigotConfig.viewDistance, // Spigot this.spigotConfig.simulationDistance, // Spigot syncWrites, @@ -27382,7 +27381,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 () -> server.overworld().getDataStorage() , savedDataStorage // Paper - initialize SavedDataStorage earlier ); -@@ -478,6 +722,20 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -479,6 +723,20 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.waypointManager = new ServerWaypointManager(this); // Paper - optimize ServerWaypointManager with locator bar disabled this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); this.updateSkyBrightness(); @@ -27403,7 +27402,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } -@@ -614,8 +872,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -627,8 +885,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet profiler.push("checkDespawn"); entity.checkDespawn(); profiler.pop(); @@ -27413,7 +27412,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 Entity vehicle = entity.getVehicle(); if (vehicle != null) { if (!vehicle.isRemoved() && vehicle.hasPassenger(entity)) { -@@ -642,7 +899,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -655,7 +912,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } profiler.push("entityManagement"); @@ -27422,7 +27421,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 profiler.pop(); profiler.push("debugSynchronizers"); if (this.debugSynchronizers.hasAnySubscriberFor(DebugSubscriptions.NEIGHBOR_UPDATES)) { -@@ -659,7 +916,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -671,7 +928,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public boolean shouldTickBlocksAt(final long chunkPos) { @@ -27434,7 +27433,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } protected void tickTime() { -@@ -683,7 +943,60 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -695,7 +955,60 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.players.stream().filter(LivingEntity::isSleeping).collect(Collectors.toList()).forEach(player -> player.stopSleepInBed(false, false)); } @@ -27495,7 +27494,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 ChunkPos chunkPos = chunk.getPos(); int minX = chunkPos.getMinBlockX(); int minZ = chunkPos.getMinBlockZ(); -@@ -692,7 +1005,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -704,7 +1017,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow for (int i = 0; i < tickSpeed; i++) { @@ -27504,7 +27503,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 this.tickPrecipitation(this.getBlockRandomPos(minX, 0, minZ, 15)); } } -@@ -700,31 +1013,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -712,31 +1025,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet profiler.popPush("tickBlocks"); if (tickSpeed > 0) { @@ -27537,7 +27536,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } profiler.pop(); -@@ -1047,6 +1336,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1059,6 +1348,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (fluidState.is(type)) { fluidState.tick(this, pos, blockState); } @@ -27550,7 +27549,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } private void tickBlock(final BlockPos pos, final Block type) { -@@ -1054,6 +1349,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1066,6 +1361,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (state.is(type)) { state.tick(this, pos, this.random); } @@ -27563,7 +27562,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } // Paper start - log detailed entity tick information -@@ -1138,6 +1439,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1150,6 +1451,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } public void save(final @Nullable ProgressListener progressListener, final boolean flush, final boolean noSave) { @@ -27575,7 +27574,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 ServerChunkCache chunkSource = this.getChunkSource(); if (!noSave) { new org.bukkit.event.world.WorldSaveEvent(this.getWorld()).callEvent(); // CraftBukkit -@@ -1150,13 +1456,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1162,13 +1468,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet progressListener.progressStage(Component.translatable("menu.savingChunks")); } @@ -27599,7 +27598,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } private void saveLevelData(final boolean sync) { -@@ -1277,7 +1588,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1289,7 +1600,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.removePlayerImmediately((ServerPlayer)existing, Entity.RemovalReason.DISCARDED); } @@ -27608,7 +27607,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } // CraftBukkit start -@@ -1308,7 +1619,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1320,7 +1631,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } // CraftBukkit end @@ -27617,7 +27616,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } } -@@ -1319,7 +1630,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1331,7 +1642,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public boolean tryAddFreshEntityWithPassengers(final Entity entity, final org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { // CraftBukkit end @@ -27626,7 +27625,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 return false; } -@@ -2112,7 +2423,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2120,7 +2431,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } } @@ -27635,7 +27634,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 output.write(String.format(Locale.ROOT, "block_entity_tickers: %d\n", this.blockEntityTickers.size())); output.write(String.format(Locale.ROOT, "block_ticks: %d\n", this.getBlockTicks().count())); output.write(String.format(Locale.ROOT, "fluid_ticks: %d\n", this.getFluidTicks().count())); -@@ -2130,13 +2441,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2138,13 +2449,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet Path chunks = rootDir.resolve("chunks.csv"); try (Writer output = Files.newBufferedWriter(chunks)) { @@ -27651,7 +27650,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } Path entities = rootDir.resolve("entities.csv"); -@@ -2231,8 +2542,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2239,8 +2550,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet Locale.ROOT, "players: %s, entities: %s [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), @@ -27662,7 +27661,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 this.blockEntityTickers.size(), getTypeCount(this.blockEntityTickers, TickingBlockEntity::getType), this.getBlockTicks().count(), -@@ -2265,15 +2576,25 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2273,15 +2584,25 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public LevelEntityGetter getEntities() { org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot @@ -27691,7 +27690,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } public void startTickingChunk(final LevelChunk levelChunk) { -@@ -2290,8 +2611,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2298,8 +2619,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public void waitForEntities(final ChunkPos centerChunk, final int radius) { List chunks = ChunkPos.rangeClosed(centerChunk, radius).toList(); @@ -27702,7 +27701,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 for (ChunkPos chunk : chunks) { if (!this.areEntitiesLoaded(chunk.pack())) { -@@ -2312,28 +2633,38 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2318,28 +2639,38 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public void close() throws IOException { super.close(); @@ -27747,7 +27746,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } public boolean anyPlayerCloseEnoughForSpawning(final BlockPos pos) { -@@ -2350,7 +2681,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2356,7 +2687,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } public boolean canSpawnEntitiesInChunk(final ChunkPos pos) { @@ -27759,7 +27758,7 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 } @Override -@@ -2398,7 +2732,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2404,7 +2738,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public CrashReportCategory fillReportDetails(final CrashReport report) { CrashReportCategory category = super.fillReportDetails(report); WeatherData weatherData = this.getWeatherData(); @@ -27769,10 +27768,10 @@ index d2eac2935a16a9127958b94414668ce408880319..0fabe7fe4d302695505bed2cef4ce580 "Server weather", () -> String.format( diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 020b63f9d356aadf0bdaf2e34067d15bacd0177a..f35f88da81abb14b393d6fce04054ee40e8d8397 100644 +index 43d65e4d8679e3ff54e0fa976437dd8aa6de220c..03282ad26e7eb38508b5bf97a18cd6da57b060e5 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; +@@ -206,7 +206,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -27781,7 +27780,7 @@ index 020b63f9d356aadf0bdaf2e34067d15bacd0177a..f35f88da81abb14b393d6fce04054ee4 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; -@@ -430,6 +430,36 @@ public class ServerPlayer extends Player { +@@ -436,6 +436,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 @@ -27818,7 +27817,7 @@ index 020b63f9d356aadf0bdaf2e34067d15bacd0177a..f35f88da81abb14b393d6fce04054ee4 public ServerPlayer(final MinecraftServer server, final ServerLevel level, final GameProfile gameProfile, final ClientInformation clientInformation) { super(level, gameProfile); this.server = server; -@@ -452,7 +482,7 @@ public class ServerPlayer extends Player { +@@ -458,7 +488,7 @@ public class ServerPlayer extends Player { @Override public BlockPos adjustSpawnLocation(final ServerLevel level, final BlockPos spawnSuggestion) { CompletableFuture future = PlayerSpawnFinder.findSpawn(level, spawnSuggestion); @@ -28284,7 +28283,7 @@ index 40f97e3657a1672d3865ab915c7f36d3dbf88c6e..b075d7f68a263422cfa1f35b1f896038 public TicketType getType() { diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java -index 4de90a597bd5c5ac639fd228b3494e70a945d7ff..147cd0458d719be6679b6bac2b6617b48d98ce4c 100644 +index 7460b6071a59530719769b6d3ec6736a73b69e95..fed2a68bf1a9e9a169c0235e129346b9b624170b 100644 --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java @@ -7,7 +7,45 @@ import java.lang.annotation.Target; @@ -28390,12 +28389,12 @@ 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 f4a426af2e638b79b783f5181da665d4e0552949..692f8684b9bccd76ab03edbc2ef31149d8a67cc8 100644 +index 48254f947cf9099de2d50b8208314c98fad4df12..ebb0923b38a7529e7df531b3947a0421df29d654 100644 --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -76,6 +76,36 @@ public class WorldGenRegion implements WorldGenLevel { - private final AtomicLong subTickCount = new AtomicLong(); - private static final Identifier WORLDGEN_REGION_RANDOM = Identifier.withDefaultNamespace("worldgen_region_random"); +@@ -79,6 +79,36 @@ public class WorldGenRegion implements WorldGenLevel { + private final int centerChunkZ; + private final int writeRadius; + // Paper start - rewrite chunk system + /** @@ -28431,7 +28430,7 @@ index f4a426af2e638b79b783f5181da665d4e0552949..692f8684b9bccd76ab03edbc2ef31149 this.generatingStep = generatingStep; this.cache = cache; diff --git a/net/minecraft/server/network/PlayerChunkSender.java b/net/minecraft/server/network/PlayerChunkSender.java -index c974b6cafb1f6aa2a57cfdc8a39c887f02f42b1d..ec40f02032f965f548b0c0a29aa9d9bbad6f439b 100644 +index a46b89895a9ce86b6f5fabd373a4e91919d88033..22b10500ef74694243a4fec40822bb54ef96cc0c 100644 --- a/net/minecraft/server/network/PlayerChunkSender.java +++ b/net/minecraft/server/network/PlayerChunkSender.java @@ -78,7 +78,7 @@ public class PlayerChunkSender { @@ -28470,10 +28469,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 58fb206651471c7fe9781733bf6d489814a68b5d..eb41400b8948d3eecc6fd89e2fefbe638ccbaad1 100644 +index a31fb3ca939fe6285ef003a65fd70f30896c5daa..f637ac9da1d0f06fab26f81e69619453a8acb5f6 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -979,8 +979,8 @@ public abstract class PlayerList { +@@ -982,8 +982,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 +28483,7 @@ index 58fb206651471c7fe9781733bf6d489814a68b5d..eb41400b8948d3eecc6fd89e2fefbe63 // Paper end - view distances if (level.isRaining()) { // CraftBukkit start - handle player weather -@@ -1197,7 +1197,7 @@ public abstract class PlayerList { +@@ -1200,7 +1200,7 @@ public abstract class PlayerList { public void setViewDistance(final int viewDistance) { this.viewDistance = viewDistance; @@ -28493,7 +28492,7 @@ index 58fb206651471c7fe9781733bf6d489814a68b5d..eb41400b8948d3eecc6fd89e2fefbe63 for (ServerLevel level : this.server.getAllLevels()) { level.getChunkSource().setViewDistance(viewDistance); -@@ -1206,7 +1206,7 @@ public abstract class PlayerList { +@@ -1209,7 +1209,7 @@ public abstract class PlayerList { public void setSimulationDistance(final int simulationDistance) { this.simulationDistance = simulationDistance; @@ -28876,10 +28875,10 @@ index 09b6da207530987b483444cebeadc2f1c9a15247..3666c3efd188508153b6482db425648e + // Paper end - block counting } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134a85c9beb 100644 +index a5352d383e35a82a2915cae699f2616d7436bef8..88b8d13309a72c5745df8e0e1fa0c0cdc6f8316a 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -167,7 +167,7 @@ public abstract class Entity +@@ -164,7 +164,7 @@ public abstract class Entity ItemOwner, SlotProvider, DebugValueSource, @@ -28888,7 +28887,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 // CraftBukkit start private static final int CURRENT_LEVEL = 2; static boolean isLevelAtLeast(ValueInput input, int level) { -@@ -176,7 +176,17 @@ public abstract class Entity +@@ -173,7 +173,17 @@ public abstract class Entity // Paper start - Share random for entities to make them more random public static RandomSource SHARED_RANDOM = new RandomRandomSource(); @@ -28907,7 +28906,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 private boolean locked = false; @Override -@@ -189,61 +199,7 @@ public abstract class Entity +@@ -186,61 +196,7 @@ public abstract class Entity } } @@ -29127,7 +29126,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 public Entity(final EntityType type, final Level level) { this.type = type; -@@ -1421,34 +1527,76 @@ public abstract class Entity +@@ -1483,34 +1589,76 @@ public abstract class Entity } private Vec3 collide(final Vec3 movement) { @@ -29152,7 +29151,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 + return movement; + } -- List colliders = collectColliders(this, this.level, entityColliders, stepUpAABB); +- List colliders = collectCollidersIgnoringWorldBorder(this, this.level, entityColliders, stepUpAABB); - float stepHeightToSkip = (float)movementStep.y; - float[] candidateStepUpHeights = collectCandidateStepUpHeights(groundedAABB, colliders, this.maxUpStep(), stepHeightToSkip); + final AABB currentBox = this.getBoundingBox(); @@ -29227,7 +29226,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 } private static float[] collectCandidateStepUpHeights( -@@ -2741,17 +2889,106 @@ public abstract class Entity +@@ -2830,17 +2978,106 @@ public abstract class Entity return false; } @@ -29344,7 +29343,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 } public InteractionResult interact(final Player player, final InteractionHand hand, final Vec3 location) { -@@ -4365,15 +4602,17 @@ public abstract class Entity +@@ -4440,15 +4677,17 @@ public abstract class Entity } public Iterable getIndirectPassengers() { @@ -29370,7 +29369,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 } public int countPlayerPassengers() { -@@ -4684,6 +4923,15 @@ public abstract class Entity +@@ -4759,6 +4998,15 @@ public abstract class Entity } public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { @@ -29386,7 +29385,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 if (!checkPosition(this, x, y, z)) { return; } -@@ -4833,6 +5081,12 @@ public abstract class Entity +@@ -4908,6 +5156,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 @@ -29399,7 +29398,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { -@@ -4843,7 +5097,7 @@ public abstract class Entity +@@ -4918,7 +5172,7 @@ public abstract class Entity this.stopRiding(); } @@ -29408,7 +29407,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 this.levelCallback.onRemove(reason); this.onRemoval(reason); // Paper start - Folia schedulers -@@ -4877,7 +5131,7 @@ public abstract class Entity +@@ -4952,7 +5206,7 @@ public abstract class Entity public boolean shouldBeSaved() { return (this.removalReason == null || this.removalReason.shouldSave()) && !this.isPassenger() @@ -29418,7 +29417,7 @@ index 666bd12677e62046d5f56544cadcbf1164211e0d..e5d56fdb5cfd4aa291dbdb879e478134 @Override diff --git a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index 3e71b3d17ffa02ce82040958c83f419121a1830e..2940dbc31a20eb49e24418ec84b73f2bfbdcfc32 100644 +index 81ad9099d2325a07b0b853b99e1d67b0caebd951..e2eb02d8a0a9481be2308c9052582591bc4f9850 100644 --- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java @@ -94,12 +94,16 @@ public class AcquirePoi { @@ -29445,7 +29444,7 @@ index 3e71b3d17ffa02ce82040958c83f419121a1830e..2940dbc31a20eb49e24418ec84b73f2b 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 96d28b513d39c4bc364d97bef7bd6024349c1bd9..a67c3ccfd24172df1bd2e440a48d7e5f262af82f 100644 +index 1f8cbb20a21b081c9fb38cce178c66891de64aed..3b07e731e8d16c2b71cb55b85163029cf56fd02e 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiManager.java @@ -40,12 +40,137 @@ import net.minecraft.world.level.chunk.storage.SectionStorage; @@ -29849,7 +29848,7 @@ index 96d28b513d39c4bc364d97bef7bd6024349c1bd9..a67c3ccfd24172df1bd2e440a48d7e5f } diff --git a/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index cf03617840bf13c6045526eba14f71e0647ffec2..263c64f340417c0b49691a350b4bec592d58739d 100644 +index 789547baacfaed25ea99406edc77f1a5901eb9bc..c708f4517ba1274db7046810044e69da4cc26b89 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; @@ -29883,10 +29882,10 @@ index cf03617840bf13c6045526eba14f71e0647ffec2..263c64f340417c0b49691a350b4bec59 this(setDirty, true, ImmutableList.of()); } diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 758b667530ba1e14e9a56fbe609a6438439dd8f2..f42fd10847a1dfbcbb2790aa90da4a49585e25a8 100644 +index 9c496533c311a13807d9a7e5d7ed1507e5f18657..9e4293c6df1851a852423b469577388d2254e169 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 { +@@ -207,7 +207,7 @@ public class ArmorStand extends LivingEntity { @Override protected void pushEntities() { if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups @@ -29896,7 +29895,7 @@ index 758b667530ba1e14e9a56fbe609a6438439dd8f2..f42fd10847a1dfbcbb2790aa90da4a49 entity.push(this); } diff --git a/net/minecraft/world/level/ClipContext.java b/net/minecraft/world/level/ClipContext.java -index fbaefb396745cc985d4c25f3cbea17d646391948..fc7900fcb391b6fe61f7d6200f7d2656579b97a1 100644 +index fbcd6dd3753a65fed36ed24fd3322802684995e0..322c9e416d7fa3b567be8e67b8fa0b8995a78a16 100644 --- a/net/minecraft/world/level/ClipContext.java +++ b/net/minecraft/world/level/ClipContext.java @@ -22,7 +22,7 @@ public class ClipContext { @@ -30025,7 +30024,7 @@ index 892b338a2b0a185511c352ca2bb76ee3890836fd..cc938f43c4a5e947ed87ca2001cbaca4 // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f716f79ad 100644 +index bfb65ccca995366261e857aec69cae0fcf0dbf07..93bc56704ef8019423d0605d176ab73d6f63d39e 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; @@ -30045,7 +30044,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("overworld")); public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("the_nether")); -@@ -130,7 +131,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -131,7 +132,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public float rainLevel; protected float oThunderLevel; public float thunderLevel; @@ -30054,7 +30053,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f @Deprecated private final RandomSource soundSeedGenerator = RandomSource.createThreadSafe(); private final Holder dimensionTypeRegistration; -@@ -192,6 +193,629 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -193,6 +194,629 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); @@ -30684,7 +30683,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f protected Level( final WritableLevelData levelData, final ResourceKey dimension, -@@ -208,6 +832,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -209,6 +833,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { java.util.function.Function paperWorldConfigCreator // Paper - create paper world config ) { @@ -30700,15 +30699,15 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f final org.bukkit.NamespacedKey worldKey = CraftNamespacedKey.fromMinecraft(dimension.identifier()); // Paper this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, worldKey); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config -@@ -231,6 +864,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -232,6 +865,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.registryAccess = registryAccess; this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); + this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system } - // Paper start - Cancel hit for vanished players -@@ -511,7 +1145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + public int getNextEntityId() { +@@ -516,7 +1150,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.setBlocksDirty(pos, oldState, newState); } @@ -30717,7 +30716,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f this.sendBlockUpdated(pos, oldState, blockState, updateFlags); } -@@ -845,6 +1479,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -851,6 +1485,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(); @@ -30725,7 +30724,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f // 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); -@@ -855,6 +1490,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -861,6 +1496,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(); @@ -30737,7 +30736,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f } } -@@ -873,6 +1513,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -879,6 +1519,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 } @@ -30745,7 +30744,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -880,7 +1521,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -886,7 +1527,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; @@ -30761,7 +30760,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -1025,7 +1673,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1031,7 +1679,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (!this.isInValidBounds(pos)) { return null; } else { @@ -30770,7 +30769,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); } -@@ -1105,20 +1753,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1111,20 +1759,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"); @@ -30798,7 +30797,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f } @Override -@@ -1134,33 +1777,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1140,33 +1783,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(type, bb, selector, output, Integer.MAX_VALUE); } @@ -30913,7 +30912,7 @@ index d7edeb01a9842e7cbe4d2ba40360c5604c69001c..85922fd54c703ce8a12452b2b3c5a00f public boolean hasEntities(final EntityTypeTest type, final AABB bb, final Predicate selector) { Profiler.get().incrementCounter("hasEntities"); -@@ -1469,13 +2173,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1475,13 +2179,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper start - allow patching this logic public final int getEntityCount() { @@ -30952,7 +30951,7 @@ index 254a967292938a9ed6a0291bbc9cf6e971eeaf01..416646f15ceea04fbbb5a5b0044c2a49 @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 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9cbfcb43c 100644 +index def5a92046a663e53b29f9863c541ddc30ee9d3a..91bb2ac15b9e9350552f4eeb9573c2f564854ce4 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java @@ -54,6 +54,249 @@ public class ServerExplosion implements Explosion { @@ -31205,7 +31204,7 @@ index 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9 public ServerExplosion( final ServerLevel level, -@@ -128,64 +371,102 @@ public class ServerExplosion implements Explosion { +@@ -128,63 +371,102 @@ public class ServerExplosion implements Explosion { } private List calculateExplodedPositions() { @@ -31232,7 +31231,6 @@ index 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9 - 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 - FluidState fluid = block.getFluidState(); // Paper - Perf: Optimize call to getFluid for explosions - if (!this.level.isInWorldBounds(pos)) { - break; @@ -31246,7 +31244,7 @@ index 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9 - } + final Vec3 center = this.center; -- if (remainingPower > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, pos, block, remainingPower)) { +- if (remainingPower > 0.0F && block.isDestroyable() && this.damageCalculator.shouldBlockExplode(this, this.level, pos, block, remainingPower)) { // Paper - Protect Bedrock and End Portal/Frames from being destroyed - toBlowSet.add(pos); - // Paper start - prevent headless pistons from forming - if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && block.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON)) { @@ -31356,7 +31354,7 @@ index 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9 } private void hurtEntities() { -@@ -342,6 +623,14 @@ public class ServerExplosion implements Explosion { +@@ -341,6 +623,14 @@ public class ServerExplosion implements Explosion { } public int explode() { @@ -31371,7 +31369,7 @@ index 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9 this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List toBlow = this.calculateExplodedPositions(); this.hurtEntities(); -@@ -356,6 +645,13 @@ public class ServerExplosion implements Explosion { +@@ -355,6 +645,13 @@ public class ServerExplosion implements Explosion { this.createFire(toBlow); } @@ -31385,7 +31383,7 @@ index 26a6c4b49b0c7737935d152ff941604c712b50a2..34d7eef8b2540172bd4dcdbf80df45e9 return toBlow.size(); } -@@ -438,12 +734,12 @@ public class ServerExplosion implements Explosion { +@@ -437,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) { @@ -31832,10 +31830,10 @@ index d9849dfbe792128390941403220110fe87eb9fe3..c139f70bf9ddd3f995c0524dad15487e public interface NoiseBiomeSource { diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index 991d6261fd8a19d1c367e518666acb298dbd7abe..a8625939a4220050990b09097d5e3bfd2d8473d5 100644 +index bbf546a6ee4ac6ac6f9c5430b14c39f11853933e..fd97524eecd5af2d67e496c8ab5c53b405edc076 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -370,7 +370,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -367,7 +367,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public static boolean isShapeFullBlock(final VoxelShape shape) { @@ -31845,10 +31843,10 @@ index 991d6261fd8a19d1c367e518666acb298dbd7abe..a8625939a4220050990b09097d5e3bfd 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 2004f5479f78f41c5af31f87f54c6529091f5cab..7093613a09a79d7ffce34f1cb54ec2605c5af384 100644 +index cb6fe72d897d1b30368e0dcc9da900fb00f25135..15ba7b34dacbe89f604adb6245c9f914de1d71a7 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 { +@@ -437,7 +437,7 @@ public abstract class BlockBehaviour implements FeatureElement { return this.properties.destroyTime; } @@ -31857,7 +31855,7 @@ index 2004f5479f78f41c5af31f87f54c6529091f5cab..7093613a09a79d7ffce34f1cb54ec260 private static final Direction[] DIRECTIONS = Direction.values(); private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], s -> Arrays.fill(s, Shapes.empty())); private static final VoxelShape[] FULL_BLOCK_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], s -> Arrays.fill(s, Shapes.block())); -@@ -470,6 +470,76 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -472,6 +472,76 @@ public abstract class BlockBehaviour implements FeatureElement { private boolean propagatesSkylightDown; private int lightDampening; @@ -31934,7 +31932,7 @@ index 2004f5479f78f41c5af31f87f54c6529091f5cab..7093613a09a79d7ffce34f1cb54ec260 protected BlockStateBase(final Block owner, final Property[] propertyKeys, final Comparable[] propertyValues) { super(owner, propertyKeys, propertyValues); BlockBehaviour.Properties properties = owner.properties; -@@ -551,6 +621,41 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -553,6 +623,41 @@ public abstract class BlockBehaviour implements FeatureElement { this.propagatesSkylightDown = this.owner.propagatesSkylightDown(this.asState()); this.lightDampening = this.owner.getLightDampening(this.asState()); @@ -32349,7 +32347,7 @@ index b95665559d646ab8de313a19dadc197a1e8be02c..b82b935272efbc7a7518e148f665f4f2 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 b23c29459a59c136ccd2f8d6bde5464c94206792..c974b1c276d29610cb59566afaad19f5bcf0c602 100644 +index de6c4c7518a48c237df4b7a1ca6ef5e6e0aa99e3..8b51041370c5184d5a1926ea3262f9111703a6d3 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; @@ -32454,7 +32452,7 @@ index b23c29459a59c136ccd2f8d6bde5464c94206792..c974b1c276d29610cb59566afaad19f5 } private static void replaceMissingSections(final PalettedContainerFactory containerFactory, final LevelChunkSection[] sections) { -@@ -433,18 +494,22 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM +@@ -439,18 +500,22 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM @Override public Holder getNoiseBiome(final int quartX, final int quartY, final int quartZ) { @@ -32488,7 +32486,7 @@ index b23c29459a59c136ccd2f8d6bde5464c94206792..c974b1c276d29610cb59566afaad19f5 } // CraftBukkit start -@@ -494,12 +559,12 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM +@@ -500,12 +565,12 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM } public void initializeLightSources() { @@ -32504,7 +32502,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 a2015a6e4e4ab87fe474d388dc3058ec57ff8dac..aed69011d7e1a7819276d4bcd14ec47d367cbeb1 100644 +index 315c35d516eca40bef4cd05167792823f3be1654..1624d73d63a848b1eced1964193f14f7ab9c1bc2 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 { @@ -32516,7 +32514,7 @@ index a2015a6e4e4ab87fe474d388dc3058ec57ff8dac..aed69011d7e1a7819276d4bcd14ec47d } public abstract void applyCarvers( -@@ -314,7 +314,7 @@ public abstract class ChunkGenerator { +@@ -318,7 +318,7 @@ public abstract class ChunkGenerator { return Pair.of(config.getLocatePos(chunkTarget), structure); } @@ -32526,7 +32524,7 @@ index a2015a6e4e4ab87fe474d388dc3058ec57ff8dac..aed69011d7e1a7819276d4bcd14ec47d if (start != null && start.isValid() && (!createReference || tryAddReference(structureManager, start))) { return Pair.of(config.getLocatePos(start.getChunkPos()), structure); diff --git a/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -index 0fa297225d75ce30f9c8cf231c0da17a41fa3099..2ad29bdbcad25e0fde49fced56b97f6f52ce0109 100644 +index f095ec93c0c5be6db15b6486ec22980ba74cf9e5..9ee8dc12f59ab8ccf03cae451174d023f2870df0 100644 --- a/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/net/minecraft/world/level/chunk/EmptyLevelChunk.java @@ -14,7 +14,7 @@ import net.minecraft.world.level.material.FluidState; @@ -32603,7 +32601,7 @@ index fde0a0e4b2a3b2bd4f2ac893703c70dd55b1ddc2..3ee35885ea1f997bb5a36dd8d5f83b16 this(bits); values.forEach(this.values::add); diff --git a/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -index 54d57f80b1cca351cac2aa59477a0e57334816e7..94652b00e18ffcbe02f1ad0578d671e2a1d1d16a 100644 +index d25b4b71d1cb26eb3afe7d105c8916bcdbb02da4..754c3bb648558d96f9eed990a41480e4366bd72f 100644 --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java @@ -29,7 +29,7 @@ import net.minecraft.world.ticks.BlackholeTickAccess; @@ -32665,7 +32663,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 ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b1c324fa8 100644 +index f5d4733e0f1654aa1495b72ff83489acdbb8f5c6..0998671b463f0db367e8a34ad4a7ebf1355a99db 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; @@ -32762,7 +32760,7 @@ index ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b profiler.popPush("queueCheckLight"); this.level.getChunkSource().getLightEngine().checkBlock(pos); profiler.pop(); -@@ -583,11 +630,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -582,11 +629,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { // CraftBukkit start public void loadCallback() { @@ -32776,7 +32774,7 @@ index ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b if (server != null) { /* * If it's a new world, the first few chunks are generated inside -@@ -596,6 +644,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -595,6 +643,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)); @@ -32784,7 +32782,7 @@ index ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b if (this.needsDecoration) { this.needsDecoration = false; -@@ -622,13 +671,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -621,13 +670,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } public void unloadCallback() { @@ -32802,7 +32800,7 @@ index ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b // Paper start this.loadedTicketLevel = false; // Paper end -@@ -636,8 +687,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -635,8 +686,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { @Override public boolean isUnsaved() { @@ -32835,7 +32833,7 @@ index ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b // CraftBukkit end public boolean isEmpty() { -@@ -720,6 +794,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -719,6 +793,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.pendingBlockEntities.clear(); this.upgradeData.upgrade(this); @@ -32844,7 +32842,7 @@ index ed3bc67e7a659c88b199870836383f150415f8bc..1b364f99d728e177e7d4b5b706690a0b 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 e247b51fe49fe5cf1dfa475b16ba0805e47d50af..0e7bb7db9e46b2cade771fa5e94469023d8b47b0 100644 +index d1bf15ab369af57d022ff133b8d37afc98f9eb8c..8fd63c2f5f790af35384c4549dc914756b7dfe45 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -9,7 +9,7 @@ import net.minecraft.world.level.biome.Climate; @@ -32853,10 +32851,10 @@ index e247b51fe49fe5cf1dfa475b16ba0805e47d50af..0e7bb7db9e46b2cade771fa5e9446902 -public class LevelChunkSection { +public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_counting.BlockCountingChunkSection { // Paper - block counting - public static final int SECTION_WIDTH = 16; - public static final int SECTION_HEIGHT = 16; - public static final int SECTION_SIZE = 4096; -@@ -21,6 +21,30 @@ public class LevelChunkSection { + public static final int BIOME_CONTAINER_BITS = 2; + short nonEmptyBlockCount; // Paper - package private + private short fluidCount; +@@ -18,6 +18,30 @@ public class LevelChunkSection { public final PalettedContainer states; private PalettedContainer> biomes; // CraftBukkit - read/write @@ -32887,7 +32885,7 @@ index e247b51fe49fe5cf1dfa475b16ba0805e47d50af..0e7bb7db9e46b2cade771fa5e9446902 private LevelChunkSection(final LevelChunkSection source) { this.nonEmptyBlockCount = source.nonEmptyBlockCount; this.fluidCount = source.fluidCount; -@@ -61,6 +85,45 @@ public class LevelChunkSection { +@@ -58,6 +82,45 @@ public class LevelChunkSection { return this.setBlockState(sectionX, sectionY, sectionZ, state, true); } @@ -32933,7 +32931,7 @@ index e247b51fe49fe5cf1dfa475b16ba0805e47d50af..0e7bb7db9e46b2cade771fa5e9446902 public BlockState setBlockState(final int sectionX, final int sectionY, final int sectionZ, final BlockState state, final boolean checkThreading) { BlockState previous; if (checkThreading) { -@@ -99,6 +162,8 @@ public class LevelChunkSection { +@@ -96,6 +159,8 @@ public class LevelChunkSection { } } @@ -32942,7 +32940,7 @@ index e247b51fe49fe5cf1dfa475b16ba0805e47d50af..0e7bb7db9e46b2cade771fa5e9446902 return previous; } -@@ -123,37 +188,71 @@ public class LevelChunkSection { +@@ -120,37 +185,71 @@ public class LevelChunkSection { } public void recalcBlockCounts() { @@ -33039,7 +33037,7 @@ index e247b51fe49fe5cf1dfa475b16ba0805e47d50af..0e7bb7db9e46b2cade771fa5e9446902 } public PalettedContainer getStates() { -@@ -171,6 +270,11 @@ public class LevelChunkSection { +@@ -168,6 +267,11 @@ public class LevelChunkSection { PalettedContainer> biomes = this.biomes.recreate(); biomes.read(buffer); this.biomes = biomes; @@ -33089,7 +33087,7 @@ index 9b9119afd89f60cd88c3d1e6ec4857b92e95ff11..eec56782be6e6e2c483e7435ff136bf8 boolean maybeHas(Predicate predicate); diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index a04bc4efcb68c049bb9ac47ad378ecb6fec2c370..4eeb920e4e71ab91cdb5a41f1eabdd47182c80fb 100644 +index d70b291a5caafc8165bcb804063fc96ff67db303..b294e6794fd6f15998ac74aba991666757e25589 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; @@ -33199,7 +33197,7 @@ index a04bc4efcb68c049bb9ac47ad378ecb6fec2c370..4eeb920e4e71ab91cdb5a41f1eabdd47 } finally { this.release(); } -@@ -310,7 +347,44 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -317,7 +354,44 @@ public class PalettedContainer implements PaletteResize, PalettedContainer void accept(final T entry, final int count); } @@ -33246,7 +33244,7 @@ index a04bc4efcb68c049bb9ac47ad378ecb6fec2c370..4eeb920e4e71ab91cdb5a41f1eabdd47 PaletteResize dummyResizer = PaletteResize.noResizeExpected(); diff --git a/net/minecraft/world/level/chunk/ProtoChunk.java b/net/minecraft/world/level/chunk/ProtoChunk.java -index 26c8a51c94b51a1ef8f5a3392f9c85a62af7f7f4..50fe95f472f143ef381557f8675e427f20aa9d09 100644 +index 3e19d1bf3b43135f1e132c9d8fa421d42bd8d34e..93a14a457312ee0b4ddf6e80c425f1a50cc9edf1 100644 --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java @@ -156,7 +156,7 @@ public class ProtoChunk extends ChunkAccess { @@ -33310,10 +33308,10 @@ index 1e3ae1ae9dac0c98f6840658d690f63deac5c406..06a7f795739df3ccb7cae0aa00c88eb8 @Override diff --git a/net/minecraft/world/level/chunk/status/ChunkPyramid.java b/net/minecraft/world/level/chunk/status/ChunkPyramid.java -index 4f71c44e4fbf48e0225ce2617c128a9c188351d6..967fd05cf5db5ae2d255a72ba15c6cfaa0e79ec5 100644 +index 0678ddc1301185524c77e5a141ba92aff9339896..40f921502178fbce05d7b6890856fdde164f2ca5 100644 --- a/net/minecraft/world/level/chunk/status/ChunkPyramid.java +++ b/net/minecraft/world/level/chunk/status/ChunkPyramid.java -@@ -48,7 +48,7 @@ public record ChunkPyramid(ImmutableList steps) { +@@ -50,7 +50,7 @@ public record ChunkPyramid(ImmutableList steps) { .step(ChunkStatus.CARVERS, s -> s) .step(ChunkStatus.FEATURES, s -> s) .step(ChunkStatus.INITIALIZE_LIGHT, s -> s.setTask(ChunkStatusTasks::initializeLight)) @@ -33407,7 +33405,7 @@ index eb09a55d08e8e910f10e6bd54a1f24bcdbb51c69..1927341832adaf70e1130e205a39f4bf this.chunkType = chunkType; this.heightmapsAfter = heightmapsAfter; diff --git a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -index 8d3eb23eb607c862e15fb9e2e7f71a2019b02d04..6eb1a3a83c5bae8935c042396d676f7a3450e135 100644 +index 28ae6e031c6ec492fd5be240ff88a25d5c9d2947..478771c9f01d8674727cffdff90008c3b8608d69 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java @@ -192,7 +192,7 @@ public class ChunkStatusTasks { @@ -33549,7 +33547,7 @@ index 81837925c0a0fac18ea9d477e82ace10e32e932c..9208924f54d5024bc50ad4501fbff9eb 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 ecc3d06a3e61b1de001e77ac35fa282e61e4d517..cd2ac98e1910c8c6222db084a1d2dffc6f9519c9 100644 +index 8324ad114ddd94b9a99ac1b53332e34a39fe079a..7e205616bec7fc7973b81ca36b8f640a5b61691f 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 { @@ -33562,7 +33560,7 @@ index ecc3d06a3e61b1de001e77ac35fa282e61e4d517..cd2ac98e1910c8c6222db084a1d2dffc 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 0113fdf0b346f1dbea3856690ca8c389a2bae0a9..026b1f31d5041786e90ba372a228732aee094c16 100644 +index e6f83b493edd89fa104ab2e7ef13e0a2a4d3399f..7767e5420e3d2e569008747523d70147ea8d97fb 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -22,7 +22,7 @@ import net.minecraft.world.level.ChunkPos; @@ -33652,7 +33650,7 @@ index 0113fdf0b346f1dbea3856690ca8c389a2bae0a9..026b1f31d5041786e90ba372a228732a } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index f2f1b9132754b3e04fbaae4fc6499a7119540b90..36f8c19e3e90740e6d58eb8dbf573b2fdf4fed3d 100644 +index 81c545c1af001b8f08468cdd7af2c9528742758a..effc7de84088a7407c15e80adf12195e97bbf080 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; @@ -33664,11 +33662,10 @@ index f2f1b9132754b3e04fbaae4fc6499a7119540b90..36f8c19e3e90740e6d58eb8dbf573b2f public static final String ANVIL_EXTENSION = ".mca"; private static final int MAX_CACHE_SIZE = 256; public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap<>(); -@@ -23,30 +23,222 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -23,6 +23,184 @@ public final class RegionFileStorage implements AutoCloseable { private final Path folder; private final boolean sync; -- RegionFileStorage(final RegionStorageInfo info, final Path folder, final boolean sync) { + // Paper start - rewrite chunk system + private static final int REGION_SHIFT = 5; + private static final int MAX_NON_EXISTING_CACHE = 1024 * 4; @@ -33847,10 +33844,10 @@ index f2f1b9132754b3e04fbaae4fc6499a7119540b90..36f8c19e3e90740e6d58eb8dbf573b2f + } + // Paper end - rewrite chunk system + -+ protected RegionFileStorage(final RegionStorageInfo info, final Path folder, final boolean sync) { // Paper - protected + public RegionFileStorage(final RegionStorageInfo info, final Path folder, final boolean sync) { this.folder = folder; this.sync = sync; - this.info = info; +@@ -30,23 +208,37 @@ public final class RegionFileStorage implements AutoCloseable { } @org.jetbrains.annotations.Contract("_, false -> !null") private @Nullable RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit @@ -33902,12 +33899,9 @@ index f2f1b9132754b3e04fbaae4fc6499a7119540b90..36f8c19e3e90740e6d58eb8dbf573b2f } public @Nullable CompoundTag read(final ChunkPos pos) throws IOException { -@@ -77,9 +269,15 @@ public final class RegionFileStorage implements AutoCloseable { - } - } +@@ -79,7 +271,13 @@ public final class RegionFileStorage implements AutoCloseable { -- protected void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException { -+ public void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException { // Paper - rewrite chunk system - public + public void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException { if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { - RegionFile region = this.getRegionFile(pos, false); // CraftBukkit + RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system @@ -34596,10 +34590,10 @@ 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 db190b3b2bcc386d6e01c9b8d694efe4ac5e54af..83bc0f6fa7624a0df546726fa8ccc9744173ff88 100644 +index 0a8b0b01df527176d4dc0f5adaca2788dd7eb0a2..cb6cf1abbb44fc5c1edb1fd48850bab060e3fd90 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 { +@@ -86,7 +86,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { return CompletableFuture.supplyAsync(() -> { this.doCreateBiomes(blender, randomState, structureManager, protoChunk); return protoChunk; @@ -34608,7 +34602,7 @@ index db190b3b2bcc386d6e01c9b8d694efe4ac5e54af..83bc0f6fa7624a0df546726fa8ccc974 } private void doCreateBiomes(final Blender blender, final RandomState randomState, final StructureManager structureManager, final ChunkAccess protoChunk) { -@@ -373,7 +373,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { +@@ -378,7 +378,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { section.release(); } } @@ -34618,7 +34612,7 @@ index db190b3b2bcc386d6e01c9b8d694efe4ac5e54af..83bc0f6fa7624a0df546726fa8ccc974 private ChunkAccess doFill( diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index d7d98399cddb2d78eda492ab177ad770e1e083a4..cba5c9ea5fd424e7aaeefaa8cc5ffe37f307b370 100644 +index 332032fa0069ffbe982e087ae9535aab20ab4323..3491dc0b85b462991086613f8004461aa19a585f 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 { @@ -35231,7 +35225,7 @@ index 8a1524836e2573f879108b6708ca307fba756d3e..efb79617cebe7234d85721da7b7f1fd6 ) { return getDirection(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ, from, scaleReference, direction, dx, dy, dz); diff --git a/net/minecraft/world/phys/shapes/ArrayVoxelShape.java b/net/minecraft/world/phys/shapes/ArrayVoxelShape.java -index 6ffcd1a4a3d73de8abd2eadf567d97c0bfa5baa9..16e8bea1aa20e02140cdb319daa84e14eadead31 100644 +index cbc68e86fd31ad787b6e66ed35d98c85dd9fe364..a4502aa85f907ae532e44b46d065c324c934e551 100644 --- a/net/minecraft/world/phys/shapes/ArrayVoxelShape.java +++ b/net/minecraft/world/phys/shapes/ArrayVoxelShape.java @@ -20,7 +20,7 @@ public class ArrayVoxelShape extends VoxelShape { @@ -35252,7 +35246,7 @@ index 6ffcd1a4a3d73de8abd2eadf567d97c0bfa5baa9..16e8bea1aa20e02140cdb319daa84e14 @Override diff --git a/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java b/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java -index 73364066033aa722db0e8ab6c7e6cc0d93f7ecfd..f229a9247f9887dd8b01116f135e1db1a26ecb95 100644 +index 810cc86e66c8f5ec050a5cc63dcf0b254b263131..0815741cb832b4be90c95747ca2b24f3a2a81f4f 100644 --- a/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java +++ b/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java @@ -4,13 +4,13 @@ import java.util.BitSet; @@ -35280,7 +35274,7 @@ index 73364066033aa722db0e8ab6c7e6cc0d93f7ecfd..f229a9247f9887dd8b01116f135e1db1 return shape; } -- protected static void forAllBoxes(final DiscreteVoxelShape voxelShape, final DiscreteVoxelShape.IntLineConsumer consumer, final boolean mergeNeighbors) { +- static void forAllBoxes(final DiscreteVoxelShape voxelShape, final DiscreteVoxelShape.IntLineConsumer consumer, final boolean mergeNeighbors) { - BitSetDiscreteVoxelShape shape = new BitSetDiscreteVoxelShape(voxelShape); + // Paper start - optimise collisions + public static void forAllBoxes(final DiscreteVoxelShape shape, final DiscreteVoxelShape.IntLineConsumer consumer, final boolean mergeAdjacent) { @@ -35414,12 +35408,12 @@ 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 77acd78861cceacd52cdcd3b5db94624b993d848..cdd7af6ed50567934763e666f9a7b0c82ffe1a1f 100644 +index 7ea10275641597b32e0e5274f100da74eb1a4e20..da356bdbd621c93310d79399c212c12b1e2c2fbc 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; public final class CubeVoxelShape extends VoxelShape { - protected CubeVoxelShape(final DiscreteVoxelShape shape) { + public CubeVoxelShape(final DiscreteVoxelShape shape) { super(shape); + ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)this).moonrise$initCache(); // Paper - optimise collisions } @@ -35526,7 +35520,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 6978aa31d0901d8126cd9c19f8171275fe922584..ccdaf6043f667b6983e4492cf570947ed5179df1 100644 +index f3235d10461382573053d890ab00c62bf17d3553..780f4b30f4b9993e548e2591993c77839b1eaf1a 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 { @@ -35667,7 +35661,7 @@ index 6978aa31d0901d8126cd9c19f8171275fe922584..ccdaf6043f667b6983e4492cf570947e } public static VoxelShape create(final AABB aabb) { -@@ -127,92 +176,54 @@ public final class Shapes { +@@ -128,92 +177,54 @@ public final class Shapes { return join(first, second, BooleanOp.OR); } @@ -35799,7 +35793,7 @@ index 6978aa31d0901d8126cd9c19f8171275fe922584..ccdaf6043f667b6983e4492cf570947e } private static boolean joinIsNotEmpty( -@@ -242,53 +253,93 @@ public final class Shapes { +@@ -243,53 +254,93 @@ public final class Shapes { return distance; } @@ -36840,15 +36834,16 @@ index 9b210edf1f28285fc206644c5d81c7d05ea5a578..ddc562fbdeb2070212019bb239625387 protected double collideX(final AxisCycle transform, final AABB moving, double distance) { if (this.isEmpty()) { diff --git a/net/minecraft/world/ticks/LevelChunkTicks.java b/net/minecraft/world/ticks/LevelChunkTicks.java -index 082258e7d8270d4026a70a5c0a9e1228d70a2e8d..c3825e91504f5df6bfd8e41de1f5dc4ae45d81e2 100644 +index cec7442a5401b2886f5ce7c473386c15f64fe0a3..88eb48034d8022600dc08b4dcf6162bbdd8c6d33 100644 --- a/net/minecraft/world/ticks/LevelChunkTicks.java +++ b/net/minecraft/world/ticks/LevelChunkTicks.java -@@ -13,12 +13,36 @@ import java.util.stream.Stream; +@@ -14,13 +14,37 @@ import java.util.stream.Stream; import net.minecraft.core.BlockPos; import org.jspecify.annotations.Nullable; -public class LevelChunkTicks implements TickContainerAccess, SerializableTickContainer { +public class LevelChunkTicks implements TickContainerAccess, SerializableTickContainer, ca.spottedleaf.moonrise.patches.chunk_system.ticks.ChunkSystemLevelChunkTicks { // Paper - rewrite chunk system + private static final Comparator> SUB_TICK_ORDERING = Comparator.comparingLong(ScheduledTick::subTickOrder); private final Queue> tickQueue = new PriorityQueue<>(ScheduledTick.DRAIN_ORDER); private @Nullable List> pendingTicks; private final Set> ticksPerPosition = new ObjectOpenCustomHashSet<>(ScheduledTick.UNIQUE_TICK_HASH); @@ -36881,7 +36876,7 @@ index 082258e7d8270d4026a70a5c0a9e1228d70a2e8d..c3825e91504f5df6bfd8e41de1f5dc4a public LevelChunkTicks() { } -@@ -41,7 +65,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT +@@ -43,7 +67,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT public @Nullable ScheduledTick poll() { ScheduledTick result = this.tickQueue.poll(); if (result != null) { @@ -36890,7 +36885,7 @@ index 082258e7d8270d4026a70a5c0a9e1228d70a2e8d..c3825e91504f5df6bfd8e41de1f5dc4a } return result; -@@ -50,7 +74,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT +@@ -52,7 +76,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT @Override public void schedule(final ScheduledTick tick) { if (this.ticksPerPosition.add(tick)) { @@ -36899,7 +36894,7 @@ index 082258e7d8270d4026a70a5c0a9e1228d70a2e8d..c3825e91504f5df6bfd8e41de1f5dc4a } } -@@ -72,7 +96,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT +@@ -74,7 +98,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT while (iterator.hasNext()) { ScheduledTick tick = iterator.next(); if (test.test(tick)) { @@ -36908,7 +36903,7 @@ index 082258e7d8270d4026a70a5c0a9e1228d70a2e8d..c3825e91504f5df6bfd8e41de1f5dc4a this.ticksPerPosition.remove(tick); } } -@@ -89,6 +113,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT +@@ -91,6 +115,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT @Override public List> pack(final long currentTick) { @@ -36916,7 +36911,7 @@ index 082258e7d8270d4026a70a5c0a9e1228d70a2e8d..c3825e91504f5df6bfd8e41de1f5dc4a List> ticks = new ArrayList<>(this.tickQueue.size()); if (this.pendingTicks != null) { ticks.addAll(this.pendingTicks); -@@ -103,6 +128,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT +@@ -108,6 +133,7 @@ public class LevelChunkTicks implements TickContainerAccess, SerializableT public void unpack(final long currentTick) { if (this.pendingTicks != null) { diff --git a/paper-server/patches/features/0001-Optimize-Connection-and-add-advanced-packet-support.patch b/paper-server/patches/features/0002-Optimize-Connection-and-add-advanced-packet-support.patch similarity index 99% rename from paper-server/patches/features/0001-Optimize-Connection-and-add-advanced-packet-support.patch rename to paper-server/patches/features/0002-Optimize-Connection-and-add-advanced-packet-support.patch index cc10c73f1835..4d0d93fbbe9c 100644 --- a/paper-server/patches/features/0001-Optimize-Connection-and-add-advanced-packet-support.patch +++ b/paper-server/patches/features/0002-Optimize-Connection-and-add-advanced-packet-support.patch @@ -28,7 +28,7 @@ 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 25de26a3fae61b4e3f33f395a5653e729cc33627..a01698455cc5650899e2dc8732154cc9b04b1bb0 100644 +index 6e7331dc7bc5f7e69f21eec0b42141dde36a6c08..fceaac42791034a047d2af4acfd160a14a25a59a 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java @@ -65,7 +65,7 @@ public class Connection extends SimpleChannelInboundHandler> { diff --git a/paper-server/patches/features/0002-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch similarity index 97% rename from paper-server/patches/features/0002-Entity-Activation-Range-2.0.patch rename to paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch index 61b48cd006e4..d321886b8a96 100644 --- a/paper-server/patches/features/0002-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch @@ -355,10 +355,10 @@ index 0000000000000000000000000000000000000000..fe05c3bd9adeddc2dd740af3546f835c + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 594d22edfaeee1097304478d09f33a3d5e0dd51d..dc12dc263ae235a5ccf1fb54e418dae9deae25e2 100644 +index 4b67719f536fcf1d3d0f416c395b603aaf471c82..e8d9eff03d098ce65d44ee0172b70b7e90a658d4 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -619,6 +619,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -877,6 +877,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet profiler.pop(); } @@ -366,7 +366,7 @@ index 594d22edfaeee1097304478d09f33a3d5e0dd51d..dc12dc263ae235a5ccf1fb54e418dae9 this.entityTickList .forEach( entity -> { -@@ -1094,12 +1095,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1395,12 +1396,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet entity.totalEntityAge++; // Paper - age-like counter for all entities profiler.push(entity.typeHolder()::getRegisteredName); profiler.incrementCounter("tickNonPassenger"); @@ -383,7 +383,7 @@ index 594d22edfaeee1097304478d09f33a3d5e0dd51d..dc12dc263ae235a5ccf1fb54e418dae9 } // Paper start - log detailed entity tick information } finally { -@@ -1110,7 +1114,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1411,7 +1415,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet // Paper end - log detailed entity tick information } @@ -392,7 +392,7 @@ index 594d22edfaeee1097304478d09f33a3d5e0dd51d..dc12dc263ae235a5ccf1fb54e418dae9 if (entity.isRemoved() || entity.getVehicle() != vehicle) { entity.stopRiding(); } else if (entity instanceof Player || this.entityTickList.contains(entity)) { -@@ -1120,12 +1124,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1421,12 +1425,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet ProfilerFiller profiler = Profiler.get(); profiler.push(entity.typeHolder()::getRegisteredName); profiler.incrementCounter("tickPassenger"); @@ -463,10 +463,10 @@ index 8948755478b9d8bcf49593be695daca45a4e65ad..76ad0a8c9161e5c8602f015deb9003b8 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 943264d99c6dd879dfa363638c072ad1fca0159b..4837708576725decc0fad19cf92e52341fffe034 100644 +index 88b8d13309a72c5745df8e0e1fa0c0cdc6f8316a..c793f9117cf3c0560f4fd2028d0beeaa0e99ed78 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -426,6 +426,15 @@ public abstract class Entity +@@ -382,6 +382,15 @@ public abstract class Entity private final int despawnTime; // Paper - entity despawn time limit public int totalEntityAge; // Paper - age-like counter for all entities public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges @@ -482,7 +482,7 @@ index 943264d99c6dd879dfa363638c072ad1fca0159b..4837708576725decc0fad19cf92e5234 // CraftBukkit end // Paper start -@@ -442,6 +451,13 @@ public abstract class Entity +@@ -548,6 +557,13 @@ public abstract class Entity this.position = Vec3.ZERO; this.blockPosition = BlockPos.ZERO; this.chunkPosition = ChunkPos.ZERO; @@ -496,7 +496,7 @@ index 943264d99c6dd879dfa363638c072ad1fca0159b..4837708576725decc0fad19cf92e5234 SynchedEntityData.Builder entityDataBuilder = new SynchedEntityData.Builder(this); entityDataBuilder.define(DATA_SHARED_FLAGS_ID, (byte)0); entityDataBuilder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply()); -@@ -1034,6 +1050,10 @@ public abstract class Entity +@@ -1140,6 +1156,10 @@ public abstract class Entity } else { if (moverType == MoverType.PISTON) { delta = this.limitPistonMovement(delta); @@ -507,7 +507,7 @@ index 943264d99c6dd879dfa363638c072ad1fca0159b..4837708576725decc0fad19cf92e5234 if (delta.equals(Vec3.ZERO)) { return; } -@@ -1049,6 +1069,13 @@ public abstract class Entity +@@ -1155,6 +1175,13 @@ public abstract class Entity this.stuckSpeedMultiplier = Vec3.ZERO; this.setDeltaMovement(Vec3.ZERO); } @@ -541,7 +541,7 @@ index 3f7ca2206ec29e77613c85129ad06f642b53a213..98a9aa825dd7dd17af1b3c269d48d758 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index c68f122ddc161ce9b4be6d826187c14a0e830a58..282ae01e8d83b866fae10354dc93a4266b0696c0 100644 +index 93fcc0dad95bf5120f7a028ced365d279fa6bccf..f5fb78892596c96a4c3d66dcf8737450ef5e08e2 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -216,6 +216,20 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs @@ -819,10 +819,10 @@ index f46cca0467bb4da5511bc953ce5b43fa606bf978..445c5cafad71028171c1f26193966177 + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index bfb65ccca995366261e857aec69cae0fcf0dbf07..2f8f8e1fbc5f01b09d70a6ea5b4ed69664249c86 100644 +index 93bc56704ef8019423d0605d176ab73d6f63d39e..5f040613ef5d1eab58ac82719cbb02a9201432e4 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 { +@@ -156,6 +156,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Nullable public List captureDrops; public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); diff --git a/paper-server/patches/features/0003-Optimize-Voxel-Shape-Merging.patch b/paper-server/patches/features/0004-Optimize-Voxel-Shape-Merging.patch similarity index 96% rename from paper-server/patches/features/0003-Optimize-Voxel-Shape-Merging.patch rename to paper-server/patches/features/0004-Optimize-Voxel-Shape-Merging.patch index 4f604c5e916e..c42c0d5a1c26 100644 --- a/paper-server/patches/features/0003-Optimize-Voxel-Shape-Merging.patch +++ b/paper-server/patches/features/0004-Optimize-Voxel-Shape-Merging.patch @@ -67,10 +67,10 @@ index 6c637af546a411d5790ceba9936aa9128d05d97e..e18f24a3941e1102648bac841851a874 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 f3235d10461382573053d890ab00c62bf17d3553..5a3852b669df2a842be5c9f41e645145e72554f9 100644 +index 780f4b30f4b9993e548e2591993c77839b1eaf1a..b709ce647334e165ac660973fd736904aff4afff 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java -@@ -293,11 +293,26 @@ public final class Shapes { +@@ -344,11 +344,26 @@ public final class Shapes { } @VisibleForTesting @@ -98,7 +98,7 @@ index f3235d10461382573053d890ab00c62bf17d3553..5a3852b669df2a842be5c9f41e645145 if (first instanceof CubePointRange && second instanceof CubePointRange) { long size = lcm(firstSize, secondSize); if (cost * size <= 256L) { -@@ -305,14 +320,21 @@ public final class Shapes { +@@ -356,14 +371,21 @@ public final class Shapes { } } diff --git a/paper-server/patches/features/0004-optimize-dirt-and-snow-spreading.patch b/paper-server/patches/features/0005-optimize-dirt-and-snow-spreading.patch similarity index 100% rename from paper-server/patches/features/0004-optimize-dirt-and-snow-spreading.patch rename to paper-server/patches/features/0005-optimize-dirt-and-snow-spreading.patch diff --git a/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch b/paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch similarity index 98% rename from paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch rename to paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch index 5b9e51de3726..a8b8f83bfa5e 100644 --- a/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch +++ b/paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch @@ -267,7 +267,7 @@ index 595db570b0ade9cad7de77d2ab7b10d9e68699df..ac095f59d9f17d8239d6493d1c1e3942 + // Paper end - Use Velocity cipher } diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index a01698455cc5650899e2dc8732154cc9b04b1bb0..99751e03a4b5389682140bbade93e5a64feff87e 100644 +index fceaac42791034a047d2af4acfd160a14a25a59a..01e5ff70c70dd7fab089d8965bd1c237fa239f45 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java @@ -744,10 +744,24 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -335,7 +335,7 @@ index c5e029444adb05c129d51b51f63fcf63a8c70ce8..4552ebad6154c0178f928a4e9a5fe061 .add( new ServerBootstrap() diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 04d027b9a044d197c15fd8de95e475b94ba3ad7c..7a83935dd71fcf69c655259209c4af5983980b50 100644 +index 98f8d7001ba7af6373bea630c376af3c02cafac4..fb5a84d2a00528d5c8f549f238abb6aa20d1ccad 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -255,9 +255,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, diff --git a/paper-server/patches/features/0006-Handle-Oversized-block-entities-in-chunks.patch b/paper-server/patches/features/0007-Handle-Oversized-block-entities-in-chunks.patch similarity index 100% rename from paper-server/patches/features/0006-Handle-Oversized-block-entities-in-chunks.patch rename to paper-server/patches/features/0007-Handle-Oversized-block-entities-in-chunks.patch diff --git a/paper-server/patches/features/0007-Optimize-Bit-Operations-by-inlining.patch b/paper-server/patches/features/0008-Optimize-Bit-Operations-by-inlining.patch similarity index 100% rename from paper-server/patches/features/0007-Optimize-Bit-Operations-by-inlining.patch rename to paper-server/patches/features/0008-Optimize-Bit-Operations-by-inlining.patch diff --git a/paper-server/patches/features/0008-Remove-streams-from-hot-code.patch b/paper-server/patches/features/0009-Remove-streams-from-hot-code.patch similarity index 100% rename from paper-server/patches/features/0008-Remove-streams-from-hot-code.patch rename to paper-server/patches/features/0009-Remove-streams-from-hot-code.patch diff --git a/paper-server/patches/features/0009-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/paper-server/patches/features/0010-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch similarity index 100% rename from paper-server/patches/features/0009-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch rename to paper-server/patches/features/0010-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch diff --git a/paper-server/patches/features/0010-Eigencraft-redstone-implementation.patch b/paper-server/patches/features/0011-Eigencraft-redstone-implementation.patch similarity index 100% rename from paper-server/patches/features/0010-Eigencraft-redstone-implementation.patch rename to paper-server/patches/features/0011-Eigencraft-redstone-implementation.patch diff --git a/paper-server/patches/features/0011-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0012-Add-Alternate-Current-redstone-implementation.patch similarity index 99% rename from paper-server/patches/features/0011-Add-Alternate-Current-redstone-implementation.patch rename to paper-server/patches/features/0012-Add-Alternate-Current-redstone-implementation.patch index 7574a44d54c0..7c0b0632653f 100644 --- a/paper-server/patches/features/0011-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0012-Add-Alternate-Current-redstone-implementation.patch @@ -2321,7 +2321,7 @@ index 0000000000000000000000000000000000000000..33cd90c30c22200a4e1ae64f40a0bf78 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index dc12dc263ae235a5ccf1fb54e418dae9deae25e2..283c293de7e1997933604983fbf86fe6848d1c6d 100644 +index e8d9eff03d098ce65d44ee0172b70b7e90a658d4..0dfcfc01dbd063d5b27081df3683c66fb437a3a5 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -234,6 +234,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @@ -2332,7 +2332,7 @@ index dc12dc263ae235a5ccf1fb54e418dae9deae25e2..283c293de7e1997933604983fbf86fe6 @Override public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { -@@ -2447,6 +2448,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2781,6 +2782,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet return this.debugSynchronizers; } @@ -2347,10 +2347,10 @@ index dc12dc263ae235a5ccf1fb54e418dae9deae25e2..283c293de7e1997933604983fbf86fe6 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 2f8f8e1fbc5f01b09d70a6ea5b4ed69664249c86..017f76d0bbca6a3b32be7f36137439365aa69f7e 100644 +index 5f040613ef5d1eab58ac82719cbb02a9201432e4..46b9b87d58947f8f789cd2ce75e1d2ef6ca74d90 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1458,6 +1458,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -2162,6 +2162,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return this.palettedContainerFactory; } diff --git a/paper-server/patches/features/0012-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0013-Incremental-chunk-and-player-saving.patch similarity index 87% rename from paper-server/patches/features/0012-Incremental-chunk-and-player-saving.patch rename to paper-server/patches/features/0013-Incremental-chunk-and-player-saving.patch index e3c53ef9bd37..728c6f7f0f6a 100644 --- a/paper-server/patches/features/0012-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0013-Incremental-chunk-and-player-saving.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 7b2a078c11cc5e7b9770ee3811e2b04479d20b37..0f41295186f7dbcdf3c496c97b70b9732ce1ca23 100644 +index 7ebfe2acac0fe980320386de9574b0600c9e3e97..1a941fe5cff1d002486306e2632f0fd2628107f6 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -869,7 +869,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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 e50ffa3c66026fae9b6be3b28a8536cd5c22f1b2..45f5a1846f857a7526edf280202fccd94858d05b 100644 +index 586e51b7d0a59b75ef98d8f5fa75c5081f79f7f2..b69051d99950aa77181e3b1803bb9bc7b48fa763 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -331,7 +331,7 @@ public abstract class PlayerList { @@ -209,10 +209,10 @@ index e50ffa3c66026fae9b6be3b28a8536cd5c22f1b2..45f5a1846f857a7526edf280202fccd9 } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 017f76d0bbca6a3b32be7f36137439365aa69f7e..8812d33fad6f54b07544605749bcd35e9551a807 100644 +index 46b9b87d58947f8f789cd2ce75e1d2ef6ca74d90..c57c8832b490b57c70da0bce74ae589a45875b3e 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 { +@@ -146,6 +146,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl private long subTickCount; // CraftBukkit start @@ -220,7 +220,7 @@ index 017f76d0bbca6a3b32be7f36137439365aa69f7e..8812d33fad6f54b07544605749bcd35e private final CraftWorld world; public org.bukkit.generator.@Nullable ChunkGenerator generator; -@@ -213,7 +214,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -837,7 +838,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl org.bukkit.generator.@Nullable BiomeProvider biomeProvider, // Paper org.bukkit.World.Environment environment, // Paper java.util.function.Function paperWorldConfigCreator, // Paper - create paper world config + java.util.concurrent.Executor executor // Paper - Anti-Xray ) { - final org.bukkit.NamespacedKey worldKey = CraftNamespacedKey.fromMinecraft(dimension.identifier()); // Paper - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, worldKey); // Spigot -@@ -238,6 +240,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.registryAccess = registryAccess; + // Paper start - getblock optimisations - cache world height/sections + final DimensionType dimType = dimensionTypeRegistration.value(); +@@ -872,6 +874,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); + this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system + this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new io.papermc.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : io.papermc.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray } public int getNextEntityId() { -@@ -459,6 +462,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1093,6 +1096,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } // CraftBukkit end - capture blockstates BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); @@ -247,15 +247,20 @@ index 017f76d0bbca6a3b32be7f36137439365aa69f7e..8812d33fad6f54b07544605749bcd35e // 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 de6c4c7518a48c237df4b7a1ca6ef5e6e0aa99e3..c1738500a2e5a7244087351081c71d7633b1c7f9 100644 +index 8b51041370c5184d5a1926ea3262f9111703a6d3..28f703204afd834cd50335346ef065670d6b37ad 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -110,13 +110,13 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM +@@ -161,7 +161,7 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM } } - replaceMissingSections(containerFactory, this.sections); + this.replaceMissingSections(containerFactory, this.sections); // Paper - Anti-Xray - make it a non-static method + // Paper start - rewrite chunk system + if (!((Object)this instanceof ImposterProtoChunk)) { + this.starlight$setBlockNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(levelHeightAccessor)); +@@ -174,10 +174,10 @@ public abstract class ChunkAccess implements LightChunk, StructureAccess, BiomeM + // Paper end - get block chunk optimisation } - private static void replaceMissingSections(final PalettedContainerFactory containerFactory, final LevelChunkSection[] sections) { @@ -268,10 +273,10 @@ index de6c4c7518a48c237df4b7a1ca6ef5e6e0aa99e3..c1738500a2e5a7244087351081c71d76 } } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index f5d4733e0f1654aa1495b72ff83489acdbb8f5c6..eb88266d43fa31b54fea433c6d47dc0e6e3a0d33 100644 +index 0998671b463f0db367e8a34ad4a7ebf1355a99db..eaa3966c039723fa4bd90f67d122a8584cd5382b 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -118,7 +118,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -151,7 +151,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot final LevelChunk.@Nullable PostLoadProcessor postLoad, final @Nullable BlendingData blendingData ) { @@ -281,10 +286,10 @@ index f5d4733e0f1654aa1495b72ff83489acdbb8f5c6..eb88266d43fa31b54fea433c6d47dc0e this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index d1bf15ab369af57d022ff133b8d37afc98f9eb8c..6276b471b3cdd49c25a2323d7a08c8892dce53e4 100644 +index 8fd63c2f5f790af35384c4549dc914756b7dfe45..a25b1747fe6bde428265f90eadfade81c0979400 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -33,8 +33,14 @@ public class LevelChunkSection { +@@ -57,8 +57,14 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ this.recalcBlockCounts(); } @@ -300,7 +305,7 @@ index d1bf15ab369af57d022ff133b8d37afc98f9eb8c..6276b471b3cdd49c25a2323d7a08c889 this.biomes = containerFactory.createForBiomes(); } -@@ -176,11 +182,17 @@ public class LevelChunkSection { +@@ -280,11 +286,17 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ this.biomes = biomes; } @@ -321,12 +326,12 @@ index d1bf15ab369af57d022ff133b8d37afc98f9eb8c..6276b471b3cdd49c25a2323d7a08c889 public int getSerializedSize() { diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e9933fc5bd4 100644 +index b294e6794fd6f15998ac74aba991666757e25589..26dbb9da7a7f50ec913b1226eff9e9ce6b4f3f12 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 private static final int MIN_PALETTE_BITS = 0; - private volatile PalettedContainer.Data data; + public volatile PalettedContainer.Data data; // Paper - optimise collisions - public private final Strategy strategy; + private final T @Nullable [] presetValues; // Paper - Anti-Xray - Add preset values //private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused @@ -355,9 +360,9 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 return codec(elementCodec, strategy, defaultValue, unpacker); } -@@ -64,17 +72,55 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - ); +@@ -91,19 +99,57 @@ public class PalettedContainer implements PaletteResize, PalettedContainer } + // Paper end - optimise palette reads - private PalettedContainer(final Strategy strategy, final Configuration dataConfiguration, final BitStorage storage, final Palette palette) { + // Paper start - Anti-Xray - Add preset values @@ -367,6 +372,7 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 + // Paper end - Anti-Xray - Add preset values this.strategy = strategy; this.data = new PalettedContainer.Data<>(dataConfiguration, storage, palette); + this.updateData(this.data); // Paper - optimise palette reads + // Paper start - Anti-Xray + if (presetValues != null + && (dataConfiguration instanceof Configuration.Simple simpleFactory && simpleFactory.factory() == Strategy.SINGLE_VALUE_PALETTE_FACTORY @@ -400,6 +406,7 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 + this.presetValues = presetValues; // Paper - Anti-Xray - Add preset values this.strategy = source.strategy; this.data = source.data.copy(); + this.updateData(this.data); // Paper - optimise palette reads } + @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Anti-Xray @@ -413,7 +420,7 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 this.strategy = strategy; this.data = this.createOrReuseData(null, 0); this.data.palette.idFor(initialValue, this); -@@ -93,14 +139,38 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -123,15 +169,39 @@ public class PalettedContainer implements PaletteResize, PalettedContainer return new PalettedContainer.Data<>(dataConfiguration, storage, palette); } @@ -444,6 +451,7 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 PalettedContainer.Data newData = this.createOrReuseData(oldData, bits); newData.copyFrom(oldData.palette, oldData.storage); this.data = newData; + this.updateData(this.data); // Paper - optimise palette reads - return newData.palette.idFor(lastAddedValue, PaletteResize.noResizeExpected()); + // Paper start - Anti-Xray + this.addPresetValues(); @@ -454,10 +462,10 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 public synchronized T getAndSet(final int x, final int y, final int z, final T value) { // Paper - synchronize this.acquire(); -@@ -164,24 +234,38 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - newData.palette.read(buffer, this.strategy.globalMap()); +@@ -201,24 +271,38 @@ public class PalettedContainer implements PaletteResize, PalettedContainer buffer.readFixedSizeLongArray(newData.storage.getRaw()); this.data = newData; + this.updateData(this.data); // Paper - optimise palette reads + this.addPresetValues(); // Paper - Anti-Xray - Add preset values (inefficient, but this isn't used by the server) } finally { this.release(); @@ -495,7 +503,7 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 List paletteEntries = discData.paletteEntries(); int entryCount = strategy.entryCount(); Configuration storedConfiguration = strategy.getConfigurationForPaletteSize(paletteEntries.size()); -@@ -220,7 +304,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -257,7 +341,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer } } @@ -504,7 +512,7 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 } @Override -@@ -293,12 +377,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -330,12 +414,12 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @Override public PalettedContainer copy() { @@ -519,7 +527,7 @@ index d70b291a5caafc8165bcb804063fc96ff67db303..14fbb5f84c0701d45272fa6794b81e99 } @Override -@@ -331,9 +415,16 @@ public class PalettedContainer implements PaletteResize, PalettedContainer +@@ -405,9 +489,16 @@ public class PalettedContainer implements PaletteResize, PalettedContainer return 1 + this.palette.getSerializedSize(globalMap) + this.storage.getRaw().length * 8; } @@ -607,7 +615,7 @@ index 5c518b6ec7da546460884c37e9af682b6ab9fc22..958be147cd940ac430576ca5b4ada70f 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 760eda9e45a3f31a68a3b2b2dc13479c7db0d3cc..8f55e7a12541e2281e607da2b6a4d4b4c2811562 100644 +index 2d326c3090a5d7621350347e131ee31d4715d3a7..470d88c5d3b701ad0148dd18f506277f4017b931 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java @@ -129,6 +129,7 @@ public record SerializableChunkData( diff --git a/paper-server/patches/features/0017-Delay-open-close-callbacks-for-chests.patch b/paper-server/patches/features/0018-Delay-open-close-callbacks-for-chests.patch similarity index 100% rename from paper-server/patches/features/0017-Delay-open-close-callbacks-for-chests.patch rename to paper-server/patches/features/0018-Delay-open-close-callbacks-for-chests.patch diff --git a/paper-server/patches/features/0018-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features/0019-Improve-exact-choice-recipe-ingredients.patch similarity index 100% rename from paper-server/patches/features/0018-Improve-exact-choice-recipe-ingredients.patch rename to paper-server/patches/features/0019-Improve-exact-choice-recipe-ingredients.patch diff --git a/paper-server/patches/features_unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features/0020-Allow-Saving-of-Oversized-Chunks.patch similarity index 98% rename from paper-server/patches/features_unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch rename to paper-server/patches/features/0020-Allow-Saving-of-Oversized-Chunks.patch index 015978c4b3e7..b0d138485dda 100644 --- a/paper-server/patches/features_unapplied/0004-Allow-Saving-of-Oversized-Chunks.patch +++ b/paper-server/patches/features/0020-Allow-Saving-of-Oversized-Chunks.patch @@ -31,7 +31,7 @@ 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 026b1f31d5041786e90ba372a228732aee094c16..d39f8ae8f5736a7f4590ca41ac95792a61975baf 100644 +index 7767e5420e3d2e569008747523d70147ea8d97fb..b6c6bf9b20fee63b7e2a37d949bb1e55cef40de6 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -68,6 +68,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche @@ -119,7 +119,7 @@ index 026b1f31d5041786e90ba372a228732aee094c16..d39f8ae8f5736a7f4590ca41ac95792a + // Paper end } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 36f8c19e3e90740e6d58eb8dbf573b2fdf4fed3d..3d0a09662e5ed1f7bc0c02dbe6de529791f2f66f 100644 +index effc7de84088a7407c15e80adf12195e97bbf080..7440bebb75762602d9010868949ebe9cd141faca 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; diff --git a/paper-server/patches/features_unapplied/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/paper-server/patches/features/0021-Optimize-GoalSelector-Goal.Flag-Set-operations.patch similarity index 97% rename from paper-server/patches/features_unapplied/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch rename to paper-server/patches/features/0021-Optimize-GoalSelector-Goal.Flag-Set-operations.patch index e4da422f54ff..995e9d7740b6 100644 --- a/paper-server/patches/features_unapplied/0009-Optimize-GoalSelector-Goal.Flag-Set-operations.patch +++ b/paper-server/patches/features/0021-Optimize-GoalSelector-Goal.Flag-Set-operations.patch @@ -69,7 +69,7 @@ index aa5f0e00daf26650b943a24676638581e494a112..60e0d618c603caef5e3516c9fdfc63ff // 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 b13bdc2852504903fa054c42f89299a5d33dfbd3..1ddf8796d14d472bec48546f25ac4583d483c8e9 100644 +index 66839736d997f5c911dfd9cf251b0d4406172782..fc748f2575e04b05438cfa3803f5ae23aeca3cb4 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 { @@ -83,7 +83,7 @@ index b13bdc2852504903fa054c42f89299a5d33dfbd3..1ddf8796d14d472bec48546f25ac4583 public void addGoal(final int prio, final Goal goal) { @@ -60,18 +61,18 @@ public class GoalSelector { - this.availableGoals.removeIf(goal -> goal.getGoal() == toRemove); + this.removeAllGoals(goal -> goal == toRemove); } - private static boolean goalContainsAnyFlags(final WrappedGoal goal, final EnumSet disabledFlags) { diff --git a/paper-server/patches/features_unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features/0022-Fix-entity-tracker-desync-when-new-players-are-added.patch similarity index 92% rename from paper-server/patches/features_unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch rename to paper-server/patches/features/0022-Fix-entity-tracker-desync-when-new-players-are-added.patch index 944b36731026..d1c658e15680 100644 --- a/paper-server/patches/features_unapplied/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch +++ b/paper-server/patches/features/0022-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 7f879bc44354c9fac0238208db12b55a948982fb..55cfe38c0daa3ca71a71bf8c7d88fd613fabd82d 100644 +index 9bbc72cea0fe169f27c63e792e35f74a13b7d943..0b54f54bf559dc1c3c49594d62df6bad246fe7a3 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1357,6 +1357,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP +@@ -1360,6 +1360,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 7f879bc44354c9fac0238208db12b55a948982fb..55cfe38c0daa3ca71a71bf8c7d88fd61 } else { this.removePlayer(player); diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index a62ec41b1319857f0d6cd223d013a92b1e2c2b0d..5fad52157fc22755196ce9eaddaa2bc23c5bb86b 100644 +index 70daec14be69c0e02759489a5ddeda8718a288cc..fcb3a4435d55f58d71cbf27d7024c60690876493 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -89,6 +89,13 @@ public class ServerEntity { @@ -77,8 +77,8 @@ index a62ec41b1319857f0d6cd223d013a92b1e2c2b0d..5fad52157fc22755196ce9eaddaa2bc2 public void sendChanges() { // Paper start - optimise collisions if (((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)this.entity).moonrise$isHardColliding()) { -@@ -130,7 +137,7 @@ public class ServerEntity { - this.sendDirtyEntityData(); +@@ -135,7 +142,7 @@ public class ServerEntity { + this.entity.syncPosition = false; } - if (this.tickCount % this.updateInterval == 0 || this.entity.needsSync || this.entity.getEntityData().isDirty()) { @@ -86,7 +86,7 @@ index a62ec41b1319857f0d6cd223d013a92b1e2c2b0d..5fad52157fc22755196ce9eaddaa2bc2 byte yRotn = Mth.packDegrees(this.entity.getYRot()); byte xRotn = Mth.packDegrees(this.entity.getXRot()); boolean shouldSendRotation = Math.abs(yRotn - this.lastSentYRot) >= 1 || Math.abs(xRotn - this.lastSentXRot) >= 1; -@@ -164,7 +171,7 @@ public class ServerEntity { +@@ -169,7 +176,7 @@ public class ServerEntity { long ya = this.positionCodec.encodeY(currentPosition); long za = this.positionCodec.encodeZ(currentPosition); boolean deltaTooBig = xa < -32768L || xa > 32767L || ya < -32768L || ya > 32767L || za < -32768L || za > 32767L; @@ -95,7 +95,7 @@ index a62ec41b1319857f0d6cd223d013a92b1e2c2b0d..5fad52157fc22755196ce9eaddaa2bc2 || deltaTooBig || this.teleportDelay > 400 || this.wasRiding -@@ -233,6 +240,7 @@ public class ServerEntity { +@@ -238,6 +245,7 @@ public class ServerEntity { } this.entity.needsSync = false; diff --git a/paper-server/patches/features_unapplied/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features/0023-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch similarity index 96% rename from paper-server/patches/features_unapplied/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch rename to paper-server/patches/features/0023-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch index 5feef0177233..1c1432f739ff 100644 --- a/paper-server/patches/features_unapplied/0017-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch +++ b/paper-server/patches/features/0023-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch @@ -8,7 +8,7 @@ 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 d39f8ae8f5736a7f4590ca41ac95792a61975baf..4d83986bccc2003b291dd93534da2d2260f6c428 100644 +index b6c6bf9b20fee63b7e2a37d949bb1e55cef40de6..3ba442ac6b823e1c6a69398abc4f116da07c32c0 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -24,6 +24,7 @@ import org.slf4j.Logger; @@ -45,7 +45,7 @@ index d39f8ae8f5736a7f4590ca41ac95792a61975baf..4d83986bccc2003b291dd93534da2d22 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 3d0a09662e5ed1f7bc0c02dbe6de529791f2f66f..fedec4d680934730d38d8c5d609fe216938b668a 100644 +index 7440bebb75762602d9010868949ebe9cd141faca..6a9a238c28c15025dd9103d42c0a95dbe148265e 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -123,11 +123,24 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise diff --git a/paper-server/patches/features_unapplied/0018-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features/0024-Entity-load-save-limit-per-chunk.patch similarity index 96% rename from paper-server/patches/features_unapplied/0018-Entity-load-save-limit-per-chunk.patch rename to paper-server/patches/features/0024-Entity-load-save-limit-per-chunk.patch index f33ad87facea..81ac04d11a19 100644 --- a/paper-server/patches/features_unapplied/0018-Entity-load-save-limit-per-chunk.patch +++ b/paper-server/patches/features/0024-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 a1ee86c18c17e14ebf98f0e72680543addc4c7fa..1ee78f52205cbb0b254a28999f3707ccccbe998e 100644 +index a5fde689f70d589d2db09ee3c60478399780e627..03b3de257f7711165b7dfb14223e2b6fa8954170 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1641,7 +1641,18 @@ public class EntityType implements EntityTypeTest, +@@ -498,7 +498,18 @@ public class EntityType implements EntityTypeTest, } public static Stream loadEntitiesRecursive(final ValueInput.ValueInputList entities, final Level level, final EntitySpawnReason reason) { diff --git a/paper-server/patches/features_unapplied/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features/0025-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 98% rename from paper-server/patches/features_unapplied/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to paper-server/patches/features/0025-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 5dab6b41935a..a6f670f4be17 100644 --- a/paper-server/patches/features_unapplied/0019-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/paper-server/patches/features/0025-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -55,7 +55,7 @@ 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 4d83986bccc2003b291dd93534da2d2260f6c428..42d07aef0b2f646ec52ed6f4e7c003dbf82bd92d 100644 +index 3ba442ac6b823e1c6a69398abc4f116da07c32c0..3de7fd2b084c38e72d7a6bc416880a881f514ad3 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -46,6 +46,363 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche @@ -633,13 +633,13 @@ index 4d83986bccc2003b291dd93534da2d2260f6c428..42d07aef0b2f646ec52ed6f4e7c003db + // Paper end - add version param ByteBuffer stub = ByteBuffer.allocate(5); stub.putInt(1); -- stub.put((byte)(this.version.getId() | 128)); -+ stub.put((byte)(version.getId() | 128)); // Paper - add version param +- stub.put((byte)(this.version.getId() | EXTERNAL_STREAM_FLAG)); ++ stub.put((byte)(version.getId() | EXTERNAL_STREAM_FLAG)); // Paper - add version param stub.flip(); return stub; } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index fedec4d680934730d38d8c5d609fe216938b668a..e47a91b1869801258d0db20c126722fb06522c80 100644 +index 6a9a238c28c15025dd9103d42c0a95dbe148265e..db118c2665f6d94c8394a478cc3c619ed010a0c6 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 @@ -800,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 2d326c3090a5d7621350347e131ee31d4715d3a7..98fb7a282a33f4391de124ed9be9bcf069178516 100644 +index 470d88c5d3b701ad0148dd18f506277f4017b931..7d29fdc6548324d97ec34d476b5b48ec0bdba0d2 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( @@ -822,7 +822,7 @@ index 2d326c3090a5d7621350347e131ee31d4715d3a7..98fb7a282a33f4391de124ed9be9bcf0 // 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(); -@@ -542,7 +554,7 @@ public record SerializableChunkData( +@@ -545,7 +557,7 @@ public record SerializableChunkData( tag.putInt("xPos", this.chunkPos.x()); tag.putInt("yPos", this.minSectionY); tag.putInt("zPos", this.chunkPos.z()); @@ -832,7 +832,7 @@ index 2d326c3090a5d7621350347e131ee31d4715d3a7..98fb7a282a33f4391de124ed9be9bcf0 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 df4f03f3a346e0ab0074757b3a077b2407135ac3..0b0265c8d4cb70aef758c1b443d007ef8d6c282b 100644 +index 4346f3bace176e09d9ffb02e9af29a1281071e2a..5b8c9d74e0fb9ed9bcace801124263f75204c9eb 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_unapplied/0021-Flush-regionfiles-on-save-configuration-option.patch b/paper-server/patches/features/0026-Flush-regionfiles-on-save-configuration-option.patch similarity index 100% rename from paper-server/patches/features_unapplied/0021-Flush-regionfiles-on-save-configuration-option.patch rename to paper-server/patches/features/0026-Flush-regionfiles-on-save-configuration-option.patch diff --git a/paper-server/patches/features_unapplied/0022-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch similarity index 93% rename from paper-server/patches/features_unapplied/0022-Optimise-collision-checking-in-player-move-packet-ha.patch rename to paper-server/patches/features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch index 2409d420f21d..abac48531767 100644 --- a/paper-server/patches/features_unapplied/0022-Optimise-collision-checking-in-player-move-packet-ha.patch +++ b/paper-server/patches/features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimise collision checking in player move packet handling Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b14f28da4 100644 +index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5f4d87707 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -633,6 +633,7 @@ public class ServerGamePacketListenerImpl +@@ -637,6 +637,7 @@ public class ServerGamePacketListenerImpl } vehicle.move(MoverType.PLAYER, new Vec3(xDist, yDist, zDist)); @@ -17,7 +17,7 @@ index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b double oyDist = yDist; xDist = targetX - vehicle.getX(); yDist = targetY - vehicle.getY(); -@@ -648,7 +649,17 @@ public class ServerGamePacketListenerImpl +@@ -652,7 +653,17 @@ public class ServerGamePacketListenerImpl LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", vehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(movedDist)); } @@ -36,7 +36,7 @@ index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b vehicle.absSnapTo(oldX, oldY, oldZ, targetYRot, targetXRot); this.send(ClientboundMoveVehiclePacket.fromEntity(vehicle)); vehicle.removeLatestMovementRecording(); -@@ -727,9 +738,32 @@ public class ServerGamePacketListenerImpl +@@ -731,9 +742,32 @@ public class ServerGamePacketListenerImpl } private boolean noBlocksAround(final Entity entity) { @@ -72,7 +72,7 @@ index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b } @Override -@@ -1541,7 +1575,7 @@ public class ServerGamePacketListenerImpl +@@ -1548,7 +1582,7 @@ public class ServerGamePacketListenerImpl } } @@ -81,7 +81,7 @@ index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b xDist = targetX - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above yDist = targetY - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above zDist = targetZ - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above -@@ -1580,6 +1614,7 @@ public class ServerGamePacketListenerImpl +@@ -1587,6 +1621,7 @@ public class ServerGamePacketListenerImpl boolean playerStandsOnSomething = this.player.verticalCollisionBelow; this.player.move(MoverType.PLAYER, new Vec3(xDist, yDist, zDist)); this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move @@ -89,7 +89,7 @@ index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b // Paper start - prevent position desync if (this.awaitingPositionFromClient != null) { return; // ... thanks Mojang for letting move calls teleport across dimensions. -@@ -1613,7 +1648,17 @@ public class ServerGamePacketListenerImpl +@@ -1620,7 +1655,17 @@ public class ServerGamePacketListenerImpl } // Paper start - Add fail move event @@ -108,7 +108,7 @@ index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b if (!allowMovement) { io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, targetX, targetY, targetZ, targetYRot, targetXRot, false); -@@ -1753,7 +1798,7 @@ public class ServerGamePacketListenerImpl +@@ -1760,7 +1805,7 @@ public class ServerGamePacketListenerImpl private boolean updateAwaitingTeleport() { if (this.awaitingPositionFromClient != null) { @@ -117,7 +117,7 @@ index 2e9b47e87a1dc9f0713420414eda71eb6c03d898..3527559c9520e07646c7fb63fe27ad1b this.awaitingTeleportTime = this.tickCount; this.teleport( this.awaitingPositionFromClient.x, -@@ -1772,6 +1817,34 @@ public class ServerGamePacketListenerImpl +@@ -1779,6 +1824,34 @@ public class ServerGamePacketListenerImpl } } diff --git a/paper-server/patches/features_unapplied/0027-Optional-per-player-mob-spawns.patch b/paper-server/patches/features/0028-Optional-per-player-mob-spawns.patch similarity index 89% rename from paper-server/patches/features_unapplied/0027-Optional-per-player-mob-spawns.patch rename to paper-server/patches/features/0028-Optional-per-player-mob-spawns.patch index b14e4733d769..f5201dee948d 100644 --- a/paper-server/patches/features_unapplied/0027-Optional-per-player-mob-spawns.patch +++ b/paper-server/patches/features/0028-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 55cfe38c0daa3ca71a71bf8c7d88fd613fabd82d..2afc89ab4404cf04ba1da813f1c4a05baa4f44e3 100644 +index 0b54f54bf559dc1c3c49594d62df6bad246fe7a3..7f1899d46e4becaf18598c402cf0134920361eb4 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,7 +42,7 @@ index 55cfe38c0daa3ca71a71bf8c7d88fd613fabd82d..2afc89ab4404cf04ba1da813f1c4a05b protected ChunkGenerator generator() { return this.worldGenContext.generator(); diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index a5685e0b50610cc8213f34c5db62b475bd54789b..a5023f6f7d912560f3488b1823ee22a1dc639203 100644 +index 9618c6f7adbfc0ab65c221dba6bdb7266cf3baa6..67838dd61af5e063acb8b601f3f0c6a14a76cab9 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -535,9 +535,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @@ -77,10 +77,10 @@ index a5685e0b50610cc8213f34c5db62b475bd54789b..a5023f6f7d912560f3488b1823ee22a1 profiler.popPush("tickSpawningChunks"); diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index c8dd908ea52305d7ae1235ea430a26c88306f183..85d22ea2e0fb7c59c387df056ace9ef556f489a2 100644 +index c4322dda780cc885d2483e8f26feec3f84dd181b..c4854bd7e32b9f73d340ce4dd325156aa428b1f1 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -411,6 +411,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -417,6 +417,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 c8dd908ea52305d7ae1235ea430a26c88306f183..85d22ea2e0fb7c59c387df056ace9ef5 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 c0a986932c25d056877e3147d09dd50d1264b13d..b1ecbc50ea908c6c11e9e1ae2f73d1eed669db08 100644 +index e977389d539236d644f478f75fb34d0af2535a81..5a5cffd7b61c45d574cdf62aa1cc0913c89c694f 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -70,6 +70,18 @@ public final class NaturalSpawner { @@ -132,16 +132,16 @@ index c0a986932c25d056877e3147d09dd50d1264b13d..b1ecbc50ea908c6c11e9e1ae2f73d1ee }); } } -@@ -133,7 +150,7 @@ public final class NaturalSpawner { - if ((spawnFriendlies || !mobCategory.isFriendly()) - && (spawnEnemies || mobCategory.isFriendly()) - && (spawnPersistent || !mobCategory.isPersistent()) -- && state.canSpawnForCategoryGlobal(mobCategory, limit)) { // Paper - Optional per player mob spawns; remove global check, check later during the local one -+ && (level.paperConfig().entities.spawning.perPlayerMobSpawns || state.canSpawnForCategoryGlobal(mobCategory, limit))) { // Paper - Optional per player mob spawns; remove global check, check later during the local one - spawningCategories.add(mobCategory); +@@ -130,7 +147,7 @@ public final class NaturalSpawner { + continue; + } + +- if ((spawnFriendlies || !mobCategory.isFriendly()) && (spawnEnemies || mobCategory.isFriendly()) && (spawnPersistent || !mobCategory.isPersistent()) && state.canSpawnForCategoryGlobal(mobCategory, limit)) { // Paper - Optional per player mob spawns; remove global check, check later during the local one ++ if ((spawnFriendlies || !mobCategory.isFriendly()) && (spawnEnemies || mobCategory.isFriendly()) && (spawnPersistent || !mobCategory.isPersistent()) && (level.paperConfig().entities.spawning.perPlayerMobSpawns || state.canSpawnForCategoryGlobal(mobCategory, limit))) { // Paper - Optional per player mob spawns; remove global check, check later during the local one // CraftBukkit end + spawningCategories.add(mobCategory); } -@@ -149,8 +166,37 @@ public final class NaturalSpawner { +@@ -146,8 +163,37 @@ public final class NaturalSpawner { profiler.push("spawner"); for (MobCategory mobCategory : spawningCategories) { @@ -181,7 +181,7 @@ index c0a986932c25d056877e3147d09dd50d1264b13d..b1ecbc50ea908c6c11e9e1ae2f73d1ee } } -@@ -174,9 +220,22 @@ public final class NaturalSpawner { +@@ -171,9 +217,22 @@ public final class NaturalSpawner { final NaturalSpawner.SpawnPredicate extraTest, final NaturalSpawner.AfterSpawnCallback spawnCallback ) { @@ -205,7 +205,7 @@ index c0a986932c25d056877e3147d09dd50d1264b13d..b1ecbc50ea908c6c11e9e1ae2f73d1ee } } -@@ -193,6 +252,20 @@ public final class NaturalSpawner { +@@ -190,6 +249,20 @@ public final class NaturalSpawner { final NaturalSpawner.SpawnPredicate extraTest, final NaturalSpawner.AfterSpawnCallback spawnCallback ) { @@ -226,7 +226,7 @@ index c0a986932c25d056877e3147d09dd50d1264b13d..b1ecbc50ea908c6c11e9e1ae2f73d1ee StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int yStart = start.getY(); -@@ -257,9 +330,14 @@ public final class NaturalSpawner { +@@ -254,9 +327,14 @@ public final class NaturalSpawner { clusterSize++; groupSize++; spawnCallback.run(mob, chunk); @@ -242,7 +242,7 @@ index c0a986932c25d056877e3147d09dd50d1264b13d..b1ecbc50ea908c6c11e9e1ae2f73d1ee return; } -@@ -591,7 +669,7 @@ public final class NaturalSpawner { +@@ -588,7 +666,7 @@ public final class NaturalSpawner { this.spawnPotential.addCharge(pos, charge); MobCategory category = type.getCategory(); this.mobCategoryCounts.addTo(category, 1); diff --git a/paper-server/patches/features_unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/paper-server/patches/features/0029-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch similarity index 90% rename from paper-server/patches/features_unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch rename to paper-server/patches/features/0029-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch index b3eb7c1ad2ce..23d7273a82fa 100644 --- a/paper-server/patches/features_unapplied/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch +++ b/paper-server/patches/features/0029-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 2afc89ab4404cf04ba1da813f1c4a05baa4f44e3..42ec67c53c35189838ce4767c2be620e05108159 100644 +index 7f1899d46e4becaf18598c402cf0134920361eb4..1e2c03cbdde141dfea89440c6de1c26b9d8cce1f 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,7 +37,7 @@ index 2afc89ab4404cf04ba1da813f1c4a05baa4f44e3..42ec67c53c35189838ce4767c2be620e // Paper end - Optional per player mob spawns diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index a5023f6f7d912560f3488b1823ee22a1dc639203..0609c4e7ac7d027ed01684ab4fec2a7838f1f30f 100644 +index 67838dd61af5e063acb8b601f3f0c6a14a76cab9..527e92e4d044a0d7cf1bb867044565cbeab68b9c 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -540,7 +540,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @@ -60,10 +60,10 @@ index a5023f6f7d912560f3488b1823ee22a1dc639203..0609c4e7ac7d027ed01684ab4fec2a78 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 85d22ea2e0fb7c59c387df056ace9ef556f489a2..d354517cbfdcee0648daa8f3eb035b2024d5ce72 100644 +index c4854bd7e32b9f73d340ce4dd325156aa428b1f1..eaab233c3b04ec127f7c434d52fe5ec85df765b1 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -415,6 +415,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -421,6 +421,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,10 +72,10 @@ index 85d22ea2e0fb7c59c387df056ace9ef556f489a2..d354517cbfdcee0648daa8f3eb035b20 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 b1ecbc50ea908c6c11e9e1ae2f73d1eed669db08..9764163a32b0389afa50ba093d0647de04d5119e 100644 +index 5a5cffd7b61c45d574cdf62aa1cc0913c89c694f..ab37d2dcfac161010f9c808a4edabbda92937b25 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -307,6 +307,11 @@ public final class NaturalSpawner { +@@ -304,6 +304,11 @@ public final class NaturalSpawner { // Paper start - PreCreatureSpawnEvent PreSpawnStatus doSpawning = isValidSpawnPostitionForType(level, mobCategory, structureManager, generator, currentSpawnData, pos, nearestPlayerDistanceSqr); diff --git a/paper-server/patches/features_unapplied/0029-Optimize-Hoppers.patch b/paper-server/patches/features/0030-Optimize-Hoppers.patch similarity index 97% rename from paper-server/patches/features_unapplied/0029-Optimize-Hoppers.patch rename to paper-server/patches/features/0030-Optimize-Hoppers.patch index 2788ec665064..d191d8d72483 100644 --- a/paper-server/patches/features_unapplied/0029-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0030-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 e69b540be1e0f0c699a57e07057cee74d4f8a771..cc35c6271c98615a486422d0490145227626bd85 100644 +index 08b24ebcef4b1f743177f21c038ec253f5838c04..3c4fb4eb8e543df49b285fc738aa3eee0df58584 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1840,6 +1840,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 e69b540be1e0f0c699a57e07057cee74d4f8a771..cc35c6271c98615a486422d049014522 profiler.push("tick"); diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index 95e0fb32457f2113de8d3e78fc18398bec83eccf..1d08ac66271a441811a157ed6619b14bf58c403f 100644 +index c0a2ee3e46f453923635376ff5a1d3b2454c2914..706e0d9ceb3c3baf7ed89535806ec262f531dd57 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -807,11 +807,17 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -782,11 +782,17 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { } public ItemStack copy() { @@ -84,7 +84,7 @@ index 95e0fb32457f2113de8d3e78fc18398bec83eccf..1d08ac66271a441811a157ed6619b14b return copy; } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index 0e2b537ff5230e6bdb55e9e99d6b2202479b8fd2..2c9fb60cae8065b1cd70d6ec53122cec9cf7f2a7 100644 +index bb61b97a9619e76344bae5458bbdf2bc96e5494c..ae0df53c3be7ebcf48886adbedfaa2c071a94023 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java @@ -39,6 +39,7 @@ import org.jspecify.annotations.Nullable; @@ -95,7 +95,7 @@ index 0e2b537ff5230e6bdb55e9e99d6b2202479b8fd2..2c9fb60cae8065b1cd70d6ec53122cec // 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; -@@ -214,6 +215,7 @@ public abstract class BlockEntity implements DebugValueSource, TypedInstance Date: Sat, 13 Jun 2026 05:49:08 -0400 Subject: [PATCH 09/30] Update README version badge for 26.2 [ci skip] (#13953) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b53f8180aead..09d6ee01f9db 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Paper [![Version](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fartifactory.papermc.io%2Fartifactory%2Funiverse%2Fio%2Fpapermc%2Fpaper%2Fpaper-api%2Fmaven-metadata.xml&strategy=highestVersion&filter=26.1*&label=version&color=%23344ceb +Paper [![Version](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fartifactory.papermc.io%2Fartifactory%2Funiverse%2Fio%2Fpapermc%2Fpaper%2Fpaper-api%2Fmaven-metadata.xml&strategy=highestVersion&filter=26.2*&label=version&color=%23344ceb )](https://papermc.io/downloads/paper) [![Paper Build Status](https://img.shields.io/github/actions/workflow/status/PaperMC/Paper/build.yml?branch=main)](https://github.com/PaperMC/Paper/actions) [![Discord](https://img.shields.io/discord/289587909051416579.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/papermc) From c04c71b2b64da9ac9c9c87c3ebd3728b5d786a2b Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 13 Jun 2026 12:19:25 +0200 Subject: [PATCH 10/30] fix folia entity scheduler Add back dropped hunk in ServerEntityLookup --- ...016-Optimise-EntityScheduler-ticking.patch | 12 +++++++ .../features/0030-Optimize-Hoppers.patch | 4 +-- .../minecraft/world/item/ItemStack.java.patch | 33 +++++++++---------- .../minecraft/world/level/Level.java.patch | 6 ++-- .../world/level/chunk/LevelChunk.java.patch | 2 +- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch index 2cbf3697c4e3..6efb6f95812b 100644 --- a/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch +++ b/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch @@ -7,6 +7,18 @@ The vast majority of the time, there are no tasks scheduled to the EntityScheduler. We can avoid iterating the entire entity list by tracking which schedulers have any tasks scheduled. +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java +index 2bc436cdf5180a7943c45fabb9fbbedae6f7db56..f312a7f5b1b2a777ab36b94ce7cbf3873f5e88bc 100644 +--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java +@@ -96,6 +96,7 @@ public final class ServerEntityLookup extends EntityLookup { + if (entity instanceof ThrownEnderpearl enderpearl) { + this.addEnderPearl(CoordinateUtils.getChunkKey(enderpearl.chunkPosition())); + } ++ entity.registerScheduler(); // Paper - optimise Folia entity scheduler + } + + @Override diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java index 1a941fe5cff1d002486306e2632f0fd2628107f6..08b24ebcef4b1f743177f21c038ec253f5838c04 100644 --- a/net/minecraft/server/MinecraftServer.java diff --git a/paper-server/patches/features/0030-Optimize-Hoppers.patch b/paper-server/patches/features/0030-Optimize-Hoppers.patch index d191d8d72483..463ebd4a676b 100644 --- a/paper-server/patches/features/0030-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0030-Optimize-Hoppers.patch @@ -60,10 +60,10 @@ index 08b24ebcef4b1f743177f21c038ec253f5838c04..3c4fb4eb8e543df49b285fc738aa3eee profiler.push("tick"); diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index c0a2ee3e46f453923635376ff5a1d3b2454c2914..706e0d9ceb3c3baf7ed89535806ec262f531dd57 100644 +index 16c702f9fce891981ba185b30d9cdb94309172b3..0ad49961a5493cf070b008c247304bad48f44a67 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -782,11 +782,17 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -781,11 +781,17 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { } public ItemStack copy() { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index ee0187c96c86..a18c951cc562 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -32,7 +32,7 @@ ItemStack.CODEC.encodeStart(ops, itemStack).getOrThrow(DecoderException::new); } -@@ -368,10 +_,141 @@ +@@ -368,10 +_,140 @@ } Item usedItem = this.getItem(); @@ -49,7 +49,7 @@ + } + + List capturedBlockStates; -+ java.util.Map capturedTileEntities; ++ List capturedBlockEntities; + org.bukkit.TreeType treeType; + InteractionResult result; + try { @@ -61,8 +61,8 @@ + capturedBlockStates = new java.util.ArrayList<>(level.capturedBlockStates.values()); + level.capturedBlockStates.clear(); + -+ capturedTileEntities = new java.util.LinkedHashMap<>(level.capturedTileEntities); -+ level.capturedTileEntities.clear(); ++ capturedBlockEntities = new java.util.ArrayList<>(level.capturedBlockEntities.values()); ++ level.capturedBlockEntities.clear(); + + treeType = net.minecraft.world.level.block.SaplingBlock.treeType; + net.minecraft.world.level.block.SaplingBlock.treeType = null; @@ -77,7 +77,7 @@ + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); + 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) capturedBlockStates); ++ structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, true, (org.bukkit.entity.Player) player.getBukkitEntity(), (List) (List) capturedBlockStates); + org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); + } + @@ -126,36 +126,35 @@ + this.setCount(newCount); + } + -+ for (java.util.Map.Entry e : capturedTileEntities.entrySet()) { -+ level.setBlockEntity(e.getValue()); ++ for (net.minecraft.world.level.block.entity.BlockEntity blockEntity : capturedBlockEntities) { ++ level.setBlockEntity(blockEntity); + } + -+ for (org.bukkit.block.BlockState snapshot : capturedBlockStates) { -+ int updateFlags = ((org.bukkit.craftbukkit.block.CraftBlockState) snapshot).getFlags(); -+ net.minecraft.world.level.block.state.BlockState oldBlock = ((org.bukkit.craftbukkit.block.CraftBlockState) snapshot).getHandle(); -+ BlockPos newPos = ((org.bukkit.craftbukkit.block.CraftBlockState) snapshot).getPosition(); ++ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : capturedBlockStates) { ++ net.minecraft.world.level.block.state.BlockState oldBlock = snapshot.getHandle(); ++ BlockPos newPos = snapshot.getPosition(); + net.minecraft.world.level.block.state.BlockState block = level.getBlockState(newPos); + + if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically + block.onPlace(level, newPos, oldBlock, true, context); + } + -+ 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 ++ level.notifyAndUpdatePhysics(newPos, null, oldBlock, block, level.getBlockState(newPos), snapshot.getFlags(), net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point + } + + BlockPos placedPos = success.paperSuccessContext().placedPos(); + if (usedItem == Items.WITHER_SKELETON_SKULL && placedPos != null) { // Special case skulls to allow wither spawns to be cancelled + net.minecraft.world.level.block.entity.BlockEntity blockEntity = level.getBlockEntity(placedPos); -+ if (blockEntity instanceof net.minecraft.world.level.block.entity.SkullBlockEntity skull) { -+ net.minecraft.world.level.block.WitherSkullBlock.checkSpawn(level, placedPos, skull); ++ if (blockEntity instanceof net.minecraft.world.level.block.entity.SkullBlockEntity placedSkull) { ++ net.minecraft.world.level.block.WitherSkullBlock.checkSpawn(level, placedPos, placedSkull); + } + } + + // SPIGOT-4678 + if (usedItem instanceof SignItem && placedPos != null) { -+ if (level.getBlockEntity(placedPos) instanceof net.minecraft.world.level.block.entity.SignBlockEntity sign) { -+ if (level.getBlockState(placedPos).getBlock() instanceof net.minecraft.world.level.block.SignBlock signBlock) { -+ signBlock.openTextEdit(player, sign, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // CraftBukkit // Paper - Add PlayerOpenSignEvent ++ if (level.getBlockEntity(placedPos) instanceof net.minecraft.world.level.block.entity.SignBlockEntity signEntity) { ++ if (level.getBlockState(placedPos).getBlock() instanceof net.minecraft.world.level.block.SignBlock sign) { ++ sign.openTextEdit(player, signEntity, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // CraftBukkit // Paper - Add PlayerOpenSignEvent + } + } + } 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 4398c1967ca8..ab2b35cb7a96 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 @@ -31,7 +31,7 @@ + public boolean captureBlockStates = false; + public boolean captureTreeGeneration = false; + public Map capturedBlockStates = new java.util.LinkedHashMap<>(); // Paper -+ public Map capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates ++ public Map capturedBlockEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates + @Nullable + public List captureDrops; + public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); @@ -514,7 +514,7 @@ public @Nullable BlockEntity getBlockEntity(final BlockPos pos) { + // Paper start - Perf: Optimize capturedTileEntities lookup + net.minecraft.world.level.block.entity.BlockEntity blockEntity; -+ if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(pos)) != null) { ++ if (!this.capturedBlockEntities.isEmpty() && (blockEntity = this.capturedBlockEntities.get(pos)) != null) { + return blockEntity; + } + // Paper end - Perf: Optimize capturedTileEntities lookup @@ -527,7 +527,7 @@ if (this.isInValidBounds(pos)) { + // CraftBukkit start + if (this.captureBlockStates) { -+ this.capturedTileEntities.put(pos.immutable(), blockEntity); ++ this.capturedBlockEntities.put(pos.immutable(), blockEntity); + return; + } + // CraftBukkit end 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 861648b07f6b..1d9a311a1e3e 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 @@ -145,7 +145,7 @@ public @Nullable BlockEntity getBlockEntity(final BlockPos pos, final LevelChunk.EntityCreationType creationType) { - BlockEntity blockEntity = this.blockEntities.get(pos); + // CraftBukkit start -+ BlockEntity blockEntity = this.level.capturedTileEntities.get(pos); ++ BlockEntity blockEntity = this.level.capturedBlockEntities.get(pos); + if (blockEntity == null) { + blockEntity = this.blockEntities.get(pos); + } From fe1b210d18e86e34433a9f1aac554c307a257064 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 13 Jun 2026 13:27:39 +0200 Subject: [PATCH 11/30] don't break Vex#getSummoner This is always a mob in vanilla unless someone use command which doesn't warrant this break. --- .../src/main/java/org/bukkit/entity/Vex.java | 39 ++++++++++++------- .../bukkit/craftbukkit/entity/CraftVex.java | 12 +++--- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/Vex.java b/paper-api/src/main/java/org/bukkit/entity/Vex.java index 83cea1a1d542..2f38affaaadf 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Vex.java +++ b/paper-api/src/main/java/org/bukkit/entity/Vex.java @@ -85,30 +85,41 @@ public interface Vex extends Monster { // Paper start /** - * Get the living entity that summoned this vex + * Gets the Mob that summoned this vex * - * @return Living entity that summoned this vex + * @return mob that summoned this vex + * @deprecated use {@link #getOwner()} */ - @Nullable - LivingEntity getSummoner(); + @Deprecated(forRemoval = true, since = "26.2") + default @Nullable Mob getSummoner() { + return this.getOwner() instanceof Mob mob ? mob : null; + } /** - * Set the summoner of this vex + * Sets the summoner of this vex * - * @param summoner New summoner + * @param summoner new summoner + * @deprecated use {@link #setOwner(LivingEntity)} */ - void setSummoner(@Nullable LivingEntity summoner); + @Deprecated(forRemoval = true, since = "26.2") + default void setSummoner(final @Nullable Mob summoner) { + this.setOwner(summoner); + } /** - * Set the summoner of this vex + * Gets the owner of this vex which is + * often its summoner. * - * @param summoner New summoner - * @deprecated Use {@link #setSummoner(LivingEntity)} + * @return new owner */ - @Deprecated(forRemoval = true, since = "26.2") - default void setSummoner(@Nullable Mob summoner) { - this.setSummoner((LivingEntity) summoner); - } + @Nullable LivingEntity getOwner(); + + /** + * Sets the owner of this vex. + * + * @param owner new owner + */ + void setOwner(@Nullable LivingEntity owner); /** * Gets if this vex should start to take damage diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index 3b6a1bf12f4b..6b5cd57ac85b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -1,12 +1,15 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; +import net.minecraft.Optionull; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.EntityReference; import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Vex; +import org.jetbrains.annotations.Nullable; public class CraftVex extends CraftMonster implements Vex { @@ -20,14 +23,13 @@ public net.minecraft.world.entity.monster.Vex getHandle() { } @Override - public org.bukkit.entity.LivingEntity getSummoner() { - net.minecraft.world.entity.LivingEntity owner = this.getHandle().getOwner(); - return owner instanceof net.minecraft.world.entity.LivingEntity livingEntity ? livingEntity.getBukkitLivingEntity() : null; + public @Nullable LivingEntity getOwner() { + return Optionull.map(this.getHandle().getOwner(), net.minecraft.world.entity.LivingEntity::getBukkitLivingEntity); } @Override - public void setSummoner(org.bukkit.entity.LivingEntity summoner) { - this.getHandle().owner = summoner == null ? null : EntityReference.of(((CraftLivingEntity) summoner).getHandle()); + public void setOwner(final @Nullable LivingEntity owner) { + this.getHandle().owner = owner == null ? null : EntityReference.of(((CraftLivingEntity) owner).getHandle()); } @Override From d16f5ccc910b20b5dd7075e03da608a525022537 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sat, 13 Jun 2026 19:57:43 +0200 Subject: [PATCH 12/30] Use more accurate placed sound for block item part 2 of f1735f44400e25f028750a010b3eba557071200e --- .../features/0030-Optimize-Hoppers.patch | 4 ++-- .../minecraft/world/item/ItemStack.java.patch | 20 +++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/paper-server/patches/features/0030-Optimize-Hoppers.patch b/paper-server/patches/features/0030-Optimize-Hoppers.patch index 463ebd4a676b..3a2abdac56cf 100644 --- a/paper-server/patches/features/0030-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0030-Optimize-Hoppers.patch @@ -60,10 +60,10 @@ index 08b24ebcef4b1f743177f21c038ec253f5838c04..3c4fb4eb8e543df49b285fc738aa3eee profiler.push("tick"); diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index 16c702f9fce891981ba185b30d9cdb94309172b3..0ad49961a5493cf070b008c247304bad48f44a67 100644 +index 888254c5dcb7e7a301dc47a0c69c503ce20840d5..dc301caf0e548cb8d63af5b47e14afcaedeb6521 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -781,11 +781,17 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { +@@ -779,11 +779,17 @@ public final class ItemStack implements DataComponentHolder, ItemInstance { } public ItemStack copy() { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index a18c951cc562..91e1f5c0b79b 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,11 +1,7 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -186,12 +_,20 @@ - - @Override - public void encode(final RegistryFriendlyByteBuf output, final ItemStack itemStack) { -- if (itemStack.isEmpty()) { -+ if (itemStack.isEmpty() || itemStack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() +@@ -189,9 +_,17 @@ + if (itemStack.isEmpty()) { output.writeVarInt(0); } else { - output.writeVarInt(itemStack.getCount()); @@ -32,7 +28,7 @@ ItemStack.CODEC.encodeStart(ops, itemStack).getOrThrow(DecoderException::new); } -@@ -368,10 +_,140 @@ +@@ -368,10 +_,138 @@ } Item usedItem = this.getItem(); @@ -160,12 +156,10 @@ + } + + // SPIGOT-1288 - play sound stripped from BlockItem -+ if (usedItem instanceof BlockItem && placedPos != null) { -+ // Paper start - Fix spigot sound playing for BlockItem ItemStacks -+ BlockState state = level.getBlockState(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 (usedItem instanceof BlockItem blockItem && placedPos != null) { ++ BlockState placedState = level.getBlockState(placedPos); ++ net.minecraft.world.level.block.SoundType soundType = placedState.getSoundType(); ++ level.playSound(player, pos, blockItem.getPlaceSound(placedState), net.minecraft.sounds.SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); + } + + player.awardStat(Stats.ITEM_USED.get(usedItem)); From 03b30e077aee14c7fb639583cab46a446ef69d73 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 14 Jun 2026 08:59:50 +0200 Subject: [PATCH 13/30] Reset updatingMinecraft --- gradle.properties | 2 +- paper-server/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index adce5e88685f..47db2843b343 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ apiVersion=26.2 channel=ALPHA # Set to true while updating Minecraft version -updatingMinecraft=true +updatingMinecraft=false org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 5a2c1f62d368..d853a070a46f 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -23,7 +23,7 @@ paperweight { gitFilePatches = false updatingMinecraft { - oldPaperCommit = "d4fe85375af18bfa88f44d7c1e6a61904ae550cc" + // oldPaperCommit = "d4fe85375af18bfa88f44d7c1e6a61904ae550cc" } } From 59797420d003e551521c1ddf071195b1c58f4624 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 16 Jun 2026 17:14:35 +0200 Subject: [PATCH 14/30] 26.2 --- gradle.properties | 2 +- paper-server/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 47db2843b343..3288cca16c6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=io.papermc.paper -mcVersion=26.2-rc-2 +mcVersion=26.2 # This is the current API version for use in (paper-)plugin.yml files # During snapshot cycles this should be the anticipated version of the release target apiVersion=26.2 diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index d853a070a46f..c5cb788f787d 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,7 +14,7 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:26.2-rc-2+build.2") + mache("io.papermc:mache:26.2+build.1") paperclip("io.papermc:paperclip:3.0.4") } From 389befc200a2fac94a573025f7d9f31a0a16c385 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Tue, 16 Jun 2026 21:37:41 +0200 Subject: [PATCH 15/30] drop old ATs --- build-data/paper.at | 148 +----------------- .../main/java/org/bukkit/entity/Firework.java | 8 +- .../java/org/bukkit/entity/HumanEntity.java | 8 +- .../src/main/java/org/bukkit/entity/Vex.java | 14 +- .../main/java/org/bukkit/entity/Zombie.java | 4 +- .../0001-Moonrise-optimisation-patches.patch | 128 +++++++-------- .../0003-Entity-Activation-Range-2.0.patch | 20 +-- ...016-Optimise-EntityScheduler-ticking.patch | 8 +- .../patches/features/0017-Anti-Xray.patch | 20 +-- ...020-Allow-Saving-of-Oversized-Chunks.patch | 4 +- .../0028-Optional-per-player-mob-spawns.patch | 10 +- .../features/0030-Optimize-Hoppers.patch | 6 +- .../util/BaseChunkSystemHooks.java.patch | 38 ++--- .../io/papermc/paper/FeatureHooks.java.patch | 12 +- .../dispenser/DispenseItemBehavior.java.patch | 2 +- .../server/MinecraftServer.java.patch | 8 +- .../ServerAdvancementManager.java.patch | 12 +- .../server/ServerScoreboard.java.patch | 2 +- .../DedicatedServerProperties.java.patch | 4 +- .../server/level/ChunkLevel.java.patch | 11 -- .../server/level/ChunkMap.java.patch | 2 +- .../server/level/ServerLevel.java.patch | 8 +- .../server/level/ServerPlayer.java.patch | 17 -- .../ServerGamePacketListenerImpl.java.patch | 40 ++--- ...rverHandshakePacketListenerImpl.java.patch | 2 +- .../config/PrepareSpawnTask.java.patch | 2 +- .../server/players/PlayerList.java.patch | 8 +- .../world/SimpleContainer.java.patch | 2 +- .../effect/SaturationMobEffect.java.patch | 2 +- .../minecraft/world/entity/Entity.java.patch | 6 +- .../world/entity/ItemBasedSteering.java.patch | 16 +- .../world/entity/LivingEntity.java.patch | 14 +- .../net/minecraft/world/entity/Mob.java.patch | 2 +- .../world/entity/animal/Animal.java.patch | 2 +- .../entity/animal/allay/Allay.java.patch | 2 +- .../entity/decoration/Mannequin.java.patch | 11 -- .../world/entity/monster/Creeper.java.patch | 2 +- .../world/entity/monster/Guardian.java.patch | 2 +- .../monster/zombie/ZombieVillager.java.patch | 2 +- .../ThrownLingeringPotion.java.patch | 2 +- .../AbstractMinecartContainer.java.patch | 4 +- .../minecraft/world/food/FoodData.java.patch | 2 +- .../world/inventory/DispenserMenu.java.patch | 2 +- .../world/item/BucketItem.java.patch | 2 +- .../world/item/ItemCooldowns.java.patch | 15 ++ .../minecraft/world/item/ItemStack.java.patch | 4 +- .../world/item/ServerItemCooldowns.java.patch | 14 +- .../world/item/TridentItem.java.patch | 2 +- .../minecraft/world/level/Level.java.patch | 2 +- .../world/level/block/Block.java.patch | 2 +- .../world/level/block/CakeBlock.java.patch | 2 +- .../entity/SculkSensorBlockEntity.java.patch | 2 +- .../block/state/BlockBehaviour.java.patch | 2 +- .../world/level/chunk/LevelChunk.java.patch | 10 +- .../level/chunk/LevelChunkSection.java.patch | 2 +- .../maps/MapItemSavedData.java.patch | 8 +- .../paper/entity/PaperPathfinder.java | 2 +- .../paper/entity/ai/PaperMobGoals.java | 4 +- .../network/PaperServerListPingEventImpl.java | 2 +- .../paper/profile/CraftPlayerProfile.java | 8 +- .../paper/adventure/AdventureCodecs.java | 3 +- .../antixray/ChunkPacketBlockController.java | 2 +- .../ChunkPacketBlockControllerAntiXray.java | 4 +- .../command/subcommands/MobcapsCommand.java | 2 +- .../paper/potion/PaperPotionBrewer.java | 2 +- .../migration/WorldMigrationContext.java | 2 +- .../org/bukkit/craftbukkit/CraftChunk.java | 10 +- .../craftbukkit/CraftOfflinePlayer.java | 2 +- .../org/bukkit/craftbukkit/CraftRaid.java | 6 +- .../org/bukkit/craftbukkit/CraftServer.java | 10 +- .../org/bukkit/craftbukkit/CraftWorld.java | 14 +- .../bukkit/craftbukkit/block/CraftBanner.java | 2 +- .../bukkit/craftbukkit/block/CraftBarrel.java | 26 ++- .../bukkit/craftbukkit/block/CraftBeacon.java | 4 +- .../craftbukkit/block/CraftBlockType.java | 2 +- .../craftbukkit/block/CraftContainer.java | 6 +- .../craftbukkit/block/CraftDispenser.java | 3 +- .../craftbukkit/block/CraftDropper.java | 3 +- .../craftbukkit/block/CraftLootable.java | 2 +- .../craftbukkit/block/CraftSculkSensor.java | 2 +- .../craftbukkit/block/CraftShulkerBox.java | 2 +- .../bukkit/craftbukkit/block/CraftSkull.java | 2 +- .../block/CraftStructureBlock.java | 36 ++--- .../craftbukkit/block/CraftTrialSpawner.java | 20 +-- .../block/CraftTrialSpawnerConfiguration.java | 4 +- .../bukkit/craftbukkit/boss/CraftBossBar.java | 2 +- .../craftbukkit/boss/CraftDragonBattle.java | 2 +- .../entity/CraftAbstractArrow.java | 28 ++-- .../craftbukkit/entity/CraftAnimals.java | 2 +- .../entity/CraftAreaEffectCloud.java | 46 +++--- .../bukkit/craftbukkit/entity/CraftBee.java | 2 +- .../bukkit/craftbukkit/entity/CraftBoat.java | 15 +- .../craftbukkit/entity/CraftEntity.java | 3 - .../craftbukkit/entity/CraftFallingBlock.java | 2 +- .../craftbukkit/entity/CraftFirework.java | 14 +- .../craftbukkit/entity/CraftFishHook.java | 13 +- .../craftbukkit/entity/CraftHoglin.java | 4 +- .../craftbukkit/entity/CraftHumanEntity.java | 38 ++--- .../bukkit/craftbukkit/entity/CraftItem.java | 8 +- .../craftbukkit/entity/CraftLivingEntity.java | 4 +- .../bukkit/craftbukkit/entity/CraftMob.java | 2 +- .../bukkit/craftbukkit/entity/CraftPig.java | 2 +- .../craftbukkit/entity/CraftPiglin.java | 6 +- .../entity/CraftPiglinAbstract.java | 4 +- .../craftbukkit/entity/CraftPillager.java | 2 +- .../craftbukkit/entity/CraftPlayer.java | 33 ++-- .../craftbukkit/entity/CraftSkeleton.java | 2 +- .../craftbukkit/entity/CraftStrider.java | 2 +- .../entity/CraftThrowableProjectile.java | 6 +- .../craftbukkit/entity/CraftThrownPotion.java | 6 - .../craftbukkit/entity/CraftTrident.java | 12 -- .../craftbukkit/entity/CraftTurtle.java | 4 +- .../bukkit/craftbukkit/entity/CraftVex.java | 10 -- .../craftbukkit/entity/CraftVillager.java | 2 +- .../entity/CraftVillagerZombie.java | 2 +- .../craftbukkit/entity/CraftWither.java | 7 +- .../craftbukkit/entity/CraftZombie.java | 7 +- .../inventory/CraftMerchantRecipe.java | 20 +-- .../craftbukkit/inventory/CraftMetaSkull.java | 4 +- .../profile/CraftPlayerProfile.java | 11 +- .../spawner/PaperSharedSpawnerLogic.java | 1 + .../structure/CraftStructureManager.java | 3 +- .../craftbukkit/util/CraftMagicNumbers.java | 4 +- .../craftbukkit/util/LazyPlayerSet.java | 2 +- .../java/org/spigotmc/RestartCommand.java | 2 +- .../java/org/spigotmc/WatchdogThread.java | 2 +- .../BukkitCommandConversionTest.java | 2 +- 127 files changed, 486 insertions(+), 730 deletions(-) delete mode 100644 paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch diff --git a/build-data/paper.at b/build-data/paper.at index 5112a0f2b6cb..3eecc4a0347d 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -3,11 +3,11 @@ private-f net.minecraft.network.CompressionDecoder inflater private-f net.minecraft.server.MinecraftServer connection private-f net.minecraft.server.MinecraftServer levels -private-f net.minecraft.server.jsonrpc.internalapi.MinecraftGameRuleServiceImpl gameRules private-f net.minecraft.world.item.ItemStack components private-f net.minecraft.world.item.ItemStack item private-f net.minecraft.world.level.block.entity.BeehiveBlockEntity stored protected net.minecraft.world.entity.LivingEntity skipDropExperience +protected net.minecraft.world.level.Level thread protected-f net.minecraft.server.MinecraftServer worldData public net.minecraft.ChatFormatting code public net.minecraft.advancements.Advancement decorateName(Lnet/minecraft/advancements/DisplayInfo;)Lnet/minecraft/network/chat/Component; @@ -19,32 +19,14 @@ public net.minecraft.nbt.ListTag (Ljava/util/List;)V public net.minecraft.nbt.ListTag identifyRawElementType()B public net.minecraft.network.Connection address public net.minecraft.network.Connection channel -public net.minecraft.network.chat.TextColor name -public net.minecraft.network.chat.contents.TranslatableContents filterAllowedArguments(Ljava/lang/Object;)Lcom/mojang/serialization/DataResult; +public net.minecraft.network.chat.contents.TranslatableContents PRIMITIVE_ARG_CODEC public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V -public net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket blockState -public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket hasPos -public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket hasRot -public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket x -public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket xRot -public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket y -public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket yRot -public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket z public net.minecraft.network.syncher.SynchedEntityData getItem(Lnet/minecraft/network/syncher/EntityDataAccessor;)Lnet/minecraft/network/syncher/SynchedEntityData$DataItem; public net.minecraft.resources.RegistryOps lookupProvider public net.minecraft.resources.RegistryOps$HolderLookupAdapter public net.minecraft.server.Main forceUpgrade(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lcom/mojang/datafixers/DataFixer;ZLjava/util/function/BooleanSupplier;Lnet/minecraft/core/RegistryAccess;Z)V public net.minecraft.server.MinecraftServer LOGGER -public net.minecraft.server.MinecraftServer doRunTask(Lnet/minecraft/server/TickTask;)V -public net.minecraft.server.MinecraftServer executor -public net.minecraft.server.MinecraftServer fixerUpper -public net.minecraft.server.MinecraftServer playerDataStorage -public net.minecraft.server.MinecraftServer resources -public net.minecraft.server.MinecraftServer serverThread -public net.minecraft.server.MinecraftServer$ReloadableResources -public net.minecraft.server.MinecraftServer$ReloadableResources (Lnet/minecraft/server/packs/resources/CloseableResourceManager;Lnet/minecraft/server/ReloadableServerResources;)V public net.minecraft.server.RegistryLayer STATIC_ACCESS -public net.minecraft.server.ReloadableServerResources public net.minecraft.server.ServerAdvancementManager advancements public net.minecraft.server.Services USERID_CACHE_FILE public net.minecraft.server.dedicated.DedicatedServerProperties$WorldDimensionData @@ -53,10 +35,9 @@ public net.minecraft.server.dedicated.Settings getStringRaw(Ljava/lang/String;)L public net.minecraft.server.dedicated.Settings properties public net.minecraft.server.level.ChunkHolder oldTicketLevel public net.minecraft.server.level.ChunkHolder playerProvider +public net.minecraft.server.level.ChunkLevel BLOCK_TICKING_LEVEL public net.minecraft.server.level.ChunkLevel ENTITY_TICKING_LEVEL -public net.minecraft.server.level.ChunkMap addEntity(Lnet/minecraft/world/entity/Entity;)V -public net.minecraft.server.level.ChunkMap anyPlayerCloseEnoughForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z -public net.minecraft.server.level.ChunkMap distanceManager +public net.minecraft.server.level.ChunkLevel FULL_CHUNK_LEVEL public net.minecraft.server.level.ChunkMap entityMap public net.minecraft.server.level.ChunkMap getVisibleChunkIfPresent(J)Lnet/minecraft/server/level/ChunkHolder; public net.minecraft.server.level.ChunkMap level @@ -73,22 +54,16 @@ public net.minecraft.server.level.ChunkMap$TrackedEntity serverEntity public net.minecraft.server.level.DistanceManager simulationDistance public net.minecraft.server.level.DistanceManager ticketStorage public net.minecraft.server.level.ServerBossEvent broadcast(Ljava/util/function/Function;)V -public net.minecraft.server.level.ServerBossEvent visible -public net.minecraft.server.level.ServerChunkCache mainThread public net.minecraft.server.level.ServerChunkCache mainThreadProcessor public net.minecraft.server.level.ServerChunkCache runDistanceManagerUpdates()Z public net.minecraft.server.level.ServerChunkCache spawnEnemies public net.minecraft.server.level.ServerChunkCache$MainThreadExecutor -public net.minecraft.server.level.ServerLevel chunkSource public net.minecraft.server.level.ServerLevel entityManager public net.minecraft.server.level.ServerLevel findLightningRod(Lnet/minecraft/core/BlockPos;)Ljava/util/Optional; -public net.minecraft.server.level.ServerLevel getEntities()Lnet/minecraft/world/level/entity/LevelEntityGetter; public net.minecraft.server.level.ServerLevel serverLevelData -public net.minecraft.server.level.ServerPlayer completeUsingItem()V public net.minecraft.server.level.ServerPlayer containerSynchronizer public net.minecraft.server.level.ServerPlayer findRespawnAndUseSpawnBlock(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/server/level/ServerPlayer$RespawnConfig;Z)Ljava/util/Optional; public net.minecraft.server.level.ServerPlayer initMenu(Lnet/minecraft/world/inventory/AbstractContainerMenu;)V -public net.minecraft.server.level.ServerPlayer isChangingDimension public net.minecraft.server.level.ServerPlayer language public net.minecraft.server.level.ServerPlayer lastSentExp public net.minecraft.server.level.ServerPlayer nextContainerCounter()V @@ -100,7 +75,6 @@ public net.minecraft.server.level.ServerPlayer triggerDimensionChangeTriggers(Ln public net.minecraft.server.level.ServerPlayer wardenSpawnTracker public net.minecraft.server.level.ServerPlayer$RespawnPosAngle public net.minecraft.server.level.ServerPlayer$RespawnPosAngle (Lnet/minecraft/world/phys/Vec3;FF)V -public net.minecraft.server.level.ServerPlayerGameMode level public net.minecraft.server.network.ServerConfigurationPacketListenerImpl clientInformation public net.minecraft.server.network.ServerConfigurationPacketListenerImpl currentTask public net.minecraft.server.network.ServerConfigurationPacketListenerImpl finishCurrentTask(Lnet/minecraft/server/network/ConfigurationTask$Type;)V @@ -112,17 +86,13 @@ public net.minecraft.server.network.ServerLoginPacketListenerImpl state public net.minecraft.server.network.ServerLoginPacketListenerImpl$State public net.minecraft.server.packs.repository.FolderRepositorySource$FolderPackDetector public net.minecraft.server.packs.repository.FolderRepositorySource$FolderPackDetector (Lnet/minecraft/world/level/validation/DirectoryValidator;)V -public net.minecraft.server.packs.repository.Pack resources public net.minecraft.server.players.PlayerList playerIo -public net.minecraft.server.players.PlayerList players public net.minecraft.server.players.PlayerList updateEntireScoreboard(Lnet/minecraft/server/ServerScoreboard;Lnet/minecraft/server/level/ServerPlayer;)V public net.minecraft.server.players.PlayerList verifyChatTrusted(Lnet/minecraft/network/chat/PlayerChatMessage;)Z -public net.minecraft.server.players.StoredUserEntry getUser()Ljava/lang/Object; public net.minecraft.stats.ServerRecipeBook known public net.minecraft.tags.TagEntry id public net.minecraft.tags.TagEntry required public net.minecraft.tags.TagEntry tag -public net.minecraft.util.AbstractListBuilder public net.minecraft.util.Util onThreadException(Ljava/lang/Thread;Ljava/lang/Throwable;)V public net.minecraft.util.datafix.fixes.BlockStateData register(ILcom/mojang/serialization/Dynamic;[Lcom/mojang/serialization/Dynamic;)V public net.minecraft.util.datafix.fixes.ItemIdFix ITEM_NAMES @@ -132,7 +102,6 @@ public net.minecraft.world.BossEvent name public net.minecraft.world.BossEvent overlay public net.minecraft.world.CompoundContainer container1 public net.minecraft.world.CompoundContainer container2 -public net.minecraft.world.SimpleContainer items public net.minecraft.world.damagesource.CombatTracker entries public net.minecraft.world.damagesource.CombatTracker getMostSignificantFall()Lnet/minecraft/world/damagesource/CombatEntry; public net.minecraft.world.damagesource.CombatTracker inCombat @@ -145,13 +114,8 @@ public net.minecraft.world.effect.MobEffect$AttributeTemplate (Lnet/minecr public net.minecraft.world.effect.MobEffectInstance hiddenEffect public net.minecraft.world.effect.MobEffectInstance isShorterDurationThan(Lnet/minecraft/world/effect/MobEffectInstance;)Z public net.minecraft.world.entity.AgeableMob setAgeLocked(Z)V -public net.minecraft.world.entity.AreaEffectCloud durationOnUse public net.minecraft.world.entity.AreaEffectCloud owner -public net.minecraft.world.entity.AreaEffectCloud potionContents -public net.minecraft.world.entity.AreaEffectCloud radiusOnUse -public net.minecraft.world.entity.AreaEffectCloud radiusPerTick public net.minecraft.world.entity.AreaEffectCloud reapplicationDelay -public net.minecraft.world.entity.AreaEffectCloud waitTime public net.minecraft.world.entity.Avatar DATA_PLAYER_MODE_CUSTOMISATION public net.minecraft.world.entity.Display DATA_POS_ROT_INTERPOLATION_DURATION_ID public net.minecraft.world.entity.Display createTransformation(Lnet/minecraft/network/syncher/SynchedEntityData;)Lcom/mojang/math/Transformation; @@ -200,20 +164,14 @@ public net.minecraft.world.entity.Entity getSharedFlag(I)Z public net.minecraft.world.entity.Entity getSwimHighSpeedSplashSound()Lnet/minecraft/sounds/SoundEvent; public net.minecraft.world.entity.Entity getSwimSound()Lnet/minecraft/sounds/SoundEvent; public net.minecraft.world.entity.Entity getSwimSplashSound()Lnet/minecraft/sounds/SoundEvent; -public net.minecraft.world.entity.Entity hasVisualFire -public net.minecraft.world.entity.Entity isAffectedByBlocks()Z public net.minecraft.world.entity.Entity isInRain()Z public net.minecraft.world.entity.Entity isInvulnerableToBase(Lnet/minecraft/world/damagesource/DamageSource;)Z public net.minecraft.world.entity.Entity onGround public net.minecraft.world.entity.Entity passengers -public net.minecraft.world.entity.Entity portalCooldown -public net.minecraft.world.entity.Entity random public net.minecraft.world.entity.Entity setLevel(Lnet/minecraft/world/level/Level;)V public net.minecraft.world.entity.Entity setRot(FF)V public net.minecraft.world.entity.Entity setSharedFlag(IZ)V -public net.minecraft.world.entity.Entity teleportPassengers()V public net.minecraft.world.entity.Entity unsetRemoved()V -public net.minecraft.world.entity.Entity wasTouchingWater public net.minecraft.world.entity.ExperienceOrb count public net.minecraft.world.entity.ExperienceOrb setValue(I)V public net.minecraft.world.entity.Interaction attack @@ -231,11 +189,9 @@ public net.minecraft.world.entity.ItemBasedSteering boostTimeTotal()I public net.minecraft.world.entity.ItemBasedSteering boosting public net.minecraft.world.entity.LightningBolt flashes public net.minecraft.world.entity.LightningBolt life -public net.minecraft.world.entity.LightningBolt visualOnly public net.minecraft.world.entity.LivingEntity DATA_ARROW_COUNT_ID public net.minecraft.world.entity.LivingEntity DATA_HEALTH_ID public net.minecraft.world.entity.LivingEntity LIVING_ENTITY_FLAG_SPIN_ATTACK -public net.minecraft.world.entity.LivingEntity activeEffects public net.minecraft.world.entity.LivingEntity completeUsingItem()V public net.minecraft.world.entity.LivingEntity detectEquipmentUpdates()V public net.minecraft.world.entity.LivingEntity effectsDirty @@ -244,10 +200,8 @@ public net.minecraft.world.entity.LivingEntity getDeathSound()Lnet/minecraft/sou public net.minecraft.world.entity.LivingEntity getFallDamageSound(I)Lnet/minecraft/sounds/SoundEvent; public net.minecraft.world.entity.LivingEntity getHurtSound(Lnet/minecraft/world/damagesource/DamageSource;)Lnet/minecraft/sounds/SoundEvent; public net.minecraft.world.entity.LivingEntity getSoundVolume()F -public net.minecraft.world.entity.LivingEntity jumping public net.minecraft.world.entity.LivingEntity lastHurt public net.minecraft.world.entity.LivingEntity lastHurtByMob -public net.minecraft.world.entity.LivingEntity lastHurtByMobTimestamp public net.minecraft.world.entity.LivingEntity lastHurtByPlayer public net.minecraft.world.entity.LivingEntity lastHurtByPlayerMemoryTime public net.minecraft.world.entity.LivingEntity playSecondaryHurtSound(Lnet/minecraft/world/damagesource/DamageSource;)V @@ -262,13 +216,11 @@ public net.minecraft.world.entity.OminousItemSpawner setItem(Lnet/minecraft/worl public net.minecraft.world.entity.OminousItemSpawner spawnItemAfterTicks public net.minecraft.world.entity.ai.attributes.Attribute sentiment public net.minecraft.world.entity.ai.attributes.AttributeSupplier getAttributeInstance(Lnet/minecraft/core/Holder;)Lnet/minecraft/world/entity/ai/attributes/AttributeInstance; -public net.minecraft.world.entity.ai.control.MoveControl$Operation public net.minecraft.world.entity.ai.gossip.GossipContainer gossips public net.minecraft.world.entity.ai.gossip.GossipContainer$EntityGossips public net.minecraft.world.entity.ai.gossip.GossipContainer$EntityGossips ()V public net.minecraft.world.entity.ai.navigation.PathNavigation pathFinder public net.minecraft.world.entity.ambient.Bat targetPosition -public net.minecraft.world.entity.animal.Animal inLove public net.minecraft.world.entity.animal.Animal loveCause public net.minecraft.world.entity.animal.allay.Allay canDuplicate()Z public net.minecraft.world.entity.animal.allay.Allay duplicateAllay()V @@ -276,7 +228,6 @@ public net.minecraft.world.entity.animal.allay.Allay duplicationCooldown public net.minecraft.world.entity.animal.allay.Allay jukeboxPos public net.minecraft.world.entity.animal.allay.Allay resetDuplicationCooldown()V public net.minecraft.world.entity.animal.axolotl.Axolotl setVariant(Lnet/minecraft/world/entity/animal/axolotl/Axolotl$Variant;)V -public net.minecraft.world.entity.animal.bee.Bee hivePos public net.minecraft.world.entity.animal.bee.Bee isRolling()Z public net.minecraft.world.entity.animal.bee.Bee numCropsGrownSincePollination public net.minecraft.world.entity.animal.bee.Bee setHasNectar(Z)V @@ -331,7 +282,6 @@ public net.minecraft.world.entity.animal.pig.Pig setSoundVariant(Lnet/minecraft/ public net.minecraft.world.entity.animal.pig.Pig setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.animal.pig.Pig steering public net.minecraft.world.entity.animal.rabbit.Rabbit moreCarrotTicks -public net.minecraft.world.entity.animal.rabbit.Rabbit registerGoals()V public net.minecraft.world.entity.animal.rabbit.Rabbit setVariant(Lnet/minecraft/world/entity/animal/rabbit/Rabbit$Variant;)V public net.minecraft.world.entity.animal.sniffer.Sniffer calculateDigPosition()Ljava/util/Optional; public net.minecraft.world.entity.animal.sniffer.Sniffer canDig()Z @@ -340,7 +290,6 @@ public net.minecraft.world.entity.animal.sniffer.Sniffer getState()Lnet/minecraf public net.minecraft.world.entity.animal.sniffer.Sniffer storeExploredPosition(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/entity/animal/sniffer/Sniffer; public net.minecraft.world.entity.animal.squid.GlowSquid setDarkTicks(I)V public net.minecraft.world.entity.animal.turtle.Turtle goingHome -public net.minecraft.world.entity.animal.turtle.Turtle homePos public net.minecraft.world.entity.animal.turtle.Turtle setHasEgg(Z)V public net.minecraft.world.entity.animal.wolf.Wolf getSoundVariant()Lnet/minecraft/core/Holder; public net.minecraft.world.entity.animal.wolf.Wolf getVariant()Lnet/minecraft/core/Holder; @@ -348,23 +297,19 @@ public net.minecraft.world.entity.animal.wolf.Wolf isWet public net.minecraft.world.entity.animal.wolf.Wolf setCollarColor(Lnet/minecraft/world/item/DyeColor;)V public net.minecraft.world.entity.animal.wolf.Wolf setSoundVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.animal.wolf.Wolf setVariant(Lnet/minecraft/core/Holder;)V -public net.minecraft.world.entity.boss.enderdragon.EnderDragon subEntities public net.minecraft.world.entity.boss.wither.WitherBoss bossEvent public net.minecraft.world.entity.decoration.ArmorStand disabledSlots public net.minecraft.world.entity.decoration.ArmorStand isDisabled(Lnet/minecraft/world/entity/EquipmentSlot;)Z public net.minecraft.world.entity.decoration.ArmorStand setMarker(Z)V public net.minecraft.world.entity.decoration.ArmorStand setSmall(Z)V public net.minecraft.world.entity.decoration.HangingEntity setDirection(Lnet/minecraft/core/Direction;)V -public net.minecraft.world.entity.decoration.ItemFrame DATA_ITEM -public net.minecraft.world.entity.decoration.ItemFrame DATA_ROTATION public net.minecraft.world.entity.decoration.ItemFrame dropChance public net.minecraft.world.entity.decoration.ItemFrame fixed -public net.minecraft.world.entity.decoration.ItemFrame setDirection(Lnet/minecraft/core/Direction;)V public net.minecraft.world.entity.decoration.Mannequin ALL_LAYERS public net.minecraft.world.entity.decoration.Mannequin DEFAULT_DESCRIPTION +public net.minecraft.world.entity.decoration.Mannequin VALID_POSES public net.minecraft.world.entity.decoration.Mannequin getDescription()Lnet/minecraft/network/chat/Component; public net.minecraft.world.entity.decoration.Mannequin getImmovable()Z -public net.minecraft.world.entity.decoration.Mannequin getProfile()Lnet/minecraft/world/item/component/ResolvableProfile; public net.minecraft.world.entity.decoration.Mannequin setDescription(Lnet/minecraft/network/chat/Component;)V public net.minecraft.world.entity.decoration.Mannequin setHideDescription(Z)V public net.minecraft.world.entity.decoration.Mannequin setImmovable(Z)V @@ -383,7 +328,6 @@ public net.minecraft.world.entity.item.ItemEntity target public net.minecraft.world.entity.item.ItemEntity thrower public net.minecraft.world.entity.item.PrimedTnt explosionPower public net.minecraft.world.entity.item.PrimedTnt owner -public net.minecraft.world.entity.monster.Creeper droppedSkulls public net.minecraft.world.entity.monster.Creeper explodeCreeper()V public net.minecraft.world.entity.monster.Creeper explosionRadius public net.minecraft.world.entity.monster.Creeper maxSwell @@ -415,7 +359,6 @@ public net.minecraft.world.entity.monster.hoglin.Hoglin isImmuneToZombification( public net.minecraft.world.entity.monster.hoglin.Hoglin timeInOverworld public net.minecraft.world.entity.monster.illager.Evoker getWololoTarget()Lnet/minecraft/world/entity/animal/sheep/Sheep; public net.minecraft.world.entity.monster.illager.Evoker setWololoTarget(Lnet/minecraft/world/entity/animal/sheep/Sheep;)V -public net.minecraft.world.entity.monster.illager.Pillager inventory public net.minecraft.world.entity.monster.illager.SpellcasterIllager getCurrentSpell()Lnet/minecraft/world/entity/monster/illager/SpellcasterIllager$IllagerSpell; public net.minecraft.world.entity.monster.illager.SpellcasterIllager$IllagerSpell public net.minecraft.world.entity.monster.illager.Vindicator DOOR_BREAKING_PREDICATE @@ -423,37 +366,29 @@ public net.minecraft.world.entity.monster.illager.Vindicator isJohnny public net.minecraft.world.entity.monster.piglin.AbstractPiglin isImmuneToZombification()Z public net.minecraft.world.entity.monster.piglin.AbstractPiglin timeInOverworld public net.minecraft.world.entity.monster.piglin.Piglin cannotHunt -public net.minecraft.world.entity.monster.piglin.Piglin inventory public net.minecraft.world.entity.monster.piglin.Piglin isChargingCrossbow()Z -public net.minecraft.world.entity.monster.skeleton.Skeleton DATA_STRAY_CONVERSION_ID public net.minecraft.world.entity.monster.skeleton.Skeleton conversionTime public net.minecraft.world.entity.monster.skeleton.Skeleton inPowderSnowTime public net.minecraft.world.entity.monster.warden.WardenSpawnTracker cooldownTicks public net.minecraft.world.entity.monster.warden.WardenSpawnTracker increaseWarningLevel()V public net.minecraft.world.entity.monster.warden.WardenSpawnTracker ticksSinceLastWarning -public net.minecraft.world.entity.monster.zombie.Zombie DATA_DROWNED_CONVERSION_ID public net.minecraft.world.entity.monster.zombie.Zombie DOOR_BREAKING_PREDICATE public net.minecraft.world.entity.monster.zombie.Zombie conversionTime public net.minecraft.world.entity.monster.zombie.Zombie isSunSensitive()Z public net.minecraft.world.entity.monster.zombie.Zombie startUnderWaterConversion(I)V public net.minecraft.world.entity.monster.zombie.ZombieVillager DATA_CONVERTING_ID public net.minecraft.world.entity.monster.zombie.ZombieVillager conversionStarter -public net.minecraft.world.entity.monster.zombie.ZombieVillager startConverting(Ljava/util/UUID;I)V public net.minecraft.world.entity.monster.zombie.ZombieVillager villagerConversionTime public net.minecraft.world.entity.npc.villager.Villager numberOfRestocksToday public net.minecraft.world.entity.npc.villager.Villager releaseAllPois()V public net.minecraft.world.entity.npc.villager.Villager setUnhappy()V public net.minecraft.world.entity.npc.villager.Villager updateDemand()V public net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader getWanderTarget()Lnet/minecraft/core/BlockPos; -public net.minecraft.world.entity.player.Abilities flyingSpeed -public net.minecraft.world.entity.player.Abilities walkingSpeed public net.minecraft.world.entity.player.Inventory equipment public net.minecraft.world.entity.player.Player closeContainer()V public net.minecraft.world.entity.player.Player enchantmentSeed -public net.minecraft.world.entity.player.Player getFireImmuneTicks()I public net.minecraft.world.entity.player.Player hurtDir public net.minecraft.world.entity.player.Player removeEntitiesOnShoulder()V -public net.minecraft.world.entity.player.Player sleepCounter public net.minecraft.world.entity.projectile.EvokerFangs warmupDelayTicks public net.minecraft.world.entity.projectile.EyeOfEnder life public net.minecraft.world.entity.projectile.EyeOfEnder surviveAfterDeath @@ -465,11 +400,9 @@ public net.minecraft.world.entity.projectile.FireworkRocketEntity attachedToEnti public net.minecraft.world.entity.projectile.FireworkRocketEntity getDefaultItem()Lnet/minecraft/world/item/ItemStack; public net.minecraft.world.entity.projectile.FireworkRocketEntity life public net.minecraft.world.entity.projectile.FireworkRocketEntity lifetime -public net.minecraft.world.entity.projectile.FishingHook DATA_HOOKED_ENTITY public net.minecraft.world.entity.projectile.FishingHook calculateOpenWater(Lnet/minecraft/core/BlockPos;)Z public net.minecraft.world.entity.projectile.FishingHook currentState public net.minecraft.world.entity.projectile.FishingHook fishAngle -public net.minecraft.world.entity.projectile.FishingHook hookedIn public net.minecraft.world.entity.projectile.FishingHook outOfWaterTime public net.minecraft.world.entity.projectile.FishingHook pullEntity(Lnet/minecraft/world/entity/Entity;)V public net.minecraft.world.entity.projectile.FishingHook setHookedEntity(Lnet/minecraft/world/entity/Entity;)V @@ -490,45 +423,31 @@ public net.minecraft.world.entity.projectile.arrow.AbstractArrow getHitGroundSou public net.minecraft.world.entity.projectile.arrow.AbstractArrow getPickupItem()Lnet/minecraft/world/item/ItemStack; public net.minecraft.world.entity.projectile.arrow.AbstractArrow isInGround()Z public net.minecraft.world.entity.projectile.arrow.AbstractArrow life -public net.minecraft.world.entity.projectile.arrow.AbstractArrow pickupItemStack public net.minecraft.world.entity.projectile.arrow.AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V public net.minecraft.world.entity.projectile.arrow.AbstractArrow setPierceLevel(B)V public net.minecraft.world.entity.projectile.arrow.Arrow NO_EFFECT_COLOR public net.minecraft.world.entity.projectile.arrow.Arrow getPotionContents()Lnet/minecraft/world/item/alchemy/PotionContents; public net.minecraft.world.entity.projectile.arrow.Arrow setPotionContents(Lnet/minecraft/world/item/alchemy/PotionContents;)V -public net.minecraft.world.entity.projectile.arrow.Arrow updateColor()V public net.minecraft.world.entity.projectile.arrow.SpectralArrow duration public net.minecraft.world.entity.projectile.arrow.ThrownTrident dealtDamage public net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile assignDirectionalMovement(Lnet/minecraft/world/phys/Vec3;D)V public net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball explosionPower public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V -public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V -public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge explode(Lnet/minecraft/world/phys/Vec3;)V -public net.minecraft.world.entity.projectile.throwableitemprojectile.ThrowableItemProjectile getDefaultItem()Lnet/minecraft/world/item/Item; public net.minecraft.world.entity.raid.Raid heroesOfTheVillage public net.minecraft.world.entity.raid.Raid raidEvent -public net.minecraft.world.entity.raid.Raid raidOmenLevel public net.minecraft.world.entity.raid.Raid ticksActive -public net.minecraft.world.entity.raid.Raid totalHealth -public net.minecraft.world.entity.raid.Raider$HoldGroundAttackGoal public net.minecraft.world.entity.raid.Raids raidMap public net.minecraft.world.entity.vehicle.VehicleEntity getDropItem()Lnet/minecraft/world/item/Item; public net.minecraft.world.entity.vehicle.boat.AbstractBoat getStatus()Lnet/minecraft/world/entity/vehicle/boat/AbstractBoat$Status; public net.minecraft.world.entity.vehicle.boat.AbstractBoat status -public net.minecraft.world.entity.vehicle.minecart.AbstractMinecartContainer lootTable -public net.minecraft.world.entity.vehicle.minecart.AbstractMinecartContainer lootTableSeed public net.minecraft.world.entity.vehicle.minecart.MinecartCommandBlock DATA_ID_COMMAND_NAME public net.minecraft.world.entity.vehicle.minecart.MinecartFurnace fuel public net.minecraft.world.entity.vehicle.minecart.MinecartTNT explode(Lnet/minecraft/world/damagesource/DamageSource;D)V public net.minecraft.world.entity.vehicle.minecart.MinecartTNT explosionPowerBase public net.minecraft.world.entity.vehicle.minecart.MinecartTNT explosionSpeedFactor public net.minecraft.world.entity.vehicle.minecart.MinecartTNT fuse -public net.minecraft.world.flag.FeatureFlag mask -public net.minecraft.world.flag.FeatureFlag universe public net.minecraft.world.flag.FeatureFlagRegistry names public net.minecraft.world.food.FoodData exhaustionLevel -public net.minecraft.world.food.FoodData foodLevel -public net.minecraft.world.food.FoodData saturationLevel public net.minecraft.world.inventory.AbstractContainerMenu menuType public net.minecraft.world.inventory.AbstractContainerMenu quickcraftSlots public net.minecraft.world.inventory.AbstractContainerMenu quickcraftStatus @@ -547,21 +466,13 @@ public net.minecraft.world.inventory.AnvilMenu itemName public net.minecraft.world.inventory.AnvilMenu repairItemCountCost public net.minecraft.world.inventory.BrewingStandMenu brewingStandData public net.minecraft.world.inventory.CraftingMenu access -public net.minecraft.world.inventory.DispenserMenu dispenser public net.minecraft.world.inventory.MerchantContainer selectionHint -public net.minecraft.world.inventory.Slot slot public net.minecraft.world.item.AdventureModePredicate predicates -public net.minecraft.world.item.BucketItem content public net.minecraft.world.item.CrossbowItem FIREWORK_POWER public net.minecraft.world.item.DebugStickItem handleInteraction(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;ZLnet/minecraft/world/item/ItemStack;)Z -public net.minecraft.world.item.ItemCooldowns cooldowns -public net.minecraft.world.item.ItemCooldowns tickCount -public net.minecraft.world.item.ItemCooldowns$CooldownInstance -public net.minecraft.world.item.ItemCooldowns$CooldownInstance (II)V public net.minecraft.world.item.ItemStackLinkedSet TYPE_AND_TAG public net.minecraft.world.item.JukeboxSongPlayer song public net.minecraft.world.item.MapItem createNewSavedData(Lnet/minecraft/server/level/ServerLevel;IIIZZLnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/level/saveddata/maps/MapId; -public net.minecraft.world.item.StandingAndWallBlockItem wallBlock public net.minecraft.world.item.component.ItemContainerContents MAX_SIZE public net.minecraft.world.item.component.ItemContainerContents items public net.minecraft.world.item.component.ResolvableProfile unpack()Lcom/mojang/datafixers/util/Either; @@ -576,8 +487,6 @@ public net.minecraft.world.item.crafting.RecipeManager recipes public net.minecraft.world.item.crafting.RecipeMap byKey public net.minecraft.world.item.crafting.RecipeMap byType public net.minecraft.world.item.trading.MerchantOffer demand -public net.minecraft.world.item.trading.MerchantOffer result -public net.minecraft.world.item.trading.MerchantOffer specialPriceDiff public net.minecraft.world.item.trading.MerchantOffer uses public net.minecraft.world.level.BaseSpawner delay(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)V public net.minecraft.world.level.BaseSpawner isNearPlayer(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Z @@ -594,9 +503,7 @@ public net.minecraft.world.level.BaseSpawner spawnRange public net.minecraft.world.level.Level DEFAULT_EXPLOSION_BLOCK_PARTICLES public net.minecraft.world.level.Level blockEntityTickers public net.minecraft.world.level.Level getEntities()Lnet/minecraft/world/level/entity/LevelEntityGetter; -public net.minecraft.world.level.Level levelData public net.minecraft.world.level.Level rainLevel -public net.minecraft.world.level.Level thread public net.minecraft.world.level.Level thunderLevel public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES public net.minecraft.world.level.StructureManager level @@ -606,19 +513,14 @@ public net.minecraft.world.level.biome.Biome getTemperature(Lnet/minecraft/core/ public net.minecraft.world.level.biome.Biome$ClimateSettings public net.minecraft.world.level.biome.Biome$ClimateSettings (ZFLnet/minecraft/world/level/biome/Biome$TemperatureModifier;F)V public net.minecraft.world.level.block.Block popExperience(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;I)V -public net.minecraft.world.level.block.ChestBlock isBlockedChestByBlock(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Z public net.minecraft.world.level.block.ComposterBlock$EmptyContainer public net.minecraft.world.level.block.ComposterBlock$InputContainer public net.minecraft.world.level.block.ComposterBlock$OutputContainer public net.minecraft.world.level.block.DispenserBlock dispenseFrom(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V -public net.minecraft.world.level.block.DropperBlock dispenseFrom(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V public net.minecraft.world.level.block.FireBlock igniteOdds public net.minecraft.world.level.block.RedStoneWireBlock canSurvive(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;)Z public net.minecraft.world.level.block.RedStoneWireBlock shouldSignal public net.minecraft.world.level.block.SelectableSlotContainer getSection(FI)I -public net.minecraft.world.level.block.ShulkerBoxBlock color -public net.minecraft.world.level.block.SoundType breakSound -public net.minecraft.world.level.block.SoundType hitSound public net.minecraft.world.level.block.TurtleEggBlock decreaseEggs(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity cookingTimer public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity cookingTotalTime @@ -627,16 +529,12 @@ public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity litTime public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity recipesUsed public net.minecraft.world.level.block.entity.BannerBlockEntity name public net.minecraft.world.level.block.entity.BarrelBlockEntity openersCounter -public net.minecraft.world.level.block.entity.BarrelBlockEntity playSound(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/sounds/SoundEvent;)V -public net.minecraft.world.level.block.entity.BarrelBlockEntity updateBlockState(Lnet/minecraft/world/level/block/state/BlockState;Z)V public net.minecraft.world.level.block.entity.BaseContainerBlockEntity lockKey public net.minecraft.world.level.block.entity.BaseContainerBlockEntity name public net.minecraft.world.level.block.entity.BeaconBlockEntity levels public net.minecraft.world.level.block.entity.BeaconBlockEntity lockKey -public net.minecraft.world.level.block.entity.BeaconBlockEntity name public net.minecraft.world.level.block.entity.BeaconBlockEntity primaryPower public net.minecraft.world.level.block.entity.BeaconBlockEntity secondaryPower -public net.minecraft.world.level.block.entity.BedBlockEntity color public net.minecraft.world.level.block.entity.BeehiveBlockEntity savedFlowerPos public net.minecraft.world.level.block.entity.BellBlockEntity resonating public net.minecraft.world.level.block.entity.BellBlockEntity resonationTicks @@ -665,35 +563,19 @@ public net.minecraft.world.level.block.entity.HopperBlockEntity cooldownTime public net.minecraft.world.level.block.entity.HopperBlockEntity setCooldown(I)V public net.minecraft.world.level.block.entity.LecternBlockEntity bookAccess public net.minecraft.world.level.block.entity.LecternBlockEntity setPage(I)V -public net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity lootTable -public net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity lootTableSeed public net.minecraft.world.level.block.entity.SculkCatalystBlockEntity$CatalystListener bloom(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/util/RandomSource;)V -public net.minecraft.world.level.block.entity.SculkSensorBlockEntity lastVibrationFrequency public net.minecraft.world.level.block.entity.SculkShriekerBlockEntity warningLevel -public net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity openCount -public net.minecraft.world.level.block.entity.SignBlockEntity playerWhoMayEdit public net.minecraft.world.level.block.entity.SkullBlockEntity customName public net.minecraft.world.level.block.entity.SkullBlockEntity noteBlockSound public net.minecraft.world.level.block.entity.SkullBlockEntity owner public net.minecraft.world.level.block.entity.StructureBlockEntity author public net.minecraft.world.level.block.entity.StructureBlockEntity ignoreEntities -public net.minecraft.world.level.block.entity.StructureBlockEntity integrity -public net.minecraft.world.level.block.entity.StructureBlockEntity metaData -public net.minecraft.world.level.block.entity.StructureBlockEntity mirror public net.minecraft.world.level.block.entity.StructureBlockEntity mode -public net.minecraft.world.level.block.entity.StructureBlockEntity rotation -public net.minecraft.world.level.block.entity.StructureBlockEntity seed -public net.minecraft.world.level.block.entity.StructureBlockEntity showAir -public net.minecraft.world.level.block.entity.StructureBlockEntity showBoundingBox -public net.minecraft.world.level.block.entity.StructureBlockEntity structurePos -public net.minecraft.world.level.block.entity.StructureBlockEntity structureSize public net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity age public net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity exactTeleport public net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity exitPortal -public net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity trialSpawner public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner config public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner isOminous -public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner stateAccessor public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData cooldownEndsAt public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData currentMobs public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData detectedPlayers @@ -706,23 +588,16 @@ public net.minecraft.world.level.block.entity.vault.VaultServerData stateUpdatin public net.minecraft.world.level.block.entity.vault.VaultSharedData getConnectedPlayers()Ljava/util/Set; public net.minecraft.world.level.block.state.BlockBehaviour getMenuProvider(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/MenuProvider; public net.minecraft.world.level.block.state.BlockBehaviour hasCollision -public net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase destroySpeed -public net.minecraft.world.level.block.state.StateHolder PROPERTY_ENTRY_TO_STRING_FUNCTION public net.minecraft.world.level.block.state.properties.IntegerProperty max public net.minecraft.world.level.block.state.properties.IntegerProperty min public net.minecraft.world.level.chunk.ChunkAccess blockEntities public net.minecraft.world.level.chunk.ChunkAccess heightmaps public net.minecraft.world.level.chunk.ChunkGenerator generationSettingsGetter -public net.minecraft.world.level.chunk.LevelChunk level -public net.minecraft.world.level.chunk.LevelChunk loaded -public net.minecraft.world.level.chunk.LevelChunkSection states public net.minecraft.world.level.chunk.status.ChunkStatusTasks postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/storage/ValueInput$ValueInputList;)V public net.minecraft.world.level.chunk.storage.EntityStorage entityDeserializerQueue public net.minecraft.world.level.chunk.storage.EntityStorage level -public net.minecraft.world.level.chunk.storage.RegionFileStorage regionCache public net.minecraft.world.level.dimension.end.EnderDragonFight GATEWAY_COUNT public net.minecraft.world.level.dimension.end.EnderDragonFight dragonEvent -public net.minecraft.world.level.dimension.end.EnderDragonFight dragonUUID public net.minecraft.world.level.dimension.end.EnderDragonFight exitPortalLocation public net.minecraft.world.level.dimension.end.EnderDragonFight findExitPortal()Lnet/minecraft/world/level/block/state/pattern/BlockPattern$BlockPatternMatch; public net.minecraft.world.level.dimension.end.EnderDragonFight gateways @@ -737,7 +612,6 @@ public net.minecraft.world.level.dimension.end.EnderDragonFight spawnNewGateway( public net.minecraft.world.level.entity.PersistentEntitySectionManager ensureChunkQueuedForLoad(J)V public net.minecraft.world.level.entity.PersistentEntitySectionManager permanentStorage public net.minecraft.world.level.gamerules.GameRules rules -public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator settings public net.minecraft.world.level.levelgen.SurfaceRules$Condition public net.minecraft.world.level.levelgen.SurfaceRules$Context public net.minecraft.world.level.levelgen.SurfaceRules$Context blockX @@ -747,9 +621,6 @@ public net.minecraft.world.level.levelgen.SurfaceRules$Context context public net.minecraft.world.level.levelgen.SurfaceRules$Context randomState public net.minecraft.world.level.levelgen.SurfaceRules$LazyCondition public net.minecraft.world.level.levelgen.SurfaceRules$LazyYCondition -public net.minecraft.world.level.levelgen.SurfaceRules$SurfaceRule -public net.minecraft.world.level.levelgen.SurfaceRules$VerticalGradientConditionSource -public net.minecraft.world.level.levelgen.SurfaceRules$VerticalGradientConditionSource (Lnet/minecraft/resources/Identifier;Lnet/minecraft/world/level/levelgen/VerticalAnchor;Lnet/minecraft/world/level/levelgen/VerticalAnchor;)V public net.minecraft.world.level.levelgen.structure.StructurePiece SHAPE_CHECK_BLOCKS public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement exclusionZone public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement frequency @@ -763,29 +634,20 @@ public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager tryLoad(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional; public net.minecraft.world.level.levelgen.structure.templatesystem.loader.TemplateSource readStructure(Ljava/io/InputStream;)Lnet/minecraft/nbt/CompoundTag; public net.minecraft.world.level.levelgen.structure.templatesystem.loader.TemplateSource readStructure(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate; -public net.minecraft.world.level.material.MapColor MATERIAL_COLORS public net.minecraft.world.level.pathfinder.Path nodes public net.minecraft.world.level.pathfinder.PathFinder nodeEvaluator public net.minecraft.world.level.saveddata.maps.MapItemSavedData carriedBy public net.minecraft.world.level.saveddata.maps.MapItemSavedData carriedByPlayers public net.minecraft.world.level.saveddata.maps.MapItemSavedData decorations -public net.minecraft.world.level.saveddata.maps.MapItemSavedData setColorsDirty(II)V -public net.minecraft.world.level.saveddata.maps.MapItemSavedData setDecorationsDirty()V -public net.minecraft.world.level.storage.LevelStorageSource baseDir -public net.minecraft.world.level.storage.LevelStorageSource$LevelStorageAccess levelDirectory public net.minecraft.world.level.storage.PrimaryLevelData settings public net.minecraft.world.level.storage.SavedDataStorage cache public net.minecraft.world.level.storage.TagValueInput input -public net.minecraft.world.scores.Objective displayName public net.minecraft.world.scores.criteria.ObjectiveCriteria CRITERIA_CACHE public-f net.minecraft.server.MinecraftServer potionBrewing public-f net.minecraft.server.MinecraftServer storageSource -public-f net.minecraft.server.ReloadableServerResources commands public-f net.minecraft.server.dedicated.DedicatedServer serverLinks public-f net.minecraft.server.dedicated.DedicatedServer settings -public-f net.minecraft.server.dedicated.DedicatedServerProperties pauseWhenEmptySeconds public-f net.minecraft.world.entity.LivingEntity combatTracker -public-f net.minecraft.world.entity.Mob goalSelector public-f net.minecraft.world.entity.Mob targetSelector public-f net.minecraft.world.entity.ai.attributes.RangedAttribute maxValue public-f net.minecraft.world.entity.player.Player gameProfile diff --git a/paper-api/src/main/java/org/bukkit/entity/Firework.java b/paper-api/src/main/java/org/bukkit/entity/Firework.java index 458c5b46763e..4c81193ba69b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Firework.java +++ b/paper-api/src/main/java/org/bukkit/entity/Firework.java @@ -77,7 +77,9 @@ public interface Firework extends Projectile { * @return the life ticks */ @Deprecated(forRemoval = true, since = "1.18.2") - int getLife(); + default int getLife() { + return this.getTicksFlown(); + } /** * Set the time in ticks this firework will exist until it is detonated. @@ -96,7 +98,9 @@ public interface Firework extends Projectile { * @return the maximum life in ticks */ @Deprecated(forRemoval = true, since = "1.18.2") - int getMaxLife(); + default int getMaxLife() { + return this.getTicksToDetonate(); + } /** * Cause this firework to explode at earliest opportunity, as if it has no diff --git a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java index 2be5f6ba8eeb..ef089ad40e1b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java @@ -440,11 +440,11 @@ default void setCooldown(Material material, int ticks) { /** * Get the cooldown time in ticks remaining for the specified cooldown group. * - * @param key the cooldown group to check + * @param cooldownGroup the cooldown group to check * @return the remaining cooldown time in ticks * @see UseCooldown#cooldownGroup() */ - public int getCooldown(Key key); + public int getCooldown(Key cooldownGroup); /** * Set a cooldown on items with the specified cooldown group for a certain amount of ticks. @@ -456,11 +456,11 @@ default void setCooldown(Material material, int ticks) { * Note that cooldowns will not by themselves stop an item from being used * for attacking. * - * @param key cooldown group to set the cooldown for + * @param cooldownGroup cooldown group to set the cooldown for * @param ticks the amount of ticks to set or 0 to remove * @see UseCooldown#cooldownGroup() */ - public void setCooldown(Key key, int ticks); + public void setCooldown(Key cooldownGroup, int ticks); /** * Get the sleep ticks of the player. This value may be capped. diff --git a/paper-api/src/main/java/org/bukkit/entity/Vex.java b/paper-api/src/main/java/org/bukkit/entity/Vex.java index 2f38affaaadf..e4267959972e 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Vex.java +++ b/paper-api/src/main/java/org/bukkit/entity/Vex.java @@ -57,11 +57,12 @@ public interface Vex extends Monster { * Gets the remaining lifespan of this entity. * * @return life in ticks - * @deprecated This API duplicates existing API which uses the more - * preferable name due to mirroring internals better + * @deprecated use {@link #getLimitedLifetimeTicks()} */ @Deprecated - int getLifeTicks(); + default int getLifeTicks() { + return this.getLimitedLifetimeTicks(); + } /** * Sets the remaining lifespan of this entity. @@ -77,11 +78,12 @@ public interface Vex extends Monster { * Gets if the entity has a limited life. * * @return true if the entity has limited life - * @deprecated This API duplicates existing API which uses the more - * preferable name due to mirroring internals better + * @deprecated use {@link #hasLimitedLifetime()} */ @Deprecated - boolean hasLimitedLife(); + default boolean hasLimitedLife() { + return this.hasLimitedLifetime(); + } // Paper start /** diff --git a/paper-api/src/main/java/org/bukkit/entity/Zombie.java b/paper-api/src/main/java/org/bukkit/entity/Zombie.java index b9ba8a47bb62..871fa5c0f9fb 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Zombie.java +++ b/paper-api/src/main/java/org/bukkit/entity/Zombie.java @@ -120,11 +120,11 @@ public interface Zombie extends Monster, Ageable { /** * Make zombie start drowning * - * @param drownedConversionTime Amount of time until zombie converts from drowning + * @param time Amount of time until zombie converts from drowning * @deprecated See {@link #setConversionTime(int)} */ @Deprecated - void startDrowning(int drownedConversionTime); + void startDrowning(int time); /** * Stop a zombie from starting the drowning conversion process diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index 3d498b6bc64e..9c4ee77360a0 100644 --- a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -335,7 +335,7 @@ index 292898e3f7563949288fcafb8893e80cb4191828..d69358d60146e47b7f4669c43afc6c97 } diff --git a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java -index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8e9395f31 100644 +index 15c181961eb669a0ffde86c256078859f4419f23..4baf46256e90a87d684e57ff623076a8e9395f31 100644 --- a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java +++ b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java @@ -1,38 +1,23 @@ @@ -386,7 +386,7 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 @Override public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run, final Priority priority) { -- level.chunkSource.mainThreadProcessor.execute(run); +- level.getChunkSource().mainThreadProcessor.execute(run); + ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkTask(chunkX, chunkZ, run, priority); } @@ -430,9 +430,9 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 - final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); - - if (addTicket) { -- level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); +- level.getChunkSource().addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } -- level.chunkSource.runDistanceManagerUpdates(); +- level.getChunkSource().runDistanceManagerUpdates(); - - final Consumer loadCallback = (final ChunkAccess chunk) -> { - try { @@ -444,20 +444,20 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 - com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); - } finally { - if (addTicket) { -- level.chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel); -- level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); +- level.getChunkSource().addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel); +- level.getChunkSource().removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } - } - }; - -- final ChunkHolder holder = level.chunkSource.chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); +- final ChunkHolder holder = level.getChunkSource().chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); - - if (holder == null || holder.getTicketLevel() > minLevel) { - loadCallback.accept(null); - return; - } - -- final CompletableFuture> loadFuture = holder.scheduleChunkGenerationTask(toStatus, level.chunkSource.chunkMap); +- final CompletableFuture> loadFuture = holder.scheduleChunkGenerationTask(toStatus, level.getChunkSource().chunkMap); - - if (loadFuture.isDone()) { - loadCallback.accept(loadFuture.join().orElse(null)); @@ -497,9 +497,9 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 - final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); - - if (addTicket) { -- level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); +- level.getChunkSource().addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } -- level.chunkSource.runDistanceManagerUpdates(); +- level.getChunkSource().runDistanceManagerUpdates(); - - final Consumer loadCallback = (final LevelChunk chunk) -> { - try { @@ -511,13 +511,13 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 - com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); - } finally { - if (addTicket) { -- level.chunkSource.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel); -- level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); +- level.getChunkSource().addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel); +- level.getChunkSource().removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } - } - }; - -- final ChunkHolder holder = level.chunkSource.chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); +- final ChunkHolder holder = level.getChunkSource().chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); - - if (holder == null || holder.getTicketLevel() > minLevel) { - loadCallback.accept(null); @@ -562,25 +562,25 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 @Override public List getVisibleChunkHolders(final ServerLevel level) { -- return new ArrayList<>(level.chunkSource.chunkMap.visibleChunkMap.values()); +- return new ArrayList<>(level.getChunkSource().chunkMap.visibleChunkMap.values()); + return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); } @Override public List getUpdatingChunkHolders(final ServerLevel level) { -- return new ArrayList<>(level.chunkSource.chunkMap.updatingChunkMap.values()); +- return new ArrayList<>(level.getChunkSource().chunkMap.updatingChunkMap.values()); + return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); } @Override public int getVisibleChunkHolderCount(final ServerLevel level) { -- return level.chunkSource.chunkMap.visibleChunkMap.size(); +- return level.getChunkSource().chunkMap.visibleChunkMap.size(); + return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); } @Override public int getUpdatingChunkHolderCount(final ServerLevel level) { -- return level.chunkSource.chunkMap.updatingChunkMap.size(); +- return level.getChunkSource().chunkMap.updatingChunkMap.size(); + return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); } @@ -647,7 +647,7 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 @Override public ChunkHolder getUnloadingChunkHolder(final ServerLevel level, final int chunkX, final int chunkZ) { -- return level.chunkSource.chunkMap.getUnloadingChunkHolder(chunkX, chunkZ); +- return level.getChunkSource().chunkMap.getUnloadingChunkHolder(chunkX, chunkZ); + return null; } @@ -663,7 +663,7 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 - if (level == null) { - return Bukkit.getViewDistance(); - } -- return level.chunkSource.chunkMap.serverViewDistance; +- return level.getChunkSource().chunkMap.serverViewDistance; + return RegionizedPlayerChunkLoader.getAPIViewDistance(player); } @@ -673,7 +673,7 @@ index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..4baf46256e90a87d684e57ff623076a8 - if (level == null) { - return Bukkit.getSimulationDistance(); - } -- return level.chunkSource.chunkMap.distanceManager.simulationDistance; +- return level.getChunkSource().chunkMap.getDistanceManager().simulationDistance; + return RegionizedPlayerChunkLoader.getAPITickViewDistance(player); } @@ -15586,7 +15586,7 @@ index 0000000000000000000000000000000000000000..1414f25ef770b0fe73ea618a450ade2f +} diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..de764da80793d272ff597b4a0742ce785838799a +index 0000000000000000000000000000000000000000..15568f598b8c61cf92563b6a7f8cae526b84484e --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -0,0 +1,2199 @@ @@ -17563,7 +17563,7 @@ index 0000000000000000000000000000000000000000..de764da80793d272ff597b4a0742ce78 + final boolean hasSpecial = ((BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks(); + final int sectionAdjust = !hasSpecial ? 1 : 0; + -+ final PalettedContainer blocks = section.states; ++ final PalettedContainer blocks = section.getStates(); + + final int minXIterate = currChunkX == minChunkX ? (minBlockX & 15) + sectionAdjust : 0; + final int maxXIterate = currChunkX == maxChunkX ? (maxBlockX & 15) - sectionAdjust : 15; @@ -18959,7 +18959,7 @@ index 0000000000000000000000000000000000000000..ed80017c8f257b981d626a37ffc5480d +} diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/BlockStarLightEngine.java b/ca/spottedleaf/moonrise/patches/starlight/light/BlockStarLightEngine.java new file mode 100644 -index 0000000000000000000000000000000000000000..7e343de2fe4348290d7275494ee14142e64b9243 +index 0000000000000000000000000000000000000000..29563672f4b0e5e13625193125656549b4eba010 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/starlight/light/BlockStarLightEngine.java @@ -0,0 +1,280 @@ @@ -19180,7 +19180,7 @@ index 0000000000000000000000000000000000000000..7e343de2fe4348290d7275494ee14142 + // no light sources in palette + continue; + } -+ final PalettedContainer states = section.states; ++ final PalettedContainer states = section.getStates(); + final int offY = sectionY << 4; + + final BlockPos.MutableBlockPos mutablePos = this.lightEmissionPos; @@ -20387,7 +20387,7 @@ index 0000000000000000000000000000000000000000..d3d1831ff4fabd87d4b18da0b28a0d75 +} diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightEngine.java b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightEngine.java new file mode 100644 -index 0000000000000000000000000000000000000000..d5eb47f26039220456d271d2f6d00be645e06616 +index 0000000000000000000000000000000000000000..8641812bc364d7b9ab1e573375d36db3ef6225ed --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightEngine.java @@ -0,0 +1,1450 @@ @@ -20699,7 +20699,7 @@ index 0000000000000000000000000000000000000000..d5eb47f26039220456d271d2f6d00be6 + final LevelChunkSection section = this.sectionCache[sectionIndex]; + + if (section != null) { -+ return section.hasOnlyAir() ? AIR_BLOCK_STATE : section.states.get(localIndex); ++ return section.hasOnlyAir() ? AIR_BLOCK_STATE : section.getStates().get(localIndex); + } + + return AIR_BLOCK_STATE; @@ -23041,7 +23041,7 @@ index 0000000000000000000000000000000000000000..95154636727366adfb4fb67e7db8b09f + private SaveUtil() {} +} diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7e1ae43e0 100644 +index 7682986e3378e48cdc7a05ea2b43d8b3f3b85272..5c6eb520ebc39dbb3f601ad0cc2d96b45c882845 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -1,6 +1,9 @@ @@ -23128,7 +23128,7 @@ index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7 private static void dumpEntity(final Entity entity) { } - public static org.bukkit.entity.Entity[] getChunkEntities(net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ) { + public static org.bukkit.entity.Entity[] getChunkEntities(Level level, int chunkX, int chunkZ) { - level.getChunk(chunkX, chunkZ); // ensure full loaded - - net.minecraft.world.level.entity.PersistentEntitySectionManager entityManager = level.entityManager; @@ -23181,7 +23181,7 @@ index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7 public static java.util.Collection getPluginChunkTickets(net.minecraft.server.level.ServerLevel level, int x, int z) { -- net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.distanceManager; +- net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.getDistanceManager(); - List tickets = chunkDistanceManager.ticketStorage.tickets.get(ChunkPos.pack(x, z)); - - if (tickets == null) { @@ -23201,7 +23201,7 @@ index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7 public static Map> getPluginChunkTickets(net.minecraft.server.level.ServerLevel level) { Map> ret = new HashMap<>(); - net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.distanceManager; + net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.getDistanceManager(); - for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry> chunkTickets : chunkDistanceManager.ticketStorage.tickets.long2ObjectEntrySet()) { + for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry> chunkTickets : chunkDistanceManager.moonrise$getChunkHolderManager().getTicketsCopy().long2ObjectEntrySet()) { // Paper - rewrite chunk system @@ -23235,7 +23235,7 @@ index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7 public static void setSendViewDistance(net.minecraft.server.level.ServerLevel level, int distance) { - throw new UnsupportedOperationException("Not implemented yet"); -+ level.chunkSource.setSendViewDistance(distance); // Paper - rewrite chunk system ++ level.getChunkSource().setSendViewDistance(distance); // Paper - rewrite chunk system } public static void tickEntityManager(net.minecraft.server.level.ServerLevel level) { @@ -23272,9 +23272,8 @@ index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7 + ((ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer)player).moonrise$getViewDistanceHolder().setSendViewDistance(distance); // Paper - rewrite chunk system } --} + } \ No newline at end of file -+} diff --git a/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/io/papermc/paper/command/subcommands/ChunkDebugCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..d86bd11e0155f767c3bf66ac05fa4acf6d2bfccb @@ -23830,7 +23829,7 @@ index 9d9fa99ff7694a3356421df711c7b1443047b057..c79206e0eb455081f63cf4de2c974136 } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 7b2a078c11cc5e7b9770ee3811e2b04479d20b37..7ebfe2acac0fe980320386de9574b0600c9e3e97 100644 +index 10f268f5e0115ee27ba693fcc1ac23fe8937c2aa..b9d4161dedfd43a1542ee8e5bc57a66ce5e39dba 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -189,7 +189,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; @@ -24586,21 +24585,8 @@ index 5e5aad112058b567214c28ccd719271f12240a35..cd5a325d37f617431ceb568a65570160 } @FunctionalInterface -diff --git a/net/minecraft/server/level/ChunkLevel.java b/net/minecraft/server/level/ChunkLevel.java -index 62290d63f44f4fb4e1eb02fb68ba9c34e051a50a..bbb7ca544df9342089d9630e3aa7e70050d3a947 100644 ---- a/net/minecraft/server/level/ChunkLevel.java -+++ b/net/minecraft/server/level/ChunkLevel.java -@@ -8,7 +8,7 @@ import org.jspecify.annotations.Nullable; - - public class ChunkLevel { - public static final int FULL_CHUNK_LEVEL = 33; // Paper - public -- private static final int BLOCK_TICKING_LEVEL = 32; -+ public static final int BLOCK_TICKING_LEVEL = 32; - public static final int ENTITY_TICKING_LEVEL = 31; - private static final ChunkStep FULL_CHUNK_STEP = ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FULL); - public static final int RADIUS_AROUND_FULL_CHUNK = FULL_CHUNK_STEP.accumulatedDependencies().getRadius(); diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 4e7904f2bc9680c52402899bc595a90dc44f116e..9bbc72cea0fe169f27c63e792e35f74a13b7d943 100644 +index d0c8796fb86446b1e2b0e2b2e372b968b1b9f0da..e72bdc0311337742c687e318b80f90e04374f149 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -124,10 +124,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP @@ -24623,7 +24609,7 @@ index 4e7904f2bc9680c52402899bc595a90dc44f116e..9bbc72cea0fe169f27c63e792e35f74a - private final ChunkTaskDispatcher lightTaskDispatcher; + // Paper - rewrite chunk system private final ChunkStatusUpdateListener chunkStatusListener; - public final ChunkMap.DistanceManager distanceManager; + private final ChunkMap.DistanceManager distanceManager; private final String storageName; private final PlayerMap playerMap = new PlayerMap(); public final Int2ObjectMap entityMap = new Int2ObjectOpenHashMap<>(); @@ -26444,7 +26430,7 @@ index 1cd13461a4229eae64ea11f7a5711ce044432719..36defbdc77c0d2b04729e9a69241046f } } diff --git a/net/minecraft/server/level/PlayerSpawnFinder.java b/net/minecraft/server/level/PlayerSpawnFinder.java -index a701288146a1d7cd258faae69f959edf466ec71c..2608ee822cc205a7d101915fd6773d037cadce21 100644 +index a701288146a1d7cd258faae69f959edf466ec71c..3509df9dd423b38d1ca3e4a420d1352ae95d3551 100644 --- a/net/minecraft/server/level/PlayerSpawnFinder.java +++ b/net/minecraft/server/level/PlayerSpawnFinder.java @@ -115,9 +115,9 @@ public class PlayerSpawnFinder { @@ -26465,12 +26451,12 @@ index a701288146a1d7cd258faae69f959edf466ec71c..2608ee822cc205a7d101915fd6773d03 this.finishedFuture.completeExceptionally(new ReportedException(report)); } - }, this.level.getServer()); -+ }, this.level.chunkSource.mainThreadProcessor); // Paper - rewrite chunk system ++ }, this.level.getChunkSource().mainThreadProcessor); // Paper - rewrite chunk system } } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index e9f26ac2ceef63c7dcb041c161ebf1529976a72e..9618c6f7adbfc0ab65c221dba6bdb7266cf3baa6 100644 +index 5e0d2bbd9223f727ec337357ee7d0088eff11ab8..3d6765f284d1817d68db4d9ae0d90c7e73e6e068 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; @@ -26986,7 +26972,7 @@ index 60e89fbbd09ada8a48527ebac43340a58aa6d001..70daec14be69c0e02759489a5ddeda87 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 594d22edfaeee1097304478d09f33a3d5e0dd51d..4b67719f536fcf1d3d0f416c395b603aaf471c82 100644 +index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d5670aaeed8b 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; @@ -27453,7 +27439,7 @@ index 594d22edfaeee1097304478d09f33a3d5e0dd51d..4b67719f536fcf1d3d0f416c395b603a + for (int sectionIndex = 0, sectionsLen = sections.length; sectionIndex < sectionsLen; sectionIndex++) { + final int offsetY = (sectionIndex + minSection) << 4; + final LevelChunkSection section = sections[sectionIndex]; -+ final net.minecraft.world.level.chunk.PalettedContainer states = section.states; ++ final net.minecraft.world.level.chunk.PalettedContainer states = section.getStates(); + if (!section.isRandomlyTickingBlocks()) { + continue; + } @@ -27768,7 +27754,7 @@ index 594d22edfaeee1097304478d09f33a3d5e0dd51d..4b67719f536fcf1d3d0f416c395b603a "Server weather", () -> String.format( diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 43d65e4d8679e3ff54e0fa976437dd8aa6de220c..03282ad26e7eb38508b5bf97a18cd6da57b060e5 100644 +index ccf61d6f82e411f7e46d909b6308f807900882bf..5f77160da6d59afb0109be40cbe8597a93a62908 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java @@ -206,7 +206,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; @@ -27822,7 +27808,7 @@ index 43d65e4d8679e3ff54e0fa976437dd8aa6de220c..03282ad26e7eb38508b5bf97a18cd6da public BlockPos adjustSpawnLocation(final ServerLevel level, final BlockPos spawnSuggestion) { CompletableFuture future = PlayerSpawnFinder.findSpawn(level, spawnSuggestion); - this.server.managedBlock(future::isDone); -+ level.chunkSource.mainThreadProcessor.managedBlock(future::isDone); // Paper - rewrite chunk system ++ level.getChunkSource().mainThreadProcessor.managedBlock(future::isDone); // Paper - rewrite chunk system return BlockPos.containing(future.join()); } @@ -28443,7 +28429,7 @@ index a46b89895a9ce86b6f5fabd373a4e91919d88033..22b10500ef74694243a4fec40822bb54 // 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 5576bfd83e101aa81b6f79f7144be69f2fbfda08..f087b290ffbb2cd719b68de98b5381b789f442df 100644 +index af2509ed6ca1b9ed68c67bd682de3823ccb09088..d91d7d438dd79c64827de7cdfbaeb8c8b0896a48 100644 --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java @@ -165,7 +165,7 @@ public class PrepareSpawnTask implements ConfigurationTask { @@ -28469,7 +28455,7 @@ 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 a31fb3ca939fe6285ef003a65fd70f30896c5daa..f637ac9da1d0f06fab26f81e69619453a8acb5f6 100644 +index b4845731ba1eaae582afece7e09e2af427b29d6a..1dbb1d49c797be89f3739c2fa226aef25f68ee87 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -982,8 +982,8 @@ public abstract class PlayerList { @@ -28875,7 +28861,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 a5352d383e35a82a2915cae699f2616d7436bef8..88b8d13309a72c5745df8e0e1fa0c0cdc6f8316a 100644 +index 745aa8356fca102c6980363d126bfd6b23415b12..ba0cdbd064ad3e0cf645c50ab14adcddef48e932 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -164,7 +164,7 @@ public abstract class Entity @@ -29283,7 +29269,7 @@ index a5352d383e35a82a2915cae699f2616d7436bef8..88b8d13309a72c5745df8e0e1fa0c0cd + continue; + } + -+ final net.minecraft.world.level.chunk.PalettedContainer blocks = section.states; ++ final net.minecraft.world.level.chunk.PalettedContainer blocks = section.getStates(); + + final int minXIterate = currChunkX == minChunkX ? (minBlockX & 15) : 0; + final int maxXIterate = currChunkX == maxChunkX ? (maxBlockX & 15) : 15; @@ -30024,7 +30010,7 @@ index 892b338a2b0a185511c352ca2bb76ee3890836fd..cc938f43c4a5e947ed87ca2001cbaca4 // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index bfb65ccca995366261e857aec69cae0fcf0dbf07..93bc56704ef8019423d0605d176ab73d6f63d39e 100644 +index d50b8738d9d5fe7e5c1802481133b7dd94ceffd8..6e3a05c2b9709272634bca2becd00d1411583627 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; @@ -30292,7 +30278,7 @@ index bfb65ccca995366261e857aec69cae0fcf0dbf07..93bc56704ef8019423d0605d176ab73d + lastChunk = level.getChunk(newChunkX, newChunkZ).getSections(); + } + final int sectionY = newChunkY - minSection; -+ lastSection = sectionY >= 0 && sectionY < lastChunk.length ? lastChunk[sectionY].states : null; ++ lastSection = sectionY >= 0 && sectionY < lastChunk.length ? lastChunk[sectionY].getStates() : null; + + lastChunkX = newChunkX; + lastChunkY = newChunkY; @@ -30514,7 +30500,7 @@ index bfb65ccca995366261e857aec69cae0fcf0dbf07..93bc56704ef8019423d0605d176ab73d + final boolean hasSpecial = ((ca.spottedleaf.moonrise.patches.block_counting.BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks(); + final int sectionAdjust = !hasSpecial ? 1 : 0; + -+ final net.minecraft.world.level.chunk.PalettedContainer blocks = section.states; ++ final net.minecraft.world.level.chunk.PalettedContainer blocks = section.getStates(); + + final int minXIterate = currChunkX == minChunkX ? (minBlockX & 15) + sectionAdjust : 0; + final int maxXIterate = currChunkX == maxChunkX ? (maxBlockX & 15) - sectionAdjust : 15; @@ -31830,7 +31816,7 @@ index d9849dfbe792128390941403220110fe87eb9fe3..c139f70bf9ddd3f995c0524dad15487e public interface NoiseBiomeSource { diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index bbf546a6ee4ac6ac6f9c5430b14c39f11853933e..fd97524eecd5af2d67e496c8ab5c53b405edc076 100644 +index 5d09a36718bb22022348a9ce8efe8a4767c21a8c..29f5182c8528bfdced6a3c2c145e58721e723777 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java @@ -367,7 +367,7 @@ public class Block extends BlockBehaviour implements ItemLike { @@ -31843,7 +31829,7 @@ index bbf546a6ee4ac6ac6f9c5430b14c39f11853933e..fd97524eecd5af2d67e496c8ab5c53b4 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 cb6fe72d897d1b30368e0dcc9da900fb00f25135..15ba7b34dacbe89f604adb6245c9f914de1d71a7 100644 +index 3ec065b2db3810cfb42a65330501998dd2e75683..c78d77089e34c4bb559f173b449bfb7d91b05d5c 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -437,7 +437,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -32663,7 +32649,7 @@ index d25b4b71d1cb26eb3afe7d105c8916bcdbb02da4..754c3bb648558d96f9eed990a41480e4 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 f5d4733e0f1654aa1495b72ff83489acdbb8f5c6..0998671b463f0db367e8a34ad4a7ebf1355a99db 100644 +index b124fe7fadd884d7e5e86de8aee310194a15d8f9..492fdd45be6b13f1b12ebe90c938854b7fdbc026 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; @@ -32842,7 +32828,7 @@ index f5d4733e0f1654aa1495b72ff83489acdbb8f5c6..0998671b463f0db367e8a34ad4a7ebf1 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 d1bf15ab369af57d022ff133b8d37afc98f9eb8c..8fd63c2f5f790af35384c4549dc914756b7dfe45 100644 +index d2a97e62e8fca8c555f8238eee5c07f21dbf7879..35c0a64409e915534905139d1d819514c02b7994 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -9,7 +9,7 @@ import net.minecraft.world.level.biome.Climate; @@ -32855,7 +32841,7 @@ index d1bf15ab369af57d022ff133b8d37afc98f9eb8c..8fd63c2f5f790af35384c4549dc91475 short nonEmptyBlockCount; // Paper - package private private short fluidCount; @@ -18,6 +18,30 @@ public class LevelChunkSection { - public final PalettedContainer states; + private final PalettedContainer states; private PalettedContainer> biomes; // CraftBukkit - read/write + // Paper start - block counting @@ -33650,7 +33636,7 @@ index e6f83b493edd89fa104ab2e7ef13e0a2a4d3399f..7767e5420e3d2e569008747523d70147 } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 81c545c1af001b8f08468cdd7af2c9528742758a..effc7de84088a7407c15e80adf12195e97bbf080 100644 +index 1869dc3093bdc0866d8f958e09278a5a6095f27d..134fb5c9adb3de350a2775be558727989986ebdd 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; @@ -33661,7 +33647,7 @@ index 81c545c1af001b8f08468cdd7af2c9528742758a..effc7de84088a7407c15e80adf12195e +public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.io.ChunkSystemRegionFileStorage { // Paper - rewrite chunk system public static final String ANVIL_EXTENSION = ".mca"; private static final int MAX_CACHE_SIZE = 256; - public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap<>(); + private final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap<>(); @@ -23,6 +23,184 @@ public final class RegionFileStorage implements AutoCloseable { private final Path folder; private final boolean sync; @@ -34590,7 +34576,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 0a8b0b01df527176d4dc0f5adaca2788dd7eb0a2..cb6cf1abbb44fc5c1edb1fd48850bab060e3fd90 100644 +index e7e65ae464aab7e4caf0925a69d658e422203aa4..3f66d1144daf7139a91bfa35e2c288d88bbae38b 100644 --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java @@ -86,7 +86,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { diff --git a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch index d321886b8a96..1b9b8502a959 100644 --- a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch @@ -15,7 +15,7 @@ Adds villagers as separate config diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java new file mode 100644 -index 0000000000000000000000000000000000000000..fe05c3bd9adeddc2dd740af3546f835c1c2de311 +index 0000000000000000000000000000000000000000..829f7685904fd741e00403647ae76d32275c34a3 --- /dev/null +++ b/io/papermc/paper/entity/activation/ActivationRange.java @@ -0,0 +1,335 @@ @@ -243,7 +243,7 @@ index 0000000000000000000000000000000000000000..fe05c3bd9adeddc2dd740af3546f835c + } + // special cases. + if (entity instanceof final LivingEntity living) { -+ if (living.blockPosition().equals(living.getLastClimbablePos().orElse(null)) || living.jumping || living.hurtTime > 0 || !living.activeEffects.isEmpty() || living.isFreezing()) { ++ if (living.blockPosition().equals(living.getLastClimbablePos().orElse(null)) || living.isJumping() || living.hurtTime > 0 || !living.getActiveEffectsMap().isEmpty() || living.isFreezing()) { + return 1; + } + if (entity instanceof final Mob mob && mob.getTarget() != null) { @@ -316,7 +316,7 @@ index 0000000000000000000000000000000000000000..fe05c3bd9adeddc2dd740af3546f835c + } + // special case always immunities + // immunize brand-new entities, dead entities, and portal scenarios -+ if (entity.defaultActivationState || entity.tickCount < 20 * 10 || !entity.isAlive() || (entity.portalProcess != null && !entity.portalProcess.hasExpired()) || entity.portalCooldown > 0) { ++ if (entity.defaultActivationState || entity.tickCount < 20 * 10 || !entity.isAlive() || (entity.portalProcess != null && !entity.portalProcess.hasExpired()) || entity.getPortalCooldown() > 0) { + return true; + } + // immunize leashed entities @@ -355,7 +355,7 @@ index 0000000000000000000000000000000000000000..fe05c3bd9adeddc2dd740af3546f835c + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 4b67719f536fcf1d3d0f416c395b603aaf471c82..e8d9eff03d098ce65d44ee0172b70b7e90a658d4 100644 +index 7861b180e1e0ed73c1702fee7181d5670aaeed8b..639b301f3ab82ea44d5c0e4ecec3983b9c0c02c3 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -877,6 +877,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @@ -442,7 +442,7 @@ index dad587ec02f434c0ce91244d9668664a9681f354..3cf4c6af77a315b7a6d05571192b1249 public void aiStep() { super.aiStep(); diff --git a/net/minecraft/world/entity/AreaEffectCloud.java b/net/minecraft/world/entity/AreaEffectCloud.java -index 8948755478b9d8bcf49593be695daca45a4e65ad..76ad0a8c9161e5c8602f015deb9003b8ee095c23 100644 +index 271ed1128959287f6c1b6ca59ded377b88f5afff..f03fa06c0ba56f7f5e1e45bc1568a490751efde3 100644 --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java @@ -140,6 +140,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { @@ -463,7 +463,7 @@ index 8948755478b9d8bcf49593be695daca45a4e65ad..76ad0a8c9161e5c8602f015deb9003b8 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 88b8d13309a72c5745df8e0e1fa0c0cdc6f8316a..c793f9117cf3c0560f4fd2028d0beeaa0e99ed78 100644 +index d462bb751b14c2fffc970c7450f3c6b5d7909e53..f3b55daf9d3b88fcb5a5e88926f33e437297647b 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -382,6 +382,15 @@ public abstract class Entity @@ -522,7 +522,7 @@ index 88b8d13309a72c5745df8e0e1fa0c0cdc6f8316a..c793f9117cf3c0560f4fd2028d0beeaa 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 3f7ca2206ec29e77613c85129ad06f642b53a213..98a9aa825dd7dd17af1b3c269d48d758352328c8 100644 +index 08e3437671b19be4415e23da7f975b6833039810..a6e4a0f0201b265d5c4a3dd3dc4d64935559fe88 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -3404,6 +3404,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @@ -541,7 +541,7 @@ index 3f7ca2206ec29e77613c85129ad06f642b53a213..98a9aa825dd7dd17af1b3c269d48d758 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 93fcc0dad95bf5120f7a028ced365d279fa6bccf..f5fb78892596c96a4c3d66dcf8737450ef5e08e2 100644 +index 5d45532ccaf362a6ed9d40453b31a291fb23dd5c..a521068fe97243adbf1e7e9b14fe7f0b19f1e65c 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -216,6 +216,20 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs @@ -759,7 +759,7 @@ index eac6a80bc21280f9872344583ad825df40e03640..325bdcd8c7dd4e03aa6f649c8f76b031 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/projectile/arrow/Arrow.java b/net/minecraft/world/entity/projectile/arrow/Arrow.java -index 3bdfe511c6df6188ea8a4ecd38864b268f42b5c6..546503142ad5330fdf8ed2acbe9ac18e6b9e3e80 100644 +index 7c62081d5af4f47d053674479188c85b04f5df9a..cd7a719bf922246a2497cc5ad897c306379e40df 100644 --- a/net/minecraft/world/entity/projectile/arrow/Arrow.java +++ b/net/minecraft/world/entity/projectile/arrow/Arrow.java @@ -71,6 +71,16 @@ public class Arrow extends AbstractArrow { @@ -819,7 +819,7 @@ index f46cca0467bb4da5511bc953ce5b43fa606bf978..445c5cafad71028171c1f26193966177 + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 93bc56704ef8019423d0605d176ab73d6f63d39e..5f040613ef5d1eab58ac82719cbb02a9201432e4 100644 +index c3f716f8cd7326af411f6e1648a3db49b5f34c36..bc03996ce2d7a885e162909958a2a06e2947523c 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -156,6 +156,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl diff --git a/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch index 6efb6f95812b..13c2fae8378a 100644 --- a/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch +++ b/paper-server/patches/features/0016-Optimise-EntityScheduler-ticking.patch @@ -20,7 +20,7 @@ index 2bc436cdf5180a7943c45fabb9fbbedae6f7db56..f312a7f5b1b2a777ab36b94ce7cbf387 @Override diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 1a941fe5cff1d002486306e2632f0fd2628107f6..08b24ebcef4b1f743177f21c038ec253f5838c04 100644 +index 35d69b00d269e6917621fe338d79b95e4fd39ba9..516c747c1025026aa2180b118ea83f5166f0cbf9 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -1783,32 +1783,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop playersInRange, final LevelChunk chunk) { -- final ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, chunk.level.getLightEngine(), null, null); +- final ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, chunk.getLevel().getLightEngine(), null, null); + // Paper start - Anti-Xray + final Map refreshPackets = new HashMap<>(); for (final ServerPlayer player : playersInRange) { @@ -26,7 +26,7 @@ index fadce1c051e6c7bc0c3d041c0cc8ecd7e1ae43e0..4dd1baf17597d8801a286346a2b74345 - player.connection.send(refreshPacket); + final Boolean shouldModify = chunk.getLevel().chunkPacketBlockController.shouldModify(player, chunk); + player.connection.send(refreshPackets.computeIfAbsent(shouldModify, s -> { // Use connection to prevent creating firing event -+ return new ClientboundLevelChunkWithLightPacket(chunk, chunk.level.getLightEngine(), null, null, (Boolean) s); ++ return new ClientboundLevelChunkWithLightPacket(chunk, chunk.getLevel().getLightEngine(), null, null, (Boolean) s); + })); + // Paper end - Anti-Xray } @@ -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 9263de563a6b1090fefd1af870dd00eeb4d716a8..2acf8596e31e5edfb550ceeaba40e0c5d437e3ed 100644 +index 0b195205654127482529a18eabefbdebf1f978c9..b8db157b5e3d42f619c07cc927e4951cf8ba05dc 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -632,7 +632,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @@ -168,14 +168,14 @@ index 9263de563a6b1090fefd1af870dd00eeb4d716a8..2acf8596e31e5edfb550ceeaba40e0c5 this.weatherData.setLevel(this); this.typeKey = typeKey; diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index c964b69953a2a515e8c3d5a42343d63f0583b560..ddd0447989ed3dd908509b9e729cfedc5498cfd6 100644 +index 4b5df81242ce397961464e247e910a7bbca3fd85..7ae3f33d8931d826b94cbc492340635c028f3fbc 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java @@ -320,6 +320,7 @@ public class ServerPlayerGameMode { org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelectedItem()); // CraftBukkit } } -+ this.level.chunkPacketBlockController.onPlayerLeftClickBlock(this, pos, action, direction, maxY, sequence); // Paper - Anti-Xray ++ this.level.chunkPacketBlockController.onPlayerLeftClickBlock(this.level, pos, action, direction, maxY, sequence); // Paper - Anti-Xray } public void destroyAndAck(final BlockPos pos, final int sequence, final String exitId) { @@ -196,7 +196,7 @@ index 22b10500ef74694243a4fec40822bb54ef96cc0c..196c01fe5f200ed57e6f23e0939cac61 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 586e51b7d0a59b75ef98d8f5fa75c5081f79f7f2..b69051d99950aa77181e3b1803bb9bc7b48fa763 100644 +index 779686f3d0c330b0c9ce4f37168503f3668b1f13..baec5d072b8f2d9379dba850b04e881e5267ca6b 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -331,7 +331,7 @@ public abstract class PlayerList { @@ -209,7 +209,7 @@ index 586e51b7d0a59b75ef98d8f5fa75c5081f79f7f2..b69051d99950aa77181e3b1803bb9bc7 } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 46b9b87d58947f8f789cd2ce75e1d2ef6ca74d90..c57c8832b490b57c70da0bce74ae589a45875b3e 100644 +index 6ea9761ee390a8c1891c0ac5a4530682ef2c748e..849f5029f6662e9768ddbe86ad37f726e6e04c78 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -146,6 +146,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -273,7 +273,7 @@ index 8b51041370c5184d5a1926ea3262f9111703a6d3..28f703204afd834cd50335346ef06567 } } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 0998671b463f0db367e8a34ad4a7ebf1355a99db..eaa3966c039723fa4bd90f67d122a8584cd5382b 100644 +index 6c6046b0263fe661f6e64d936a65cc97356135db..32cbcec09e310683ae02abdc421156bca0a73db8 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java @@ -151,7 +151,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot @@ -286,7 +286,7 @@ index 0998671b463f0db367e8a34ad4a7ebf1355a99db..eaa3966c039723fa4bd90f67d122a858 this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index 8fd63c2f5f790af35384c4549dc914756b7dfe45..a25b1747fe6bde428265f90eadfade81c0979400 100644 +index 35c0a64409e915534905139d1d819514c02b7994..705f6314d2550b0f1c8c5209dd65161d89cbfd7e 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -57,8 +57,14 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ diff --git a/paper-server/patches/features/0020-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features/0020-Allow-Saving-of-Oversized-Chunks.patch index b0d138485dda..15f4e92bbec9 100644 --- a/paper-server/patches/features/0020-Allow-Saving-of-Oversized-Chunks.patch +++ b/paper-server/patches/features/0020-Allow-Saving-of-Oversized-Chunks.patch @@ -119,7 +119,7 @@ index 7767e5420e3d2e569008747523d70147ea8d97fb..b6c6bf9b20fee63b7e2a37d949bb1e55 + // Paper end } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index effc7de84088a7407c15e80adf12195e97bbf080..7440bebb75762602d9010868949ebe9cd141faca 100644 +index 134fb5c9adb3de350a2775be558727989986ebdd..bb7fcf6cc4bfc51d9984331466a0b10573a19604 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; @@ -129,7 +129,7 @@ index effc7de84088a7407c15e80adf12195e97bbf080..7440bebb75762602d9010868949ebe9c + private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper public static final String ANVIL_EXTENSION = ".mca"; private static final int MAX_CACHE_SIZE = 256; - public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap<>(); + private final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap<>(); @@ -241,6 +242,43 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper end - rewrite chunk system } diff --git a/paper-server/patches/features/0028-Optional-per-player-mob-spawns.patch b/paper-server/patches/features/0028-Optional-per-player-mob-spawns.patch index f5201dee948d..090b392c3b3d 100644 --- a/paper-server/patches/features/0028-Optional-per-player-mob-spawns.patch +++ b/paper-server/patches/features/0028-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 0b54f54bf559dc1c3c49594d62df6bad246fe7a3..7f1899d46e4becaf18598c402cf0134920361eb4 100644 +index c8a65d411ccb8a0ef1dad2da8e8f95e8ce4e36a5..a79b74beb7a21dccf667eb0dea0506339acc797d 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,7 +42,7 @@ index 0b54f54bf559dc1c3c49594d62df6bad246fe7a3..7f1899d46e4becaf18598c402cf01349 protected ChunkGenerator generator() { return this.worldGenContext.generator(); diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 9618c6f7adbfc0ab65c221dba6bdb7266cf3baa6..67838dd61af5e063acb8b601f3f0c6a14a76cab9 100644 +index 3d6765f284d1817d68db4d9ae0d90c7e73e6e068..a7ef3915dca196e6c5afac43dff99c870f4dee2a 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -535,9 +535,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @@ -77,7 +77,7 @@ index 9618c6f7adbfc0ab65c221dba6bdb7266cf3baa6..67838dd61af5e063acb8b601f3f0c6a1 profiler.popPush("tickSpawningChunks"); diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index c4322dda780cc885d2483e8f26feec3f84dd181b..c4854bd7e32b9f73d340ce4dd325156aa428b1f1 100644 +index 980db7010cf455f048129b1dbf3e7469840beb58..f2a9724d7f578dc115f8a02c84550d7b4e5ca0a0 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java @@ -417,6 +417,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc @@ -92,7 +92,7 @@ index c4322dda780cc885d2483e8f26feec3f84dd181b..c4854bd7e32b9f73d340ce4dd325156a 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 e977389d539236d644f478f75fb34d0af2535a81..5a5cffd7b61c45d574cdf62aa1cc0913c89c694f 100644 +index e977389d539236d644f478f75fb34d0af2535a81..c75fcec1aaa88da8f50a8b2d94fa76a058b171a7 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -70,6 +70,18 @@ public final class NaturalSpawner { @@ -126,7 +126,7 @@ index e977389d539236d644f478f75fb34d0af2535a81..5a5cffd7b61c45d574cdf62aa1cc0913 mobCounts.addTo(category, 1); + // Paper start - Optional per player mob spawns + if (countMobs) { -+ chunk.level.getChunkSource().chunkMap.updatePlayerMobTypeMap(entity); ++ ((ServerLevel) chunk.getLevel()).getChunkSource().chunkMap.updatePlayerMobTypeMap(entity); + } + // Paper end - Optional per player mob spawns }); diff --git a/paper-server/patches/features/0030-Optimize-Hoppers.patch b/paper-server/patches/features/0030-Optimize-Hoppers.patch index 3a2abdac56cf..f1d81ca12609 100644 --- a/paper-server/patches/features/0030-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0030-Optimize-Hoppers.patch @@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf + } +} diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 08b24ebcef4b1f743177f21c038ec253f5838c04..3c4fb4eb8e543df49b285fc738aa3eee0df58584 100644 +index 516c747c1025026aa2180b118ea83f5166f0cbf9..6cf4dbafdb8ee62bbd1f1f0986b05ca2d10d7596 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -1839,6 +1839,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop loadCallback = (final ChunkAccess chunk) -> { + try { @@ -99,20 +99,20 @@ + com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); + } finally { + if (addTicket) { -+ level.chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel); -+ level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); ++ level.getChunkSource().addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel); ++ level.getChunkSource().removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); + } + } + }; + -+ final ChunkHolder holder = level.chunkSource.chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); ++ final ChunkHolder holder = level.getChunkSource().chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); + + if (holder == null || holder.getTicketLevel() > minLevel) { + loadCallback.accept(null); + return; + } + -+ final CompletableFuture> loadFuture = holder.scheduleChunkGenerationTask(toStatus, level.chunkSource.chunkMap); ++ final CompletableFuture> loadFuture = holder.scheduleChunkGenerationTask(toStatus, level.getChunkSource().chunkMap); + + if (loadFuture.isDone()) { + loadCallback.accept(loadFuture.join().orElse(null)); @@ -151,9 +151,9 @@ + final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); + + if (addTicket) { -+ level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); ++ level.getChunkSource().addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); + } -+ level.chunkSource.runDistanceManagerUpdates(); ++ level.getChunkSource().runDistanceManagerUpdates(); + + final Consumer loadCallback = (final LevelChunk chunk) -> { + try { @@ -165,13 +165,13 @@ + com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); + } finally { + if (addTicket) { -+ level.chunkSource.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel); -+ level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); ++ level.getChunkSource().addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel); ++ level.getChunkSource().removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); + } + } + }; + -+ final ChunkHolder holder = level.chunkSource.chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); ++ final ChunkHolder holder = level.getChunkSource().chunkMap.updatingChunkMap.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); + + if (holder == null || holder.getTicketLevel() > minLevel) { + loadCallback.accept(null); @@ -215,22 +215,22 @@ + + @Override + public List getVisibleChunkHolders(final ServerLevel level) { -+ return new ArrayList<>(level.chunkSource.chunkMap.visibleChunkMap.values()); ++ return new ArrayList<>(level.getChunkSource().chunkMap.visibleChunkMap.values()); + } + + @Override + public List getUpdatingChunkHolders(final ServerLevel level) { -+ return new ArrayList<>(level.chunkSource.chunkMap.updatingChunkMap.values()); ++ return new ArrayList<>(level.getChunkSource().chunkMap.updatingChunkMap.values()); + } + + @Override + public int getVisibleChunkHolderCount(final ServerLevel level) { -+ return level.chunkSource.chunkMap.visibleChunkMap.size(); ++ return level.getChunkSource().chunkMap.visibleChunkMap.size(); + } + + @Override + public int getUpdatingChunkHolderCount(final ServerLevel level) { -+ return level.chunkSource.chunkMap.updatingChunkMap.size(); ++ return level.getChunkSource().chunkMap.updatingChunkMap.size(); + } + + @Override @@ -290,7 +290,7 @@ + + @Override + public ChunkHolder getUnloadingChunkHolder(final ServerLevel level, final int chunkX, final int chunkZ) { -+ return level.chunkSource.chunkMap.getUnloadingChunkHolder(chunkX, chunkZ); ++ return level.getChunkSource().chunkMap.getUnloadingChunkHolder(chunkX, chunkZ); + } + + @Override @@ -304,7 +304,7 @@ + if (level == null) { + return Bukkit.getViewDistance(); + } -+ return level.chunkSource.chunkMap.serverViewDistance; ++ return level.getChunkSource().chunkMap.serverViewDistance; + } + + @Override @@ -313,7 +313,7 @@ + if (level == null) { + return Bukkit.getSimulationDistance(); + } -+ return level.chunkSource.chunkMap.distanceManager.simulationDistance; ++ return level.getChunkSource().chunkMap.getDistanceManager().simulationDistance; + } + + @Override diff --git a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch index eeda6652aeb0..03dbac5bfd06 100644 --- a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch +++ b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch @@ -48,7 +48,7 @@ + } + + public static void sendChunkRefreshPackets(final List playersInRange, final LevelChunk chunk) { -+ final ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, chunk.level.getLightEngine(), null, null); ++ final ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, chunk.getLevel().getLightEngine(), null, null); + for (final ServerPlayer player : playersInRange) { + if (player.connection == null) continue; + @@ -96,7 +96,7 @@ + private static void dumpEntity(final Entity entity) { + } + -+ public static org.bukkit.entity.Entity[] getChunkEntities(net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ) { ++ public static org.bukkit.entity.Entity[] getChunkEntities(Level level, int chunkX, int chunkZ) { + level.getChunk(chunkX, chunkZ); // ensure full loaded + + net.minecraft.world.level.entity.PersistentEntitySectionManager entityManager = level.entityManager; @@ -148,7 +148,7 @@ + + public static java.util.Collection getPluginChunkTickets(net.minecraft.server.level.ServerLevel level, + int x, int z) { -+ net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.distanceManager; ++ net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.getDistanceManager(); + List tickets = chunkDistanceManager.ticketStorage.tickets.get(ChunkPos.pack(x, z)); + + if (tickets == null) { @@ -167,7 +167,7 @@ + + public static Map> getPluginChunkTickets(net.minecraft.server.level.ServerLevel level) { + Map> ret = new HashMap<>(); -+ net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.distanceManager; ++ net.minecraft.server.level.DistanceManager chunkDistanceManager = level.getChunkSource().chunkMap.getDistanceManager(); + + for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry> chunkTickets : chunkDistanceManager.ticketStorage.tickets.long2ObjectEntrySet()) { + long chunkKey = chunkTickets.getLongKey(); @@ -206,14 +206,14 @@ + if (distance < 2 || distance > 32) { + throw new IllegalArgumentException("View distance " + distance + " is out of range of [2, 32]"); + } -+ level.chunkSource.chunkMap.setServerViewDistance(distance); ++ level.getChunkSource().chunkMap.setServerViewDistance(distance); + } + + public static void setSimulationDistance(net.minecraft.server.level.ServerLevel level, int distance) { + if (distance < 2 || distance > 32) { + throw new IllegalArgumentException("Simulation distance " + distance + " is out of range of [2, 32]"); + } -+ level.chunkSource.chunkMap.distanceManager.updateSimulationDistance(distance); ++ level.getChunkSource().chunkMap.getDistanceManager().updateSimulationDistance(distance); + } + + public static void setSendViewDistance(net.minecraft.server.level.ServerLevel level, int distance) { diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index f403aa041850..6f3c4e44b053 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -88,7 +88,7 @@ + /* Taken from SolidBucketItem#emptyContents */ + boolean willEmptyContentsSolidBucketItem = bucket instanceof net.minecraft.world.item.SolidBucketItem && level.isInWorldBounds(target) && state.isAir(); + /* Taken from BucketItem#emptyContents */ -+ boolean willEmptyBucketItem = bucket instanceof final net.minecraft.world.item.BucketItem bucketItem && bucketItem.content instanceof net.minecraft.world.level.material.FlowingFluid && (state.isAir() || state.canBeReplaced(bucketItem.content) || (state.getBlock() instanceof net.minecraft.world.level.block.LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(null, level, target, state, bucketItem.content))); ++ boolean willEmptyBucketItem = bucket instanceof final net.minecraft.world.item.BucketItem bucketItem && bucketItem.getContent() instanceof net.minecraft.world.level.material.FlowingFluid && (state.isAir() || state.canBeReplaced(bucketItem.getContent()) || (state.getBlock() instanceof net.minecraft.world.level.block.LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(null, level, target, state, bucketItem.getContent()))); + if (willEmptyContentsSolidBucketItem || willEmptyBucketItem) { + // Paper end - correctly check if the bucket place will succeed + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, source.pos()); 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 acdc44780519..f5b330a0ebfb 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -16,7 +16,7 @@ private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; @@ -218,7 +_,7 @@ - public final PlayerDataStorage playerDataStorage; + protected final PlayerDataStorage playerDataStorage; private final SavedDataStorage savedDataStorage; private final List tickables = Lists.newArrayList(); - private final GameRules gameRules; @@ -1102,8 +1102,8 @@ + this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit + // Paper start - Folia scheduler API + ((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) org.bukkit.Bukkit.getGlobalRegionScheduler()).tick(); -+ for (ServerPlayer player : this.playerList.players) { -+ if (!this.playerList.players.contains(player)) { ++ for (ServerPlayer player : this.playerList.getPlayers()) { ++ if (!this.playerList.getPlayers().contains(player)) { + continue; + } + final org.bukkit.craftbukkit.entity.CraftEntity bukkit = player.getBukkitEntityRaw(); @@ -1363,7 +1363,7 @@ } ) .thenAcceptAsync(newResources -> { -+ io.papermc.paper.command.brigadier.PaperBrigadier.moveBukkitCommands(this.resources.managers().getCommands(), newResources.managers().commands); // Paper ++ io.papermc.paper.command.brigadier.PaperBrigadier.moveBukkitCommands(this.resources.managers().getCommands(), newResources.managers().getCommands()); // Paper this.resources.close(); this.resources = newResources; - this.packRepository.setSelected(packsToEnable); diff --git a/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch index a31bc2aeb710..ce0e0f413f1d 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/server/ServerAdvancementManager.java +++ b/net/minecraft/server/ServerAdvancementManager.java -@@ -22,7 +_,7 @@ - - public class ServerAdvancementManager extends SimpleJsonResourceReloadListener { - private static final Logger LOGGER = LogUtils.getLogger(); -- public Map advancements = Map.of(); -+ public Map advancements = new java.util.HashMap<>(); // CraftBukkit - SPIGOT-7734: mutable - private AdvancementTree tree = new AdvancementTree(); - private final HolderLookup.Provider registries; - @@ -35,12 +_,18 @@ protected void apply(final Map preparations, final ResourceManager manager, final ProfilerFiller profiler) { Builder builder = ImmutableMap.builder(); @@ -21,8 +12,7 @@ this.validate(id, advancement); builder.put(id, new AdvancementHolder(id, advancement)); }); -- this.advancements = builder.buildOrThrow(); -+ this.advancements = new java.util.HashMap<>(builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable + this.advancements = builder.buildOrThrow(); AdvancementTree tree = new AdvancementTree(); tree.addAll(this.advancements.values()); + LOGGER.info("Loaded {} advancements", tree.nodes().size()); // Paper - Improve logging and errors; moved from AdvancementTree#addAll diff --git a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch index f515b4a2c308..5e2f1d638d53 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch @@ -161,7 +161,7 @@ } + // CraftBukkit start - Send to players + private void broadcastAll(Packet packet) { -+ for (ServerPlayer serverPlayer : this.server.getPlayerList().players) { ++ for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { + if (serverPlayer.getBukkitEntity().getScoreboard().getHandle() == this) { + serverPlayer.connection.send(packet); + } diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index 6cb19c477e5d..ad88c408f41f 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -21,8 +21,8 @@ public final Settings.MutableValue whiteList = this.getMutable("white-list", false); public final boolean enforceSecureProfile = this.get("enforce-secure-profile", true); public final boolean logIPs = this.get("log-ips", true); -- public Settings.MutableValue pauseWhenEmptySeconds = this.getMutable("pause-when-empty-seconds", 60); -+ public Settings.MutableValue pauseWhenEmptySeconds = this.getMutable("pause-when-empty-seconds", -1); // Paper - disable tick sleeping by default +- public final Settings.MutableValue pauseWhenEmptySeconds = this.getMutable("pause-when-empty-seconds", 60); ++ public final Settings.MutableValue pauseWhenEmptySeconds = this.getMutable("pause-when-empty-seconds", -1); // Paper - disable tick sleeping by default private final DedicatedServerProperties.WorldDimensionData worldDimensionData; public final WorldOptions worldOptions; public final Settings.MutableValue acceptsTransfers = this.getMutable("accepts-transfers", false); diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch deleted file mode 100644 index a6ccc990f4f3..000000000000 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/level/ChunkLevel.java -+++ b/net/minecraft/server/level/ChunkLevel.java -@@ -7,7 +_,7 @@ - import org.jspecify.annotations.Nullable; - - public class ChunkLevel { -- private static final int FULL_CHUNK_LEVEL = 33; -+ public static final int FULL_CHUNK_LEVEL = 33; // Paper - public - private static final int BLOCK_TICKING_LEVEL = 32; - public static final int ENTITY_TICKING_LEVEL = 31; - private static final ChunkStep FULL_CHUNK_STEP = ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FULL); 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 d139327fc816..f341c6f15362 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 @@ -262,7 +262,7 @@ @@ -1142,9 +_,19 @@ } - public void addEntity(final Entity entity) { + protected void addEntity(final Entity entity) { + org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot + // Paper start - ignore and warn about illegal addEntity calls instead of crashing server + if (!entity.valid || entity.level() != this.level || this.entityMap.containsKey(entity.getId())) { 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 db7fa776b4a3..1f9af3adf702 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 @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/level/ServerLevel.java @@ -195,7 +_,7 @@ private final List players = Lists.newArrayList(); - public final ServerChunkCache chunkSource; + private final ServerChunkCache chunkSource; private final MinecraftServer server; - public final ServerLevelData serverLevelData; + public final io.papermc.paper.world.saveddata.PaperLevelOverrides serverLevelData; // Paper - type @@ -198,7 +198,7 @@ + if (biomeProvider != null) { + net.minecraft.world.level.biome.BiomeSource biomeSource = new org.bukkit.craftbukkit.generator.CustomWorldChunkManager(this.getWorld(), biomeProvider, generator.getBiomeSource()); // Paper - add vanillaBiomeProvider + if (generator instanceof net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator noiseBased) { -+ generator = new net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator(biomeSource, noiseBased.settings); ++ generator = new net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator(biomeSource, noiseBased.generatorSettings()); + } else if (generator instanceof net.minecraft.world.level.levelgen.FlatLevelSource flatLevel) { + generator = new net.minecraft.world.level.levelgen.FlatLevelSource(flatLevel.settings(), biomeSource); + } @@ -1086,7 +1086,7 @@ + + // Paper start - respect global sound events gamerule + public List getPlayersForGlobalSoundGamerule() { -+ return this.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players(); ++ return this.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) ? this.getServer().getPlayerList().getPlayers() : this.players(); + } + + public double getGlobalSoundRangeSquared(java.util.function.Function rangeFunction) { @@ -1220,7 +1220,7 @@ + // CraftBukkit start + entity.valid = false; + if (!(entity instanceof ServerPlayer)) { -+ for (ServerPlayer player : ServerLevel.this.server.getPlayerList().players) { // Paper - call onEntityRemove for all online players ++ for (ServerPlayer player : ServerLevel.this.server.getPlayerList().getPlayers()) { // Paper - call onEntityRemove for all online players + player.getBukkitEntity().onEntityRemove(entity); + } + } 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 68042aa2e57d..7c2e7871c4a3 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 @@ -201,23 +201,6 @@ if (enderPearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -516,6 +_,16 @@ - } - } - -+ // CraftBukkit start -+ public void spawnIn(final ServerLevel level) { -+ if (level == null) { -+ throw new IllegalArgumentException("level can't be null"); -+ } -+ this.setLevel(level); -+ this.gameMode.setLevel(level); -+ } -+ // CraftBukkit end -+ - public void setExperiencePoints(final int amount) { - float limit = this.getXpNeededForNextLevel(); - float max = (limit - 1.0F) / limit; @@ -580,6 +_,11 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 48204d3eeaee..858029664bb2 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -256,9 +256,9 @@ + } + double speed; + if (this.player.getAbilities().flying) { -+ speed = this.player.getAbilities().flyingSpeed * 20f; ++ speed = this.player.getAbilities().getFlyingSpeed() * 20f; + } else { -+ speed = this.player.getAbilities().walkingSpeed * 10f; ++ speed = this.player.getAbilities().getWalkingSpeed() * 10f; + } + speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + @@ -755,16 +755,16 @@ deltaPackets = 1; } + // CraftBukkit start - handle custom speeds and skipped ticks -+ if (packet.hasRot || movedDist > 0) { ++ if (packet.hasRotation() || movedDist > 0) { + this.allowedPlayerTicks -= 1; + } else { + this.allowedPlayerTicks = 20; + } + double speed; + if (this.player.getAbilities().flying) { -+ speed = this.player.getAbilities().flyingSpeed * 20f; ++ speed = this.player.getAbilities().getFlyingSpeed() * 20f; + } else { -+ speed = this.player.getAbilities().walkingSpeed * 10f; ++ speed = this.player.getAbilities().getWalkingSpeed() * 10f; + } + // Paper start - Prevent moving into unloaded chunks + if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != targetX || this.player.getZ() != targetZ) && !level.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(targetX, targetY, targetZ).subtract(this.player.position())))) { @@ -821,16 +821,16 @@ + Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + + // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (packet.hasPos) { -+ to.setX(packet.x); -+ to.setY(packet.y); -+ to.setZ(packet.z); ++ if (packet.hasPosition()) { ++ to.setX(packet.getX(0.0)); ++ to.setY(packet.getY(0.0)); ++ to.setZ(packet.getZ(0.0)); + } + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packet.hasRot) { -+ to.setYaw(packet.yRot); -+ to.setPitch(packet.xRot); ++ if (packet.hasRotation()) { ++ to.setYaw(packet.getYRot(0.0F)); ++ to.setPitch(packet.getXRot(0.0F)); + } + + com.destroystokyo.paper.event.player.PlayerJumpEvent event = new com.destroystokyo.paper.event.player.PlayerJumpEvent(player, from, to); @@ -915,23 +915,23 @@ + Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + + // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (packet.hasPos) { -+ to.setX(packet.x); -+ to.setY(packet.y); -+ to.setZ(packet.z); ++ if (packet.hasPosition()) { ++ to.setX(packet.getX(0.0)); ++ to.setY(packet.getY(0.0)); ++ to.setZ(packet.getZ(0.0)); + } + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packet.hasRot) { -+ to.setYaw(packet.yRot); -+ to.setPitch(packet.xRot); ++ if (packet.hasRotation()) { ++ to.setYaw(packet.getYRot(0.0F)); ++ to.setPitch(packet.getXRot(0.0F)); + } + + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Mth.square(this.lastPosX - to.getX()) + Mth.square(this.lastPosY - to.getY()) + Mth.square(this.lastPosZ - to.getZ()); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + -+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { ++ if ((delta > 1f / 256 || deltaAngle > 10.0F) && !this.player.isImmobile()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch index e2d38ce27f53..3dc489fc8f03 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -96,7 +96,7 @@ + boolean handledByEvent = false; + // Try and handle the handshake through the event + if (com.destroystokyo.paper.event.player.PlayerHandshakeEvent.getHandlerList().getRegisteredListeners().length != 0) { // Hello? Can you hear me? -+ java.net.SocketAddress socketAddress = this.connection.address; ++ java.net.SocketAddress socketAddress = this.connection.getRemoteAddress(); + String hostnameOfRemote = socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getHostString() : java.net.InetAddress.getLoopbackAddress().getHostAddress(); + com.destroystokyo.paper.event.player.PlayerHandshakeEvent event = new com.destroystokyo.paper.event.player.PlayerHandshakeEvent(packet.hostName(), hostnameOfRemote, !proxyLogicEnabled); + if (event.callEvent()) { diff --git a/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch b/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch index b9b280a6aeab..b6b4c0c7b902 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/config/PrepareSpawnTask.java.patch @@ -183,7 +183,7 @@ + .map(tag -> { + org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer = player.getBukkitEntity(); + // Only update first played if it is older than the one we have -+ long modified = new java.io.File(net.minecraft.server.network.config.PrepareSpawnTask.this.server.playerDataStorage.getPlayerDir(), player.getStringUUID() + ".dat").lastModified(); ++ long modified = new java.io.File(PrepareSpawnTask.this.server.getPlayerList().playerIo.getPlayerDir(), player.getStringUUID() + ".dat").lastModified(); + if (modified < craftPlayer.getFirstPlayed()) { + craftPlayer.setFirstPlayed(modified); + } 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 99af78cb2fbd..aee225f04858 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 @@ -4,8 +4,8 @@ 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; -- public final List players = Lists.newArrayList(); -+ public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety +- private final List players = Lists.newArrayList(); ++ private final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety private final Map playersByUUID = Maps.newHashMap(); private final UserBanList bans; private final IpBanList ipBans; @@ -171,7 +171,7 @@ + // Paper end - Use single player info update packet on join + player.sentListPacket = true; + player.suppressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready -+ ((ServerLevel)player.level()).getChunkSource().chunkMap.addEntity(player); // Paper - Fire PlayerJoinEvent when Player is actually ready; track entity now ++ player.level().getChunkSource().addEntity(player); // Paper - Fire PlayerJoinEvent when Player is actually ready; track entity now + // CraftBukkit end + + //player.refreshEntityData(player); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn // Paper - THIS IS NOT NEEDED ANYMORE @@ -501,7 +501,7 @@ + // Paper start - Once we not reuse the player entity we can remove this. + if (!keepAllPlayerData) serverPlayer.reset(); -+ player.spawnIn(level); ++ player.setServerLevel(level); + player.unsetRemoved(); + player.setShiftKeyDown(false); + // Paper end diff --git a/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch index d16d9204ce28..7f3cf390c5ae 100644 --- a/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/SimpleContainer.java @@ -15,7 +_,90 @@ private final int size; - public final NonNullList items; + private final NonNullList items; + // Paper start - add fields and methods + public List transaction = new java.util.ArrayList<>(); diff --git a/paper-server/patches/sources/net/minecraft/world/effect/SaturationMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/SaturationMobEffect.java.patch index 040d7f476b31..95cf08f60763 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/SaturationMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/SaturationMobEffect.java.patch @@ -6,7 +6,7 @@ if (mob instanceof Player player) { - player.getFoodData().eat(amplification + 1, 1.0F); + // CraftBukkit start -+ int oldFoodLevel = player.getFoodData().foodLevel; ++ int oldFoodLevel = player.getFoodData().getFoodLevel(); + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, amplification + 1 + oldFoodLevel); + if (!event.isCancelled()) { + player.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); 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 5ce895506263..65564828f602 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 @@ -110,8 +110,8 @@ public double yOld; public double zOld; public boolean noPhysics; -- public final RandomSource random = RandomSource.create(); -+ public final RandomSource random = SHARED_RANDOM; // Paper - Share random for entities to make them more random +- protected final RandomSource random = RandomSource.create(); ++ protected final RandomSource random = SHARED_RANDOM; // Paper - Share random for entities to make them more random public int tickCount; private int remainingFireTicks; private final EntityFluidInteraction fluidInteraction = new EntityFluidInteraction(Set.of(FluidTags.WATER, FluidTags.LAVA)); @@ -125,7 +125,7 @@ private long pistonDeltasGameTime; private EntityDimensions dimensions; @@ -293,6 +_,7 @@ - public boolean hasVisualFire; + private boolean hasVisualFire; private Vec3 lastKnownSpeed = Vec3.ZERO; private @Nullable Vec3 lastKnownPosition; + public net.kyori.adventure.util.TriState visualFire = net.kyori.adventure.util.TriState.NOT_SET; // Paper - improve visual fire API diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch index 49b9f128fccf..49c46543941d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch @@ -1,15 +1,17 @@ --- a/net/minecraft/world/entity/ItemBasedSteering.java +++ b/net/minecraft/world/entity/ItemBasedSteering.java -@@ -47,4 +_,12 @@ - public int boostTimeTotal() { - return this.entityData.get(this.boostTimeAccessor); +@@ -34,6 +_,14 @@ + return true; } -+ + + // CraftBukkit start -+ public void setBoostTicks(int ticks) { ++ public void boost(final int boostTime) { + this.boosting = true; + this.boostTime = 0; -+ this.entityData.set(this.boostTimeAccessor, ticks); ++ this.entityData.set(this.boostTimeAccessor, boostTime); + } + // CraftBukkit end - } ++ + public void tickBoost() { + if (this.boosting && this.boostTime++ > this.boostTimeTotal()) { + this.boosting = false; 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 b6320b5cc5d5..b96085dbb22a 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 @@ -847,13 +847,7 @@ this.level().broadcastEntityEvent(this, EntityEvent.DEATH); } -@@ -1489,18 +_,23 @@ - protected void createWitherRose(final @Nullable LivingEntity killer) { - if (this.level() instanceof ServerLevel serverLevel) { - boolean var6 = false; -- if (killer instanceof WitherBoss) { -+ if (this.dead && killer instanceof WitherBoss) { // Paper - if (serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { +@@ -1494,13 +_,18 @@ BlockPos pos = this.blockPosition(); BlockState state = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(pos).isAir() && state.canSurvive(this.level(), pos)) { @@ -1356,11 +1350,11 @@ } public void onAttack() { -+ // Paper start -+ onAttack(null); ++ // Paper start ++ this.onAttack(null); + } + public void onAttack(Entity entity) { -+ // Paper end ++ // Paper end } public void detectEquipmentUpdates() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index 1276bcb416dd..3fad4afd6618 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -18,7 +18,7 @@ @@ -132,6 +_,7 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; - public GoalSelector goalSelector; + protected final GoalSelector goalSelector; + public net.minecraft.world.entity.ai.goal.@Nullable FloatGoal goalFloat; // Paper - Allow nerfed mobs to jump and float public GoalSelector targetSelector; private @Nullable LivingEntity target; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch index 9d09a0a9ef99..9c3878e575c5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/entity/animal/Animal.java @@ -45,6 +_,7 @@ private static final int DEFAULT_IN_LOVE_TIME = 0; - public int inLove = 0; + private int inLove = 0; public @Nullable EntityReference loveCause; + public @Nullable ItemStack breedItem; // CraftBukkit - Add breedItem variable 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 1499eb1343f5..ce9d7215ff33 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 @@ -81,7 +81,7 @@ } - public void duplicateAllay() { -+ @Nullable public Allay duplicateAllay() { // CraftBukkit - return allay ++ public @Nullable Allay duplicateAllay() { // CraftBukkit - return allay Allay allay = EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); if (allay != null) { allay.snapTo(this.position()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch deleted file mode 100644 index 6b8f13bc2542..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Mannequin.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/decoration/Mannequin.java -+++ b/net/minecraft/world/entity/decoration/Mannequin.java -@@ -34,7 +_,7 @@ - Mannequin.class, EntityDataSerializers.OPTIONAL_COMPONENT - ); - public static final byte ALL_LAYERS = (byte)Arrays.stream(PlayerModelPart.values()).mapToInt(PlayerModelPart::getMask).reduce(0, (a, b) -> a | b); -- private static final Set VALID_POSES = Set.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING, Pose.FALL_FLYING, Pose.SLEEPING); -+ public static final Set VALID_POSES = Set.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING, Pose.FALL_FLYING, Pose.SLEEPING); // Paper - public - public static final Codec POSE_CODEC = Pose.CODEC - .validate(pose -> VALID_POSES.contains(pose) ? DataResult.success(pose) : DataResult.error(() -> "Invalid pose: " + pose.getSerializedName())); - private static final Codec LAYERS_CODEC = PlayerModelPart.CODEC diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch index 3420bb386c81..4172da4efebc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch @@ -3,7 +3,7 @@ @@ -55,6 +_,7 @@ public int maxSwell = 30; public int explosionRadius = 3; - public boolean droppedSkulls; + private boolean droppedSkulls; + public @Nullable Entity entityIgniter; // CraftBukkit public Creeper(final EntityType type, final Level level) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch index 70b864f1a433..7548f0518391 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Guardian.java.patch @@ -4,7 +4,7 @@ private int clientSideAttackTime; private boolean clientSideTouchedGround; public @Nullable RandomStrollGoal randomStrollGoal; -+ public Guardian.GuardianAttackGoal guardianAttackGoal; // CraftBukkit - add field ++ public @Nullable GuardianAttackGoal guardianAttackGoal; // CraftBukkit - add field public Guardian(final EntityType type, final Level level) { super(type, level); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch index b8b3b8748bd9..4afe8bdd4869 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch @@ -3,7 +3,7 @@ @@ -196,12 +_,20 @@ } - public void startConverting(final @Nullable UUID player, final int time) { + private void startConverting(final @Nullable UUID player, final int time) { + // Paper start - missing entity behaviour api - converting without entity event + this.startConverting(player, time, true); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch index 3c496ba166cd..64cbf2b02ccc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch @@ -16,7 +16,7 @@ + boolean noEffects = this.getItem().getOrDefault(net.minecraft.core.component.DataComponents.POTION_CONTENTS, net.minecraft.world.item.alchemy.PotionContents.EMPTY).hasEffects(); // Paper - Fix potions splash events + // CraftBukkit start + org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, hitResult, cloud); -+ if (!(event.isCancelled() || cloud.isRemoved() || (!event.allowsEmptyCreation() && (noEffects && !cloud.potionContents.hasEffects())))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling ++ if (!(event.isCancelled() || cloud.isRemoved() || (!event.allowsEmptyCreation() && (noEffects && !cloud.get(net.minecraft.core.component.DataComponents.POTION_CONTENTS).hasEffects())))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling level.addFreshEntity(cloud); + } else { + cloud.discard(null); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch index ad9fdfdd241a..bfa8dbad4a3a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch @@ -6,8 +6,8 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity { - private NonNullList itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); + private NonNullList itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 - public @Nullable ResourceKey lootTable; - public long lootTableSeed; + private @Nullable ResourceKey lootTable; + private long lootTableSeed; + private final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(); // Paper - LootTable API protected AbstractMinecartContainer(final EntityType type, final Level level) { diff --git a/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch b/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch index 1612f8473deb..ccc7d39dbe9e 100644 --- a/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/food/FoodData.java +++ b/net/minecraft/world/food/FoodData.java @@ -15,6 +_,11 @@ - public float saturationLevel = FoodConstants.START_SATURATION; + private float saturationLevel = FoodConstants.START_SATURATION; public float exhaustionLevel; private int tickTimer; + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch index 7e5de9a28a0a..5aa7d879db29 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch @@ -3,7 +3,7 @@ @@ -13,6 +_,10 @@ private static final int USE_ROW_SLOT_START = 36; private static final int USE_ROW_SLOT_END = 45; - public final Container dispenser; + private final Container dispenser; + // CraftBukkit start + private org.bukkit.craftbukkit.inventory.@org.jspecify.annotations.Nullable CraftInventoryView view = null; + private final Inventory inventory; 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 index 9b17c075014e..d1a861696089 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch @@ -5,7 +5,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { + private static @Nullable ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper - Fix PlayerBucketEmptyEvent result itemstack - public final Fluid content; + protected final Fluid content; public BucketItem(final Fluid content, final Item.Properties properties) { @@ -57,7 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch index 521dd59f86c5..6e6be571f138 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemCooldowns.java.patch @@ -14,3 +14,18 @@ this.cooldowns.put(cooldownGroup, new ItemCooldowns.CooldownInstance(this.tickCount, this.tickCount + time)); this.onCooldownStarted(cooldownGroup, time); } +@@ -73,4 +_,14 @@ + + private record CooldownInstance(int startTime, int endTime) { + } ++ ++ // Paper start - util ++ public int getRemainingCooldown(final Identifier cooldownGroup) { ++ final CooldownInstance cooldown = this.cooldowns.get(cooldownGroup); ++ if (cooldown == null) { ++ return 0; ++ } ++ return Math.max(0, cooldown.endTime() - this.tickCount); ++ } ++ // Paper end + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index 91e1f5c0b79b..0e3171b6949c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -238,7 +238,7 @@ if (this.isBroken()) { Item item = this.getItem(); + // CraftBukkit start - Check for item breaking -+ if (this.count == 1 && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent ++ if (this.getCount() == 1 && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(serverPlayer, this); // Paper - Add EntityDamageItemEvent + } + // CraftBukkit end @@ -356,7 +356,7 @@ public void consume(final int amount, final @Nullable LivingEntity owner) { - if (owner == null || !owner.hasInfiniteMaterials()) { -+ if ((owner == null || !owner.hasInfiniteMaterials()) && this != ItemStack.EMPTY) { // CraftBukkit ++ if ((owner == null || !owner.hasInfiniteMaterials())) { this.shrink(amount); } } diff --git a/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch index 9cbecc8fa477..a159dffc509d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ServerItemCooldowns.java.patch @@ -1,18 +1,10 @@ --- a/net/minecraft/world/item/ServerItemCooldowns.java +++ b/net/minecraft/world/item/ServerItemCooldowns.java -@@ -11,6 +_,50 @@ +@@ -11,6 +_,42 @@ this.player = player; } + // Paper start - Add PlayerItemCooldownEvent -+ private int getCurrentCooldown(final Identifier groupId) { -+ final net.minecraft.world.item.ItemCooldowns.CooldownInstance cooldownInstance = this.cooldowns.get(groupId); -+ if (cooldownInstance == null) { -+ return 0; -+ } -+ return Math.max(0, cooldownInstance.endTime() - this.tickCount); -+ } -+ + @Override + public void addCooldown(ItemStack item, int duration) { + final Identifier cooldownGroup = this.getCooldownGroup(item); @@ -25,7 +17,7 @@ + if (event.callEvent()) { + this.addCooldown(cooldownGroup, event.getCooldown(), false); + } else { -+ this.player.connection.send(new ClientboundCooldownPacket(cooldownGroup, this.getCurrentCooldown(cooldownGroup))); ++ this.player.connection.send(new ClientboundCooldownPacket(cooldownGroup, this.getRemainingCooldown(cooldownGroup))); + } + } + @@ -38,7 +30,7 @@ + time + ); + if (!event.callEvent()) { -+ this.player.connection.send(new ClientboundCooldownPacket(cooldownGroup, this.getCurrentCooldown(cooldownGroup))); ++ this.player.connection.send(new ClientboundCooldownPacket(cooldownGroup, this.getRemainingCooldown(cooldownGroup))); + return; + } + 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 index b1a73a1154b9..603f4f408ce2 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch @@ -24,7 +24,7 @@ + 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 ++ trident.setPickupItemStack(thrownItemStack.copy()); // SPIGOT-4511 update since damage call moved - use thrownItemStack; count = 1 + if (event.shouldConsume()) { + itemStack.consume(1, player); + } 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 ab2b35cb7a96..3a05f08dc81b 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 @@ -203,7 +203,7 @@ + @Nullable + @Override + public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) { -+ return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z); ++ return ((ServerLevel)this).getChunkSource().getChunkAtIfLoadedImmediately(x, z); + } + + @Override 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 1d718731767a..b3fcedc0af12 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 @@ -129,7 +129,7 @@ public void popExperience(final ServerLevel level, final BlockPos pos, final int amount) { + // Paper start - add entity parameter -+ popExperience(level, pos, amount, null); ++ this.popExperience(level, pos, amount, null); + } + + public void popExperience(ServerLevel level, BlockPos pos, int amount, net.minecraft.world.entity.@Nullable Entity entity) { 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 index 0ccf56fb4699..262ba00eec7a 100644 --- 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 @@ -31,7 +31,7 @@ + // CraftBukkit start + // player.getFoodData().eat(2, 0.1F); + // int bites = state.getValue(BITES); // Paper - move up -+ int oldFoodLevel = player.getFoodData().foodLevel; ++ int oldFoodLevel = player.getFoodData().getFoodLevel(); + + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, 2 + oldFoodLevel); + 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 e8611b4ad6e4..8d993a6852cf 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 @@ -3,7 +3,7 @@ @@ -21,6 +_,7 @@ private final VibrationSystem.Listener vibrationListener; private final VibrationSystem.User vibrationUser; - public int lastVibrationFrequency = 0; + private int lastVibrationFrequency = 0; + @Nullable public Integer rangeOverride = null; // Paper - Configurable sculk sensor listener range protected SculkSensorBlockEntity(final BlockEntityType type, final BlockPos worldPosition, final BlockState blockState) { 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 539fac6942f6..b74db39b6f37 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 @@ -160,7 +160,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); -+ if (dropExperience) {this.getBlock().popExperience(level, pos, this.getBlock().getExpDrop(this.asState(), level, pos, tool, true));} // Paper - Properly handle xp dropping ++ if (dropExperience) this.getBlock().popExperience(level, pos, this.getBlock().getExpDrop(this.asState(), level, pos, tool, true)); // Paper - Properly handle xp dropping } public List getDrops(final LootParams.Builder params) { 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 1d9a311a1e3e..402350f5a783 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 @@ -3,9 +3,9 @@ @@ -87,13 +_,21 @@ }; private final Map tickersInLevel = Maps.newHashMap(); - public boolean loaded; -- public final Level level; -+ public final ServerLevel level; // CraftBukkit - type + private boolean loaded; +- private final Level level; ++ private final ServerLevel level; // CraftBukkit - type private @Nullable Supplier fullStatus; private LevelChunk.@Nullable PostLoadProcessor postLoad; private final Int2ObjectMap gameEventListenerRegistrySections; @@ -73,7 +73,7 @@ + || this.sections[sectionIndex].nonEmptyBlockCount == 0) { + return Blocks.AIR.defaultBlockState(); + } -+ return this.sections[sectionIndex].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15); ++ return this.sections[sectionIndex].getStates().get((y & 15) << 8 | (z & 15) << 4 | x & 15); + } + @Override @@ -114,7 +114,7 @@ LevelChunkSection currentSection = this.sections[sectionIndex]; if (!currentSection.hasOnlyAir()) { - return currentSection.getFluidState(x & 15, y & 15, z & 15); -+ return currentSection.states.get((y & 15) << 8 | (z & 15) << 4 | x & 15).getFluidState(); // Paper - Perf: Optimise Chunk#getFluid ++ return currentSection.getStates().get((y & 15) << 8 | (z & 15) << 4 | x & 15).getFluidState(); // Paper - Perf: Optimise Chunk#getFluid } } 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 b57440711af9..bfebfece049b 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 @@ -9,7 +9,7 @@ private short fluidCount; private short tickingBlockCount; private short tickingFluidCount; - public final PalettedContainer states; + private final PalettedContainer states; - private PalettedContainerRO> biomes; + private PalettedContainer> biomes; // CraftBukkit - read/write 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 418f1511929b..e674e94cd9d0 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 @@ -17,13 +17,12 @@ public final List carriedBy = Lists.newArrayList(); public final Map carriedByPlayers = Maps.newHashMap(); private final Map bannerMarkers = Maps.newHashMap(); -@@ -76,6 +_,13 @@ +@@ -76,6 +_,12 @@ private final Map frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; + // CraftBukkit start + public final org.bukkit.craftbukkit.map.CraftMapView mapView; -+ private final org.bukkit.craftbukkit.CraftServer server; + public java.util.UUID uniqueId; + public MapId id; + // CraftBukkit end @@ -31,14 +30,13 @@ public static SavedDataType type(final MapId id) { return new SavedDataType<>(Identifier.withDefaultNamespace(id.key()), () -> { throw new IllegalStateException("Should never create an empty map saved data"); -@@ -98,7 +_,29 @@ +@@ -98,7 +_,28 @@ this.trackingPosition = trackingPosition; this.unlimitedTracking = unlimitedTracking; this.locked = locked; - } + // CraftBukkit start + this.mapView = new org.bukkit.craftbukkit.map.CraftMapView(this); -+ this.server = (org.bukkit.craftbukkit.CraftServer) org.bukkit.Bukkit.getServer(); + this.vanillaRender.buffer = colors; // Paper - Use Vanilla map renderer when possible + // CraftBukkit end + } @@ -99,7 +97,7 @@ @@ -375,7 +_,12 @@ } - public void setColorsDirty(final int x, final int y) { + private void setColorsDirty(final int x, final int y) { - this.setDirty(); + // Paper start - Fix unnecessary map data saves + this.setColorsDirty(x, y, true); diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java index 0a9da3d25d7f..559df35d7c88 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java @@ -140,7 +140,7 @@ public Location getNextPoint() { if (this.path.isDone()) { return null; } - return CraftLocation.toBukkit(this.path.nodes.get(this.path.getNextNodeIndex()), PaperPathfinder.this.entity.level()); + return CraftLocation.toBukkit(this.path.getNode(this.path.getNextNodeIndex()), PaperPathfinder.this.entity.level()); } } } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java index a617e3d61826..83f698af8581 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java @@ -212,7 +212,7 @@ private GoalSelector getHandle(CraftMob mob, EnumSet types) { if (types.contains(GoalType.TARGET)) { return mob.getHandle().targetSelector; } else { - return mob.getHandle().goalSelector; + return mob.getHandle().getGoalSelector(); } } @@ -220,7 +220,7 @@ private GoalSelector getHandle(CraftMob mob, GoalType type) { if (type == GoalType.TARGET) { return mob.getHandle().targetSelector; } else { - return mob.getHandle().goalSelector; + return mob.getHandle().getGoalSelector(); } } } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java b/paper-server/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java index 6ed2114f577c..13b03dab807c 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java @@ -20,7 +20,7 @@ class PaperServerListPingEventImpl extends PaperServerListPingEvent { @Override protected final Object[] getOnlinePlayers() { - return this.server.getPlayerList().players.toArray(); + return this.server.getPlayerList().getPlayers().toArray(); } @Override diff --git a/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java index 6d986b9f3b8b..ceaf63c76272 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -188,8 +188,12 @@ public void setProperty(@NotNull String propertyName, @Nullable Property propert @Override public @NotNull ResolvableProfile buildResolvableProfile() { - if (emptyName != emptyUUID && this.properties.isEmpty()) { - return new ResolvableProfile.Dynamic(emptyName ? Either.right(this.profile.id()) : Either.left(this.profile.name()), PlayerSkin.Patch.EMPTY); + if (this.emptyName != this.emptyUUID && this.properties.isEmpty()) { + if (this.emptyName) { + return ResolvableProfile.createUnresolved(this.profile.id()); + } else { + return ResolvableProfile.createUnresolved(this.profile.name()); + } } return ResolvableProfile.createResolved(this.buildGameProfile()); } diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java index 90f6bec5dfef..81ce59c7f865 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java @@ -283,8 +283,7 @@ static Function> nullableGetter(final Function TEXT_COMPONENT_MAP_CODEC = mapCodec((instance) -> { return instance.group(Codec.STRING.fieldOf("text").forGetter(TextComponent::content)).apply(instance, Component::text); }); - static final Codec PRIMITIVE_ARG_CODEC = ExtraCodecs.JAVA.validate(TranslatableContents::filterAllowedArguments); - static final Codec ARG_CODEC = Codec.either(PRIMITIVE_ARG_CODEC, COMPONENT_CODEC).flatXmap((primitiveOrComponent) -> { + static final Codec ARG_CODEC = Codec.either(TranslatableContents.PRIMITIVE_ARG_CODEC, COMPONENT_CODEC).flatXmap((primitiveOrComponent) -> { return primitiveOrComponent.map(o -> { final TranslationArgument arg; if (o instanceof String s) { diff --git a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java index 568d12d00699..774a1b05212f 100644 --- a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java +++ b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockController.java @@ -40,7 +40,7 @@ public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockSta } - public void onPlayerLeftClickBlock(ServerPlayerGameMode serverPlayerGameMode, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) { + public void onPlayerLeftClickBlock(Level level, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) { } } diff --git a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java index 582937bbb8b5..57e091df0758 100644 --- a/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java +++ b/paper-server/src/main/java/io/papermc/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -615,9 +615,9 @@ public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockSta } @Override - public void onPlayerLeftClickBlock(ServerPlayerGameMode serverPlayerGameMode, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) { + public void onPlayerLeftClickBlock(Level level, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) { if (blockPos.getY() <= maxBlockHeightUpdatePosition) { - updateNearbyBlocks(serverPlayerGameMode.level, blockPos); + updateNearbyBlocks(level, blockPos); } } diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java index 0be14f948308..4bee7701f7c5 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java @@ -171,7 +171,7 @@ private void printPlayerMobcaps(final CommandSender sender, final String[] args) sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for player: "), Component.text(player.getName(), NamedTextColor.GREEN))); sender.sendMessage(createMobcapsComponent( - category -> level.chunkSource.chunkMap.getMobCountNear(serverPlayer, category), + category -> level.getChunkSource().chunkMap.getMobCountNear(serverPlayer, category), category -> level.getWorld().getSpawnLimitUnsafe(org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category)) )); } diff --git a/paper-server/src/main/java/io/papermc/paper/potion/PaperPotionBrewer.java b/paper-server/src/main/java/io/papermc/paper/potion/PaperPotionBrewer.java index d9390227a2bb..9bba6ce4d4f9 100644 --- a/paper-server/src/main/java/io/papermc/paper/potion/PaperPotionBrewer.java +++ b/paper-server/src/main/java/io/papermc/paper/potion/PaperPotionBrewer.java @@ -46,7 +46,7 @@ public void addPotionMix(final PotionMix potionMix) { @Override public void removePotionMix(final NamespacedKey key) { - this.minecraftServer.potionBrewing.removePotionMix(key); + this.minecraftServer.potionBrewing().removePotionMix(key); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/world/migration/WorldMigrationContext.java b/paper-server/src/main/java/io/papermc/paper/world/migration/WorldMigrationContext.java index 4e6a8b78f01d..f2bc81da1885 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/migration/WorldMigrationContext.java +++ b/paper-server/src/main/java/io/papermc/paper/world/migration/WorldMigrationContext.java @@ -18,7 +18,7 @@ record WorldMigrationContext( ResourceKey dimensionKey ) { Path baseRoot() { - return this.rootAccess.levelDirectory.path(); + return this.rootAccess.getLevelDirectory().path(); } Path targetDimensionPath() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index c8d179d936d5..136fcace6e37 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -12,9 +12,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.SectionPos; -import net.minecraft.nbt.NbtOps; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.DataLayer; @@ -23,7 +22,6 @@ import net.minecraft.world.level.chunk.PalettedContainer; import net.minecraft.world.level.chunk.PalettedContainerRO; import net.minecraft.world.level.chunk.status.ChunkStatus; -import net.minecraft.world.level.chunk.storage.SerializableChunkData; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.WorldgenRandom; import net.minecraft.world.level.lighting.LevelLightEngine; @@ -45,7 +43,7 @@ import org.bukkit.plugin.Plugin; public class CraftChunk implements Chunk { - private final ServerLevel level; + private final Level level; private final int x; private final int z; private static final PalettedContainer emptyBlockIDs = FeatureHooks.emptyPalettedBlockContainer(); @@ -53,12 +51,12 @@ public class CraftChunk implements Chunk { private static final byte[] EMPTY_LIGHT = new byte[2048]; public CraftChunk(net.minecraft.world.level.chunk.LevelChunk chunk) { - this.level = chunk.level; + this.level = chunk.getLevel(); this.x = chunk.getPos().x(); this.z = chunk.getPos().z(); } - public CraftChunk(ServerLevel level, int x, int z) { + public CraftChunk(Level level, int x, int z) { this.level = level; this.x = x; this.z = z; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 97b097eca4f1..1aa8f1e0a309 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -42,7 +42,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa protected CraftOfflinePlayer(CraftServer server, NameAndId nameAndId) { this.server = server; this.nameAndId = nameAndId; - this.storage = server.console.playerDataStorage; + this.storage = server.console.getPlayerList().playerIo; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java index c4d4e2b35ea9..21d8be83ab0a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRaid.java @@ -38,14 +38,14 @@ public long getActiveTicks() { @Override public int getBadOmenLevel() { - return this.handle.raidOmenLevel; + return this.handle.getRaidOmenLevel(); } @Override public void setBadOmenLevel(int badOmenLevel) { int max = this.handle.getMaxRaidOmenLevel(); Preconditions.checkArgument(0 <= badOmenLevel && badOmenLevel <= max, "Bad Omen level must be between 0 and %s", max); - this.handle.raidOmenLevel = badOmenLevel; + this.handle.setRaidOmenLevel(badOmenLevel); } @Override @@ -74,7 +74,7 @@ public int getSpawnedGroups() { @Override public int getTotalGroups() { - return this.handle.numGroups + (this.handle.raidOmenLevel > 1 ? 1 : 0); + return this.handle.numGroups + (this.handle.getRaidOmenLevel() > 1 ? 1 : 0); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 622d023bf1e0..4ad3230bde2a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -59,7 +59,6 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ReloadableServerRegistries; -import net.minecraft.server.WorldLoader; import net.minecraft.server.bossevents.CustomBossEvent; import net.minecraft.server.commands.ReloadCommand; import net.minecraft.server.dedicated.DedicatedPlayerList; @@ -77,6 +76,7 @@ import net.minecraft.server.players.UserWhiteListEntry; import net.minecraft.tags.TagKey; import net.minecraft.util.GsonHelper; +import net.minecraft.util.Util; import net.minecraft.util.datafix.DataFixers; import net.minecraft.world.damagesource.DamageType; import net.minecraft.world.entity.EntityType; @@ -398,7 +398,7 @@ public final boolean isGlobalTickThread() { public CraftServer(DedicatedServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; - this.playerView = MCUtil.transformUnmodifiable(playerList.players, ServerPlayer::getBukkitEntity); + this.playerView = MCUtil.transformUnmodifiable(playerList.getPlayers(), ServerPlayer::getBukkitEntity); this.serverVersion = io.papermc.paper.ServerBuildInfo.buildInfo().asString(io.papermc.paper.ServerBuildInfo.StringRepresentation.VERSION_SIMPLE); // Paper - improve version this.structureManager = new CraftStructureManager(console.getStructureManager(), console.registryAccess()); this.serverTickManager = new CraftServerTickManager(console.tickRateManager()); @@ -610,7 +610,7 @@ public void syncCommands() { Commands dispatcher = this.getHandle().getServer().getCommands(); // Paper - We now register directly to the dispatcher. // Refresh commands - for (ServerPlayer player : this.getHandle().players) { + for (ServerPlayer player : this.getHandle().getPlayers()) { dispatcher.sendCommands(player); } } @@ -1284,7 +1284,7 @@ public World createWorld(WorldCreator creator) { ServerLevel serverLevel = new ServerLevel( this.console, - this.console.executor, + Util.backgroundExecutor(), this.console.storageSource, genSettingsFinal, dimensionKey, @@ -2183,7 +2183,7 @@ public Path getLevelDirectory() { @Override public OfflinePlayer[] getOfflinePlayers() { - PlayerDataStorage storage = this.console.playerDataStorage; + PlayerDataStorage storage = this.console.getPlayerList().playerIo; String[] files = storage.getPlayerDir().list((dir, name) -> name.endsWith(".dat")); Set players = new HashSet<>(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 6fe05d7ab465..0c1e9abfa9eb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -259,7 +259,7 @@ public int getPlayerCount() { @Override public BiomeProvider vanillaBiomeProvider() { - ServerChunkCache serverCache = this.getHandle().chunkSource; + ServerChunkCache serverCache = this.getHandle().getChunkSource(); final net.minecraft.world.level.chunk.ChunkGenerator gen = serverCache.getGenerator(); net.minecraft.world.level.biome.BiomeSource biomeSource; @@ -432,7 +432,7 @@ public boolean isChunkGenerated(int x, int z) { @Override public Chunk[] getLoadedChunks() { - ServerChunkCache serverChunkCache = this.getHandle().chunkSource; + ServerChunkCache serverChunkCache = this.getHandle().getChunkSource(); ReferenceList chunks = new ReferenceList<>(new Chunk[serverChunkCache.fullChunks.size()]); for (PrimitiveIterator.OfLong iterator = serverChunkCache.fullChunks.keyIterator(); iterator.hasNext();) { @@ -570,7 +570,7 @@ public boolean addPluginChunkTicket(int x, int z, Plugin plugin) { Preconditions.checkArgument(plugin != null, "null plugin"); Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled"); - final DistanceManager distanceManager = this.world.getChunkSource().chunkMap.distanceManager; + final DistanceManager distanceManager = this.world.getChunkSource().chunkMap.getDistanceManager(); if (distanceManager.ticketStorage.addPluginRegionTicket(new ChunkPos(x, z), plugin)) { this.getChunkAt(x, z); // ensure it's loaded return true; @@ -583,7 +583,7 @@ public boolean addPluginChunkTicket(int x, int z, Plugin plugin) { public boolean removePluginChunkTicket(int x, int z, Plugin plugin) { Preconditions.checkNotNull(plugin, "null plugin"); - final DistanceManager distanceManager = this.world.getChunkSource().chunkMap.distanceManager; + final DistanceManager distanceManager = this.world.getChunkSource().chunkMap.getDistanceManager(); return distanceManager.ticketStorage.removePluginRegionTicket(new ChunkPos(x, z), plugin); } @@ -591,7 +591,7 @@ public boolean removePluginChunkTicket(int x, int z, Plugin plugin) { public void removePluginChunkTickets(Plugin plugin) { Preconditions.checkNotNull(plugin, "null plugin"); - DistanceManager chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; + DistanceManager chunkDistanceManager = this.world.getChunkSource().chunkMap.getDistanceManager(); chunkDistanceManager.ticketStorage.removeAllPluginRegionTickets(TicketType.PLUGIN_TICKET, ChunkMap.FORCED_TICKET_LEVEL, plugin); } @@ -836,7 +836,7 @@ public boolean isDayTime() { @Override public long getGameTime() { - return this.world.levelData.getGameTime(); + return this.world.getLevelData().getGameTime(); } @Override @@ -1935,7 +1935,7 @@ public Raid locateNearestRaid(Location location, int radius) { // Paper start - more Raid API @Override public @Nullable Raid getRaid(final int id) { - final net.minecraft.world.entity.raid.@Nullable Raid nmsRaid = this.world.getRaids().raidMap.get(id); + final net.minecraft.world.entity.raid.@Nullable Raid nmsRaid = this.world.getRaids().get(id); return nmsRaid != null ? new CraftRaid(nmsRaid, this.world) : null; } // Paper end - more Raid API diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java index cc6e8b25f864..49bb995b25b3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java @@ -118,7 +118,7 @@ public CraftBanner copy(Location location) { @Override public net.kyori.adventure.text.Component customName() { - return this.getSnapshot().name == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().name); + return this.getSnapshot().getCustomName() == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().getCustomName()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java index 921452422c41..7aa0cf0f2abd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java @@ -37,16 +37,12 @@ public Inventory getInventory() { @Override public void open() { this.requirePlaced(); - if (!this.getBlockEntity().openersCounter.opened) { - BlockState state = this.getBlockEntity().getBlockState(); - boolean open = state.getValue(BarrelBlock.OPEN); + if (!this.getBlockEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level level) { + BlockState block = this.getBlockEntity().getBlockState(); + int openCount = this.getBlockEntity().openersCounter.getOpenerCount(); - if (!open) { - this.getBlockEntity().updateBlockState(state, true); - if (this.getWorldHandle() instanceof net.minecraft.world.level.Level) { - this.getBlockEntity().playSound(state, SoundEvents.BARREL_OPEN); - } - } + this.getBlockEntity().openersCounter.onOpenAPI(level, this.getPosition(), block); + this.getBlockEntity().openersCounter.openerCountChangedAPI(level, this.getPosition(), block, openCount, openCount + 1); } this.getBlockEntity().openersCounter.opened = true; } @@ -54,12 +50,12 @@ public void open() { @Override public void close() { this.requirePlaced(); - if (this.getBlockEntity().openersCounter.opened) { - BlockState state = this.getBlockEntity().getBlockState(); - this.getBlockEntity().updateBlockState(state, false); - if (this.getWorldHandle() instanceof net.minecraft.world.level.Level) { - this.getBlockEntity().playSound(state, SoundEvents.BARREL_CLOSE); - } + if (this.getBlockEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level level) { + BlockState block = this.getBlockEntity().getBlockState(); + int openCount = this.getBlockEntity().openersCounter.getOpenerCount(); + + this.getBlockEntity().openersCounter.onCloseAPI(level, this.getPosition(), block); + this.getBlockEntity().openersCounter.openerCountChangedAPI(level, this.getPosition(), block, openCount, 0); } this.getBlockEntity().openersCounter.opened = false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index daf00bcb98b4..950cf04aab80 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -83,7 +83,7 @@ public void setSecondaryEffect(PotionEffectType effect) { @Override public net.kyori.adventure.text.Component customName() { final BeaconBlockEntity beacon = this.getSnapshot(); - return beacon.name != null ? io.papermc.paper.adventure.PaperAdventure.asAdventure(beacon.name) : null; + return beacon.getCustomName() != null ? io.papermc.paper.adventure.PaperAdventure.asAdventure(beacon.getCustomName()) : null; } @Override @@ -94,7 +94,7 @@ public void customName(final net.kyori.adventure.text.Component customName) { @Override public String getCustomName() { BeaconBlockEntity beacon = this.getSnapshot(); - return beacon.name != null ? CraftChatMessage.fromComponent(beacon.name) : null; + return beacon.getCustomName() != null ? CraftChatMessage.fromComponent(beacon.getCustomName()) : null; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java index 78744b74d7a0..15a8d8c6f168 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java @@ -215,7 +215,7 @@ public boolean isInteractable() { @Override public float getHardness() { - return this.getHandle().defaultBlockState().destroySpeed; + return this.getHandle().defaultBlockState().getDestroySpeed(null, null); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index c6ef79a3f0fd..20a3485a3818 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -27,7 +27,7 @@ protected CraftContainer(CraftContainer state, Location location) { @Override public boolean isLocked() { - return this.getSnapshot().lockKey != LockCode.NO_LOCK; + return this.getSnapshot().isLocked(); } @Override @@ -74,7 +74,7 @@ public void customName(final net.kyori.adventure.text.Component customName) { @Override public String getCustomName() { T container = this.getSnapshot(); - return container.name != null ? CraftChatMessage.fromComponent(container.getCustomName()) : null; + return container.getCustomName() != null ? CraftChatMessage.fromComponent(container.getCustomName()) : null; } @Override @@ -86,7 +86,7 @@ public void setCustomName(String name) { public void applyTo(T blockEntity) { super.applyTo(blockEntity); - if (this.getSnapshot().name == null) { + if (this.getSnapshot().getCustomName() == null) { blockEntity.name = null; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java index ece2d91a5684..24d6a5659b3d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java @@ -55,9 +55,8 @@ public boolean dispense() { Block block = this.getBlock(); if (block.getType() == Material.DISPENSER) { CraftWorld world = (CraftWorld) this.getWorld(); - DispenserBlock dispense = (DispenserBlock) Blocks.DISPENSER; - dispense.dispenseFrom(world.getHandle(), this.getHandle(), this.getPosition()); + ((DispenserBlock) Blocks.DISPENSER).dispenseFrom(world.getHandle(), this.getHandle(), this.getPosition()); return true; } else { return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java index 8653fc54d4e4..4c97a285216f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java @@ -42,9 +42,8 @@ public void drop() { Block block = this.getBlock(); if (block.getType() == Material.DROPPER) { CraftWorld world = (CraftWorld) this.getWorld(); - DropperBlock drop = (DropperBlock) Blocks.DROPPER; - drop.dispenseFrom(world.getHandle(), this.getHandle(), this.getPosition()); + ((DropperBlock) Blocks.DROPPER).dispenseFrom(world.getHandle(), this.getHandle(), this.getPosition()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java index 0daa6c97df01..1e4845f114b1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java @@ -22,7 +22,7 @@ protected CraftLootable(CraftLootable state, Location location) { public void applyTo(T blockEntity) { super.applyTo(blockEntity); - if (this.getSnapshot().lootTable == null) { + if (this.getSnapshot().getLootTable() == null) { blockEntity.setLootTable(null, 0L); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java index 2b5ce9e8be2d..8f31eb16989a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSculkSensor.java @@ -24,7 +24,7 @@ public int getLastVibrationFrequency() { @Override public void setLastVibrationFrequency(int lastVibrationFrequency) { Preconditions.checkArgument(0 <= lastVibrationFrequency && lastVibrationFrequency <= 15, "Vibration frequency must be between 0-15"); - this.getSnapshot().lastVibrationFrequency = lastVibrationFrequency; + this.getSnapshot().setLastVibrationFrequency(lastVibrationFrequency); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java index c9337d641d5f..2e46d8831e86 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java @@ -37,7 +37,7 @@ public Inventory getInventory() { @Override public DyeColor getColor() { - net.minecraft.world.item.DyeColor color = ((ShulkerBoxBlock) CraftBlockType.bukkitToMinecraft(this.getType())).color; + net.minecraft.world.item.DyeColor color = ((ShulkerBoxBlock) CraftBlockType.bukkitToMinecraft(this.getType())).getColor(); return (color == null) ? null : DyeColor.getByWoolData((byte) color.getId()); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index c9de829c3719..7329b504cf54 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -123,7 +123,7 @@ public void setOwningPlayer(OfflinePlayer player) { if (player instanceof CraftPlayer craftPlayer) { this.profile = ResolvableProfile.createResolved(craftPlayer.getProfile()); } else { - this.profile = new ResolvableProfile.Dynamic(Either.right(player.getUniqueId()), PlayerSkin.Patch.EMPTY); + this.profile = ResolvableProfile.createUnresolved(player.getUniqueId()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java index b7f08dc4133b..ea846890eae1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java @@ -59,7 +59,7 @@ public void setAuthor(LivingEntity entity) { @Override public BlockVector getRelativePosition() { - return CraftBlockVector.toBukkit(this.getSnapshot().structurePos); + return CraftBlockVector.toBukkit(this.getSnapshot().getStructurePos()); } @Override @@ -67,12 +67,12 @@ public void setRelativePosition(BlockVector vector) { Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockX(), -CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE), "Structure Size (X) must be between -%s and %s but got %s", CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE, vector.getBlockX()); Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockY(), -CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE), "Structure Size (Y) must be between -%s and %s but got %s", CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE, vector.getBlockY()); Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockZ(), -CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE), "Structure Size (Z) must be between -%s and %s but got %s", CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE, vector.getBlockZ()); - this.getSnapshot().structurePos = CraftBlockVector.toBlockPosition(vector); + this.getSnapshot().setStructurePos(CraftBlockVector.toBlockPosition(vector)); } @Override public BlockVector getStructureSize() { - return CraftBlockVector.toBukkit(this.getSnapshot().structureSize); + return CraftBlockVector.toBukkit(this.getSnapshot().getStructureSize()); } @Override @@ -80,29 +80,29 @@ public void setStructureSize(BlockVector vector) { Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockX(), 0, CraftStructureBlock.MAX_SIZE), "Structure Size (X) must be between %s and %s but got %s", 0, CraftStructureBlock.MAX_SIZE, vector.getBlockX()); Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockY(), 0, CraftStructureBlock.MAX_SIZE), "Structure Size (Y) must be between %s and %s but got %s", 0, CraftStructureBlock.MAX_SIZE, vector.getBlockY()); Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockZ(), 0, CraftStructureBlock.MAX_SIZE), "Structure Size (Z) must be between %s and %s but got %s", 0, CraftStructureBlock.MAX_SIZE, vector.getBlockZ()); - this.getSnapshot().structureSize = CraftBlockVector.toBlockPosition(vector); + this.getSnapshot().setStructureSize(CraftBlockVector.toBlockPosition(vector)); } @Override public void setMirror(Mirror mirror) { Preconditions.checkArgument(mirror != null, "Mirror cannot be null"); - this.getSnapshot().mirror = net.minecraft.world.level.block.Mirror.valueOf(mirror.name()); + this.getSnapshot().setMirror(net.minecraft.world.level.block.Mirror.valueOf(mirror.name())); } @Override public Mirror getMirror() { - return Mirror.valueOf(this.getSnapshot().mirror.name()); + return Mirror.valueOf(this.getSnapshot().getMirror().name()); } @Override public void setRotation(StructureRotation rotation) { Preconditions.checkArgument(rotation != null, "StructureRotation cannot be null"); - this.getSnapshot().rotation = Rotation.valueOf(rotation.name()); + this.getSnapshot().setRotation(Rotation.valueOf(rotation.name())); } @Override public StructureRotation getRotation() { - return StructureRotation.valueOf(this.getSnapshot().rotation.name()); + return StructureRotation.valueOf(this.getSnapshot().getRotation().name()); } @Override @@ -128,56 +128,56 @@ public boolean isIgnoreEntities() { @Override public void setShowAir(boolean showAir) { - this.getSnapshot().showAir = showAir; + this.getSnapshot().setShowAir(showAir); } @Override public boolean isShowAir() { - return this.getSnapshot().showAir; + return this.getSnapshot().getShowAir(); } @Override public void setBoundingBoxVisible(boolean showBoundingBox) { - this.getSnapshot().showBoundingBox = showBoundingBox; + this.getSnapshot().setShowBoundingBox(showBoundingBox); } @Override public boolean isBoundingBoxVisible() { - return this.getSnapshot().showBoundingBox; + return this.getSnapshot().getShowBoundingBox(); } @Override public void setIntegrity(float integrity) { Preconditions.checkArgument(CraftStructureBlock.isBetween(integrity, 0.0f, 1.0f), "Integrity must be between 0.0f and 1.0f but got %s", integrity); - this.getSnapshot().integrity = integrity; + this.getSnapshot().setIntegrity(integrity); } @Override public float getIntegrity() { - return this.getSnapshot().integrity; + return this.getSnapshot().getIntegrity(); } @Override public void setSeed(long seed) { - this.getSnapshot().seed = seed; + this.getSnapshot().setSeed(seed); } @Override public long getSeed() { - return this.getSnapshot().seed; + return this.getSnapshot().getSeed(); } @Override public void setMetadata(String metadata) { Preconditions.checkArgument(metadata != null, "Structure metadata cannot be null"); if (this.getUsageMode() == UsageMode.DATA) { - this.getSnapshot().metaData = metadata; + this.getSnapshot().setMetaData(metadata); } } @Override public String getMetadata() { - return this.getSnapshot().metaData; + return this.getSnapshot().getMetaData(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawner.java index 4fedf2554b25..ae5f1904c8e6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawner.java @@ -35,42 +35,42 @@ protected CraftTrialSpawner(CraftTrialSpawner state, Location location) { @Override public long getCooldownEnd() { - return this.getSnapshot().trialSpawner.getStateData().cooldownEndsAt; + return this.getSnapshot().getTrialSpawner().getStateData().cooldownEndsAt; } @Override public void setCooldownEnd(long ticks) { - this.getSnapshot().trialSpawner.getStateData().cooldownEndsAt = ticks; + this.getSnapshot().getTrialSpawner().getStateData().cooldownEndsAt = ticks; } @Override public long getNextSpawnAttempt() { - return this.getSnapshot().trialSpawner.getStateData().nextMobSpawnsAt; + return this.getSnapshot().getTrialSpawner().getStateData().nextMobSpawnsAt; } @Override public void setNextSpawnAttempt(long ticks) { - this.getSnapshot().trialSpawner.getStateData().nextMobSpawnsAt = ticks; + this.getSnapshot().getTrialSpawner().getStateData().nextMobSpawnsAt = ticks; } @Override public int getCooldownLength() { - return this.getSnapshot().trialSpawner.getTargetCooldownLength(); + return this.getSnapshot().getTrialSpawner().getTargetCooldownLength(); } @Override public void setCooldownLength(int ticks) { - this.getSnapshot().trialSpawner.config = this.getSnapshot().trialSpawner.config.overrideTargetCooldownLength(ticks); + this.getSnapshot().getTrialSpawner().config = this.getSnapshot().getTrialSpawner().config.overrideTargetCooldownLength(ticks); } @Override public int getRequiredPlayerRange() { - return this.getSnapshot().trialSpawner.getRequiredPlayerRange(); + return this.getSnapshot().getTrialSpawner().getRequiredPlayerRange(); } @Override public void setRequiredPlayerRange(int requiredPlayerRange) { - this.getSnapshot().trialSpawner.config = this.getSnapshot().trialSpawner.config.overrideRequiredPlayerRange(requiredPlayerRange); + this.getSnapshot().getTrialSpawner().config = this.getSnapshot().getTrialSpawner().config.overrideRequiredPlayerRange(requiredPlayerRange); } @Override @@ -152,7 +152,7 @@ public void setOminous(boolean ominous) { return; // block data changed } - this.getSnapshot().trialSpawner.isOminous = ominous; + this.getSnapshot().getTrialSpawner().isOminous = ominous; if (ominous) { this.block = this.block.setValue(TrialSpawnerBlock.OMINOUS, true); // TODO: Consider calling TrialSpawnerData#resetAfterBecomingOminous in update(...), but note that method also removes entities @@ -176,7 +176,7 @@ public TrialSpawnerConfiguration getOminousConfiguration() { protected void applyTo(TrialSpawnerBlockEntity blockEntity) { super.applyTo(blockEntity); - blockEntity.trialSpawner.config = blockEntity.trialSpawner.config.overrideConfigs( + blockEntity.getTrialSpawner().config = blockEntity.getTrialSpawner().config.overrideConfigs( Holder.direct(this.normalConfig.toMinecraft()), Holder.direct(this.ominousConfig.toMinecraft()) ); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java index dd70d5010d2d..8ea913655842 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTrialSpawnerConfiguration.java @@ -304,12 +304,12 @@ public void setPossibleRewards(Map rewards) { @Override public int getRequiredPlayerRange() { - return this.snapshot.trialSpawner.getRequiredPlayerRange(); + return this.snapshot.getTrialSpawner().getRequiredPlayerRange(); } @Override public void setRequiredPlayerRange(int requiredPlayerRange) { - this.snapshot.trialSpawner.config = this.snapshot.trialSpawner.config.overrideRequiredPlayerRange(requiredPlayerRange); + this.snapshot.getTrialSpawner().config = this.snapshot.getTrialSpawner().config.overrideRequiredPlayerRange(requiredPlayerRange); } private TrialSpawnerStateData getTrialData() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java index 3b2220d895a6..f499c02b2ff2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java @@ -184,7 +184,7 @@ public void setVisible(boolean visible) { @Override public boolean isVisible() { - return this.handle.visible; + return this.handle.isVisible(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java index 543af9f698fd..29ba9b0a1089 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java @@ -32,7 +32,7 @@ public CraftDragonBattle(EnderDragonFight handle) { @Override public EnderDragon getEnderDragon() { - Entity entity = this.handle.level.getEntity(this.handle.dragonUUID); + Entity entity = this.handle.level.getEntity(this.handle.dragonUUID()); return (entity != null) ? (EnderDragon) entity.getBukkitEntity() : null; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java index 3874807787f7..cbcb8a805173 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java @@ -14,6 +14,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.AbstractArrow; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; public abstract class CraftAbstractArrow extends AbstractProjectile implements AbstractArrow { @@ -35,6 +36,16 @@ public int getKnockbackStrength() { return 0; } + @Override + public ItemStack getItem() { + return this.getItemStack(); + } + + @Override + public void setItem(@NotNull ItemStack item) { + this.setItemStack(item); + } + @Override public double getDamage() { return this.getHandle().baseDamage; @@ -68,6 +79,11 @@ public void setCritical(boolean critical) { this.getHandle().setCritArrow(critical); } + @Override + public boolean isOnGround() { + return this.getHandle().isInGround(); + } + @Override public boolean isInBlock() { return this.getHandle().isInGround(); @@ -117,18 +133,6 @@ public boolean isShotFromCrossbow() { public void setShotFromCrossbow(boolean shotFromCrossbow) { } - @Override - public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(this.getHandle().pickupItemStack); - } - - @Override - public void setItem(ItemStack item) { - Preconditions.checkArgument(item != null, "ItemStack cannot be null"); - - this.getHandle().pickupItemStack = CraftItemStack.asNMSCopy(item); - } - @Override public ItemStack getWeapon() { if (this.getHandle().getWeaponItem() == null) return null; // Paper - fix NPE diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java index 8862314eeadc..e10748f9d1ce 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -45,7 +45,7 @@ public void setLoveModeTicks(int ticks) { @Override public int getLoveModeTicks() { - return this.getHandle().inLove; + return this.getHandle().getInLoveTime(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java index d0bb2bf5dfba..568c5c88cbcc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java @@ -2,9 +2,11 @@ import com.google.common.collect.ImmutableList; import java.util.List; +import java.util.Objects; import java.util.Optional; import net.minecraft.Optionull; import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponents; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.EntityReference; @@ -47,7 +49,7 @@ public void setDuration(int duration) { @Override public int getWaitTime() { - return this.getHandle().waitTime; + return this.getHandle().getWaitTime(); } @Override @@ -67,12 +69,12 @@ public void setReapplicationDelay(int delay) { @Override public int getDurationOnUse() { - return this.getHandle().durationOnUse; + return this.getHandle().getDurationOnUse(); } @Override public void setDurationOnUse(int duration) { - this.getHandle().durationOnUse = duration; + this.getHandle().setDurationOnUse(duration); } @Override @@ -87,7 +89,7 @@ public void setRadius(float radius) { @Override public float getRadiusOnUse() { - return this.getHandle().radiusOnUse; + return this.getHandle().getRadiusOnUse(); } @Override @@ -97,7 +99,7 @@ public void setRadiusOnUse(float radius) { @Override public float getRadiusPerTick() { - return this.getHandle().radiusPerTick; + return this.getHandle().getRadiusPerTick(); } @Override @@ -122,13 +124,13 @@ public void setParticle(Particle particle, T data) { @Override public Color getColor() { - return Color.fromRGB(this.getHandle().potionContents.getColor() & 0x00FFFFFF); // Paper - skip alpha channel + return Color.fromRGB(this.potionContents().getColor() & 0x00FFFFFF); // Paper - skip alpha channel } @Override public void setColor(Color color) { - PotionContents old = this.getHandle().potionContents; - this.getHandle().setPotionContents(new PotionContents(old.potion(), Optional.ofNullable(color).map(Color::asRGB), old.customEffects(), old.customName())); + PotionContents current = this.potionContents(); + this.getHandle().setPotionContents(new PotionContents(current.potion(), Optional.ofNullable(color).map(Color::asRGB), current.customEffects(), current.customName())); } @Override @@ -145,14 +147,14 @@ public boolean addCustomEffect(PotionEffect effect, boolean override) { @Override public void clearCustomEffects() { - PotionContents old = this.getHandle().potionContents; - this.getHandle().setPotionContents(new PotionContents(old.potion(), old.customColor(), List.of(), old.customName())); + PotionContents current = this.potionContents(); + this.getHandle().setPotionContents(new PotionContents(current.potion(), current.customColor(), List.of(), current.customName())); } @Override public List getCustomEffects() { ImmutableList.Builder builder = ImmutableList.builder(); - for (MobEffectInstance effect : this.getHandle().potionContents.customEffects()) { + for (MobEffectInstance effect : this.potionContents().customEffects()) { builder.add(CraftPotionUtil.toBukkit(effect)); } return builder.build(); @@ -160,7 +162,7 @@ public List getCustomEffects() { @Override public boolean hasCustomEffect(PotionEffectType type) { - for (MobEffectInstance effect : this.getHandle().potionContents.customEffects()) { + for (MobEffectInstance effect : this.potionContents().customEffects()) { if (CraftPotionUtil.equals(effect.getEffect(), type)) { return true; } @@ -170,7 +172,7 @@ public boolean hasCustomEffect(PotionEffectType type) { @Override public boolean hasCustomEffects() { - return !this.getHandle().potionContents.customEffects().isEmpty(); + return !this.potionContents().customEffects().isEmpty(); } @Override @@ -178,10 +180,10 @@ public boolean removeCustomEffect(PotionEffectType effect) { if (!this.hasCustomEffect(effect)) { return false; } - Holder minecraft = CraftPotionEffectType.bukkitToMinecraftHolder(effect); - PotionContents old = this.getHandle().potionContents; - this.getHandle().setPotionContents(new PotionContents(old.potion(), old.customColor(), old.customEffects().stream().filter((mobEffect) -> !mobEffect.getEffect().equals(minecraft)).toList(), old.customName())); + Holder minecraft = CraftPotionEffectType.bukkitToMinecraftHolder(effect); + PotionContents current = this.potionContents(); + this.getHandle().setPotionContents(new PotionContents(current.potion(), current.customColor(), current.customEffects().stream().filter((mobEffect) -> !mobEffect.getEffect().equals(minecraft)).toList(), current.customName())); return true; } @@ -198,16 +200,20 @@ public PotionData getBasePotionData() { @Override public void setBasePotionType(PotionType potionType) { if (potionType != null) { - this.getHandle().setPotionContents(this.getHandle().potionContents.withPotion(CraftPotionType.bukkitToMinecraftHolder(potionType))); + this.getHandle().setPotionContents(this.potionContents().withPotion(CraftPotionType.bukkitToMinecraftHolder(potionType))); } else { - PotionContents old = this.getHandle().potionContents; - this.getHandle().setPotionContents(new PotionContents(Optional.empty(), old.customColor(), old.customEffects(), old.customName())); + PotionContents current = this.potionContents(); + this.getHandle().setPotionContents(new PotionContents(Optional.empty(), current.customColor(), current.customEffects(), current.customName())); } } @Override public PotionType getBasePotionType() { - return this.getHandle().potionContents.potion().map(CraftPotionType::minecraftHolderToBukkit).orElse(null); + return this.potionContents().potion().map(CraftPotionType::minecraftHolderToBukkit).orElse(null); + } + + private PotionContents potionContents() { + return Objects.requireNonNull(this.getHandle().get(DataComponents.POTION_CONTENTS)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java index 27155539258c..bc6dae85f708 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -27,7 +27,7 @@ public Location getHive() { @Override public void setHive(Location location) { Preconditions.checkArgument(location == null || this.getWorld().equals(location.getWorld()), "Hive must be in same world"); - this.getHandle().hivePos = (location == null) ? null : CraftLocation.toBlockPos(location); + this.getHandle().setHivePos((location == null) ? null : CraftLocation.toBlockPos(location)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index e445d377fa34..c28655fa74e6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -89,18 +89,17 @@ public org.bukkit.Material getBoatMaterial() { @Override public Status getStatus() { - // Paper start - Fix NPE on Boat getStatus final net.minecraft.world.entity.vehicle.boat.AbstractBoat handle = this.getHandle(); - if (handle.status == null) { - if (handle.valid) { - // Don't actually set the status because it would skew the old status check in the next tick - return CraftBoat.boatStatusFromNms(handle.getStatus()); - } else { + AbstractBoat.Status status = this.getHandle().status; + if (status == null) { + if (!handle.valid) { return Status.NOT_IN_WORLD; } + + // Don't actually set the status because it would skew the old status check in the next tick + status = handle.getStatus(); } - // Paper end - Fix NPE on Boat getStatus - return CraftBoat.boatStatusFromNms(this.getHandle().status); + return CraftBoat.boatStatusFromNms(status); } public static Boat.Type boatTypeFromNms(EntityType boatType) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 30f012468eb6..c3074d51faec 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -251,9 +251,6 @@ public BoundingBox getBoundingBox() { @Override public boolean isOnGround() { - if (this.entity instanceof AbstractArrow abstractArrow) { - return abstractArrow.isInGround(); - } return this.entity.onGround(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java index ded2f19ab8bd..05e6007b52df 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -41,7 +41,7 @@ public void setBlockData(final BlockData blockData) { @Override public org.bukkit.block.BlockState getBlockState() { - return org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.getHandle().blockState, this.getHandle().blockData); + return org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.getHandle().getBlockState(), this.getHandle().blockData); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 6e0d195bb80a..405f5ad30ae8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -27,7 +27,7 @@ public FireworkRocketEntity getHandle() { @Override public FireworkMeta getFireworkMeta() { - return (FireworkMeta) CraftItemStack.getItemMeta(this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM), org.bukkit.inventory.ItemType.FIREWORK_ROCKET); + return (FireworkMeta) CraftItemStack.getItemMeta(this.getHandle().getItem(), org.bukkit.inventory.ItemType.FIREWORK_ROCKET); } @Override @@ -70,11 +70,6 @@ public boolean setLife(int ticks) { return true; } - @Override - public int getLife() { - return this.getHandle().life; - } - @Override public boolean setMaxLife(int ticks) { Preconditions.checkArgument(ticks > 0, "ticks must be greater than 0"); @@ -87,14 +82,9 @@ public boolean setMaxLife(int ticks) { return true; } - @Override - public int getMaxLife() { - return this.getHandle().lifetime; - } - @Override public void detonate() { - this.setLife(this.getMaxLife() + 1); + this.setLife(this.getTicksToDetonate() + 1); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java index 327a686a20d8..82c742161a2c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java @@ -171,26 +171,23 @@ public boolean isInOpenWater() { @Override public Entity getHookedEntity() { - net.minecraft.world.entity.Entity hooked = this.getHandle().hookedIn; + net.minecraft.world.entity.Entity hooked = this.getHandle().getHookedIn(); return (hooked != null) ? hooked.getBukkitEntity() : null; } @Override public void setHookedEntity(Entity entity) { - FishingHook hook = this.getHandle(); - - hook.hookedIn = (entity != null) ? ((CraftEntity) entity).getHandle() : null; - hook.getEntityData().set(FishingHook.DATA_HOOKED_ENTITY, hook.hookedIn != null ? hook.hookedIn.getId() + 1 : 0); + this.getHandle().setHookedEntity(entity != null ? ((CraftEntity) entity).getHandle() : null); } @Override public boolean pullHookedEntity() { FishingHook hook = this.getHandle(); - if (hook.hookedIn == null) { + if (hook.getHookedIn() == null) { return false; } - hook.pullEntity(hook.hookedIn); + hook.pullEntity(hook.getHookedIn()); return true; } @@ -222,7 +219,7 @@ public void setTimeUntilBite(final int ticks) { // Reset the fish angle hook only when this call "enters" the fish into the lure stage. final boolean alreadyInLuringPhase = hook.timeUntilHooked > 0 && hook.timeUntilLured <= 0; if (!alreadyInLuringPhase) { - hook.fishAngle = net.minecraft.util.Mth.nextFloat(hook.random, hook.minLureAngle, hook.maxLureAngle); + hook.fishAngle = net.minecraft.util.Mth.nextFloat(hook.getRandom(), hook.minLureAngle, hook.maxLureAngle); hook.timeUntilLured = 0; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java index 9565572393d6..e9fd3b15367d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java @@ -44,10 +44,10 @@ public int getConversionTime() { @Override public void setConversionTime(int time) { if (time < 0) { - this.getHandle().timeInOverworld = -1; + this.getHandle().setTimeInOverworld(-1); this.getHandle().setImmuneToZombification(false); } else { - this.getHandle().timeInOverworld = time; + this.getHandle().setTimeInOverworld(time); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 0c98e3ec53b4..2aea80487ff1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -163,7 +163,7 @@ public boolean isDeeplySleeping() { @Override public int getSleepTicks() { - return this.getHandle().sleepCounter; + return this.getHandle().getSleepTimer(); } @Override @@ -615,12 +615,12 @@ public boolean setWindowProperty(InventoryView.Property prop, int value) { @Override public int getEnchantmentSeed() { - return this.getHandle().enchantmentSeed; + return this.getHandle().getEnchantmentSeed(); } @Override - public void setEnchantmentSeed(int i) { - this.getHandle().enchantmentSeed = i; + public void setEnchantmentSeed(int seed) { + this.getHandle().enchantmentSeed = seed; } @Override @@ -660,13 +660,8 @@ public boolean hasCooldown(ItemStack item) { public int getCooldown(ItemStack item) { Preconditions.checkArgument(item != null, "Item cannot be null"); - Identifier group = this.getHandle().getCooldowns().getCooldownGroup(CraftItemStack.asNMSCopy(item)); - if (group == null) { - return 0; - } - - ItemCooldowns.CooldownInstance cooldown = this.getHandle().getCooldowns().cooldowns.get(group); - return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime() - this.getHandle().getCooldowns().tickCount); + Identifier cooldownGroup = this.getHandle().getCooldowns().getCooldownGroup(CraftItemStack.asNMSCopy(item)); + return this.getHandle().getCooldowns().getRemainingCooldown(cooldownGroup); } @Override @@ -678,19 +673,18 @@ public void setCooldown(ItemStack item, int ticks) { } @Override - public int getCooldown(Key key) { - Preconditions.checkArgument(key != null, "Key cannot be null"); + public int getCooldown(Key cooldownGroup) { + Preconditions.checkArgument(cooldownGroup != null, "cooldownGroup cannot be null"); - ItemCooldowns.CooldownInstance cooldown = this.getHandle().getCooldowns().cooldowns.get(PaperAdventure.asVanilla(key)); - return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime() - this.getHandle().getCooldowns().tickCount); + return this.getHandle().getCooldowns().getRemainingCooldown(PaperAdventure.asVanilla(cooldownGroup)); } @Override - public void setCooldown(Key key, int ticks) { - Preconditions.checkArgument(key != null, "Key cannot be null"); + public void setCooldown(Key cooldownGroup, int ticks) { + Preconditions.checkArgument(cooldownGroup != null, "cooldownGroup cannot be null"); Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown"); - this.getHandle().getCooldowns().addCooldown(PaperAdventure.asVanilla(key), ticks); + this.getHandle().getCooldowns().addCooldown(PaperAdventure.asVanilla(cooldownGroup), ticks); } @Override @@ -837,22 +831,22 @@ public void setExhaustion(float value) { @Override public float getSaturation() { - return this.getHandle().getFoodData().saturationLevel; + return this.getHandle().getFoodData().getSaturationLevel(); } @Override public void setSaturation(float value) { - this.getHandle().getFoodData().saturationLevel = value; + this.getHandle().getFoodData().setSaturation(value); } @Override public int getFoodLevel() { - return this.getHandle().getFoodData().foodLevel; + return this.getHandle().getFoodData().getFoodLevel(); } @Override public void setFoodLevel(int value) { - this.getHandle().getFoodData().foodLevel = value; + this.getHandle().getFoodData().setFoodLevel(value); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index 7c017df81f1a..e7c9ffeabbc0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -41,13 +41,13 @@ public int getPickupDelay() { @Override public void setPickupDelay(int delay) { - this.getHandle().pickupDelay = Math.min(delay, NO_PICKUP_TIME); + this.getHandle().setPickUpDelay(Math.min(delay, NO_PICKUP_TIME)); } @Override public void setUnlimitedLifetime(boolean unlimited) { if (unlimited) { - this.getHandle().age = NO_AGE_TIME; + this.getHandle().setUnlimitedLifetime(); } else { this.getHandle().age = this.getTicksLived(); } @@ -85,12 +85,12 @@ public boolean canPlayerPickup() { @Override public void setCanPlayerPickup(boolean canPlayerPickup) { - this.getHandle().pickupDelay = canPlayerPickup ? 0 : NO_PICKUP_TIME; + this.getHandle().setPickUpDelay(canPlayerPickup ? 0 : NO_PICKUP_TIME); } @Override public boolean willAge() { - return this.getHandle().age != NO_AGE_TIME; + return this.getHandle().getAge() != NO_AGE_TIME; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index d1448cf50f15..74cb4d0c1e34 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -538,7 +538,7 @@ public void removePotionEffect(PotionEffectType type) { @Override public Collection getActivePotionEffects() { List effects = new ArrayList<>(); - for (MobEffectInstance handle : this.getHandle().activeEffects.values()) { + for (MobEffectInstance handle : this.getHandle().getActiveEffects()) { effects.add(org.bukkit.craftbukkit.potion.CraftPotionUtil.toBukkit(handle)); // Paper } return effects; @@ -996,7 +996,7 @@ public org.bukkit.inventory.EquipmentSlot getActiveItemHand() { @Override public boolean isJumping() { - return this.getHandle().jumping; + return this.getHandle().isJumping(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index d30f9b4a8896..e24043d41180 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -105,7 +105,7 @@ public void setSeed(long seed) { @Override public long getSeed() { - return this.getHandle().lootTableSeed; + return this.getHandle().getLootTableSeed(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index b82683cf8867..9802062711bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -46,7 +46,7 @@ public int getBoostTicks() { public void setBoostTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0"); - this.getHandle().steering.setBoostTicks(ticks); + this.getHandle().steering.boost(ticks); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java index 849873a9f5c5..eae3c31e9266 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -25,12 +25,12 @@ public net.minecraft.world.entity.monster.piglin.Piglin getHandle() { @Override public boolean isAbleToHunt() { - return this.getHandle().cannotHunt; + return !this.getHandle().cannotHunt; } @Override public void setIsAbleToHunt(boolean flag) { - this.getHandle().cannotHunt = flag; + this.getHandle().cannotHunt = !flag; } @Override @@ -77,7 +77,7 @@ public Set getBarterList() { @Override public Inventory getInventory() { - return new CraftInventory(this.getHandle().inventory); + return new CraftInventory(this.getHandle().getInventory()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java index c2faff9b6910..dc6caf9369d4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java @@ -35,10 +35,10 @@ public int getConversionTime() { @Override public void setConversionTime(int time) { if (time < 0) { - this.getHandle().timeInOverworld = -1; + this.getHandle().setTimeInOverworld(-1); this.getHandle().setImmuneToZombification(false); } else { - this.getHandle().timeInOverworld = time; + this.getHandle().setTimeInOverworld(time); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java index 1c416a449e2d..999ccf4acdb5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java @@ -18,6 +18,6 @@ public net.minecraft.world.entity.monster.illager.Pillager getHandle() { @Override public Inventory getInventory() { - return new CraftInventory(this.getHandle().inventory); + return new CraftInventory(this.getHandle().getInventory()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index b47a215db4b1..261aeb211039 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -557,7 +557,7 @@ public void setDisplayName(final String name) { public void playerListName(net.kyori.adventure.text.Component name) { getHandle().listName = name == null ? null : io.papermc.paper.adventure.PaperAdventure.asVanilla(name); if (getHandle().connection == null) return; // Updates are possible before the player has fully joined - for (ServerPlayer player : server.getHandle().players) { + for (ServerPlayer player : server.getHandle().getPlayers()) { if (player.getBukkitEntity().canSee(this)) { player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, getHandle())); } @@ -588,7 +588,7 @@ public void setPlayerListName(String name) { } this.getHandle().listName = name.equals(this.getName()) ? null : CraftChatMessage.fromStringOrNull(name); if (this.getHandle().connection == null) return; // Paper - Updates are possible before the player has fully joined - for (ServerPlayer player : this.server.getHandle().players) { + for (ServerPlayer player : this.server.getHandle().getPlayers()) { if (player.getBukkitEntity().canSee(this)) { player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, this.getHandle())); } @@ -607,7 +607,7 @@ public void setPlayerListOrder(int order) { this.getHandle().listOrder = order; // Paper start - Send update packet if (getHandle().connection == null) return; // Updates are possible before the player has fully joined - for (ServerPlayer player : server.getHandle().players) { + for (ServerPlayer player : server.getHandle().getPlayers()) { if (player.getBukkitEntity().canSee(this)) { player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LIST_ORDER, getHandle())); } @@ -786,12 +786,12 @@ public void playNote(Location loc, Instrument instrument, Note note) { @Override public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { - this.playSound(loc, sound, category, volume, pitch, this.getHandle().random.nextLong()); + this.playSound(loc, sound, category, volume, pitch, this.getHandle().getRandom().nextLong()); } @Override public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) { - this.playSound(loc, sound, category, volume, pitch, this.getHandle().random.nextLong()); + this.playSound(loc, sound, category, volume, pitch, this.getHandle().getRandom().nextLong()); } @Override @@ -819,12 +819,12 @@ private void playSound0(Location loc, Holder soundEffectHolder, net. @Override public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { - this.playSound(entity, sound, category, volume, pitch, this.getHandle().random.nextLong()); + this.playSound(entity, sound, category, volume, pitch, this.getHandle().getRandom().nextLong()); } @Override public void playSound(org.bukkit.entity.Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch) { - this.playSound(entity, sound, category, volume, pitch, this.getHandle().random.nextLong()); + this.playSound(entity, sound, category, volume, pitch, this.getHandle().getRandom().nextLong()); } @Override @@ -1312,7 +1312,7 @@ protected boolean teleport0(Location location, org.bukkit.event.player.PlayerTel } // Minecraft does not currently support teleporting players between worlds with passengers. // It causes them to be dismounted, and causes weird behavior. - if (location.getWorld() != this.getWorld() && !this.getHandle().passengers.isEmpty()) { + if (location.getWorld() != this.getWorld() && this.getHandle().isVehicle()) { return false; } @@ -1742,8 +1742,7 @@ public int getLevel() { @Override public void setLevel(int level) { Preconditions.checkArgument(level >= 0, "Experience level must not be negative (%s)", level); - this.getHandle().experienceLevel = level; - this.getHandle().lastSentExp = -1; + this.getHandle().setExperienceLevels(level); } @Override @@ -1984,7 +1983,7 @@ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profi self.gameProfile = gameProfile; return; } - List players = this.server.getServer().getPlayerList().players; + List players = this.server.getServer().getPlayerList().getPlayers(); // First unregister the player for all players with the OLD game profile for (ServerPlayer player : players) { CraftPlayer bukkitPlayer = player.getBukkitEntity(); @@ -2468,7 +2467,7 @@ public void setFlyingFallDamage(@NonNull TriState flyingFallDamage) { public void setFlySpeed(float value) { this.validateSpeed(value); ServerPlayer player = this.getHandle(); - player.getAbilities().flyingSpeed = value / 2f; + player.getAbilities().setFlyingSpeed(value / 2.0F); player.onUpdateAbilities(); } @@ -2477,23 +2476,23 @@ public void setFlySpeed(float value) { public void setWalkSpeed(float value) { this.validateSpeed(value); ServerPlayer player = this.getHandle(); - player.getAbilities().walkingSpeed = value / 2f; + player.getAbilities().setWalkingSpeed(value / 2.0F); player.onUpdateAbilities(); - this.getHandle().getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(player.getAbilities().walkingSpeed); // SPIGOT-5833: combination of the two in 1.16+ + this.getHandle().getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(player.getAbilities().getWalkingSpeed()); // SPIGOT-5833: combination of the two in 1.16+ } @Override public float getFlySpeed() { - return this.getHandle().getAbilities().flyingSpeed * 2f; + return this.getHandle().getAbilities().getFlyingSpeed() * 2.0F; } @Override public float getWalkSpeed() { - return this.getHandle().getAbilities().walkingSpeed * 2f; + return this.getHandle().getAbilities().getWalkingSpeed() * 2.0F; } private void validateSpeed(float value) { - Preconditions.checkArgument(value <= 1f && value >= -1f, "Speed value (%s) need to be between -1f and 1f", value); + Preconditions.checkArgument(value <= 1.0F && value >= -1.0F, "Speed value (%s) need to be between -1 and 1", value); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index 1cd0d2738e5e..61d9914aa4cf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -30,7 +30,7 @@ public int getConversionTime() { public void setConversionTime(int time) { if (time < 0) { this.getHandle().conversionTime = -1; - this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.skeleton.Skeleton.DATA_STRAY_CONVERSION_ID, false); + this.getHandle().setFreezeConverting(false); } else { this.getHandle().startFreezeConversion(time); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java index 6c03adc7b0dd..5f9002b16c71 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -48,7 +48,7 @@ public int getBoostTicks() { public void setBoostTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0"); - this.getHandle().steering.setBoostTicks(ticks); + this.getHandle().steering.boost(ticks); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java index 7044d72edb6e..8e02e2da86f7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -19,11 +19,7 @@ public ThrowableItemProjectile getHandle() { @Override public ItemStack getItem() { - if (this.getHandle().getItem().isEmpty()) { - return CraftItemStack.asBukkitCopy(new net.minecraft.world.item.ItemStack(this.getHandle().getDefaultItem())); - } else { - return CraftItemStack.asBukkitCopy(this.getHandle().getItem()); - } + return CraftItemStack.asBukkitCopy(this.getHandle().getItem()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java index 88080e8e9790..e8d081134e1d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -10,7 +10,6 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.potion.CraftPotionUtil; import org.bukkit.entity.ThrownPotion; -import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffect; @@ -34,11 +33,6 @@ public Collection getEffects() { return builder.build(); } - @Override - public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(this.getHandle().getItem()); - } - @Override public void setPotionMeta(PotionMeta meta) { net.minecraft.world.item.ItemStack item = this.getHandle().getItem(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java index 505b8603829e..59aa27782a76 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -2,9 +2,7 @@ import net.minecraft.world.entity.projectile.arrow.ThrownTrident; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; public class CraftTrident extends CraftAbstractArrow implements Trident { @@ -17,16 +15,6 @@ public ThrownTrident getHandle() { return (ThrownTrident) this.entity; } - @Override - public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(this.getHandle().pickupItemStack); - } - - @Override - public void setItem(ItemStack itemStack) { - this.getHandle().pickupItemStack = CraftItemStack.asNMSCopy(itemStack); - } - @Override public boolean hasGlint() { return this.getHandle().isFoil(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java index 3a9a9677465d..6d74943e8d79 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java @@ -27,12 +27,12 @@ public boolean isLayingEgg() { @Override public org.bukkit.Location getHome() { - return CraftLocation.toBukkit(this.getHandle().homePos, this.getHandle().level()); + return CraftLocation.toBukkit(this.getHandle().getHomePos(), this.getHandle().level()); } @Override public void setHome(org.bukkit.Location location) { - this.getHandle().homePos = CraftLocation.toBlockPos(location); + this.getHandle().setHomePos(CraftLocation.toBlockPos(location)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index 6b5cd57ac85b..b48f3525c120 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -78,11 +78,6 @@ public void setBound(Location location) { } } - @Override - public int getLifeTicks() { - return this.getHandle().limitedLifeTicks; - } - @Override public void setLifeTicks(int lifeTicks) { this.getHandle().setLimitedLife(lifeTicks); @@ -90,9 +85,4 @@ public void setLifeTicks(int lifeTicks) { this.getHandle().hasLimitedLife = false; } } - - @Override - public boolean hasLimitedLife() { - return this.getHandle().hasLimitedLife; - } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index 8184b397fc3b..ae00321c8985 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -231,7 +231,7 @@ public void setReputations(Map reputations) { @Override public void clearReputations() { - this.getHandle().getGossips().gossips.clear(); + this.getHandle().getGossips().clear(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index 745f5e77e5a7..3feab14a2493 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -63,7 +63,7 @@ public void setConversionTime(int time) { public void setConversionTime(int time, boolean broadcastEntityEvent) { // Paper end - missing entity behaviour api - converting without entity event if (time < 0) { - this.getHandle().villagerConversionTime = -1; + this.getHandle().setVillagerConversionTime(-1); this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.zombie.ZombieVillager.DATA_CONVERTING_ID, false); this.getHandle().conversionStarter = null; this.getHandle().removeEffect(MobEffects.STRENGTH, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java index 2e11df97e5c8..4e4eda483988 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -11,14 +11,11 @@ public class CraftWither extends CraftMonster implements Wither, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - private BossBar bossBar; + private final BossBar bossBar; public CraftWither(CraftServer server, WitherBoss entity) { super(server, entity); - - if (entity.bossEvent != null) { - this.bossBar = new CraftBossBar(entity.bossEvent); - } + this.bossBar = new CraftBossBar(entity.bossEvent); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 08c549628e17..260e85d1eb4c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -62,8 +62,7 @@ public int getConversionTime() { @Override public void setConversionTime(int time) { if (time < 0) { - this.getHandle().conversionTime = -1; - this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.zombie.Zombie.DATA_DROWNED_CONVERSION_ID, false); + this.getHandle().stopDrowning(); } else { this.getHandle().startUnderWaterConversion(time); } @@ -89,8 +88,8 @@ public boolean isDrowning() { } @Override - public void startDrowning(int drownedConversionTime) { - this.getHandle().startUnderWaterConversion(drownedConversionTime); + public void startDrowning(int time) { + this.getHandle().startUnderWaterConversion(time); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java index 1d381afe5c2d..a060ce84f0f1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java @@ -16,10 +16,10 @@ public class CraftMerchantRecipe extends MerchantRecipe { private final net.minecraft.world.item.trading.MerchantOffer handle; public CraftMerchantRecipe(net.minecraft.world.item.trading.MerchantOffer merchantRecipe) { - super(CraftItemStack.asBukkitCopy(merchantRecipe.result), 0); + super(CraftItemStack.asBukkitCopy(merchantRecipe.getResult()), 0); this.handle = merchantRecipe; - this.addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.baseCostA.itemStack())); - merchantRecipe.costB.ifPresent((costB) -> this.addIngredient(CraftItemStack.asBukkitCopy(costB.itemStack()))); + this.addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.getItemCostA().itemStack())); + merchantRecipe.getItemCostB().ifPresent((costB) -> this.addIngredient(CraftItemStack.asBukkitCopy(costB.itemStack()))); } @Deprecated @@ -60,12 +60,12 @@ public int getSpecialPrice() { @Override public void setSpecialPrice(int specialPrice) { - this.handle.specialPriceDiff = specialPrice; + this.handle.setSpecialPriceDiff(specialPrice); } @Override public int getDemand() { - return this.handle.demand; + return this.handle.getDemand(); } @Override @@ -75,7 +75,7 @@ public void setDemand(int demand) { @Override public int getUses() { - return this.handle.uses; + return this.handle.getUses(); } @Override @@ -85,7 +85,7 @@ public void setUses(int uses) { @Override public int getMaxUses() { - return this.handle.maxUses; + return this.handle.getMaxUses(); } @Override @@ -95,7 +95,7 @@ public void setMaxUses(int maxUses) { @Override public boolean hasExperienceReward() { - return this.handle.rewardExp; + return this.handle.shouldRewardExp(); } @Override @@ -105,7 +105,7 @@ public void setExperienceReward(boolean flag) { @Override public int getVillagerExperience() { - return this.handle.xp; + return this.handle.getXp(); } @Override @@ -115,7 +115,7 @@ public void setVillagerExperience(int villagerExperience) { @Override public float getPriceMultiplier() { - return this.handle.priceMultiplier; + return this.handle.getPriceMultiplier(); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index f8b8e89a2cb9..aaec9e9bc8fa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -189,7 +189,7 @@ public boolean setOwner(String name) { this.setProfile( player != null ? ResolvableProfile.createResolved(player.getGameProfile()) - : new ResolvableProfile.Dynamic(Either.left(name), PlayerSkin.Patch.EMPTY) + : ResolvableProfile.createUnresolved(name) ); } @@ -203,7 +203,7 @@ public boolean setOwningPlayer(OfflinePlayer owner) { } else if (owner instanceof CraftPlayer craftPlayer) { this.setProfile(ResolvableProfile.createResolved(craftPlayer.getProfile())); } else { - this.setProfile(new ResolvableProfile.Dynamic(Either.right(owner.getUniqueId()), PlayerSkin.Patch.EMPTY)); + this.setProfile(ResolvableProfile.createUnresolved(owner.getUniqueId())); } return true; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java index 30a11ae7e872..32bf16ed0d77 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java @@ -168,9 +168,14 @@ private CraftPlayerProfile getUpdatedProfile() { @Override public ResolvableProfile buildResolvableProfile() { this.rebuildDirtyProperties(); - return this.properties.isEmpty() && (name == null) != (uniqueId == null) // Heuristic copied from net.minecraft.world.item.component.ResolvableProfile.create - ? new ResolvableProfile.Dynamic(name == null ? Either.right(uniqueId) : Either.left(name), PlayerSkin.Patch.EMPTY) - : ResolvableProfile.createResolved(this.buildGameProfile()); + if (this.properties.isEmpty() && (this.name == null) != (this.uniqueId == null)) { // Heuristic copied from ResolvableProfile.create + if (this.name == null) { + return ResolvableProfile.createUnresolved(this.uniqueId); + } else { + return ResolvableProfile.createUnresolved(this.name); + } + } + return ResolvableProfile.createResolved(this.buildGameProfile()); } // This always returns a new GameProfile instance to ensure that property changes to the original or previously diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java index 47e85f78552c..42a443f260ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java @@ -32,6 +32,7 @@ public interface PaperSharedSpawnerLogic extends Spawner { RegistryAccess getRegistryAccess(); BlockPos getInternalPosition(); + default boolean isActivated() { return this.getSpawner().isNearPlayer(this.getInternalWorld(), this.getInternalPosition()); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java index a24343bdfa30..b9b750f06f25 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/structure/CraftStructureManager.java @@ -65,7 +65,6 @@ public Structure loadStructure(NamespacedKey structureKey, boolean register) { if (register) { this.structureManager.structureRepository.put(id, structure); } - return structure.map((template) -> new CraftStructure(template, this.registry)).orElse(null); } @@ -119,7 +118,7 @@ public void deleteStructure(NamespacedKey structureKey, boolean unregister) thro Identifier id = CraftNamespacedKey.toMinecraft(structureKey); if (unregister) { - this.structureManager.structureRepository.remove(id); + this.structureManager.remove(id); } Path path = this.structureManager.worldTemplates().createAndValidatePathToStructure(id, StructureTemplateManager.WORLD_STRUCTURE_LISTER); Files.deleteIfExists(path); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 14b99f9fdc19..55d463de7f91 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -474,7 +474,7 @@ public ItemStack deserializeItemFromJson(com.google.gson.JsonObject data) throws final int dataVersion = data.get(SharedConstants.DATA_VERSION_TAG).getAsInt(); final int currentVersion = this.getDataVersion(); - data = (com.google.gson.JsonObject) MinecraftServer.getServer().fixerUpper.update(References.ITEM_STACK, new Dynamic<>(com.mojang.serialization.JsonOps.INSTANCE, data), dataVersion, currentVersion).getValue(); + data = (com.google.gson.JsonObject) MinecraftServer.getServer().getFixerUpper().update(References.ITEM_STACK, new Dynamic<>(com.mojang.serialization.JsonOps.INSTANCE, data), dataVersion, currentVersion).getValue(); com.mojang.serialization.DynamicOps ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(com.mojang.serialization.JsonOps.INSTANCE); return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.CODEC.parse(ops, data).getOrThrow(IllegalArgumentException::new)); } @@ -548,7 +548,7 @@ public org.bukkit.entity.Entity deserializeEntity(byte[] data, World world, bool CompoundTag tag = MCUtil.deserializeTagFromBytes(data); int dataVersion = NbtUtils.getDataVersion(tag, 0); Preconditions.checkArgument(dataVersion <= Bukkit.getUnsafe().getDataVersion(), "Newer version! Server downgrades are not supported!"); - tag = PlatformHooks.get().convertNBT(References.ENTITY, MinecraftServer.getServer().fixerUpper, tag, dataVersion, this.getDataVersion()); // Paper - possibly use dataconverter + tag = PlatformHooks.get().convertNBT(References.ENTITY, MinecraftServer.getServer().getFixerUpper(), tag, dataVersion, this.getDataVersion()); // Paper - possibly use dataconverter if (!preservePassengers) { tag.remove(Entity.TAG_PASSENGERS); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java index 25aae550dcdc..15261d2e9634 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java @@ -23,7 +23,7 @@ protected Set makeReference() { // Paper - protected } public static Set makePlayerSet(final MinecraftServer server) { - List players = server.getPlayerList().players; + List players = server.getPlayerList().getPlayers(); Set reference = new HashSet<>(players.size()); for (ServerPlayer player : players) { reference.add(player.getBukkitEntity()); diff --git a/paper-server/src/main/java/org/spigotmc/RestartCommand.java b/paper-server/src/main/java/org/spigotmc/RestartCommand.java index 905dde12db8a..692da58856d6 100644 --- a/paper-server/src/main/java/org/spigotmc/RestartCommand.java +++ b/paper-server/src/main/java/org/spigotmc/RestartCommand.java @@ -52,7 +52,7 @@ private static void restart(final String restartScript) { private static void shutdownServer(boolean isRestarting) { if (MinecraftServer.getServer().isSameThread()) { // Kick all players - for (ServerPlayer p : com.google.common.collect.ImmutableList.copyOf(MinecraftServer.getServer().getPlayerList().players)) { + for (ServerPlayer p : com.google.common.collect.ImmutableList.copyOf(MinecraftServer.getServer().getPlayerList().getPlayers())) { p.connection.disconnect(CraftChatMessage.fromStringOrEmpty(SpigotConfig.restartMessage, true), org.bukkit.event.player.PlayerKickEvent.Cause.RESTART_COMMAND); // Paper - kick event reason (cause is never used) } // Give the socket a chance to send the packets diff --git a/paper-server/src/main/java/org/spigotmc/WatchdogThread.java b/paper-server/src/main/java/org/spigotmc/WatchdogThread.java index 5c1306ac6eb6..aec0bd17d25a 100644 --- a/paper-server/src/main/java/org/spigotmc/WatchdogThread.java +++ b/paper-server/src/main/java/org/spigotmc/WatchdogThread.java @@ -109,7 +109,7 @@ public void run() { logger.log(Level.SEVERE, "------------------------------"); logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):"); // Paper FeatureHooks.dumpAllChunkLoadInfo(MinecraftServer.getServer(), isLongTimeout); // Paper - log detailed tick information - WatchdogThread.dumpThread(ManagementFactory.getThreadMXBean().getThreadInfo(MinecraftServer.getServer().serverThread.threadId(), Integer.MAX_VALUE), logger); + WatchdogThread.dumpThread(ManagementFactory.getThreadMXBean().getThreadInfo(MinecraftServer.getServer().getRunningThread().threadId(), Integer.MAX_VALUE), logger); logger.log(Level.SEVERE, "------------------------------"); // Paper start - Only print full dump on long timeouts diff --git a/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java b/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java index 4649f0e8e302..cdfcbf0552af 100644 --- a/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java +++ b/paper-server/src/test/java/io/papermc/paper/command/brigadier/BukkitCommandConversionTest.java @@ -32,7 +32,7 @@ public void test() throws CommandSyntaxException { CommandSourceStack object = Mockito.mock(CommandSourceStack.class); Mockito.when(object.getLocation()).thenReturn(new Location(null, 0, 0, 0)); - CommandDispatcher dispatcher = RegistryHelper.context().datapack().commands.getDispatcher(); + CommandDispatcher dispatcher = RegistryHelper.context().datapack().getCommands().getDispatcher(); dispatcher.setConsumer((context, success, result) -> {}); CommandMap commandMap = new SimpleCommandMap(Bukkit.getServer(), new BukkitBrigForwardingMap()); Map stringCommandMap = commandMap.getKnownCommands(); From 14bb579bc49aa04fed206a69f598e29be47e8ff3 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Tue, 16 Jun 2026 22:11:27 +0200 Subject: [PATCH 16/30] fix bad exhaustion reasons for player movement --- .../net/minecraft/server/level/ServerPlayer.java.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 7c2e7871c4a3..f821b7e01d01 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 @@ -1111,14 +1111,14 @@ if (distance > 0) { this.awardStat(Stats.SWIM_ONE_CM, distance); - this.causeFoodExhaustion(0.01F * distance * 0.01F); -+ this.causeFoodExhaustion(this.level().spigotConfig.swimMultiplier * distance * 0.01F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent // Spigot ++ this.causeFoodExhaustion(this.level().spigotConfig.swimMultiplier * distance * 0.01F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent // Spigot } } else if (this.isEyeInFluid(FluidTags.WATER)) { int distance = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (distance > 0) { this.awardStat(Stats.WALK_UNDER_WATER_ONE_CM, distance); - this.causeFoodExhaustion(0.01F * distance * 0.01F); -+ this.causeFoodExhaustion(this.level().spigotConfig.swimMultiplier * distance * 0.01F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent // Spigot ++ this.causeFoodExhaustion(this.level().spigotConfig.swimMultiplier * distance * 0.01F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent // Spigot } } else if (this.isInWater()) { int horizontalDistance = Math.round((float)Math.sqrt(dx * dx + dz * dz) * 100.0F); @@ -1134,7 +1134,7 @@ if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, horizontalDistance); - this.causeFoodExhaustion(0.1F * horizontalDistance * 0.01F); -+ this.causeFoodExhaustion(this.level().spigotConfig.sprintMultiplier * horizontalDistance * 0.01F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent // Spigot ++ this.causeFoodExhaustion(this.level().spigotConfig.sprintMultiplier * horizontalDistance * 0.01F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent // Spigot } else if (this.isCrouching()) { this.awardStat(Stats.CROUCH_ONE_CM, horizontalDistance); - this.causeFoodExhaustion(0.0F * horizontalDistance * 0.01F); From 0b4fed78843db5d4e251d0f465005b8351da9f82 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Wed, 17 Jun 2026 01:40:54 +0200 Subject: [PATCH 17/30] fix misc issues thanks to demidude76 for reporting these --- .../0001-Moonrise-optimisation-patches.patch | 64 +++++++++---------- .../0003-Entity-Activation-Range-2.0.patch | 16 ++--- ...nate-Current-redstone-implementation.patch | 12 ++-- ...-Incremental-chunk-and-player-saving.patch | 10 +-- .../patches/features/0017-Anti-Xray.patch | 10 +-- .../server/level/ChunkMap.java.patch | 2 +- .../server/level/ServerEntity.java.patch | 14 ++-- .../server/level/ServerLevel.java.patch | 8 ++- .../server/level/ServerPlayer.java.patch | 35 ++++++---- .../ServerGamePacketListenerImpl.java.patch | 22 +++---- .../projectile/arrow/AbstractArrow.java.patch | 25 +++++--- .../projectile/arrow/ThrownTrident.java.patch | 11 ++++ .../world/inventory/LoomMenu.java.patch | 13 +++- .../block/LayeredCauldronBlock.java.patch | 2 +- .../SculkCatalystBlockEntity.java.patch | 2 +- .../treedecorators/CocoaDecorator.java.patch | 10 --- .../org/bukkit/craftbukkit/CraftWorld.java | 21 +----- 17 files changed, 143 insertions(+), 134 deletions(-) delete mode 100644 paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java.patch diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index 9c4ee77360a0..715aeb070b70 100644 --- a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -24586,7 +24586,7 @@ index 5e5aad112058b567214c28ccd719271f12240a35..cd5a325d37f617431ceb568a65570160 @FunctionalInterface diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index d0c8796fb86446b1e2b0e2b2e372b968b1b9f0da..e72bdc0311337742c687e318b80f90e04374f149 100644 +index 00caaaddb3858926b1c6ce42dcf25386d7c073ea..e72bdc0311337742c687e318b80f90e04374f149 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -124,10 +124,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP @@ -25795,7 +25795,7 @@ index d0c8796fb86446b1e2b0e2b2e372b968b1b9f0da..e72bdc0311337742c687e318b80f90e0 - for (Entity passenger : this.entity.getIndirectPassengers()) { - int passengerRange = passenger.getType().clientTrackingRange() * 16; -- passengerRange = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, passengerRange); // Paper +- passengerRange = org.spigotmc.TrackingRange.getEntityTrackingRange(passenger, passengerRange); // Paper - if (passengerRange > effectiveRange) { - effectiveRange = passengerRange; - } @@ -26956,7 +26956,7 @@ index 5e0d2bbd9223f727ec337357ee7d0088eff11ab8..3d6765f284d1817d68db4d9ae0d90c7e } } diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 60e89fbbd09ada8a48527ebac43340a58aa6d001..70daec14be69c0e02759489a5ddeda8718a288cc 100644 +index f11c5ea1ee9381e7bf65305b959bd7da67423ece..26822e1211194b411dd8ea75ce523133e5389e47 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -90,6 +90,11 @@ public class ServerEntity { @@ -26972,7 +26972,7 @@ index 60e89fbbd09ada8a48527ebac43340a58aa6d001..70daec14be69c0e02759489a5ddeda87 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 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d5670aaeed8b 100644 +index d30f5ed54da9c9518cf61015669e7916cc60e6ca..ac3d8d819bc5042b476f68a2c023cc5717fde847 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; @@ -26993,7 +26993,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 private final GameEventDispatcher gameEventDispatcher; public boolean noSave; private final SleepStatus sleepStatus; -@@ -277,12 +277,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -279,12 +279,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public final void loadChunksForMoveAsync(AABB box, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -27007,7 +27007,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 int minBlockX = Mth.floor(box.minX - 1.0E-7) - 3; int minBlockZ = Mth.floor(box.minZ - 1.0E-7) - 3; -@@ -301,30 +296,171 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -303,30 +298,171 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public final void loadChunks(int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -27195,7 +27195,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } } } -@@ -338,16 +474,135 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -340,16 +476,135 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } } } @@ -27338,7 +27338,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 public ServerLevel( final MinecraftServer server, -@@ -417,18 +672,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -419,18 +674,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet // CraftBukkit end boolean syncWrites = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); @@ -27358,7 +27358,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 this.chunkSource = new ServerChunkCache( this, levelStorage, -@@ -439,7 +683,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -441,7 +685,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.spigotConfig.viewDistance, // Spigot this.spigotConfig.simulationDistance, // Spigot syncWrites, @@ -27367,7 +27367,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 () -> server.overworld().getDataStorage() , savedDataStorage // Paper - initialize SavedDataStorage earlier ); -@@ -479,6 +723,20 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -481,6 +725,20 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.waypointManager = new ServerWaypointManager(this); // Paper - optimize ServerWaypointManager with locator bar disabled this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); this.updateSkyBrightness(); @@ -27388,7 +27388,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } -@@ -627,8 +885,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -629,8 +887,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet profiler.push("checkDespawn"); entity.checkDespawn(); profiler.pop(); @@ -27398,7 +27398,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 Entity vehicle = entity.getVehicle(); if (vehicle != null) { if (!vehicle.isRemoved() && vehicle.hasPassenger(entity)) { -@@ -655,7 +912,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -657,7 +914,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } profiler.push("entityManagement"); @@ -27407,7 +27407,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 profiler.pop(); profiler.push("debugSynchronizers"); if (this.debugSynchronizers.hasAnySubscriberFor(DebugSubscriptions.NEIGHBOR_UPDATES)) { -@@ -671,7 +928,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -673,7 +930,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public boolean shouldTickBlocksAt(final long chunkPos) { @@ -27419,7 +27419,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } protected void tickTime() { -@@ -695,7 +955,60 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -697,7 +957,60 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.players.stream().filter(LivingEntity::isSleeping).collect(Collectors.toList()).forEach(player -> player.stopSleepInBed(false, false)); } @@ -27480,7 +27480,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 ChunkPos chunkPos = chunk.getPos(); int minX = chunkPos.getMinBlockX(); int minZ = chunkPos.getMinBlockZ(); -@@ -704,7 +1017,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -706,7 +1019,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow for (int i = 0; i < tickSpeed; i++) { @@ -27489,7 +27489,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 this.tickPrecipitation(this.getBlockRandomPos(minX, 0, minZ, 15)); } } -@@ -712,31 +1025,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -714,31 +1027,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet profiler.popPush("tickBlocks"); if (tickSpeed > 0) { @@ -27522,7 +27522,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } profiler.pop(); -@@ -1059,6 +1348,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1061,6 +1350,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (fluidState.is(type)) { fluidState.tick(this, pos, blockState); } @@ -27535,7 +27535,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } private void tickBlock(final BlockPos pos, final Block type) { -@@ -1066,6 +1361,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1068,6 +1363,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet if (state.is(type)) { state.tick(this, pos, this.random); } @@ -27548,7 +27548,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } // Paper start - log detailed entity tick information -@@ -1150,6 +1451,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1152,6 +1453,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } public void save(final @Nullable ProgressListener progressListener, final boolean flush, final boolean noSave) { @@ -27560,7 +27560,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 ServerChunkCache chunkSource = this.getChunkSource(); if (!noSave) { new org.bukkit.event.world.WorldSaveEvent(this.getWorld()).callEvent(); // CraftBukkit -@@ -1162,13 +1468,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1164,13 +1470,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet progressListener.progressStage(Component.translatable("menu.savingChunks")); } @@ -27584,7 +27584,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } private void saveLevelData(final boolean sync) { -@@ -1289,7 +1600,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1291,7 +1602,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet this.removePlayerImmediately((ServerPlayer)existing, Entity.RemovalReason.DISCARDED); } @@ -27593,7 +27593,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } // CraftBukkit start -@@ -1320,7 +1631,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1322,7 +1633,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } // CraftBukkit end @@ -27602,7 +27602,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } } -@@ -1331,7 +1642,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1333,7 +1644,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public boolean tryAddFreshEntityWithPassengers(final Entity entity, final org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { // CraftBukkit end @@ -27611,7 +27611,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 return false; } -@@ -2120,7 +2431,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2122,7 +2433,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } } @@ -27620,7 +27620,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 output.write(String.format(Locale.ROOT, "block_entity_tickers: %d\n", this.blockEntityTickers.size())); output.write(String.format(Locale.ROOT, "block_ticks: %d\n", this.getBlockTicks().count())); output.write(String.format(Locale.ROOT, "fluid_ticks: %d\n", this.getFluidTicks().count())); -@@ -2138,13 +2449,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2140,13 +2451,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet Path chunks = rootDir.resolve("chunks.csv"); try (Writer output = Files.newBufferedWriter(chunks)) { @@ -27636,7 +27636,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } Path entities = rootDir.resolve("entities.csv"); -@@ -2239,8 +2550,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2241,8 +2552,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet Locale.ROOT, "players: %s, entities: %s [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), @@ -27647,7 +27647,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 this.blockEntityTickers.size(), getTypeCount(this.blockEntityTickers, TickingBlockEntity::getType), this.getBlockTicks().count(), -@@ -2273,15 +2584,25 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2275,15 +2586,25 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public LevelEntityGetter getEntities() { org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot @@ -27676,7 +27676,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } public void startTickingChunk(final LevelChunk levelChunk) { -@@ -2298,8 +2619,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2300,8 +2621,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public void waitForEntities(final ChunkPos centerChunk, final int radius) { List chunks = ChunkPos.rangeClosed(centerChunk, radius).toList(); @@ -27687,7 +27687,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 for (ChunkPos chunk : chunks) { if (!this.areEntitiesLoaded(chunk.pack())) { -@@ -2318,28 +2639,38 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2320,28 +2641,38 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet @Override public void close() throws IOException { super.close(); @@ -27732,7 +27732,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } public boolean anyPlayerCloseEnoughForSpawning(final BlockPos pos) { -@@ -2356,7 +2687,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2358,7 +2689,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet } public boolean canSpawnEntitiesInChunk(final ChunkPos pos) { @@ -27744,7 +27744,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 } @Override -@@ -2404,7 +2738,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2406,7 +2740,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public CrashReportCategory fillReportDetails(final CrashReport report) { CrashReportCategory category = super.fillReportDetails(report); WeatherData weatherData = this.getWeatherData(); @@ -27754,7 +27754,7 @@ index 394eafb08758f5e3c312108046abf3048747abfe..7861b180e1e0ed73c1702fee7181d567 "Server weather", () -> String.format( diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index ccf61d6f82e411f7e46d909b6308f807900882bf..5f77160da6d59afb0109be40cbe8597a93a62908 100644 +index 330f2262bcde7cbc85564631a0c0c38c75eb3959..4ea2a918d3f9d76cf6650243f14eb87e9c657f36 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java @@ -206,7 +206,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; diff --git a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch index 1b9b8502a959..23bc7bf8ffa8 100644 --- a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch @@ -355,10 +355,10 @@ index 0000000000000000000000000000000000000000..829f7685904fd741e00403647ae76d32 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 7861b180e1e0ed73c1702fee7181d5670aaeed8b..639b301f3ab82ea44d5c0e4ecec3983b9c0c02c3 100644 +index ac3d8d819bc5042b476f68a2c023cc5717fde847..bbfe1e0519929ad91d3aecabb510fbf436c203d3 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -877,6 +877,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -879,6 +879,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet profiler.pop(); } @@ -366,7 +366,7 @@ index 7861b180e1e0ed73c1702fee7181d5670aaeed8b..639b301f3ab82ea44d5c0e4ecec3983b this.entityTickList .forEach( entity -> { -@@ -1395,12 +1396,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1397,12 +1398,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet entity.totalEntityAge++; // Paper - age-like counter for all entities profiler.push(entity.typeHolder()::getRegisteredName); profiler.incrementCounter("tickNonPassenger"); @@ -383,7 +383,7 @@ index 7861b180e1e0ed73c1702fee7181d5670aaeed8b..639b301f3ab82ea44d5c0e4ecec3983b } // Paper start - log detailed entity tick information } finally { -@@ -1411,7 +1415,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1413,7 +1417,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet // Paper end - log detailed entity tick information } @@ -392,7 +392,7 @@ index 7861b180e1e0ed73c1702fee7181d5670aaeed8b..639b301f3ab82ea44d5c0e4ecec3983b if (entity.isRemoved() || entity.getVehicle() != vehicle) { entity.stopRiding(); } else if (entity instanceof Player || this.entityTickList.contains(entity)) { -@@ -1421,12 +1425,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -1423,12 +1427,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet ProfilerFiller profiler = Profiler.get(); profiler.push(entity.typeHolder()::getRegisteredName); profiler.incrementCounter("tickPassenger"); @@ -463,7 +463,7 @@ index 271ed1128959287f6c1b6ca59ded377b88f5afff..f03fa06c0ba56f7f5e1e45bc1568a490 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index d462bb751b14c2fffc970c7450f3c6b5d7909e53..f3b55daf9d3b88fcb5a5e88926f33e437297647b 100644 +index ba0cdbd064ad3e0cf645c50ab14adcddef48e932..68855c16d2cb3e5b7d7a86f05e7bb2e7922a5ba0 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -382,6 +382,15 @@ public abstract class Entity @@ -522,7 +522,7 @@ index d462bb751b14c2fffc970c7450f3c6b5d7909e53..f3b55daf9d3b88fcb5a5e88926f33e43 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 08e3437671b19be4415e23da7f975b6833039810..a6e4a0f0201b265d5c4a3dd3dc4d64935559fe88 100644 +index c471349faf04931668d40faba0f8f45937f1d711..d4fa50aa52a3a6c076d632989e21ff424eec7cf2 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -3404,6 +3404,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @@ -819,7 +819,7 @@ index f46cca0467bb4da5511bc953ce5b43fa606bf978..445c5cafad71028171c1f26193966177 + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index c3f716f8cd7326af411f6e1648a3db49b5f34c36..bc03996ce2d7a885e162909958a2a06e2947523c 100644 +index 6e3a05c2b9709272634bca2becd00d1411583627..7b536017ea5703e7b86359673fd999143299d2a2 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -156,6 +156,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl diff --git a/paper-server/patches/features/0012-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0012-Add-Alternate-Current-redstone-implementation.patch index 7c0b0632653f..fa3d71c1e3e0 100644 --- a/paper-server/patches/features/0012-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0012-Add-Alternate-Current-redstone-implementation.patch @@ -2321,18 +2321,18 @@ index 0000000000000000000000000000000000000000..33cd90c30c22200a4e1ae64f40a0bf78 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index e8d9eff03d098ce65d44ee0172b70b7e90a658d4..0dfcfc01dbd063d5b27081df3683c66fb437a3a5 100644 +index bbfe1e0519929ad91d3aecabb510fbf436c203d3..4eee4a42425bef4f7bcf2fe8115e3cc03064ed5b 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -234,6 +234,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet - private @Nullable ServerClockManager clockManager; - public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent +@@ -236,6 +236,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent + 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 = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current) @Override public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { -@@ -2781,6 +2782,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet +@@ -2783,6 +2784,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet return this.debugSynchronizers; } @@ -2347,7 +2347,7 @@ index e8d9eff03d098ce65d44ee0172b70b7e90a658d4..0dfcfc01dbd063d5b27081df3683c66f 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 5f040613ef5d1eab58ac82719cbb02a9201432e4..46b9b87d58947f8f789cd2ce75e1d2ef6ca74d90 100644 +index 7b536017ea5703e7b86359673fd999143299d2a2..411f1b8dea6b57cd5d6dc3b6b4c3c0f8e2383786 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -2162,6 +2162,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl diff --git a/paper-server/patches/features/0013-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0013-Incremental-chunk-and-player-saving.patch index 728c6f7f0f6a..5c6ed23c42dc 100644 --- a/paper-server/patches/features/0013-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0013-Incremental-chunk-and-player-saving.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 7ebfe2acac0fe980320386de9574b0600c9e3e97..1a941fe5cff1d002486306e2632f0fd2628107f6 100644 +index b9d4161dedfd43a1542ee8e5bc57a66ce5e39dba..35d69b00d269e6917621fe338d79b95e4fd39ba9 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -960,7 +960,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop effectiveRange) { effectiveRange = passengerRange; } diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch index 242c94deec0a..e9fb785e88d0 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch @@ -99,18 +99,18 @@ } Packet packet = this.entity.getAddEntityPacket(this); -@@ -285,6 +_,11 @@ - +@@ -286,6 +_,11 @@ if (this.entity instanceof LivingEntity livingEntity) { Collection attributes = livingEntity.getAttributes().getSyncableAttributes(); -+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health -+ if (this.entity.getId() == player.getId()) { -+ ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(attributes, false); -+ } -+ // CraftBukkit end if (!attributes.isEmpty()) { ++ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health ++ if (this.entity.getId() == player.getId()) { ++ ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(attributes, false); ++ } ++ // CraftBukkit end broadcast.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), attributes)); } + } @@ -301,8 +_,9 @@ } 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 1f9af3adf702..376be7a4b144 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 @@ -9,7 +9,7 @@ private final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; private EnvironmentAttributeSystem environmentAttributes; -@@ -222,24 +_,199 @@ +@@ -222,24 +_,201 @@ private final boolean tickTime; private final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -25,6 +25,8 @@ + private @Nullable ServerClockManager clockManager; + public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent + public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent ++ 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 = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + + @Override + public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { @@ -192,7 +194,7 @@ + } + // Paper end - per-world time + if (loadedWorldData.pdc() != null) { -+ this.getWorld().readBukkitValues(loadedWorldData.pdc().persistentData().toTagCompound()); ++ this.persistentDataContainer.putAll(loadedWorldData.pdc().persistentData().toTagCompound()); + } + + if (biomeProvider != null) { @@ -589,7 +591,7 @@ private void saveLevelData(final boolean sync) { SavedDataStorage savedDataStorage = this.getChunkSource().getDataStorage(); -+ savedDataStorage.computeIfAbsent(io.papermc.paper.world.saveddata.PaperWorldPDC.TYPE).setFrom((org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer) this.getWorld().getPersistentDataContainer()); // Paper ++ savedDataStorage.computeIfAbsent(io.papermc.paper.world.saveddata.PaperWorldPDC.TYPE).setFrom(this.persistentDataContainer); // Paper if (sync) { savedDataStorage.saveAndJoin(); } else { 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 f821b7e01d01..55ed4d0119a0 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 @@ -125,13 +125,18 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -405,6 +_,19 @@ +@@ -405,12 +_,26 @@ 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); -+ // Paper start - Expand PlayerGameModeChangeEvent -+ this.loadGameTypes(input); -+ } +- this.gameMode +- .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); ++ this.loadGameTypes(input); // Paper - Expand PlayerGameModeChangeEvent + this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); + this.setShoulderEntityRight(input.read("ShoulderEntityRight", CompoundTag.CODEC).orElseGet(CompoundTag::new)); + } + ++ // Paper start - Expand PlayerGameModeChangeEvent + private void loadGameTypes(ValueInput input) { + if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != readPlayerMode(input, "playerGameType")) { + if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), org.bukkit.GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) { @@ -141,10 +146,14 @@ + } + return; + } -+ // Paper end - Expand PlayerGameModeChangeEvent - this.gameMode - .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); - this.setShoulderEntityLeft(input.read("ShoulderEntityLeft", CompoundTag.CODEC).orElseGet(CompoundTag::new)); ++ this.gameMode ++ .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType")); ++ } ++ // Paper end - Expand PlayerGameModeChangeEvent ++ + @Override + protected void addAdditionalSaveData(final ValueOutput output) { + super.addAdditionalSaveData(output); @@ -433,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); @@ -240,7 +249,7 @@ public void doTick() { try { - if (!this.isSpectator() || !this.touchingUnloadedChunk()) { -+ if (valid && !this.isSpectator() || !this.touchingUnloadedChunk()) { // Paper - don't tick dead players that are not in the world currently (pending respawn) ++ if (this.valid && (!this.isSpectator() || !this.touchingUnloadedChunk())) { // Paper - don't tick dead players that are not in the world currently (pending respawn) super.tick(); if (!this.containerMenu.stillValid(this)) { - this.closeContainer(); @@ -1362,14 +1371,14 @@ if (oldCamera != this.camera) { + // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity + if (this.camera == this) { -+ com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent playerStopSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), camera.getBukkitEntity()); -+ if (!playerStopSpectatingEntityEvent.callEvent()) { ++ com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent spectateEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), oldCamera.getBukkitEntity()); ++ if (!spectateEvent.callEvent()) { + this.camera = oldCamera; // rollback camera entity again + return; + } + } else { -+ com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent playerStartSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent(this.getBukkitEntity(), camera.getBukkitEntity(), newCamera.getBukkitEntity()); -+ if (!playerStartSpectatingEntityEvent.callEvent()) { ++ com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent spectateEvent = new com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent(this.getBukkitEntity(), oldCamera.getBukkitEntity(), newCamera.getBukkitEntity()); ++ if (!spectateEvent.callEvent()) { + this.camera = oldCamera; // rollback camera entity again + return; + } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 858029664bb2..9c8b04e6cc71 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -314,7 +314,7 @@ + this.hasMoved = true; + } + Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. -+ Location to = CraftLocation.toBukkit(packet.position(), player.getWorld(), packet.yRot(), packet.xRot()); ++ Location to = new Location(player.getWorld(), targetX, targetY, targetZ, targetYRot, targetXRot); + + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Mth.square(this.lastPosX - to.getX()) + Mth.square(this.lastPosY - to.getY()) + Mth.square(this.lastPosZ - to.getZ()); @@ -822,15 +822,15 @@ + + // If the packet contains movement information then we update the To location with the correct XYZ. + if (packet.hasPosition()) { -+ to.setX(packet.getX(0.0)); -+ to.setY(packet.getY(0.0)); -+ to.setZ(packet.getZ(0.0)); ++ to.setX(targetX); ++ to.setY(targetY); ++ to.setZ(targetZ); + } + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. + if (packet.hasRotation()) { -+ to.setYaw(packet.getYRot(0.0F)); -+ to.setPitch(packet.getXRot(0.0F)); ++ to.setYaw(targetYRot); ++ to.setPitch(targetXRot); + } + + com.destroystokyo.paper.event.player.PlayerJumpEvent event = new com.destroystokyo.paper.event.player.PlayerJumpEvent(player, from, to); @@ -916,15 +916,15 @@ + + // If the packet contains movement information then we update the To location with the correct XYZ. + if (packet.hasPosition()) { -+ to.setX(packet.getX(0.0)); -+ to.setY(packet.getY(0.0)); -+ to.setZ(packet.getZ(0.0)); ++ to.setX(targetX); ++ to.setY(targetY); ++ to.setZ(targetZ); + } + + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. + if (packet.hasRotation()) { -+ to.setYaw(packet.getYRot(0.0F)); -+ to.setPitch(packet.getXRot(0.0F)); ++ to.setYaw(targetYRot); ++ to.setPitch(targetXRot); + } + + // Prevent 40 event-calls for less than a single pixel of movement >.> diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch index 6ad7884b21b5..4cac04fdc598 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch @@ -200,24 +200,23 @@ this.pickup = switch (owner) { case Player ignored when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -650,9 +_,22 @@ +@@ -650,17 +_,29 @@ @Override public void playerTouch(final Player player) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { - if (this.tryPickup(player)) { + // CraftBukkit start -+ ItemStack itemstack = this.getPickupItem(); -+ if (this.pickup == Pickup.ALLOWED && !itemstack.isEmpty() && player.getInventory().canHold(itemstack) > 0) { -+ net.minecraft.world.entity.item.ItemEntity item = new net.minecraft.world.entity.item.ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack); ++ ItemStack pickupItem = this.getPickupItem(); ++ if (this.pickup == Pickup.ALLOWED && !pickupItem.isEmpty() && player.getInventory().canHold(pickupItem) > 0) { ++ net.minecraft.world.entity.item.ItemEntity item = new net.minecraft.world.entity.item.ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), pickupItem); + org.bukkit.event.player.PlayerPickupArrowEvent event = new org.bukkit.event.player.PlayerPickupArrowEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.Item) item.getBukkitEntity(), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); -+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO ++ // event.setCancelled(!player.canPickUpLoot()); TODO + if (!event.callEvent()) { + return; + } -+ itemstack = item.getItem(); ++ pickupItem = item.getItem(); + } -+ -+ if ((this.pickup == AbstractArrow.Pickup.ALLOWED && player.getInventory().add(itemstack)) || (this.pickup == AbstractArrow.Pickup.CREATIVE_ONLY && player.getAbilities().instabuild)) { ++ if (this.tryPickup(player, pickupItem)) { + // CraftBukkit end player.take(this, 1); - this.discard(); @@ -225,3 +224,13 @@ } } } + +- protected boolean tryPickup(final Player player) { ++ protected boolean tryPickup(final Player player, final ItemStack pickupItem) { // Paper - pass custom pickup item + return switch (this.pickup) { + case DISALLOWED -> false; +- case ALLOWED -> player.getInventory().add(this.getPickupItem()); ++ case ALLOWED -> player.getInventory().add(pickupItem); // Paper - pass custom pickup item + case CREATIVE_ONLY -> player.hasInfiniteMaterials(); + }; + } 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 e451c4dcb70c..07a413fa8ebf 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 @@ -56,3 +56,14 @@ Entity currentOwner = this.getOwner(); DamageSource damageSource = this.damageSources().trident(this, currentOwner == null ? this : currentOwner); if (this.level() instanceof ServerLevel serverLevel) { +@@ -170,8 +_,8 @@ + } + + @Override +- protected boolean tryPickup(final Player player) { +- return super.tryPickup(player) || this.isNoPhysics() && this.ownedBy(player) && player.getInventory().add(this.getPickupItem()); ++ protected boolean tryPickup(final Player player, final ItemStack pickupItem) { // Paper - pass custom pickup item ++ return super.tryPickup(player, pickupItem) || this.isNoPhysics() && this.ownedBy(player) && player.getInventory().add(pickupItem); // Paper - pass custom pickup item + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch index 2fe82f342fce..efe2bd9b59f7 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch @@ -39,11 +39,10 @@ public LoomMenu(final int containerId, final Inventory inventory) { this(containerId, inventory, ContainerLevelAccess.NULL); -@@ -61,6 +_,28 @@ +@@ -61,6 +_,35 @@ public LoomMenu(final int containerId, final Inventory inventory, final ContainerLevelAccess access) { super(MenuType.LOOM, containerId); this.access = access; -+ // CraftBukkit start + this.inputContainer = new SimpleContainer(this.createBlockHolder(access), 3) { // Paper - Add missing InventoryHolders + @Override + public void setChanged() { @@ -51,6 +50,13 @@ + LoomMenu.this.slotsChanged(this); + LoomMenu.this.slotUpdateListener.run(); + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.Location getLocation() { ++ return access.getLocation(); ++ } ++ // CraftBukkit end + }; + this.outputContainer = new SimpleContainer(this.createBlockHolder(access), 1) { // Paper - Add missing InventoryHolders + @Override @@ -59,12 +65,13 @@ + LoomMenu.this.slotUpdateListener.run(); + } + ++ // CraftBukkit start + @Override + public org.bukkit.Location getLocation() { + return access.getLocation(); + } ++ // CraftBukkit end + }; -+ // CraftBukkit end this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { @Override public boolean mayPlace(final ItemStack itemStack) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch index 61ca775594c3..be0701211f18 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch @@ -10,7 +10,7 @@ effectApplier.runBefore(InsideBlockEffectType.EXTINGUISH, e -> { - if (e.isOnFire() && e.mayInteract(serverLevel, blockPos)) { - this.handleEntityOnFireInside(state, level, blockPos); -+ if (e.isOnFire() && (entity instanceof net.minecraft.world.entity.player.Player || serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING)) && e.mayInteract(serverLevel, blockPos)) { // Paper - Fixes MC-248588 ++ if (e.isOnFire() && (e instanceof net.minecraft.world.entity.player.Player || serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING)) && e.mayInteract(serverLevel, blockPos)) { // Paper - Fixes MC-248588 + // Paper start - Call CauldronLevelChangeEvent + if (this.handleEntityOnFireInside(state, level, blockPos, e)) { // Paper - track entity + InsideBlockEffectType.EXTINGUISH.effect().affect(e, blockPos); // apply extinguishing if event was not cancelled. diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch index ea19fc3705be..4829925ac24d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java.patch @@ -13,7 +13,7 @@ + // Paper end - Fix NPE in SculkBloomEvent world access + public static void serverTick(final Level level, final BlockPos pos, final BlockState state, final SculkCatalystBlockEntity entity) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = entity.getBlockPos(); // CraftBukkit - SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPos up to five methods deep. ++ org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = pos; // CraftBukkit - SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPos up to five methods deep. entity.catalystListener.getSculkSpreader().updateCursors(level, pos, level.getRandom(), true); + org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = null; // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java.patch deleted file mode 100644 index 45cf44178437..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java -+++ b/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java -@@ -24,6 +_,7 @@ - - @Override - public void place(final TreeDecorator.Context context) { -+ if (context.logs().isEmpty()) return; // Paper - Fix crash when trying to generate without logs - RandomSource random = context.random(); - if (!(random.nextFloat() >= this.probability)) { - List logs = context.logs(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0c1e9abfa9eb..faa57d7a4dc7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -42,8 +42,6 @@ import net.minecraft.core.QuartPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.registries.Registries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.protocol.game.ClientboundLevelEventPacket; import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket; import net.minecraft.network.protocol.game.ClientboundSoundPacket; @@ -103,7 +101,6 @@ import org.bukkit.WorldBorder; import org.bukkit.block.Biome; import org.bukkit.block.Block; -import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; import org.bukkit.boss.DragonBattle; import org.bukkit.craftbukkit.block.CraftBiome; @@ -119,8 +116,6 @@ import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.metadata.BlockMetadataStore; -import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; -import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; import org.bukkit.craftbukkit.util.CraftBiomeSearchResult; import org.bukkit.craftbukkit.util.CraftDifficulty; import org.bukkit.craftbukkit.util.CraftLocation; @@ -169,7 +164,6 @@ import org.jetbrains.annotations.Nullable; public class CraftWorld extends CraftRegionAccessor implements World { - private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); private static final PointersSupplier POINTERS_SUPPLIER = PointersSupplier.builder() .resolving(net.kyori.adventure.identity.Identity.NAME, World::getName) // todo key pointer @@ -181,7 +175,6 @@ public class CraftWorld extends CraftRegionAccessor implements World { private final List populators = new ArrayList<>(); private final BlockMetadataStore blockMetadata = new BlockMetadataStore(this); private final Object2IntOpenHashMap spawnCategoryLimit = new Object2IntOpenHashMap<>(); - private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftWorld.DATA_TYPE_REGISTRY); private final ServerLevel world; private final NamespacedKey key; private final Environment environment; @@ -1977,19 +1970,7 @@ private List getStructures(int x, int z, Predicate Date: Wed, 17 Jun 2026 14:19:11 +0200 Subject: [PATCH 18/30] fix contract of ItemContainerContents#contents The method was wrongly updated and could return null items instead of empty ones --- ...on-checking-in-player-move-packet-ha.patch | 18 +-- .../ServerGamePacketListenerImpl.java.patch | 116 +++++++----------- .../item/PaperChargedProjectiles.java | 2 +- .../item/PaperItemContainerContents.java | 2 +- 4 files changed, 54 insertions(+), 84 deletions(-) diff --git a/paper-server/patches/features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch index abac48531767..22b0a9997ca4 100644 --- a/paper-server/patches/features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch +++ b/paper-server/patches/features/0027-Optimise-collision-checking-in-player-move-packet-ha.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimise collision checking in player move packet handling Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5f4d87707 100644 +index d55b217d58f85e8f82efc87b1ea69e7074f9ae85..bc9edc64a7850f7989dd6adf1358ce08df01fd80 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -637,6 +637,7 @@ public class ServerGamePacketListenerImpl +@@ -636,6 +636,7 @@ public class ServerGamePacketListenerImpl } vehicle.move(MoverType.PLAYER, new Vec3(xDist, yDist, zDist)); @@ -17,7 +17,7 @@ index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5 double oyDist = yDist; xDist = targetX - vehicle.getX(); yDist = targetY - vehicle.getY(); -@@ -652,7 +653,17 @@ public class ServerGamePacketListenerImpl +@@ -651,7 +652,17 @@ public class ServerGamePacketListenerImpl LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", vehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(movedDist)); } @@ -36,7 +36,7 @@ index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5 vehicle.absSnapTo(oldX, oldY, oldZ, targetYRot, targetXRot); this.send(ClientboundMoveVehiclePacket.fromEntity(vehicle)); vehicle.removeLatestMovementRecording(); -@@ -731,9 +742,32 @@ public class ServerGamePacketListenerImpl +@@ -730,9 +741,32 @@ public class ServerGamePacketListenerImpl } private boolean noBlocksAround(final Entity entity) { @@ -72,7 +72,7 @@ index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5 } @Override -@@ -1548,7 +1582,7 @@ public class ServerGamePacketListenerImpl +@@ -1544,7 +1578,7 @@ public class ServerGamePacketListenerImpl } } @@ -81,7 +81,7 @@ index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5 xDist = targetX - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above yDist = targetY - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above zDist = targetZ - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above -@@ -1587,6 +1621,7 @@ public class ServerGamePacketListenerImpl +@@ -1570,6 +1604,7 @@ public class ServerGamePacketListenerImpl boolean playerStandsOnSomething = this.player.verticalCollisionBelow; this.player.move(MoverType.PLAYER, new Vec3(xDist, yDist, zDist)); this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move @@ -89,7 +89,7 @@ index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5 // Paper start - prevent position desync if (this.awaitingPositionFromClient != null) { return; // ... thanks Mojang for letting move calls teleport across dimensions. -@@ -1620,7 +1655,17 @@ public class ServerGamePacketListenerImpl +@@ -1603,7 +1638,17 @@ public class ServerGamePacketListenerImpl } // Paper start - Add fail move event @@ -108,7 +108,7 @@ index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5 if (!allowMovement) { io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, targetX, targetY, targetZ, targetYRot, targetXRot, false); -@@ -1760,7 +1805,7 @@ public class ServerGamePacketListenerImpl +@@ -1730,7 +1775,7 @@ public class ServerGamePacketListenerImpl private boolean updateAwaitingTeleport() { if (this.awaitingPositionFromClient != null) { @@ -117,7 +117,7 @@ index 0183a98b7ec3ef3527df226b9fc6d9c51f0e11b9..ed8759bbf5e8b6ca5292c32c6b9974e5 this.awaitingTeleportTime = this.tickCount; this.teleport( this.awaitingPositionFromClient.x, -@@ -1779,6 +1824,34 @@ public class ServerGamePacketListenerImpl +@@ -1749,6 +1794,34 @@ public class ServerGamePacketListenerImpl } } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 9c8b04e6cc71..7aaac62096ee 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -222,6 +_,38 @@ +@@ -222,6 +_,37 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -26,7 +26,6 @@ +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInputEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; -+import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerRespawnEvent.RespawnReason; @@ -63,8 +62,8 @@ + private double lastPosX = Double.MAX_VALUE; + private double lastPosY = Double.MAX_VALUE; + private double lastPosZ = Double.MAX_VALUE; -+ private float lastPitch = Float.MAX_VALUE; -+ private float lastYaw = Float.MAX_VALUE; ++ private float lastYRot = Float.MAX_VALUE; ++ private float lastXRot = Float.MAX_VALUE; + private boolean justTeleported = false; + // CraftBukkit end private @Nullable RemoteChatSession chatSession; @@ -213,11 +212,11 @@ if (vehicle != this.player && vehicle.getControllingPassenger() == this.player && vehicle == this.lastVehicle) { ServerLevel level = this.player.level(); + // CraftBukkit - store current player position -+ double prevX = this.player.getX(); -+ double prevY = this.player.getY(); -+ double prevZ = this.player.getZ(); -+ float prevYaw = this.player.getYRot(); -+ float prevPitch = this.player.getXRot(); ++ float startYRot = this.player.getYRot(); ++ float startXRot = this.player.getXRot(); ++ double startX = this.player.getX(); ++ double startY = this.player.getY(); ++ double startZ = this.player.getZ(); + // CraftBukkit end double oldX = vehicle.getX(); double oldY = vehicle.getY(); @@ -306,26 +305,26 @@ + this.player.absSnapTo(targetX, targetY, targetZ, this.player.getYRot(), this.player.getXRot()); // Paper - TODO: This breaks alot of stuff + org.bukkit.entity.Player player = this.getCraftPlayer(); + if (!this.hasMoved) { -+ this.lastPosX = prevX; -+ this.lastPosY = prevY; -+ this.lastPosZ = prevZ; -+ this.lastYaw = prevYaw; -+ this.lastPitch = prevPitch; ++ this.lastPosX = startX; ++ this.lastPosY = startY; ++ this.lastPosZ = startZ; ++ this.lastYRot = startYRot; ++ this.lastXRot = startXRot; + this.hasMoved = true; + } -+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. ++ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYRot, this.lastXRot); // Get the Players previous Event location. + Location to = new Location(player.getWorld(), targetX, targetY, targetZ, targetYRot, targetXRot); + + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Mth.square(this.lastPosX - to.getX()) + Mth.square(this.lastPosY - to.getY()) + Mth.square(this.lastPosZ - to.getZ()); -+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); ++ float deltaAngle = Math.abs(this.lastYRot - to.getYaw()) + Math.abs(this.lastXRot - to.getPitch()); + + if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); -+ this.lastYaw = to.getYaw(); -+ this.lastPitch = to.getPitch(); ++ this.lastYRot = to.getYaw(); ++ this.lastXRot = to.getPitch(); + + Location oldTo = to.clone(); + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); @@ -702,18 +701,15 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -1084,7 +_,15 @@ +@@ -1084,7 +_,12 @@ 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); + this.allowedPlayerTicks = 20; // CraftBukkit } else { + // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify -+ double prevX = this.player.getX(); -+ double prevY = this.player.getY(); -+ double prevZ = this.player.getZ(); -+ float prevYaw = this.player.getYRot(); -+ float prevPitch = this.player.getXRot(); ++ float startYRot = this.player.getYRot(); ++ float startXRot = this.player.getXRot(); + // CraftBukkit end double startX = this.player.getX(); double startY = this.player.getY(); @@ -723,9 +719,9 @@ double expectedDist = this.player.getDeltaMovement().lengthSqr(); double movedDist = xDist * xDist + yDist * yDist + zDist * zDist; + // Paper start - fix large move vectors killing the server -+ double currDeltaX = targetX - prevX; -+ double currDeltaY = targetY - prevY; -+ double currDeltaZ = targetZ - prevZ; ++ double currDeltaX = targetX - startX; ++ double currDeltaY = targetY - startY; ++ double currDeltaZ = targetZ - startZ; + movedDist = Math.max(movedDist, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1); + double otherFieldX = targetX - this.lastGoodX; + double otherFieldY = targetY - this.lastGoodY; @@ -750,7 +746,7 @@ LOGGER.debug( "{} is sending move packets too frequently ({} packets since last tick)", this.player.getPlainTextName(), -@@ -1110,30 +_,96 @@ +@@ -1110,30 +_,83 @@ ); deltaPackets = 1; } @@ -817,21 +813,8 @@ - this.player.jumpFromGround(); + // Paper start - Add PlayerJumpEvent + org.bukkit.entity.Player player = this.getCraftPlayer(); -+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. -+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. -+ -+ // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (packet.hasPosition()) { -+ to.setX(targetX); -+ to.setY(targetY); -+ to.setZ(targetZ); -+ } -+ -+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packet.hasRotation()) { -+ to.setYaw(targetYRot); -+ to.setPitch(targetXRot); -+ } ++ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYRot, this.lastXRot); // Get the Players previous Event location. ++ Location to = new Location(player.getWorld(), targetX, targetY, targetZ, targetYRot, targetXRot); + + com.destroystokyo.paper.event.player.PlayerJumpEvent event = new com.destroystokyo.paper.event.player.PlayerJumpEvent(player, from, to); + @@ -856,7 +839,7 @@ double oyDist = yDist; xDist = targetX - this.player.getX(); yDist = targetY - this.player.getY(); -@@ -1143,21 +_,101 @@ +@@ -1143,21 +_,88 @@ zDist = targetZ - this.player.getZ(); movedDist = xDist * xDist + yDist * yDist + zDist * zDist; @@ -900,43 +883,30 @@ + // Paper end - Add fail move event + // CraftBukkit start - fire PlayerMoveEvent + // Reset to old location first -+ this.player.absSnapTo(prevX, prevY, prevZ, prevYaw, prevPitch); ++ this.player.absSnapTo(startX, startY, startZ, startYRot, startXRot); + + org.bukkit.entity.Player player = this.getCraftPlayer(); + if (!this.hasMoved) { -+ this.lastPosX = prevX; -+ this.lastPosY = prevY; -+ this.lastPosZ = prevZ; -+ this.lastYaw = prevYaw; -+ this.lastPitch = prevPitch; ++ this.lastPosX = startX; ++ this.lastPosY = startY; ++ this.lastPosZ = startZ; ++ this.lastYRot = startYRot; ++ this.lastXRot = startXRot; + this.hasMoved = true; + } -+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. -+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. -+ -+ // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (packet.hasPosition()) { -+ to.setX(targetX); -+ to.setY(targetY); -+ to.setZ(targetZ); -+ } -+ -+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packet.hasRotation()) { -+ to.setYaw(targetYRot); -+ to.setPitch(targetXRot); -+ } ++ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYRot, this.lastXRot); // Get the Players previous Event location. ++ Location to = new Location(player.getWorld(), targetX, targetY, targetZ, targetYRot, targetXRot); + + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Mth.square(this.lastPosX - to.getX()) + Mth.square(this.lastPosY - to.getY()) + Mth.square(this.lastPosZ - to.getZ()); -+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); ++ float deltaAngle = Math.abs(this.lastYRot - to.getYaw()) + Math.abs(this.lastXRot - to.getPitch()); + + if ((delta > 1f / 256 || deltaAngle > 10.0F) && !this.player.isImmobile()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); -+ this.lastYaw = to.getYaw(); -+ this.lastPitch = to.getPitch(); ++ this.lastYRot = to.getYaw(); ++ this.lastXRot = to.getPitch(); + + Location oldTo = to.clone(); + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); @@ -1071,8 +1041,8 @@ + this.lastPosX = this.awaitingPositionFromClient.x; + this.lastPosY = this.awaitingPositionFromClient.y; + this.lastPosZ = this.awaitingPositionFromClient.z; -+ this.lastYaw = this.player.getYRot(); -+ this.lastPitch = this.player.getXRot(); ++ this.lastYRot = this.player.getYRot(); ++ this.lastXRot = this.player.getXRot(); + // CraftBukkit end this.send(ClientboundPlayerPositionPacket.of(this.awaitingTeleport, destination, relatives)); } @@ -2636,10 +2606,10 @@ + + // Paper start - Add fail move event + private io.papermc.paper.event.player.PlayerFailMoveEvent fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason failReason, -+ double toX, double toY, double toZ, float toYaw, float toPitch, boolean logWarning) { ++ double targetX, double targetY, double targetZ, float targetYRot, float targetXRot, boolean logWarning) { + org.bukkit.entity.Player player = this.getCraftPlayer(); -+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); -+ Location to = new Location(player.getWorld(), toX, toY, toZ, toYaw, toPitch); ++ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYRot, this.lastXRot); ++ Location to = new Location(player.getWorld(), targetX, targetY, targetZ, targetYRot, targetXRot); + io.papermc.paper.event.player.PlayerFailMoveEvent event = new io.papermc.paper.event.player.PlayerFailMoveEvent(player, failReason, + false, logWarning, from, to); + event.callEvent(); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java index 19df68577dab..82808cc84a74 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperChargedProjectiles.java @@ -19,7 +19,7 @@ public net.minecraft.world.item.component.ChargedProjectiles getHandle() { @Override public List projectiles() { - return MCUtil.transformUnmodifiable(this.impl.itemCopies() /*makes copies internally*/, CraftItemStack::asCraftMirror); + return MCUtil.transformUnmodifiable(this.impl.itemCopies(), CraftItemStack::asCraftMirror); } static final class BuilderImpl implements ChargedProjectiles.Builder { diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java index 4f6f45e3d451..7555c29ba761 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperItemContainerContents.java @@ -19,7 +19,7 @@ public net.minecraft.world.item.component.ItemContainerContents getHandle() { @Override public List contents() { - return MCUtil.transformUnmodifiable(this.impl.items, optional -> optional.map(CraftItemStack::asBukkitCopy).orElse(null)); + return MCUtil.transformUnmodifiable(this.impl.items, optional -> optional.map(CraftItemStack::asBukkitCopy).orElse(ItemStack.empty())); } static final class BuilderImpl implements ItemContainerContents.Builder { From af55c9de7052bca1508114915e954825b57389ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Slatnar=20=C5=A0tagar?= <99482159+Privatech38@users.noreply.github.com> Date: Wed, 17 Jun 2026 15:29:38 +0200 Subject: [PATCH 19/30] Fix Geyser particle options waterBlocks precondition (#13961) --- paper-api/src/main/java/org/bukkit/Particle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/Particle.java b/paper-api/src/main/java/org/bukkit/Particle.java index db8e9313e047..d3adf8703081 100644 --- a/paper-api/src/main/java/org/bukkit/Particle.java +++ b/paper-api/src/main/java/org/bukkit/Particle.java @@ -423,7 +423,7 @@ private abstract static class AbstractGeyser { private final int waterBlocks; protected AbstractGeyser(final int waterBlocks) { - Preconditions.checkArgument(waterBlocks > 1, "waterBlocks must be positive"); + Preconditions.checkArgument(waterBlocks > 0, "waterBlocks must be positive"); this.waterBlocks = waterBlocks; } From 1daadd58cf8b60a4766b311ca34a37b7bb326358 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Wed, 17 Jun 2026 10:05:32 -0400 Subject: [PATCH 20/30] Prevent EnderDragon and Wither from receiving effect of vanilla sources (#13956) Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> --- .../0003-Entity-Activation-Range-2.0.patch | 4 ++-- .../world/entity/LivingEntity.java.patch | 3 ++- .../boss/enderdragon/EnderDragon.java.patch | 14 ++++++++++++++ .../entity/boss/wither/WitherBoss.java.patch | 15 ++++++++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch index 23bc7bf8ffa8..e5a2c317f059 100644 --- a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch @@ -522,10 +522,10 @@ index ba0cdbd064ad3e0cf645c50ab14adcddef48e932..68855c16d2cb3e5b7d7a86f05e7bb2e7 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 c471349faf04931668d40faba0f8f45937f1d711..d4fa50aa52a3a6c076d632989e21ff424eec7cf2 100644 +index 9895b1abac28d624bee16750ca146fff7094d0bd..bd5b96c87c140917a420c7e505924687005dae0b 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3404,6 +3404,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3405,6 +3405,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin protected void playAttackSound() { } 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 b96085dbb22a..ad34885bb720 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 @@ -334,7 +334,7 @@ } public Collection getActiveEffects() { -@@ -1009,24 +_,69 @@ +@@ -1009,24 +_,70 @@ } public final boolean addEffect(final MobEffectInstance newEffect) { @@ -355,6 +355,7 @@ + // Paper start - Don't fire sync event during generation + return this.addEffect(newEffect, source, cause, true); + } ++ + public boolean addEffect(final MobEffectInstance newEffect, final @Nullable Entity source, final EntityPotionEffectEvent.Cause cause, final boolean fireEvent) { + // Paper end - Don't fire sync event during generation + // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API 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 9713e242bdf9..77e1c1dec7bf 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 @@ -257,6 +257,20 @@ float dist = Math.max((float)Math.sqrt(egg.distToCenterSqr(this.position())) / 4.0F, 1.0F); float yOffset = 6.0F / dist; float xRotOld = this.getXRot(); +@@ -847,7 +_,12 @@ + } + + @Override +- public boolean addEffect(final MobEffectInstance newEffect, final @Nullable Entity source) { ++ // Paper start - Only allow plugins to bypass this requirement ++ public boolean addEffect(final MobEffectInstance newEffect, final @Nullable Entity source, final org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, final boolean fireEvent) { ++ if (cause == org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PLUGIN) { ++ return super.addEffect(newEffect, source, cause, fireEvent); ++ } ++ // Paper end - Only allow plugins to bypass this requirement + return false; + } + @@ -880,4 +_,23 @@ 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 5b56ab670b64..0ac53702edc6 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 @@ -81,7 +81,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -488,16 +_,16 @@ +@@ -488,23 +_,28 @@ @Override protected void dropCustomDeathLoot(final ServerLevel level, final DamageSource source, final boolean killedByPlayer) { super.dropCustomDeathLoot(level, source, killedByPlayer); @@ -102,6 +102,19 @@ } else { this.noActionTime = 0; } + } + + @Override +- public boolean addEffect(final MobEffectInstance newEffect, final @Nullable Entity source) { ++ // Paper start - Only allow plugins to bypass this requirement ++ public boolean addEffect(final MobEffectInstance newEffect, final @Nullable Entity source, final org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, final boolean fireEvent) { ++ if (cause == org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PLUGIN) { ++ return super.addEffect(newEffect, source, cause, fireEvent); ++ } ++ // Paper end - Only allow plugins to bypass this requirement + return false; + } + @@ -552,12 +_,18 @@ @Override From ca8eb49f937c2349992da828243c325ae12bd7d5 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Wed, 17 Jun 2026 10:12:34 -0400 Subject: [PATCH 21/30] Mention MOJIRA issue for correct stacktrace fix in FileFixerUpper [ci skip] (#13962) --- .../net/minecraft/util/filefix/FileFixerUpper.java.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch b/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch index b6a5c478366a..b97f864e04e6 100644 --- a/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/filefix/FileFixerUpper.java.patch @@ -13,7 +13,7 @@ Files.deleteIfExists(movesFile); } catch (IOException e2) { - LOGGER.warn("Failed to delete {}", movesFile, e); -+ LOGGER.warn("Failed to delete {}", movesFile, e2); // Paper - print correct stacktrace ++ LOGGER.warn("Failed to delete {}", movesFile, e2); // Paper - print correct stacktrace (MC-308790) } } @@ -23,8 +23,8 @@ } catch (Exception e2) { - LOGGER.warn("Failed to delete outdated world folder: ", e); - throw new FailedCleanupFileFixException(e, tempWorldTopLevel.getFileName().toString(), fileSystemCapabilities); -+ LOGGER.warn("Failed to delete outdated world folder: ", e2); // Paper - print correct stacktrace -+ throw new FailedCleanupFileFixException(e2, tempWorldTopLevel.getFileName().toString(), fileSystemCapabilities); // Paper - print correct stacktrace ++ LOGGER.warn("Failed to delete outdated world folder: ", e2); // Paper - print correct stacktrace (MC-308790) ++ throw new FailedCleanupFileFixException(e2, tempWorldTopLevel.getFileName().toString(), fileSystemCapabilities); // Paper - print correct stacktrace (MC-308790) } } From 80d109893799b4a9fdb62f07b3663f2ec04c689b Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Wed, 17 Jun 2026 15:00:35 -0400 Subject: [PATCH 22/30] Expose Entity Source for EntityPotionEffectEvent (#13957) Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> --- .../java/org/bukkit/entity/LivingEntity.java | 8 +-- .../event/entity/EntityPotionEffectEvent.java | 48 +++++++++----- .../0003-Entity-Activation-Range-2.0.patch | 4 +- .../world/entity/LivingEntity.java.patch | 65 +++++++------------ .../craftbukkit/entity/CraftLivingEntity.java | 5 +- .../craftbukkit/event/CraftEventFactory.java | 27 ++++---- 6 files changed, 74 insertions(+), 83 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 19a48dce7c2f..22940977c13f 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -623,9 +623,7 @@ default void setNextBeeStingerRemoval(@NonNegative int ticks) { * @param effect PotionEffect to be added * @return whether the effect could be added */ - default boolean addPotionEffect(@NotNull PotionEffect effect) { - return this.addPotionEffect(effect, false); - } + boolean addPotionEffect(@NotNull PotionEffect effect); /** * Adds the given {@link PotionEffect} to the living entity. @@ -639,7 +637,9 @@ default boolean addPotionEffect(@NotNull PotionEffect effect) { * now supported. */ @Deprecated(since = "1.15.2") - public boolean addPotionEffect(@NotNull PotionEffect effect, boolean force); + default boolean addPotionEffect(@NotNull PotionEffect effect, boolean force) { + return this.addPotionEffect(effect); + } /** * Attempts to add all of the given {@link PotionEffect} to the living diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java index 61ff80a91c39..bd071ee390e7 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java @@ -1,25 +1,28 @@ package org.bukkit.event.entity; +import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Called when a potion effect is modified on an entity. *

* If the event is cancelled, no change will be made on the entity. */ +@NullMarked public class EntityPotionEffectEvent extends EntityEvent implements Cancellable { private static final HandlerList HANDLER_LIST = new HandlerList(); - private final PotionEffect oldEffect; - private final PotionEffect newEffect; + private final @Nullable PotionEffect oldEffect; + private final @Nullable PotionEffect newEffect; + private final @Nullable Entity entitySource; private final Cause cause; private final Action action; private boolean override; @@ -27,23 +30,28 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable private boolean cancelled; @ApiStatus.Internal - public EntityPotionEffectEvent(@NotNull LivingEntity livingEntity, @Nullable PotionEffect oldEffect, @Nullable PotionEffect newEffect, @NotNull Cause cause, @NotNull Action action, boolean override) { + public EntityPotionEffectEvent(final LivingEntity livingEntity, final @Nullable PotionEffect oldEffect, final @Nullable PotionEffect newEffect, final @Nullable Entity entitySource, final Cause cause, final Action action, final boolean override) { super(livingEntity); this.oldEffect = oldEffect; this.newEffect = newEffect; + this.entitySource = entitySource; this.cause = cause; this.action = action; this.override = override; } + @Override + public LivingEntity getEntity() { + return (LivingEntity) super.getEntity(); + } + /** * Gets the old potion effect of the changed type, which will be removed. * * @return The old potion effect or {@code null} if the entity did not have the * changed effect type. */ - @Nullable - public PotionEffect getOldEffect() { + public @Nullable PotionEffect getOldEffect() { return this.oldEffect; } @@ -53,17 +61,25 @@ public PotionEffect getOldEffect() { * @return The new potion effect or {@code null} if the effect of the changed type * will be removed. */ - @Nullable - public PotionEffect getNewEffect() { + public @Nullable PotionEffect getNewEffect() { return this.newEffect; } + /** + * Gets the entity which caused the effect to change + * (Not applicable for {@link Action#REMOVED}). + * + * @return The entity which caused the effect to change or {@code null} + */ + public @Nullable Entity getSource() { + return this.entitySource; + } + /** * Gets the cause why the effect has changed. * * @return A Cause value why the effect has changed. */ - @NotNull public Cause getCause() { return this.cause; } @@ -73,7 +89,6 @@ public Cause getCause() { * * @return An action to be performed on the potion effect type. */ - @NotNull public Action getAction() { return this.action; } @@ -83,14 +98,13 @@ public Action getAction() { * * @return The effect type which will be modified on the entity. */ - @NotNull public PotionEffectType getModifiedType() { - return (this.oldEffect == null) ? ((this.newEffect == null) ? null : this.newEffect.getType()) : this.oldEffect.getType(); // todo not null? + return this.oldEffect == null ? this.newEffect.getType() : this.oldEffect.getType(); } /** * Returns if the new potion effect will override the old potion effect - * (Only applicable for the CHANGED Action). + * (Only applicable for {@link Action#CHANGED}). * * @return If the new effect will override the old one. */ @@ -99,8 +113,8 @@ public boolean isOverride() { } /** - * Sets if the new potion effect will override the old potion effect (Only - * applicable for the CHANGED action). + * Sets if the new potion effect will override the old potion effect + * (Only applicable for {@link Action#CHANGED}). * * @param override If the new effect will override the old one. */ @@ -118,13 +132,11 @@ public void setCancelled(boolean cancel) { this.cancelled = cancel; } - @NotNull @Override public HandlerList getHandlers() { return HANDLER_LIST; } - @NotNull public static HandlerList getHandlerList() { return HANDLER_LIST; } diff --git a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch index e5a2c317f059..2071b39cbd30 100644 --- a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch @@ -522,10 +522,10 @@ index ba0cdbd064ad3e0cf645c50ab14adcddef48e932..68855c16d2cb3e5b7d7a86f05e7bb2e7 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 9895b1abac28d624bee16750ca146fff7094d0bd..bd5b96c87c140917a420c7e505924687005dae0b 100644 +index b94efe5ec36c2203b10645994066058578cd308b..9b0b1b56768d6209abc5dfd582fb43fb7f552126 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3405,6 +3405,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3386,6 +3386,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin protected void playAttackSound() { } 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 ad34885bb720..918f565626c8 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 @@ -230,37 +230,18 @@ }, this::clearSleepingPos); input.read("Brain", Brain.Packed.CODEC).ifPresent(packedBrain -> this.brain = this.makeBrain(packedBrain)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -846,15 +_,44 @@ +@@ -846,15 +_,25 @@ this.updateDirtyEffects(); } -+ // CraftBukkit start -+ private boolean isTickingEffects = false; -+ private final List effectsToProcess = Lists.newArrayList(); -+ -+ private static class ProcessableEffect { -+ -+ private Holder type; -+ private MobEffectInstance effect; -+ private final EntityPotionEffectEvent.Cause cause; -+ -+ private ProcessableEffect(MobEffectInstance effect, EntityPotionEffectEvent.Cause cause) { -+ this.effect = effect; -+ this.cause = cause; -+ } -+ -+ private ProcessableEffect(Holder type, EntityPotionEffectEvent.Cause cause) { -+ this.type = type; -+ this.cause = cause; -+ } -+ } -+ // CraftBukkit end ++ private boolean tickingEffects = false; // CraftBukkit ++ private final java.util.Queue deferredEffectUpdates = new java.util.concurrent.ConcurrentLinkedQueue<>(); // CraftBukkit + protected void tickEffects() { if (this.level() instanceof ServerLevel serverLevel) { Iterator> iterator = this.activeEffects.keySet().iterator(); -+ this.isTickingEffects = true; // CraftBukkit ++ this.tickingEffects = true; // CraftBukkit try { while (iterator.hasNext()) { Holder mobEffect = iterator.next(); @@ -275,21 +256,16 @@ iterator.remove(); this.onEffectsRemoved(List.of(effect)); } else if (effect.getDuration() % 600 == 0) { -@@ -863,6 +_,18 @@ +@@ -863,6 +_,13 @@ } } catch (ConcurrentModificationException var6) { } -+ + // CraftBukkit start -+ this.isTickingEffects = false; -+ for (ProcessableEffect effect : this.effectsToProcess) { -+ if (effect.effect != null) { -+ this.addEffect(effect.effect, effect.cause); -+ } else { -+ this.removeEffect(effect.type, effect.cause); -+ } ++ this.tickingEffects = false; ++ Runnable task; ++ while ((task = this.deferredEffectUpdates.poll()) != null) { ++ task.run(); + } -+ this.effectsToProcess.clear(); + // CraftBukkit end } else { for (MobEffectInstance effect : this.activeEffects.values()) { @@ -334,7 +310,7 @@ } public Collection getActiveEffects() { -@@ -1009,24 +_,70 @@ +@@ -1009,24 +_,69 @@ } public final boolean addEffect(final MobEffectInstance newEffect) { @@ -358,9 +334,8 @@ + + public boolean addEffect(final MobEffectInstance newEffect, final @Nullable Entity source, final EntityPotionEffectEvent.Cause cause, final boolean fireEvent) { + // Paper end - Don't fire sync event during generation -+ // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API -+ if (this.isTickingEffects) { -+ this.effectsToProcess.add(new ProcessableEffect(newEffect, cause)); ++ if (this.tickingEffects) { ++ this.deferredEffectUpdates.offer(() -> this.addEffect(newEffect, source, cause, fireEvent)); + return true; + } + // CraftBukkit end @@ -379,7 +354,7 @@ + } + + if (fireEvent) { -+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, newEffect, cause, override); ++ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, newEffect, source, cause, null, override); + override = event.isOverride(); + if (event.isCancelled()) { + return false; @@ -407,16 +382,17 @@ } newEffect.onEffectStarted(this); -@@ -1060,11 +_,35 @@ +@@ -1060,11 +_,41 @@ } public final @Nullable MobEffectInstance removeEffectNoUpdate(final Holder effect) { + // CraftBukkit start + return this.removeEffectNoUpdate(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } -+ public @Nullable MobEffectInstance removeEffectNoUpdate(final Holder effect, final EntityPotionEffectEvent.Cause cause) { -+ if (this.isTickingEffects) { -+ this.effectsToProcess.add(new ProcessableEffect(effect, cause)); ++ ++ public final @Nullable MobEffectInstance removeEffectNoUpdate(final Holder effect, final EntityPotionEffectEvent.Cause cause) { ++ if (this.tickingEffects) { ++ this.deferredEffectUpdates.offer(() -> this.removeEffectNoUpdate(effect, cause)); + return null; + } + @@ -439,6 +415,11 @@ + } + + public boolean removeEffect(final Holder effect, final EntityPotionEffectEvent.Cause cause) { ++ if (this.tickingEffects) { ++ this.deferredEffectUpdates.offer(() -> this.removeEffect(effect, cause)); ++ return true; ++ } ++ + MobEffectInstance effectInstance = this.removeEffectNoUpdate(effect, cause); + // CraftBukkit end if (effectInstance != null) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 74cb4d0c1e34..fdde7295df23 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -504,10 +504,9 @@ public void setKiller(Player killer) { } @Override - public boolean addPotionEffect(PotionEffect effect, boolean force) { + public boolean addPotionEffect(PotionEffect effect) { org.spigotmc.AsyncCatcher.catchOp("effect add"); // Paper - this.getHandle().addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(effect), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon - return true; + return this.getHandle().addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(effect), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 72bc687efb64..a5ea91906abe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -2,7 +2,6 @@ import com.google.common.base.Function; import com.google.common.base.Functions; -import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import com.mojang.datafixers.util.Either; @@ -25,6 +24,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; +import net.minecraft.Optionull; import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -1885,31 +1885,30 @@ public static BlockPhysicsEvent callBlockPhysicsEvent(LevelAccessor level, Block } public static EntityPotionEffectEvent callEntityPotionEffectChangeEvent(net.minecraft.world.entity.LivingEntity entity, @Nullable MobEffectInstance oldEffect, @Nullable MobEffectInstance newEffect, EntityPotionEffectEvent.Cause cause) { - return CraftEventFactory.callEntityPotionEffectChangeEvent(entity, oldEffect, newEffect, cause, true); + return CraftEventFactory.callEntityPotionEffectChangeEvent(entity, oldEffect, newEffect, null, cause, null, true); } public static EntityPotionEffectEvent callEntityPotionEffectChangeEvent(net.minecraft.world.entity.LivingEntity entity, @Nullable MobEffectInstance oldEffect, @Nullable MobEffectInstance newEffect, EntityPotionEffectEvent.Cause cause, EntityPotionEffectEvent.Action action) { - return CraftEventFactory.callEntityPotionEffectChangeEvent(entity, oldEffect, newEffect, cause, action, true); + return CraftEventFactory.callEntityPotionEffectChangeEvent(entity, oldEffect, newEffect, null, cause, action, true); } - public static EntityPotionEffectEvent callEntityPotionEffectChangeEvent(net.minecraft.world.entity.LivingEntity entity, @Nullable MobEffectInstance oldEffect, @Nullable MobEffectInstance newEffect, EntityPotionEffectEvent.Cause cause, boolean willOverride) { - EntityPotionEffectEvent.Action action = EntityPotionEffectEvent.Action.CHANGED; + private static EntityPotionEffectEvent.Action computeEffectAction(@Nullable MobEffectInstance oldEffect, @Nullable MobEffectInstance newEffect) { if (oldEffect == null) { - action = EntityPotionEffectEvent.Action.ADDED; - } else if (newEffect == null) { - action = EntityPotionEffectEvent.Action.REMOVED; + return EntityPotionEffectEvent.Action.ADDED; } - - return CraftEventFactory.callEntityPotionEffectChangeEvent(entity, oldEffect, newEffect, cause, action, willOverride); + if (newEffect == null) { + return EntityPotionEffectEvent.Action.REMOVED; + } + return EntityPotionEffectEvent.Action.CHANGED; } - public static EntityPotionEffectEvent callEntityPotionEffectChangeEvent(net.minecraft.world.entity.LivingEntity entity, @Nullable MobEffectInstance oldEffect, @Nullable MobEffectInstance newEffect, EntityPotionEffectEvent.Cause cause, EntityPotionEffectEvent.Action action, boolean willOverride) { + public static EntityPotionEffectEvent callEntityPotionEffectChangeEvent(net.minecraft.world.entity.LivingEntity entity, @Nullable MobEffectInstance oldEffect, @Nullable MobEffectInstance newEffect, @Nullable net.minecraft.world.entity.Entity source, EntityPotionEffectEvent.Cause cause, @Nullable EntityPotionEffectEvent.Action knownAction, boolean willOverride) { + assert oldEffect != null || newEffect != null; + PotionEffect bukkitOldEffect = (oldEffect == null) ? null : CraftPotionUtil.toBukkit(oldEffect); PotionEffect bukkitNewEffect = (newEffect == null) ? null : CraftPotionUtil.toBukkit(newEffect); - Preconditions.checkState(bukkitOldEffect != null || bukkitNewEffect != null, "Old and new potion effect are both null"); - - EntityPotionEffectEvent event = new EntityPotionEffectEvent((LivingEntity) entity.getBukkitEntity(), bukkitOldEffect, bukkitNewEffect, cause, action, willOverride); + EntityPotionEffectEvent event = new EntityPotionEffectEvent((LivingEntity) entity.getBukkitEntity(), bukkitOldEffect, bukkitNewEffect, Optionull.map(source, Entity::getBukkitEntity), cause, knownAction != null ? knownAction : computeEffectAction(oldEffect, newEffect), willOverride); Bukkit.getPluginManager().callEvent(event); return event; From 2c0341f9f291cba995c5293122bf888138427d17 Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Tue, 31 Mar 2026 14:57:17 +0100 Subject: [PATCH 23/30] Update adventure to 5.1.1 Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> --- paper-api/build.gradle.kts | 29 +++--- .../aikar/timings/TimingsReportListener.java | 18 +++- .../event/server/AsyncTabCompleteEvent.java | 58 +----------- .../item/WritableBookContent.java | 3 +- .../item/WrittenBookContent.java | 3 +- .../papermc/paper/text/PaperComponents.java | 16 ---- .../main/java/org/bukkit/UnsafeValues.java | 1 - .../org/bukkit/command/CommandSender.java | 25 ++++-- .../bukkit/command/ProxiedCommandSender.java | 18 +++- .../main/java/org/bukkit/entity/Entity.java | 2 +- .../main/java/org/bukkit/entity/Player.java | 2 +- .../org/bukkit/inventory/meta/BookMeta.java | 89 ++++++------------- .../inventory/meta/WritableBookMeta.java | 3 +- .../network/chat/MessageSignature.java.patch | 2 +- .../console/TerminalConsoleCommandSender.java | 7 +- .../paper/adventure/AdventureCodecs.java | 20 ++--- .../paper/adventure/PaperAdventure.java | 3 - .../GsonComponentSerializerProviderImpl.java | 3 +- .../commands/FeedbackForwardingSender.java | 6 +- .../item/PaperWritableBookContent.java | 17 ++++ .../item/PaperWrittenBookContent.java | 16 ++++ .../command/CraftBlockCommandSender.java | 2 +- .../command/CraftConsoleCommandSender.java | 2 +- .../craftbukkit/entity/CraftPlayer.java | 4 +- .../craftbukkit/inventory/CraftMetaBook.java | 55 ++---------- .../inventory/CraftMetaBookSigned.java | 41 ++------- .../craftbukkit/util/CraftMagicNumbers.java | 5 -- .../paper/adventure/AdventureCodecsTest.java | 29 +++--- 28 files changed, 192 insertions(+), 287 deletions(-) diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index 7a6c3a388315..ea5242199f95 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -12,12 +12,16 @@ java { } val annotationsVersion = "26.0.2" -val adventureVersion = "4.26.1" +val adventureVersion = "5.1.1" val bungeeCordChatVersion = "1.21-R0.2-deprecated+build.21" val slf4jVersion = "2.0.17" val log4jVersion = "2.26.0" -val apiAndDocs: Configuration by configurations.creating { +val apiAndDocs: Configuration by configurations.creating +configurations.api { + extendsFrom(apiAndDocs) +} +val javadocSourcepath: Configuration by configurations.creating { attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) @@ -25,9 +29,6 @@ val apiAndDocs: Configuration by configurations.creating { attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) } } -configurations.api { - extendsFrom(apiAndDocs) -} // Configure mockito agent that is needed in newer Java versions val mockitoAgent = configurations.register("mockitoAgent") @@ -60,6 +61,7 @@ dependencies { apiAndDocs(platform("net.kyori:adventure-bom:$adventureVersion")) apiAndDocs("net.kyori:adventure-api") + apiAndDocs("net.kyori:adventure-key") apiAndDocs("net.kyori:adventure-text-minimessage") apiAndDocs("net.kyori:adventure-text-serializer-gson") apiAndDocs("net.kyori:adventure-text-serializer-legacy") @@ -74,12 +76,13 @@ dependencies { val annotations = "org.jetbrains:annotations:$annotationsVersion" compileOnly(annotations) testCompileOnly(annotations) + javadocSourcepath(annotations) // For adventure-api module requirements val checkerQual = "org.checkerframework:checker-qual:3.49.2" compileOnlyApi(checkerQual) testCompileOnly(checkerQual) - api("org.jspecify:jspecify:1.0.0") + apiAndDocs("org.jspecify:jspecify:1.0.0") // Test dependencies testImplementation("org.apache.commons:commons-lang3:3.20.0") @@ -193,13 +196,7 @@ tasks.withType().configureEach { "https://www.javadocs.dev/org.joml/joml/1.10.8/", "https://www.javadocs.dev/com.google.code.gson/gson/2.14.0", "https://jspecify.dev/docs/api/", - "https://jd.advntr.dev/api/$adventureVersion/", - "https://jd.advntr.dev/key/$adventureVersion/", - "https://jd.advntr.dev/text-minimessage/$adventureVersion/", - "https://jd.advntr.dev/text-serializer-gson/$adventureVersion/", - "https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/", - "https://jd.advntr.dev/text-serializer-plain/$adventureVersion/", - "https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/", + "https://jd.papermc.io/adventure/$adventureVersion/", "https://www.javadocs.dev/org.slf4j/slf4j-api/$slf4jVersion/", "https://logging.apache.org/log4j/2.x/javadoc/log4j-api/", "https://www.javadocs.dev/org.apache.maven.resolver/maven-resolver-api/1.7.3", @@ -207,12 +204,12 @@ tasks.withType().configureEach { options.tags("apiNote:a:API Note:") options.tags("implNote:a:Implementation Note:") - inputs.files(apiAndDocs).ignoreEmptyDirectories().withPropertyName(apiAndDocs.name + "-configuration") - val apiAndDocsElements = apiAndDocs.elements + inputs.files(javadocSourcepath).ignoreEmptyDirectories().withPropertyName(javadocSourcepath.name + "-configuration") + val javadocSourcepathElements = javadocSourcepath.elements doFirst { options.addStringOption( "sourcepath", - apiAndDocsElements.get().map { it.asFile }.joinToString(separator = File.pathSeparator, transform = File::getPath) + javadocSourcepathElements.get().map { it.asFile }.joinToString(separator = File.pathSeparator, transform = File::getPath) ) } diff --git a/paper-api/src/main/java/co/aikar/timings/TimingsReportListener.java b/paper-api/src/main/java/co/aikar/timings/TimingsReportListener.java index df066d6f8d55..e5c113ef39eb 100644 --- a/paper-api/src/main/java/co/aikar/timings/TimingsReportListener.java +++ b/paper-api/src/main/java/co/aikar/timings/TimingsReportListener.java @@ -2,6 +2,10 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import net.kyori.adventure.audience.ForwardingAudience; +import net.kyori.adventure.chat.ChatType; +import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; @@ -61,8 +65,18 @@ public void done(@Nullable String url) { } @Override - public void sendMessage(final @NotNull net.kyori.adventure.identity.Identity source, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { - net.kyori.adventure.audience.ForwardingAudience.super.sendMessage(source, message, type); + public void sendMessage(final @NotNull Component message) { + ForwardingAudience.super.sendMessage(message); + } + + @Override + public void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) { + ForwardingAudience.super.sendMessage(message, boundChatType); + } + + @Override + public void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) { + ForwardingAudience.super.sendMessage(signedMessage, boundChatType); } @NotNull diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java index f6964cd1c0ed..be9a3b7463fa 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java @@ -28,11 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.stream.Stream; import net.kyori.adventure.text.Component; -import net.kyori.examination.Examinable; -import net.kyori.examination.ExaminableProperty; -import net.kyori.examination.string.StringExaminer; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -240,10 +236,8 @@ private static List fromStrings(final List suggestions) { /** * A rich tab completion, consisting of a string suggestion, and a nullable {@link Component} tooltip. - *

- * Warning: In a future update, this class will no longer implement {@link Examinable}. */ - public interface Completion extends Examinable { + public interface Completion { /** * Get the suggestion string for this {@link Completion}. @@ -259,12 +253,6 @@ public interface Completion extends Examinable { */ @Nullable Component tooltip(); - @Override - @Deprecated(forRemoval = true, since = "1.21.11") - default Stream examinableProperties() { - return Stream.of(ExaminableProperty.of("suggestion", this.suggestion()), ExaminableProperty.of("tooltip", this.tooltip())); - } - /** * Create a new {@link Completion} from a suggestion string. * @@ -290,47 +278,9 @@ static Completion completion(final String suggestion, final @Nullable Component } @ApiStatus.Internal - static final class CompletionImpl implements Completion { - - private final String suggestion; - private final @Nullable Component tooltip; - - CompletionImpl(final String suggestion, final @Nullable Component tooltip) { - this.suggestion = suggestion; - this.tooltip = tooltip; - } - - @Override - public String suggestion() { - return this.suggestion; - } - - @Override - public @Nullable Component tooltip() { - return this.tooltip; - } - - @Override - public boolean equals(final @Nullable Object o) { - if (this == o) { - return true; - } - if (o == null || this.getClass() != o.getClass()) { - return false; - } - final CompletionImpl that = (CompletionImpl) o; - return this.suggestion.equals(that.suggestion) - && Objects.equals(this.tooltip, that.tooltip); - } - - @Override - public int hashCode() { - return Objects.hash(this.suggestion, this.tooltip); - } - - @Override - public String toString() { - return StringExaminer.simpleEscaping().examine(this); + record CompletionImpl(String suggestion, @Nullable Component tooltip) implements Completion { + CompletionImpl { + Objects.requireNonNull(suggestion, "suggestion"); } } } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java index 828d3bb1c763..7b0af5b832cd 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WritableBookContent.java @@ -3,6 +3,7 @@ import io.papermc.paper.datacomponent.DataComponentBuilder; import io.papermc.paper.text.Filtered; import java.util.List; +import net.kyori.adventure.inventory.BookLike; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Unmodifiable; @@ -15,7 +16,7 @@ @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable -public interface WritableBookContent { +public interface WritableBookContent extends BookLike { @Contract(value = "-> new", pure = true) static WritableBookContent.Builder writeableBookContent() { diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java index 979bc05009b8..df3314a01eeb 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/WrittenBookContent.java @@ -3,6 +3,7 @@ import io.papermc.paper.datacomponent.DataComponentBuilder; import io.papermc.paper.text.Filtered; import java.util.List; +import net.kyori.adventure.inventory.BookLike; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import org.checkerframework.common.value.qual.IntRange; @@ -18,7 +19,7 @@ @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable -public interface WrittenBookContent { +public interface WrittenBookContent extends BookLike { @Contract(value = "_, _ -> new", pure = true) static WrittenBookContent.Builder writtenBookContent(final String title, final String author) { diff --git a/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java b/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java index cfa9fd3700c6..44abb6980979 100644 --- a/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java +++ b/paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java @@ -7,7 +7,6 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -94,21 +93,6 @@ public static ComponentFlattener flattener() { return InternalAPIBridge.get().componentFlattener(); } - /** - * Get a serializer for {@link Component}s that will convert components to - * a plain-text string. - * - *

Implementations may provide a serializer capable of processing any - * information that requires access to implementation details.

- * - * @return a serializer to plain text - * @deprecated will be removed in adventure 5.0.0, use {@link PlainTextComponentSerializer#plainText()} - */ - @Deprecated(forRemoval = true, since = "1.18.1") - public static PlainComponentSerializer plainSerializer() { - return Bukkit.getUnsafe().plainComponentSerializer(); - } - /** * Get a serializer for {@link Component}s that will convert components to * a plain-text string. diff --git a/paper-api/src/main/java/org/bukkit/UnsafeValues.java b/paper-api/src/main/java/org/bukkit/UnsafeValues.java index b3574dd72345..bb29c4c72375 100644 --- a/paper-api/src/main/java/org/bukkit/UnsafeValues.java +++ b/paper-api/src/main/java/org/bukkit/UnsafeValues.java @@ -242,5 +242,4 @@ static boolean isLegacyPlugin(org.bukkit.plugin.Plugin plugin) { */ @NotNull ItemStack deserializeItemHover(HoverEvent.@NotNull ShowItem itemHover); - @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer(); } diff --git a/paper-api/src/main/java/org/bukkit/command/CommandSender.java b/paper-api/src/main/java/org/bukkit/command/CommandSender.java index 1fd0f5f4dc26..039bf7e9cf71 100644 --- a/paper-api/src/main/java/org/bukkit/command/CommandSender.java +++ b/paper-api/src/main/java/org/bukkit/command/CommandSender.java @@ -1,8 +1,9 @@ package org.bukkit.command; +import java.util.Objects; import java.util.UUID; -import net.kyori.adventure.audience.MessageType; -import net.kyori.adventure.identity.Identity; +import net.kyori.adventure.chat.ChatType; +import net.kyori.adventure.chat.SignedMessage; import net.kyori.adventure.text.Component; import org.bukkit.Server; import org.bukkit.permissions.Permissible; @@ -38,7 +39,7 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe * * @param message Message to be displayed * @param sender The sender of this message - * @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component) + * @see #sendMessage(net.kyori.adventure.text.Component) * @deprecated sender UUID is ignored */ @Deprecated // Paper @@ -49,7 +50,7 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe * * @param messages An array of messages to be displayed * @param sender The sender of this message - * @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component) + * @see #sendMessage(net.kyori.adventure.text.Component) * @deprecated sender UUID is ignored */ @Deprecated // Paper @@ -134,10 +135,20 @@ public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat public net.kyori.adventure.text.@NotNull Component name(); @Override - default void sendMessage(final net.kyori.adventure.identity.@NotNull Identity identity, final net.kyori.adventure.text.@NotNull Component message, final net.kyori.adventure.audience.@NotNull MessageType type) { + default void sendMessage(final net.kyori.adventure.text.@NotNull Component message) { this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message)); } + @Override + default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) { + this.sendMessage(message); + } + + @Override + default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) { + this.sendMessage(Objects.requireNonNullElseGet(signedMessage.unsignedContent(), () -> Component.text(signedMessage.message()))); + } + /** * Sends a message with the MiniMessage format to the command sender. *

@@ -179,7 +190,7 @@ default void sendPlainMessage(final @NotNull String message) { * the component will be sent as legacy text.

* * @param component the component to send - * @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead + * @deprecated use {@link #sendMessage(Component)} instead */ @Deprecated default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { @@ -193,7 +204,7 @@ default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent compone * the components will be sent as legacy text.

* * @param components the components to send - * @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead + * @deprecated use {@link #sendMessage(Component)} instead */ @Deprecated default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { diff --git a/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java b/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java index 5c813ac024f6..4af1f18912ae 100644 --- a/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java +++ b/paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java @@ -1,6 +1,10 @@ package org.bukkit.command; +import net.kyori.adventure.audience.ForwardingAudience; +import net.kyori.adventure.chat.ChatType; +import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.text.Component; import org.jetbrains.annotations.NotNull; public interface ProxiedCommandSender extends CommandSender, net.kyori.adventure.audience.ForwardingAudience.Single { // Paper @@ -23,8 +27,18 @@ public interface ProxiedCommandSender extends CommandSender, net.kyori.adventure // Paper start @Override - default void sendMessage(final net.kyori.adventure.identity.@NotNull Identity source, final net.kyori.adventure.text.@NotNull Component message, final net.kyori.adventure.audience.@NotNull MessageType type) { - net.kyori.adventure.audience.ForwardingAudience.Single.super.sendMessage(source, message, type); + default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) { + ForwardingAudience.Single.super.sendMessage(message, boundChatType); + } + + @Override + default void sendMessage(final @NotNull Component message) { + ForwardingAudience.Single.super.sendMessage(message); + } + + @Override + default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) { + ForwardingAudience.Single.super.sendMessage(signedMessage, boundChatType); } @NotNull diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java index 2c68aae864a7..087fd5f9f0fe 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -1086,7 +1086,7 @@ public class Spigot extends CommandSender.Spigot { @NotNull @Override default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { - return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.customName()))); + return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.showEntity(this.getType().getKey(), this.getUniqueId(), this.customName()))); } /** diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index 5c3eb7d3cfab..530f9dba2097 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -3558,7 +3558,7 @@ default void openSign(Sign sign) { // Paper start @Override default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final java.util.function.UnaryOperator op) { - return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.displayName()))); + return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.showEntity(this.getType().getKey(), this.getUniqueId(), this.displayName()))); } // Paper end diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java index 28dd27df9f4c..a32ab901c169 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/BookMeta.java @@ -1,8 +1,10 @@ package org.bukkit.inventory.meta; import java.util.List; +import net.kyori.adventure.text.Component; import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.Material; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,11 +16,8 @@ * {@link org.bukkit.inventory.ItemStack#getType()}. {@code instanceof} on * the meta instance is not sufficient due to unusual inheritance * with relation to {@link WritableBookMeta}. - *

- * Warning: in an upcoming version of Paper, this interface will no - * longer extend Adventure's {@link net.kyori.adventure.inventory.Book}. */ -public interface BookMeta extends WritableBookMeta, net.kyori.adventure.inventory.Book { // Paper - adventure +public interface BookMeta extends WritableBookMeta { /** * Represents the generation (or level of copying) of a written book @@ -177,7 +176,6 @@ enum Generation { * * @return the title of the book */ - @Override net.kyori.adventure.text.@Nullable Component title(); /** @@ -188,8 +186,7 @@ enum Generation { * @param title the title to set * @return the same {@link BookMeta} instance */ - @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false) - @Override + @org.jetbrains.annotations.Contract(value = "_ -> this") @NotNull BookMeta title(net.kyori.adventure.text.@Nullable Component title); /** @@ -200,7 +197,6 @@ enum Generation { * * @return the author of the book */ - @Override net.kyori.adventure.text.@Nullable Component author(); /** @@ -209,8 +205,7 @@ enum Generation { * @param author the author to set * @return the same {@link BookMeta} instance */ - @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false) - @Override + @org.jetbrains.annotations.Contract(value = "_ -> this") @NotNull BookMeta author(net.kyori.adventure.text.@Nullable Component author); @@ -247,59 +242,33 @@ enum Generation { void addPages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages); /** - * @deprecated BookMeta is mutable, there is no need for a builder. - */ - @Deprecated(forRemoval = true, since = "1.21.11") - interface BookMetaBuilder extends net.kyori.adventure.inventory.Book.Builder { - /** - * @deprecated BookMeta is mutable, there is no need for a builder. - */ - @Deprecated(forRemoval = true, since = "1.21.11") - @Override - @NotNull BookMetaBuilder title(net.kyori.adventure.text.@Nullable Component title); - - /** - * @deprecated BookMeta is mutable, there is no need for a builder. - */ - @Deprecated(forRemoval = true, since = "1.21.11") - @Override - @NotNull BookMetaBuilder author(net.kyori.adventure.text.@Nullable Component author); - - /** - * @deprecated BookMeta is mutable, there is no need for a builder. - */ - @Deprecated(forRemoval = true, since = "1.21.11") - @Override - @NotNull BookMetaBuilder addPage(net.kyori.adventure.text.@NotNull Component page); - - /** - * @deprecated BookMeta is mutable, there is no need for a builder. - */ - @Deprecated(forRemoval = true, since = "1.21.11") - @Override - @NotNull BookMetaBuilder pages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages); - - /** - * @deprecated BookMeta is mutable, there is no need for a builder. - */ - @Deprecated(forRemoval = true, since = "1.21.11") - @Override - @NotNull BookMetaBuilder pages(java.util.@NotNull Collection pages); - - /** - * @deprecated BookMeta is mutable, there is no need for a builder. - */ - @Deprecated(forRemoval = true, since = "1.21.11") - @Override - @NotNull BookMeta build(); - } + * Gets the list of pages. + * + *

The returned collection will be unmodifiable.

+ * + * @return the list of pages + */ + @NotNull List pages(); /** - * @deprecated BookMeta is mutable, there is no need for a builder. + * Sets the pages of the book. + * + * @param pages the pages to set + * @return this book instance */ - @Deprecated(forRemoval = true, since = "1.21.11") - @Override - @NotNull BookMetaBuilder toBuilder(); + @Contract(value = "_ -> this") + @NotNull BookMeta pages(final @NotNull List pages); + + /** + * Sets the pages of the book. + * + * @param pages the pages to set + * @return this book instance + */ + @Contract(value = "_ -> this") + default @NotNull BookMeta pages(final @NotNull Component @NotNull... pages) { + return this.pages(List.of(pages)); + } // Paper end // Spigot start diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java index 9fc47c879ee6..dcc8d545d031 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java @@ -1,6 +1,7 @@ package org.bukkit.inventory.meta; import java.util.List; +import net.kyori.adventure.inventory.BookLike; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; @@ -14,7 +15,7 @@ * the meta instance is not sufficient due to unusual inheritance * with relation to {@link BookMeta}. */ -public interface WritableBookMeta extends ItemMeta { +public interface WritableBookMeta extends ItemMeta, BookLike { /** * Checks for the existence of pages in the book. diff --git a/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch index 18e60d87993d..28c96b810037 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/MessageSignature.java.patch @@ -4,7 +4,7 @@ import org.jspecify.annotations.Nullable; public record MessageSignature(byte[] bytes) { -+ public net.kyori.adventure.chat.SignedMessage.Signature adventure() { return () -> this.bytes; } // Paper - adventure; support signed messages ++ public net.kyori.adventure.chat.SignedMessage.Signature adventure() { return net.kyori.adventure.chat.SignedMessage.signature(this.bytes); } // Paper - adventure; support signed messages public static final Codec CODEC = ExtraCodecs.BASE64_STRING.xmap(MessageSignature::new, MessageSignature::bytes); public static final int BYTES = 256; diff --git a/paper-server/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java b/paper-server/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java index 8f07539a82f4..5ee14ec34005 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java @@ -1,12 +1,11 @@ package com.destroystokyo.paper.console; -import net.kyori.adventure.audience.MessageType; -import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.logger.slf4j.ComponentLogger; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.apache.logging.log4j.LogManager; import org.bukkit.craftbukkit.command.CraftConsoleCommandSender; +import org.jetbrains.annotations.NotNull; public class TerminalConsoleCommandSender extends CraftConsoleCommandSender { @@ -15,11 +14,11 @@ public class TerminalConsoleCommandSender extends CraftConsoleCommandSender { @Override public void sendRawMessage(String message) { final Component msg = LegacyComponentSerializer.legacySection().deserialize(message); - this.sendMessage(Identity.nil(), msg, MessageType.SYSTEM); + this.sendMessage(msg); } @Override - public void sendMessage(Identity identity, Component message, MessageType type) { + public void sendMessage(final @NotNull Component message) { LOGGER.info(message); } diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java index 81ce59c7f865..c1e1f08e74d7 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java @@ -172,14 +172,14 @@ public String getSerializedName() { public static final Function GET_CLICK_EVENT_TYPE = he -> switch (he.action()) { - case OPEN_URL -> OPEN_URL_CLICK_EVENT_TYPE; - case OPEN_FILE -> OPEN_FILE_CLICK_EVENT_TYPE; - case RUN_COMMAND -> RUN_COMMAND_CLICK_EVENT_TYPE; - case SUGGEST_COMMAND -> SUGGEST_COMMAND_CLICK_EVENT_TYPE; - case CHANGE_PAGE -> CHANGE_PAGE_CLICK_EVENT_TYPE; - case COPY_TO_CLIPBOARD -> COPY_TO_CLIPBOARD_CLICK_EVENT_TYPE; - case SHOW_DIALOG -> SHOW_DIALOG_CLICK_EVENT_TYPE; - case CUSTOM -> CUSTOM_CLICK_EVENT_TYPE; + case ClickEvent.Action.ChangePage ignored -> CHANGE_PAGE_CLICK_EVENT_TYPE; + case ClickEvent.Action.CopyToClipboard ignored -> COPY_TO_CLIPBOARD_CLICK_EVENT_TYPE; + case ClickEvent.Action.OpenFile ignored -> OPEN_FILE_CLICK_EVENT_TYPE; + case ClickEvent.Action.OpenUrl ignored -> OPEN_URL_CLICK_EVENT_TYPE; + case ClickEvent.Action.RunCommand ignored -> RUN_COMMAND_CLICK_EVENT_TYPE; + case ClickEvent.Action.SuggestCommand ignored -> SUGGEST_COMMAND_CLICK_EVENT_TYPE; + case ClickEvent.Action.ShowDialog ignored -> SHOW_DIALOG_CLICK_EVENT_TYPE; + case ClickEvent.Action.Custom ignored -> CUSTOM_CLICK_EVENT_TYPE; }; static final Codec CLICK_EVENT_CODEC = CLICK_EVENT_TYPE_CODEC.dispatch("action", GET_CLICK_EVENT_TYPE, ClickEventType::codec); @@ -469,7 +469,7 @@ public String getSerializedName() { } } - static final MapCodec> NBT_COMPONENT_MAP_CODEC = mapCodec((instance) -> { + static final MapCodec> NBT_COMPONENT_MAP_CODEC = mapCodec((instance) -> { return instance.group( Codec.STRING.fieldOf("nbt").forGetter(NBTComponent::nbtPath), Codec.BOOL.lenientOptionalFieldOf("interpret", false).forGetter(NBTComponent::interpret), @@ -504,7 +504,7 @@ public String getSerializedName() { static final ComponentType OBJECT = new ComponentType<>(OBJECT_COMPONENT_MAP_CODEC, ObjectComponent.class::isInstance, "object"); static final ComponentType SCORE = new ComponentType<>(SCORE_COMPONENT_MAP_CODEC, ScoreComponent.class::isInstance, "score"); static final ComponentType SELECTOR = new ComponentType<>(SELECTOR_COMPONENT_MAP_CODEC, SelectorComponent.class::isInstance, "selector"); - static final ComponentType> NBT = new ComponentType<>(NBT_COMPONENT_MAP_CODEC, NBTComponent.class::isInstance, "nbt"); + static final ComponentType> NBT = new ComponentType<>(NBT_COMPONENT_MAP_CODEC, NBTComponent.class::isInstance, "nbt"); static Codec createCodec(final Codec selfCodec) { final ExtraCodecs.LateBoundIdMapper> lateBoundIdMapper = new ExtraCodecs.LateBoundIdMapper<>(); diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java index 2f4ca0271dab..bef2c6b6cbd5 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java @@ -30,7 +30,6 @@ import net.kyori.adventure.text.serializer.ComponentSerializer; import net.kyori.adventure.text.serializer.ansi.ANSIComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.kyori.adventure.translation.GlobalTranslator; import net.kyori.adventure.util.Codec; @@ -113,8 +112,6 @@ public final class PaperAdventure { }) .build(); public static final AttributeKey LOCALE_ATTRIBUTE = AttributeKey.valueOf("adventure:locale"); // init after FLATTENER because classloading triggered here might create a logger - @Deprecated - public static final PlainComponentSerializer PLAIN = PlainComponentSerializer.builder().flattener(FLATTENER).build(); public static final ANSIComponentSerializer ANSI_SERIALIZER = ANSIComponentSerializer.builder().flattener(FLATTENER).build(); private static final TagParser NBT_PARSER = TagParser.create(NbtOps.INSTANCE); public static final Codec NBT_CODEC = new Codec<>() { diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java index c620d5aa2b02..716bb7e73d32 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java @@ -1,6 +1,7 @@ package io.papermc.paper.adventure.providers; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; +import net.kyori.adventure.text.serializer.json.JSONOptions; import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -19,7 +20,7 @@ public class GsonComponentSerializerProviderImpl implements GsonComponentSeriali public @NotNull GsonComponentSerializer gsonLegacy() { return GsonComponentSerializer.builder() .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE) - .downsampleColors() + .editOptions(builder -> builder.value(JSONOptions.EMIT_RGB, false)) .build(); } diff --git a/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java b/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java index b84c2c663e9b..13f88be43ed7 100644 --- a/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java +++ b/paper-server/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java @@ -2,8 +2,6 @@ import io.papermc.paper.adventure.PaperAdventure; import java.util.function.Consumer; -import net.kyori.adventure.audience.MessageType; -import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minecraft.commands.CommandSource; @@ -43,7 +41,7 @@ public void sendMessage(final String... messages) { } @Override - public void sendMessage(final Identity identity, final Component message, final MessageType type) { + public void sendMessage(final Component message) { this.feedback.accept(message); } @@ -85,7 +83,7 @@ public CommandSourceStack asVanilla() { private record Source(FeedbackForwardingSender sender) implements CommandSource { @Override public void sendSystemMessage(final net.minecraft.network.chat.Component message) { - this.sender.sendMessage(Identity.nil(), PaperAdventure.asAdventure(message)); + this.sender.sendMessage(PaperAdventure.asAdventure(message)); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java index 5d2fda0ac2da..1b2b3ed5140e 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWritableBookContent.java @@ -5,7 +5,11 @@ import io.papermc.paper.util.MCUtil; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; +import java.util.stream.Collectors; +import net.kyori.adventure.inventory.Book; +import net.kyori.adventure.text.Component; import net.minecraft.server.network.Filterable; import org.bukkit.craftbukkit.util.Handleable; import org.jetbrains.annotations.Unmodifiable; @@ -24,6 +28,19 @@ public net.minecraft.world.item.component.WritableBookContent getHandle() { return MCUtil.transformUnmodifiable(this.impl.pages(), input -> Filtered.of(input.raw(), input.filtered().orElse(null))); } + @Override + public Book asBook() { + return Book.book( + Component.empty(), + Component.empty(), + this.pages() + .stream() + .map(filtered -> Objects.requireNonNullElseGet(filtered.filtered(), filtered::raw)) + .map(Component::text) + .collect(Collectors.toList()) + ); + } + static final class BuilderImpl implements WritableBookContent.Builder { private final List> pages = new ObjectArrayList<>(); diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java index af461ec42a2a..b2d30bac03d5 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWrittenBookContent.java @@ -6,7 +6,10 @@ import io.papermc.paper.util.MCUtil; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; +import java.util.stream.Collectors; +import net.kyori.adventure.inventory.Book; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; @@ -56,6 +59,19 @@ public boolean resolved() { return this.impl.resolved(); } + @Override + public Book asBook() { + final Filtered title = this.title(); + return Book.book( + Component.text(Objects.requireNonNull(title.filtered(), title::raw)), + Component.text(this.author()), + this.pages() + .stream() + .map(filtered -> Objects.requireNonNullElseGet(filtered.filtered(), filtered::raw)) + .collect(Collectors.toList()) + ); + } + static final class BuilderImpl implements WrittenBookContent.Builder { private final List> pages = new ObjectArrayList<>(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java index 46691547832c..e39a34c25e33 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java @@ -62,7 +62,7 @@ public String getName() { } @Override - public void sendMessage(net.kyori.adventure.identity.Identity identity, net.kyori.adventure.text.Component message, net.kyori.adventure.audience.MessageType type) { + public void sendMessage(final net.kyori.adventure.text.Component message) { this.sourceStack.source.sendSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java index 6e2f931b06d4..f8753cf0d2fe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -87,7 +87,7 @@ public boolean isConversing() { } @Override - public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { + public void sendMessage(final net.kyori.adventure.text.Component message) { this.sendRawMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 261aeb211039..73f66b893c2d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -2819,11 +2819,9 @@ public void sendMessage(net.kyori.adventure.chat.SignedMessage signedMessage, ne // this.getHandle().sendChatMessage(net.minecraft.network.chat.OutgoingChatMessage.create(playerChatMessage), this.getHandle().isTextFilteringEnabled(), this.toHandle(boundChatType)); } - @Deprecated(forRemoval = true) @Override - public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { + public void sendMessage(final net.kyori.adventure.text.Component message) { if (getHandle().connection == null) return; - final net.minecraft.core.Registry chatTypeRegistry = this.getHandle().level().registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.CHAT_TYPE); this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(message, false)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index e5b584764432..bb1fba1cc8a9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -10,6 +10,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.stream.Collectors; +import net.kyori.adventure.inventory.Book; import net.md_5.bungee.api.chat.BaseComponent; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponents; @@ -22,6 +24,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.WritableBookMeta; +import org.jetbrains.annotations.NotNull; @DelegateDeserialization(SerializableMeta.class) public class CraftMetaBook extends CraftMetaItem implements BookMeta, WritableBookMeta { @@ -238,53 +241,6 @@ public void addPages(net.kyori.adventure.text.Component... pages) { } } - private CraftMetaBook(List pages) { - super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK)); - this.pages = pages.subList(0, Math.min(MAX_PAGES, pages.size())).stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).collect(java.util.stream.Collectors.toList()); - } - - static class CraftMetaBookBuilder implements BookMetaBuilder { - protected final List pages = new java.util.ArrayList<>(); - - @Override - public BookMetaBuilder title(net.kyori.adventure.text.Component title) { - return this; - } - - @Override - public BookMetaBuilder author(net.kyori.adventure.text.Component author) { - return this; - } - - @Override - public BookMetaBuilder addPage(net.kyori.adventure.text.Component page) { - this.pages.add(page); - return this; - } - - @Override - public BookMetaBuilder pages(net.kyori.adventure.text.Component... pages) { - java.util.Collections.addAll(this.pages, pages); - return this; - } - - @Override - public BookMetaBuilder pages(java.util.Collection pages) { - this.pages.addAll(pages); - return this; - } - - @Override - public BookMeta build() { - return new CraftMetaBook(this.pages); - } - } - - @Override - public BookMetaBuilder toBuilder() { - return new CraftMetaBookBuilder(); - } - @Override public String getPage(final int page) { Preconditions.checkArgument(this.isValidPage(page), "Invalid page number (%s)", page); @@ -410,6 +366,11 @@ ImmutableMap.Builder serialize(ImmutableMap.Builder serialize(com.goo return builder; } + @Override + public @NotNull Book asBook() { + return Book.book(net.kyori.adventure.text.Component.empty(), net.kyori.adventure.text.Component.empty(), this.getPages().stream().map(net.kyori.adventure.text.Component::text).collect(Collectors.toList())); + } + // Spigot start private BookMeta.Spigot spigot = new SpigotMeta(); private class SpigotMeta extends BookMeta.Spigot { @@ -449,39 +457,6 @@ public BookMeta.Spigot spigot() { public static final net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.builder() .character(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.SECTION_CHAR) .build(); - private CraftMetaBookSigned(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, java.util.List pages) { - super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(Material.WRITABLE_BOOK)); - this.title = title == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(title); - this.author = author == null ? null : LEGACY_DOWNSAMPLING_COMPONENT_SERIALIZER.serialize(author); - this.pages = io.papermc.paper.adventure.PaperAdventure.asVanilla(pages); - } - - static final class CraftMetaBookSignedBuilder extends CraftMetaBook.CraftMetaBookBuilder { - private net.kyori.adventure.text.Component title; - private net.kyori.adventure.text.Component author; - - @Override - public org.bukkit.inventory.meta.BookMeta.BookMetaBuilder title(final net.kyori.adventure.text.Component title) { - this.title = title; - return this; - } - - @Override - public org.bukkit.inventory.meta.BookMeta.BookMetaBuilder author(final net.kyori.adventure.text.Component author) { - this.author = author; - return this; - } - - @Override - public org.bukkit.inventory.meta.BookMeta build() { - return new CraftMetaBookSigned(this.title, this.author, this.pages); - } - } - - @Override - public BookMetaBuilder toBuilder() { - return new CraftMetaBookSignedBuilder(); - } @Override public net.kyori.adventure.text.Component title() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 55d463de7f91..3ac6c7571a20 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -94,11 +94,6 @@ public final class CraftMagicNumbers implements UnsafeValues { private CraftMagicNumbers() {} - @Override - public net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer() { - return io.papermc.paper.adventure.PaperAdventure.PLAIN; - } - public static BlockState getBlock(MaterialData material) { return CraftMagicNumbers.getBlock(material.getItemType(), material.getData()); } diff --git a/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java b/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java index ec8053b6a7f7..d2ce84cbd5d6 100644 --- a/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java +++ b/paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java @@ -14,6 +14,7 @@ import java.net.URI; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.UUID; import java.util.function.Function; import java.util.stream.Stream; @@ -45,7 +46,6 @@ import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; import org.junitpioneer.jupiter.cartesian.CartesianTest; @@ -113,17 +113,24 @@ void testKey() { assertEquals(key.asString(), location.toString()); } + static List> clickEventActions() { + final var skip = Set.of(ClickEvent.Action.OPEN_FILE, ClickEvent.Action.SHOW_DIALOG, ClickEvent.Action.CUSTOM); + return ClickEvent.Action.NAMES.values().stream().filter( + action -> !skip.contains(action) + ).toList(); + } + @ParameterizedTest(name = PARAMETERIZED_NAME) - @EnumSource(value = ClickEvent.Action.class, mode = EnumSource.Mode.EXCLUDE, names = {"OPEN_FILE", "SHOW_DIALOG", "CUSTOM"}) - void testClickEvent(final ClickEvent.Action action) { - final ClickEvent event = switch (action) { - case OPEN_URL -> openUrl("https://google.com"); - case RUN_COMMAND -> ClickEvent.runCommand("/say hello"); - case SUGGEST_COMMAND -> suggestCommand("/suggest hello"); - case CHANGE_PAGE -> ClickEvent.changePage(2); - case COPY_TO_CLIPBOARD -> ClickEvent.copyToClipboard("clipboard content"); - case CUSTOM -> ClickEvent.custom(key("test"), BinaryTagHolder.binaryTagHolder("3")); - case SHOW_DIALOG, OPEN_FILE -> throw new IllegalArgumentException(); + @MethodSource("clickEventActions") + void testClickEvent(final ClickEvent.Action action) { + final ClickEvent event = switch (action) { + case ClickEvent.Action.OpenUrl _ -> openUrl("https://google.com"); + case ClickEvent.Action.RunCommand _ -> ClickEvent.runCommand("/say hello"); + case ClickEvent.Action.SuggestCommand _ -> suggestCommand("/suggest hello"); + case ClickEvent.Action.ChangePage _ -> ClickEvent.changePage(2); + case ClickEvent.Action.CopyToClipboard _ -> ClickEvent.copyToClipboard("clipboard content"); + case ClickEvent.Action.Custom _ -> ClickEvent.custom(key("test"), BinaryTagHolder.binaryTagHolder("3")); + case ClickEvent.Action.ShowDialog _, ClickEvent.Action.OpenFile _ -> throw new IllegalArgumentException(); }; final Tag result = CLICK_EVENT_CODEC.encodeStart(NbtOps.INSTANCE, event).result().orElseThrow(() -> new RuntimeException("Failed to encode ClickEvent: " + event)); final net.minecraft.network.chat.ClickEvent nms = net.minecraft.network.chat.ClickEvent.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst(); From 649002a4275125dd89664efde1b103fe4c26c6d0 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:50:41 +0200 Subject: [PATCH 24/30] fix IOOB for '..' namespace --- .../main/java/org/bukkit/NamespacedKey.java | 10 +++++++--- .../paper/adventure/AdventureCodecs.java | 18 +++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/NamespacedKey.java b/paper-api/src/main/java/org/bukkit/NamespacedKey.java index b53028683bfa..ac63c379b5cc 100644 --- a/paper-api/src/main/java/org/bukkit/NamespacedKey.java +++ b/paper-api/src/main/java/org/bukkit/NamespacedKey.java @@ -81,14 +81,18 @@ public NamespacedKey(@NotNull Plugin plugin, @NotNull String key) { private void validate() { Preconditions.checkArgument(this.namespace.length() + 1 + this.key.length() <= Short.MAX_VALUE, "NamespacedKey must be less than 32768 characters"); - checkError("[a-z0-9_-.]", "namespace", this.namespace, Key.checkNamespace(this.namespace)); // note: for now we will pretend ".." is a valid namespace like adventure to not break conversion + checkError("[a-z0-9_-.]", "namespace", this.namespace, Key.checkNamespace(this.namespace)); checkError("[a-z0-9_-./]", "key", this.key, Key.checkValue(this.key)); } private static void checkError(String pattern, String name, String value, OptionalInt index) { index.ifPresent(indexValue -> { - char character = value.charAt(indexValue); - throw new IllegalArgumentException(String.format("Non %s character in %s '%s' at index %d ('%s', bytes: %s)", pattern, name, value, indexValue, character, Arrays.toString(String.valueOf(character).getBytes(StandardCharsets.UTF_8)))); + if (indexValue == -1) { + throw new IllegalArgumentException(String.format("'%s' is not a valid value for %s", value, name)); + } else { + char character = value.charAt(indexValue); + throw new IllegalArgumentException(String.format("Non %s character in %s '%s' at index %d ('%s', bytes: %s)", pattern, name, value, indexValue, character, Arrays.toString(String.valueOf(character).getBytes(StandardCharsets.UTF_8)))); + } }); } diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java index c1e1f08e74d7..9ee1508f1538 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java @@ -171,15 +171,15 @@ public String getSerializedName() { } public static final Function GET_CLICK_EVENT_TYPE = - he -> switch (he.action()) { - case ClickEvent.Action.ChangePage ignored -> CHANGE_PAGE_CLICK_EVENT_TYPE; - case ClickEvent.Action.CopyToClipboard ignored -> COPY_TO_CLIPBOARD_CLICK_EVENT_TYPE; - case ClickEvent.Action.OpenFile ignored -> OPEN_FILE_CLICK_EVENT_TYPE; - case ClickEvent.Action.OpenUrl ignored -> OPEN_URL_CLICK_EVENT_TYPE; - case ClickEvent.Action.RunCommand ignored -> RUN_COMMAND_CLICK_EVENT_TYPE; - case ClickEvent.Action.SuggestCommand ignored -> SUGGEST_COMMAND_CLICK_EVENT_TYPE; - case ClickEvent.Action.ShowDialog ignored -> SHOW_DIALOG_CLICK_EVENT_TYPE; - case ClickEvent.Action.Custom ignored -> CUSTOM_CLICK_EVENT_TYPE; + ce -> switch (ce.action()) { + case ClickEvent.Action.ChangePage _ -> CHANGE_PAGE_CLICK_EVENT_TYPE; + case ClickEvent.Action.CopyToClipboard _ -> COPY_TO_CLIPBOARD_CLICK_EVENT_TYPE; + case ClickEvent.Action.OpenFile _ -> OPEN_FILE_CLICK_EVENT_TYPE; + case ClickEvent.Action.OpenUrl _ -> OPEN_URL_CLICK_EVENT_TYPE; + case ClickEvent.Action.RunCommand _ -> RUN_COMMAND_CLICK_EVENT_TYPE; + case ClickEvent.Action.SuggestCommand _ -> SUGGEST_COMMAND_CLICK_EVENT_TYPE; + case ClickEvent.Action.ShowDialog _ -> SHOW_DIALOG_CLICK_EVENT_TYPE; + case ClickEvent.Action.Custom _ -> CUSTOM_CLICK_EVENT_TYPE; }; static final Codec CLICK_EVENT_CODEC = CLICK_EVENT_TYPE_CODEC.dispatch("action", GET_CLICK_EVENT_TYPE, ClickEventType::codec); From 783b6f09726d339fd1578797a30ae8d9ab3ea1d9 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:01:19 +0200 Subject: [PATCH 25/30] add preconditions to particles --- .../src/main/java/org/bukkit/Particle.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/Particle.java b/paper-api/src/main/java/org/bukkit/Particle.java index d3adf8703081..9a29e6771416 100644 --- a/paper-api/src/main/java/org/bukkit/Particle.java +++ b/paper-api/src/main/java/org/bukkit/Particle.java @@ -3,8 +3,12 @@ import com.google.common.base.Preconditions; import org.bukkit.block.data.BlockData; import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.index.qual.Positive; import org.jetbrains.annotations.NotNull; +import static io.papermc.paper.util.BoundChecker.requirePositive; +import static io.papermc.paper.util.BoundChecker.requireRange; + public enum Particle implements Keyed { POOF("poof"), EXPLOSION("explosion"), @@ -263,7 +267,7 @@ public static class DustOptions { public DustOptions(@NotNull Color color, float size) { Preconditions.checkArgument(color != null, "color"); this.color = color; - this.size = size; + this.size = requireRange(size, "size", 0.01F, 4.0F); } /** @@ -320,10 +324,10 @@ public static class Trail { private final Color color; private final int duration; - public Trail(@NotNull Location target, @NotNull Color color, int duration) { + public Trail(@NotNull Location target, @NotNull Color color, @Positive int duration) { this.target = target; this.color = color; - this.duration = duration; + this.duration = requirePositive(duration, "duration"); } /** @@ -351,7 +355,7 @@ public Color getColor() { * * @return trail duration */ - public int getDuration() { + public @Positive int getDuration() { return duration; } } @@ -422,9 +426,8 @@ private abstract static class AbstractGeyser { private final int waterBlocks; - protected AbstractGeyser(final int waterBlocks) { - Preconditions.checkArgument(waterBlocks > 0, "waterBlocks must be positive"); - this.waterBlocks = waterBlocks; + protected AbstractGeyser(final @Positive int waterBlocks) { + this.waterBlocks = requirePositive(waterBlocks, "waterBlocks"); } /** @@ -433,7 +436,7 @@ protected AbstractGeyser(final int waterBlocks) { * * @return the number of water blocks */ - public int getWaterBlocks() { + public @Positive int getWaterBlocks() { return waterBlocks; } } From 11427785e07eb16fbc7d6ff4eefd3c8ac28a0509 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 18 Jun 2026 13:08:54 +0200 Subject: [PATCH 26/30] only pre cancel InventoryClickEvent when in spectator --- .../java/org/bukkit/entity/AbstractCubeMob.java | 13 ++++++------- .../main/java/org/bukkit/entity/MagmaCube.java | 16 ++++++++++++++++ .../src/main/java/org/bukkit/entity/Slime.java | 15 +++++++++++++++ .../ServerGamePacketListenerImpl.java.patch | 12 ++++++------ .../craftbukkit/entity/CraftMagmaCube.java | 2 +- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java b/paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java index 0f0c32b34f80..551e8918d6b7 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractCubeMob.java @@ -6,34 +6,33 @@ public interface AbstractCubeMob extends Creature { /** - * @return the size of the slime + * @return the size of the cube mob */ int getSize(); /** - * Setting the size of the slime (regardless of previous size) + * Setting the size of the cube mob (regardless of previous size) * will set the following attributes: *
    *
  • {@link org.bukkit.attribute.Attribute#MAX_HEALTH}
  • *
  • {@link org.bukkit.attribute.Attribute#MOVEMENT_SPEED}
  • - *
  • {@link org.bukkit.attribute.Attribute#ATTACK_DAMAGE}
  • *
* to their per-size defaults and heal the - * slime to its max health (assuming it's alive). + * cube mob to its max health (assuming it's alive). * - * @param size the new size of the slime. + * @param size the new size of the cube mob. */ void setSize(int size); /** - * Get whether this slime can randomly wander/jump around on its own + * Get whether this cube mob can randomly wander/jump around on its own * * @return {@code true} if can wander */ boolean canWander(); /** - * Set whether this slime can randomly wander/jump around on its own + * Set whether this cube mob can randomly wander/jump around on its own * * @param canWander {@code true} if can wander */ diff --git a/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java b/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java index f35c47ff34dd..df32f4363a90 100644 --- a/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java +++ b/paper-api/src/main/java/org/bukkit/entity/MagmaCube.java @@ -4,4 +4,20 @@ * Represents a MagmaCube. */ public interface MagmaCube extends AbstractCubeMob, Enemy { + + /** + * Setting the size of the magma cube (regardless of previous size) + * will set the following attributes: + *
    + *
  • {@link org.bukkit.attribute.Attribute#MAX_HEALTH}
  • + *
  • {@link org.bukkit.attribute.Attribute#MOVEMENT_SPEED}
  • + *
  • {@link org.bukkit.attribute.Attribute#ATTACK_DAMAGE}
  • + *
  • {@link org.bukkit.attribute.Attribute#ARMOR}
  • + *
+ * to their per-size defaults and heal the + * magma cube to its max health (assuming it's alive). + * + * @param size the new size of the magma cube. + */ + void setSize(int size); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Slime.java b/paper-api/src/main/java/org/bukkit/entity/Slime.java index bbcd9b7d9a19..a6a4a138f5bb 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Slime.java +++ b/paper-api/src/main/java/org/bukkit/entity/Slime.java @@ -4,4 +4,19 @@ * Represents a Slime. */ public interface Slime extends AbstractCubeMob, Enemy { + + /** + * Setting the size of the slime (regardless of previous size) + * will set the following attributes: + *
    + *
  • {@link org.bukkit.attribute.Attribute#MAX_HEALTH}
  • + *
  • {@link org.bukkit.attribute.Attribute#MOVEMENT_SPEED}
  • + *
  • {@link org.bukkit.attribute.Attribute#ATTACK_DAMAGE}
  • + *
+ * to their per-size defaults and heal the + * slime to its max health (assuming it's alive). + * + * @param size the new size of the slime. + */ + void setSize(int size); } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 7aaac62096ee..2647d8aee000 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1965,8 +1965,8 @@ - if (this.player.containerMenu.containerId == packet.containerId()) { - if (this.player.isSpectator() || this.player.isDeadOrDying()) { + if (this.player.containerMenu.containerId == packet.containerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit -+ boolean cancelled = this.player.isSpectator() || this.player.isDeadOrDying(); // CraftBukkit - see below if -+ if (false && this.player.isSpectator() || this.player.isDeadOrDying()) { // CraftBukkit ++ boolean cancelled = this.player.isSpectator(); // CraftBukkit - pre cancelled when in spectator ++ if ((false && this.player.isSpectator()) || this.player.isDeadOrDying()) { // CraftBukkit this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); @@ -2165,11 +2165,11 @@ + net.minecraft.world.inventory.AbstractContainerMenu containerMenu = this.player.containerMenu; + int currentStatus = this.player.containerMenu.quickcraftStatus; + int newStatus = net.minecraft.world.inventory.AbstractContainerMenu.getQuickcraftHeader(packet.buttonNum()); -+ if ((currentStatus != 1 || newStatus != 2 && currentStatus != newStatus)) { ++ if ((currentStatus != net.minecraft.world.inventory.AbstractContainerMenu.QUICKCRAFT_HEADER_CONTINUE || newStatus != net.minecraft.world.inventory.AbstractContainerMenu.QUICKCRAFT_HEADER_END && currentStatus != newStatus)) { + } else if (containerMenu.getCarried().isEmpty()) { -+ } else if (newStatus == 0) { -+ } else if (newStatus == 1) { -+ } else if (newStatus == 2) { ++ } else if (newStatus == net.minecraft.world.inventory.AbstractContainerMenu.QUICKCRAFT_HEADER_START) { ++ } else if (newStatus == net.minecraft.world.inventory.AbstractContainerMenu.QUICKCRAFT_HEADER_CONTINUE) { ++ } else if (newStatus == net.minecraft.world.inventory.AbstractContainerMenu.QUICKCRAFT_HEADER_END) { + if (!this.player.containerMenu.quickcraftSlots.isEmpty()) { + if (this.player.containerMenu.quickcraftSlots.size() == 1) { + int index = containerMenu.quickcraftSlots.iterator().next().index; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java index 4e51bd14f84a..16d34b9f38b9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java @@ -3,7 +3,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.MagmaCube; -public class CraftMagmaCube extends CraftAbstractCubeMob implements MagmaCube { +public class CraftMagmaCube extends CraftAbstractCubeMob implements MagmaCube, CraftEnemy { public CraftMagmaCube(CraftServer server, net.minecraft.world.entity.monster.cubemob.MagmaCube entity) { super(server, entity); From 250ea420645e9bcbaa7d96c6412de36ac1d85f65 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 18 Jun 2026 20:55:36 +0200 Subject: [PATCH 27/30] add missing kick event causes --- .../bukkit/event/player/PlayerKickEvent.java | 10 ++++++++-- .../server/commands/KickCommand.java.patch | 2 +- .../jsonrpc/methods/BanlistService.java.patch | 20 +++++++++++++++++++ .../methods/IpBanlistService.java.patch | 20 +++++++++++++++++++ .../jsonrpc/methods/PlayerService.java.patch | 11 ++++++++++ .../ServerCommonPacketListenerImpl.java.patch | 2 +- .../ServerGamePacketListenerImpl.java.patch | 9 +++++++++ .../minecraft/world/item/BlockItem.java.patch | 2 +- 8 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/BanlistService.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/IpBanlistService.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/PlayerService.java.patch diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java index 3596c1bf733a..d9d44d81c98c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java @@ -161,7 +161,7 @@ public enum Cause { WHITELIST, BANNED, IP_BANNED, - KICK_COMMAND, + KICK, FLYING_PLAYER, FLYING_VEHICLE, TIMEOUT, @@ -190,6 +190,12 @@ public enum Cause { /** * Fallback cause */ - UNKNOWN, + UNKNOWN; + + /** + * @deprecated use {@link #KICK}, kicks can also occur through the server management protocol. + */ + @Deprecated(since = "26.2") + public static final Cause KICK_COMMAND = KICK; } } 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 index 5ea8e5eccc39..4ba19f2afaad 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch @@ -5,7 +5,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 ++ player.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK); // 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/jsonrpc/methods/BanlistService.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/BanlistService.java.patch new file mode 100644 index 000000000000..76522197c5c6 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/BanlistService.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/jsonrpc/methods/BanlistService.java ++++ b/net/minecraft/server/jsonrpc/methods/BanlistService.java +@@ -45,7 +_,7 @@ + minecraftApi.banListService().addUserBan(userBan.toBanEntry(), clientInfo); + ServerPlayer player = minecraftApi.playerListService().getPlayer(ban.get().player().id()); + if (player != null) { +- player.connection.disconnect(Component.translatable("multiplayer.disconnect.banned")); ++ player.connection.disconnect(Component.translatable("multiplayer.disconnect.banned"), org.bukkit.event.player.PlayerKickEvent.Cause.BANNED); // Paper - kick event cause + } + } + } +@@ -90,7 +_,7 @@ + minecraftApi.banListService().addUserBan(ban.toBanEntry(), clientInfo); + ServerPlayer player = minecraftApi.playerListService().getPlayer(ban.player().id()); + if (player != null) { +- player.connection.disconnect(Component.translatable("multiplayer.disconnect.banned")); ++ player.connection.disconnect(Component.translatable("multiplayer.disconnect.banned"), org.bukkit.event.player.PlayerKickEvent.Cause.BANNED); // Paper - kick event cause + } + }); + return get(minecraftApi); diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/IpBanlistService.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/IpBanlistService.java.patch new file mode 100644 index 000000000000..eee18adf68ef --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/IpBanlistService.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/jsonrpc/methods/IpBanlistService.java ++++ b/net/minecraft/server/jsonrpc/methods/IpBanlistService.java +@@ -33,7 +_,7 @@ + bans.stream() + .map(ban -> banIp(minecraftApi, ban, clientInfo)) + .flatMap(Collection::stream) +- .forEach(player -> player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"))); ++ .forEach(player -> player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"), org.bukkit.event.player.PlayerKickEvent.Cause.IP_BANNED)); // Paper - kick event cause + return get(minecraftApi); + } + +@@ -83,7 +_,7 @@ + finalBanlist.stream() + .filter(ban -> !currentBans.contains(ban)) + .flatMap(ban -> minecraftApi.playerListService().getPlayersWithAddress(ban.ip()).stream()) +- .forEach(player -> player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"))); ++ .forEach(player -> player.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"), org.bukkit.event.player.PlayerKickEvent.Cause.IP_BANNED)); // Paper - kick event cause + return get(minecraftApi); + } + diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/PlayerService.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/PlayerService.java.patch new file mode 100644 index 000000000000..ef4a8ca016ba --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/PlayerService.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/jsonrpc/methods/PlayerService.java ++++ b/net/minecraft/server/jsonrpc/methods/PlayerService.java +@@ -25,7 +_,7 @@ + ServerPlayer serverPlayer = getServerPlayer(minecraftApi, kickDto.player()); + if (serverPlayer != null) { + minecraftApi.playerListService().remove(serverPlayer, clientInfo); +- serverPlayer.connection.disconnect(kickDto.message.flatMap(Message::asComponent).orElse(DEFAULT_KICK_MESSAGE)); ++ serverPlayer.connection.disconnect(kickDto.message.flatMap(Message::asComponent).orElse(DEFAULT_KICK_MESSAGE), org.bukkit.event.player.PlayerKickEvent.Cause.KICK); // Paper - kick event cause + kicked.add(kickDto.player()); + } + } 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 2396d8f904ad..e70ed774eb69 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 @@ -222,7 +222,7 @@ } } -+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - kick event causes ++ @Deprecated // Paper - kick event causes TODO check on update: ensure all call to this are from the configuration phase public void disconnect(final Component reason) { - this.disconnect(new DisconnectionDetails(reason)); + // Paper start - kick event causes diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 2647d8aee000..706ddff5c781 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -578,6 +578,15 @@ } } +@@ -788,7 +_,7 @@ + } + + if (!menu.updateEffects(packet.primary(), packet.secondary())) { +- this.disconnect(Component.translatable("multiplayer.disconnect.generic")); ++ this.disconnect(Component.translatable("multiplayer.disconnect.generic"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause + LOGGER.warn("Player {} tried to set invalid beacon effects", this.player); + } + } @@ -797,7 +_,7 @@ @Override public void handleSetGameRule(final ServerboundSetGameRulePacket packet) { 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 index 91b414fa6501..ba51373fab3e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch @@ -20,7 +20,7 @@ + ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(false); + 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")); ++ serverPlayer.connection.disconnect(net.minecraft.network.chat.Component.literal("Packet processing error"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); + return InteractionResult.FAIL; + } + throw ex; // Rethrow exception if not placed by a player From 1e3ffb92e567c07117978dbf17435aaa6ff642eb Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 19 Jun 2026 14:53:02 +0200 Subject: [PATCH 28/30] clean block placement from API --- .../bukkit/event/player/PlayerKickEvent.java | 6 ++-- .../server/commands/KickCommand.java.patch | 2 +- .../jsonrpc/methods/PlayerService.java.patch | 2 +- .../craftbukkit/CraftRegionAccessor.java | 6 ++-- .../bukkit/craftbukkit/block/CraftBlock.java | 34 ++++--------------- .../craftbukkit/block/CraftBlockState.java | 21 ++---------- 6 files changed, 16 insertions(+), 55 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java index d9d44d81c98c..5e43145151c7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java @@ -161,7 +161,7 @@ public enum Cause { WHITELIST, BANNED, IP_BANNED, - KICK, + KICKED, FLYING_PLAYER, FLYING_VEHICLE, TIMEOUT, @@ -193,9 +193,9 @@ public enum Cause { UNKNOWN; /** - * @deprecated use {@link #KICK}, kicks can also occur through the server management protocol. + * @deprecated use {@link #KICKED}, kicks can also occur through the server management protocol. */ @Deprecated(since = "26.2") - public static final Cause KICK_COMMAND = KICK; + public static final Cause KICK_COMMAND = KICKED; } } 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 index 4ba19f2afaad..2e4c2bc9d30a 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/KickCommand.java.patch @@ -5,7 +5,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); // Paper - kick event cause ++ player.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICKED); // 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/jsonrpc/methods/PlayerService.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/PlayerService.java.patch index ef4a8ca016ba..3d19ba4f2775 100644 --- a/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/PlayerService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/methods/PlayerService.java.patch @@ -5,7 +5,7 @@ if (serverPlayer != null) { minecraftApi.playerListService().remove(serverPlayer, clientInfo); - serverPlayer.connection.disconnect(kickDto.message.flatMap(Message::asComponent).orElse(DEFAULT_KICK_MESSAGE)); -+ serverPlayer.connection.disconnect(kickDto.message.flatMap(Message::asComponent).orElse(DEFAULT_KICK_MESSAGE), org.bukkit.event.player.PlayerKickEvent.Cause.KICK); // Paper - kick event cause ++ serverPlayer.connection.disconnect(kickDto.message.flatMap(Message::asComponent).orElse(DEFAULT_KICK_MESSAGE), org.bukkit.event.player.PlayerKickEvent.Cause.KICKED); // Paper - kick event cause kicked.add(kickDto.player()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java index 5339ff469a38..76f4af792c1f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -20,6 +20,7 @@ import net.minecraft.world.entity.SpawnGroupData; import net.minecraft.world.level.MoonPhase; import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.ChorusFlowerBlock; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; @@ -112,11 +113,8 @@ private net.minecraft.world.level.block.state.BlockState getData(int x, int y, i @Override public void setBlockData(int x, int y, int z, BlockData blockData) { - WorldGenLevel world = this.getHandle(); BlockPos pos = new BlockPos(x, y, z); - net.minecraft.world.level.block.state.BlockState old = this.getHandle().getBlockState(pos); - - CraftBlock.setBlockState(world, pos, old, ((CraftBlockData) blockData).getState(), true); + this.getHandle().setBlock(pos, ((CraftBlockData) blockData).getState(), Block.UPDATE_ALL); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 51b9dbde5688..bf98fc87b0a2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -18,7 +18,6 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.SignalGetter; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.RedStoneWireBlock; import net.minecraft.world.level.block.SaplingBlock; @@ -186,37 +185,18 @@ public void setBlockData(BlockData data, boolean applyPhysics) { } boolean setBlockState(final net.minecraft.world.level.block.state.BlockState state, final boolean applyPhysics) { - return setBlockState(this.level, this.position, this.getBlockState(), state, applyPhysics); + return setBlockState(this.level, this.position, state, applyPhysics); } - public static boolean setBlockState(LevelAccessor world, BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, boolean applyPhysics) { - // SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in block entity cleanup - if (oldState.hasBlockEntity() && newState.getBlock() != oldState.getBlock()) { // SPIGOT-3725 remove old block entity if block changes - // SPIGOT-4612: faster - just clear tile - if (world instanceof net.minecraft.world.level.Level) { - ((net.minecraft.world.level.Level) world).removeBlockEntity(pos); - } else { - world.setBlock(pos, Blocks.AIR.defaultBlockState(), 0); - } - } - + public static boolean setBlockState(LevelAccessor level, BlockPos pos, net.minecraft.world.level.block.state.BlockState newState, boolean applyPhysics) { + int updateFlags = net.minecraft.world.level.block.Block.UPDATE_CLIENTS; if (applyPhysics) { - return world.setBlock(pos, newState, net.minecraft.world.level.block.Block.UPDATE_ALL); + updateFlags |= net.minecraft.world.level.block.Block.UPDATE_NEIGHBORS; } else { - boolean success = world.setBlock(pos, newState, - net.minecraft.world.level.block.Block.UPDATE_CLIENTS | - net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE | - net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE); - if (success && world instanceof net.minecraft.world.level.Level) { - world.getMinecraftWorld().sendBlockUpdated( - pos, - oldState, - newState, - net.minecraft.world.level.block.Block.UPDATE_ALL - ); - } - return success; + updateFlags |= net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE; } + + return level.setBlock(pos, newState, updateFlags); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 8380df946b0e..ec3343ecbe68 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -18,7 +18,6 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.util.CraftLocation; import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.material.Attachable; import org.bukkit.material.MaterialData; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; @@ -214,31 +213,15 @@ public boolean update(boolean force, boolean applyPhysics) { if (!this.isPlaced()) { return true; } - LevelAccessor access = this.getWorldHandle(); - CraftBlock block = this.getBlock(); + CraftBlock block = this.getBlock(); if (block.getType() != this.getType()) { if (!force) { return false; } } - net.minecraft.world.level.block.state.BlockState newBlock = this.block; - block.setBlockState(newBlock, applyPhysics); - if (access instanceof net.minecraft.world.level.Level) { - this.world.getHandle().sendBlockUpdated( - this.position, - block.getBlockState(), - newBlock, - net.minecraft.world.level.block.Block.UPDATE_ALL - ); - } - - // Update levers etc - if (false && applyPhysics && this.getData() instanceof Attachable) { // Call does not map to new API - this.world.getHandle().updateNeighborsAt(this.position.relative(CraftBlock.blockFaceToNotch(((Attachable) this.getData()).getAttachedFace())), newBlock.getBlock()); - } - + block.setBlockState(this.block, applyPhysics); return true; } From 19d83f9dc9ad835830aa7e9ff1fb8d8f970ec9f2 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Fri, 19 Jun 2026 09:21:05 -0400 Subject: [PATCH 29/30] Add missing obsolete on Bukkit.getWorldContainer [ci skip] (#13970) --- paper-api/src/main/java/org/bukkit/Bukkit.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index 6dc049664394..d083e3e5f00a 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -1756,10 +1756,14 @@ public static CommandSender createCommandSender(final @NotNull java.util.functio // Paper end /** - * Gets the folder that contains all the various {@link World}s. + * Gets the folder that contains {@link Server#getLevelDirectory()}. * - * @return folder that contains all worlds + *

This is usually the server's current working directory + * but can be overridden using command line flags (i.e. {@code --universe} or {@code --world-container}).

+ * + * @return folder that contains the level directory */ + @ApiStatus.Obsolete @NotNull public static File getWorldContainer() { return server.getWorldContainer(); From 61ed18e0536d0e7ae41c4bd57a87ba44f986a0d2 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sat, 20 Jun 2026 16:32:33 +0100 Subject: [PATCH 30/30] Use a concurrent cache in CraftRegistry CraftRegistry#get lazily populates its backing cache, reading and then writing a plain HashMap with no synchronization. That cache is reached off the main thread while building ItemMeta: CraftItemStack#getItemMeta resolves the item's CraftItemType via CraftRegistry#get to select the meta subclass, and CraftMetaItem resolves the item's enchantments through CraftRegistry#get as well. Plugins build ItemMeta from other threads, so this map is read and written concurrently, which is unsafe for a HashMap. Switch the cache to a ConcurrentHashMap and collapse the read-then-put into an atomic computeIfAbsent. This is safe against computeIfAbsent's recursive-update restriction: the wrapper constructors only store their holder and defer derived work lazily, so the mapping function never re-enters this cache. lockReferenceHolders is made volatile as it is now read from the concurrent path. Co-Authored-By: Claude Opus 4.8 --- .../org/bukkit/craftbukkit/CraftRegistry.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java index f2d20cc87a89..3b8bbbd42719 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -10,10 +10,10 @@ import io.papermc.paper.util.Holderable; import io.papermc.paper.util.MCUtil; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiFunction; import java.util.stream.Stream; import net.minecraft.core.Holder; @@ -148,12 +148,12 @@ public static B get(RegistryKey bukkitKey, NamespacedKey na } private final Class bukkitClass; // Paper - relax preload class - private final Map cache = new HashMap<>(); + private final Map cache = new ConcurrentHashMap<>(); private final net.minecraft.core.Registry minecraftRegistry; private final io.papermc.paper.registry.entry.RegistryTypeMapper minecraftToBukkit; // Paper - switch to Holder private final BiFunction serializationUpdater; // Paper - rename to make it *clear* what it is *only* for private final InvalidHolderOwner invalidHolderOwner = new InvalidHolderOwner(); - private boolean lockReferenceHolders; + private volatile boolean lockReferenceHolders; public CraftRegistry(Class bukkitClass, net.minecraft.core.Registry minecraftRegistry, BiFunction minecraftToBukkit, BiFunction serializationUpdater) { // Paper - relax preload class // Paper start - switch to Holder @@ -190,11 +190,10 @@ public void lockReferenceHolders() { @Override public B get(NamespacedKey namespacedKey) { - B cached = this.cache.get(namespacedKey); - if (cached != null) { - return cached; - } + return this.cache.computeIfAbsent(namespacedKey, this::loadBukkit); + } + private B loadBukkit(final NamespacedKey namespacedKey) { // Important to use the ResourceKey "get" method below because it will work before registry is frozen final Optional> holderOptional = this.minecraftRegistry.get(CraftNamespacedKey.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); final Holder.Reference holder; @@ -208,11 +207,7 @@ public B get(NamespacedKey namespacedKey) { } else { return null; } - final B bukkit = this.createBukkit(holder); - - this.cache.put(namespacedKey, bukkit); - - return bukkit; + return this.createBukkit(holder); } @NotNull