diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 96b8149693be..bc99062660a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -192,6 +192,30 @@ and your server. While we will fix minor formatting issues, you should stick to the guide below when making and submitting changes. +### Branches and Minecraft Versions + +Generally, PRs should be targeted at the `main` branch, where active development for +the latest Minecraft release happens. + +If a new Minecraft release is imminent, it may be wise to wait until it's released +and merged to `main` to avoid having to rebase your PR, as the `main` branch will be +frozen during this time (you can ask in the Paper Discord if you're unsure). + +For old Minecraft versions - we are unlikely to accept PRs targeting any versions not +marked as supported at https://fill-ui.papermc.io/projects/paper. + +For snapshots and other pre-release versions - you should only target these branches +for changes specific to features or changes in those versions. For example, if Copper +Golem is going to be added in 1.21.9, you can PR to the relevant dev branch as it would +not make sense to merge that into `main`. Or, if you are fixing a bug that only exists in +a dev branch, you should target that branch. When submitting PRs to dev branches, please +coordinate with the dev team in Discord or open an issue before starting work to ensure +it's an area we want to accept changes for. The team prefers to handle initial updating +work through to the server running ourselves, so do not attempt to PR version updates +(i.e. 25w42a -> 25w43a, etc.) or while there are still unapplied source patches. Feature +patches are also not applied until at earliest the pre-release phase to avoid unnecessary +churn. + ## Formatting All modifications to Vanilla files should be marked. For historical reasons, diff --git a/build-data/paper.at b/build-data/paper.at index 99cbcc236fbb..c8e2c32d9298 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -9,7 +9,6 @@ private-f net.minecraft.world.level.block.entity.BeehiveBlockEntity stored protected net.minecraft.world.entity.LivingEntity skipDropExperience protected-f net.minecraft.server.MinecraftServer worldData public net.minecraft.ChatFormatting code -public net.minecraft.Util onThreadException(Ljava/lang/Thread;Ljava/lang/Throwable;)V public net.minecraft.advancements.Advancement decorateName(Lnet/minecraft/advancements/DisplayInfo;)Lnet/minecraft/network/chat/Component; public net.minecraft.commands.CommandSourceStack source public net.minecraft.commands.arguments.DimensionArgument ERROR_INVALID_VALUE @@ -21,8 +20,6 @@ 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.numbers.FixedFormat value -public net.minecraft.network.chat.numbers.StyledFormat style 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 @@ -120,6 +117,7 @@ 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.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 public net.minecraft.util.datafix.fixes.ItemSpawnEggFix ID_TO_ENTITY @@ -209,7 +207,6 @@ 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.GlowSquid setDarkTicks(I)V public net.minecraft.world.entity.Interaction attack public net.minecraft.world.entity.Interaction getHeight()F public net.minecraft.world.entity.Interaction getResponse()Z @@ -260,70 +257,72 @@ 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.AbstractSchoolingFish leader -public net.minecraft.world.entity.animal.AbstractSchoolingFish schoolSize public net.minecraft.world.entity.animal.Animal inLove public net.minecraft.world.entity.animal.Animal loveCause -public net.minecraft.world.entity.animal.Bee hivePos -public net.minecraft.world.entity.animal.Bee isRolling()Z -public net.minecraft.world.entity.animal.Bee numCropsGrownSincePollination -public net.minecraft.world.entity.animal.Bee setHasNectar(Z)V -public net.minecraft.world.entity.animal.Bee setHasStung(Z)V -public net.minecraft.world.entity.animal.Bee setRolling(Z)V -public net.minecraft.world.entity.animal.Bee stayOutOfHiveCountdown -public net.minecraft.world.entity.animal.Bee ticksWithoutNectarSinceExitingHive -public net.minecraft.world.entity.animal.Bee timeSinceSting -public net.minecraft.world.entity.animal.Cat isRelaxStateOne()Z -public net.minecraft.world.entity.animal.Cat setCollarColor(Lnet/minecraft/world/item/DyeColor;)V -public net.minecraft.world.entity.animal.Cat setRelaxStateOne(Z)V -public net.minecraft.world.entity.animal.Cat setVariant(Lnet/minecraft/core/Holder;)V -public net.minecraft.world.entity.animal.Dolphin treasurePos -public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_0 -public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_1 -public net.minecraft.world.entity.animal.Fox isDefending()Z -public net.minecraft.world.entity.animal.Fox setDefending(Z)V -public net.minecraft.world.entity.animal.Fox setFaceplanted(Z)V -public net.minecraft.world.entity.animal.Fox setSleeping(Z)V -public net.minecraft.world.entity.animal.Fox setVariant(Lnet/minecraft/world/entity/animal/Fox$Variant;)V -public net.minecraft.world.entity.animal.MushroomCow setVariant(Lnet/minecraft/world/entity/animal/MushroomCow$Variant;)V -public net.minecraft.world.entity.animal.MushroomCow stewEffects -public net.minecraft.world.entity.animal.Ocelot isTrusting()Z -public net.minecraft.world.entity.animal.Ocelot setTrusting(Z)V -public net.minecraft.world.entity.animal.Panda getEatCounter()I -public net.minecraft.world.entity.animal.Panda setEatCounter(I)V -public net.minecraft.world.entity.animal.Parrot setVariant(Lnet/minecraft/world/entity/animal/Parrot$Variant;)V -public net.minecraft.world.entity.animal.Pig setVariant(Lnet/minecraft/core/Holder;)V -public net.minecraft.world.entity.animal.Pig steering -public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks -public net.minecraft.world.entity.animal.Rabbit registerGoals()V -public net.minecraft.world.entity.animal.Rabbit setVariant(Lnet/minecraft/world/entity/animal/Rabbit$Variant;)V -public net.minecraft.world.entity.animal.Salmon setVariant(Lnet/minecraft/world/entity/animal/Salmon$Variant;)V -public net.minecraft.world.entity.animal.TropicalFish getPackedVariant()I -public net.minecraft.world.entity.animal.TropicalFish setPackedVariant(I)V -public net.minecraft.world.entity.animal.Turtle goingHome -public net.minecraft.world.entity.animal.Turtle homePos -public net.minecraft.world.entity.animal.Turtle setHasEgg(Z)V public net.minecraft.world.entity.animal.allay.Allay canDuplicate()Z public net.minecraft.world.entity.animal.allay.Allay duplicateAllay()V 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 +public net.minecraft.world.entity.animal.bee.Bee setHasStung(Z)V +public net.minecraft.world.entity.animal.bee.Bee setRolling(Z)V +public net.minecraft.world.entity.animal.bee.Bee stayOutOfHiveCountdown +public net.minecraft.world.entity.animal.bee.Bee ticksWithoutNectarSinceExitingHive +public net.minecraft.world.entity.animal.bee.Bee timeSinceSting +public net.minecraft.world.entity.animal.cow.MushroomCow setVariant(Lnet/minecraft/world/entity/animal/cow/MushroomCow$Variant;)V +public net.minecraft.world.entity.animal.cow.MushroomCow stewEffects +public net.minecraft.world.entity.animal.dolphin.Dolphin treasurePos +public net.minecraft.world.entity.animal.equine.AbstractHorse createInventory()V +public net.minecraft.world.entity.animal.equine.AbstractHorse inventory +public net.minecraft.world.entity.animal.equine.AbstractHorse owner +public net.minecraft.world.entity.animal.equine.Horse setVariantAndMarkings(Lnet/minecraft/world/entity/animal/equine/Variant;Lnet/minecraft/world/entity/animal/equine/Markings;)V +public net.minecraft.world.entity.animal.equine.Llama setVariant(Lnet/minecraft/world/entity/animal/equine/Llama$Variant;)V +public net.minecraft.world.entity.animal.equine.SkeletonHorse trapTime +public net.minecraft.world.entity.animal.feline.Cat isRelaxStateOne()Z +public net.minecraft.world.entity.animal.feline.Cat setCollarColor(Lnet/minecraft/world/item/DyeColor;)V +public net.minecraft.world.entity.animal.feline.Cat setRelaxStateOne(Z)V +public net.minecraft.world.entity.animal.feline.Cat setVariant(Lnet/minecraft/core/Holder;)V +public net.minecraft.world.entity.animal.feline.Ocelot isTrusting()Z +public net.minecraft.world.entity.animal.feline.Ocelot setTrusting(Z)V +public net.minecraft.world.entity.animal.fish.AbstractSchoolingFish leader +public net.minecraft.world.entity.animal.fish.AbstractSchoolingFish schoolSize +public net.minecraft.world.entity.animal.fish.Salmon setVariant(Lnet/minecraft/world/entity/animal/fish/Salmon$Variant;)V +public net.minecraft.world.entity.animal.fish.TropicalFish getPackedVariant()I +public net.minecraft.world.entity.animal.fish.TropicalFish setPackedVariant(I)V +public net.minecraft.world.entity.animal.fox.Fox DATA_TRUSTED_ID_0 +public net.minecraft.world.entity.animal.fox.Fox DATA_TRUSTED_ID_1 +public net.minecraft.world.entity.animal.fox.Fox isDefending()Z +public net.minecraft.world.entity.animal.fox.Fox setDefending(Z)V +public net.minecraft.world.entity.animal.fox.Fox setFaceplanted(Z)V +public net.minecraft.world.entity.animal.fox.Fox setSleeping(Z)V +public net.minecraft.world.entity.animal.fox.Fox setVariant(Lnet/minecraft/world/entity/animal/fox/Fox$Variant;)V public net.minecraft.world.entity.animal.frog.Frog setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.animal.frog.Tadpole age public net.minecraft.world.entity.animal.goat.Goat DATA_HAS_LEFT_HORN public net.minecraft.world.entity.animal.goat.Goat DATA_HAS_RIGHT_HORN -public net.minecraft.world.entity.animal.horse.AbstractHorse createInventory()V -public net.minecraft.world.entity.animal.horse.AbstractHorse inventory -public net.minecraft.world.entity.animal.horse.AbstractHorse owner -public net.minecraft.world.entity.animal.horse.Horse setVariantAndMarkings(Lnet/minecraft/world/entity/animal/horse/Variant;Lnet/minecraft/world/entity/animal/horse/Markings;)V -public net.minecraft.world.entity.animal.horse.Llama setVariant(Lnet/minecraft/world/entity/animal/horse/Llama$Variant;)V -public net.minecraft.world.entity.animal.horse.SkeletonHorse trapTime +public net.minecraft.world.entity.animal.nautilus.AbstractNautilus inventory +public net.minecraft.world.entity.animal.panda.Panda getEatCounter()I +public net.minecraft.world.entity.animal.panda.Panda setEatCounter(I)V +public net.minecraft.world.entity.animal.parrot.Parrot setVariant(Lnet/minecraft/world/entity/animal/parrot/Parrot$Variant;)V +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 public net.minecraft.world.entity.animal.sniffer.Sniffer getExploredPositions()Ljava/util/stream/Stream; public net.minecraft.world.entity.animal.sniffer.Sniffer getState()Lnet/minecraft/world/entity/animal/sniffer/Sniffer$State; 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; public net.minecraft.world.entity.animal.wolf.Wolf isWet @@ -351,7 +350,7 @@ public net.minecraft.world.entity.decoration.Mannequin setDescription(Lnet/minec public net.minecraft.world.entity.decoration.Mannequin setHideDescription(Z)V public net.minecraft.world.entity.decoration.Mannequin setImmovable(Z)V public net.minecraft.world.entity.decoration.Mannequin setProfile(Lnet/minecraft/world/item/component/ResolvableProfile;)V -public net.minecraft.world.entity.decoration.Painting setVariant(Lnet/minecraft/core/Holder;)V +public net.minecraft.world.entity.decoration.painting.Painting setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.item.FallingBlockEntity (Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/level/block/state/BlockState;)V public net.minecraft.world.entity.item.FallingBlockEntity blockState public net.minecraft.world.entity.item.FallingBlockEntity cancelDrop @@ -373,14 +372,11 @@ public net.minecraft.world.entity.monster.Creeper swell public net.minecraft.world.entity.monster.EnderMan teleport()Z public net.minecraft.world.entity.monster.EnderMan teleportTowards(Lnet/minecraft/world/entity/Entity;)Z public net.minecraft.world.entity.monster.Endermite life -public net.minecraft.world.entity.monster.Evoker getWololoTarget()Lnet/minecraft/world/entity/animal/sheep/Sheep; -public net.minecraft.world.entity.monster.Evoker setWololoTarget(Lnet/minecraft/world/entity/animal/sheep/Sheep;)V public net.minecraft.world.entity.monster.Guardian randomStrollGoal public net.minecraft.world.entity.monster.Guardian setActiveAttackTarget(I)V public net.minecraft.world.entity.monster.Guardian$GuardianAttackGoal public net.minecraft.world.entity.monster.Guardian$GuardianAttackGoal attackTime public net.minecraft.world.entity.monster.Phantom anchorPoint -public net.minecraft.world.entity.monster.Pillager inventory public net.minecraft.world.entity.monster.Ravager attackTick public net.minecraft.world.entity.monster.Ravager roarTick public net.minecraft.world.entity.monster.Ravager stunnedTick @@ -388,44 +384,46 @@ public net.minecraft.world.entity.monster.Shulker DATA_COLOR_ID public net.minecraft.world.entity.monster.Shulker getRawPeekAmount()I public net.minecraft.world.entity.monster.Shulker setAttachFace(Lnet/minecraft/core/Direction;)V public net.minecraft.world.entity.monster.Shulker setRawPeekAmount(I)V -public net.minecraft.world.entity.monster.Skeleton DATA_STRAY_CONVERSION_ID -public net.minecraft.world.entity.monster.Skeleton conversionTime -public net.minecraft.world.entity.monster.Skeleton inPowderSnowTime -public net.minecraft.world.entity.monster.SpellcasterIllager getCurrentSpell()Lnet/minecraft/world/entity/monster/SpellcasterIllager$IllagerSpell; -public net.minecraft.world.entity.monster.SpellcasterIllager$IllagerSpell public net.minecraft.world.entity.monster.Strider steering 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.Vindicator DOOR_BREAKING_PREDICATE -public net.minecraft.world.entity.monster.Vindicator isJohnny public net.minecraft.world.entity.monster.Witch usingTime -public net.minecraft.world.entity.monster.Zombie DATA_DROWNED_CONVERSION_ID -public net.minecraft.world.entity.monster.Zombie DOOR_BREAKING_PREDICATE -public net.minecraft.world.entity.monster.Zombie conversionTime -public net.minecraft.world.entity.monster.Zombie isSunSensitive()Z -public net.minecraft.world.entity.monster.Zombie startUnderWaterConversion(I)V -public net.minecraft.world.entity.monster.ZombieVillager DATA_CONVERTING_ID -public net.minecraft.world.entity.monster.ZombieVillager conversionStarter -public net.minecraft.world.entity.monster.ZombieVillager startConverting(Ljava/util/UUID;I)V -public net.minecraft.world.entity.monster.ZombieVillager villagerConversionTime 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 +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 +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.npc.Villager increaseMerchantCareer()V -public net.minecraft.world.entity.npc.Villager numberOfRestocksToday -public net.minecraft.world.entity.npc.Villager releaseAllPois()V -public net.minecraft.world.entity.npc.Villager setUnhappy()V -public net.minecraft.world.entity.npc.Villager updateDemand()V -public net.minecraft.world.entity.npc.WanderingTrader getWanderTarget()Lnet/minecraft/core/BlockPos; +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 @@ -435,20 +433,6 @@ 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.AbstractArrow baseDamage -public net.minecraft.world.entity.projectile.AbstractArrow firedFromWeapon -public net.minecraft.world.entity.projectile.AbstractArrow getHitGroundSoundEvent()Lnet/minecraft/sounds/SoundEvent; -public net.minecraft.world.entity.projectile.AbstractArrow getPickupItem()Lnet/minecraft/world/item/ItemStack; -public net.minecraft.world.entity.projectile.AbstractArrow isInGround()Z -public net.minecraft.world.entity.projectile.AbstractArrow life -public net.minecraft.world.entity.projectile.AbstractArrow pickupItemStack -public net.minecraft.world.entity.projectile.AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V -public net.minecraft.world.entity.projectile.AbstractArrow setPierceLevel(B)V -public net.minecraft.world.entity.projectile.AbstractHurtingProjectile assignDirectionalMovement(Lnet/minecraft/world/phys/Vec3;D)V -public net.minecraft.world.entity.projectile.Arrow NO_EFFECT_COLOR -public net.minecraft.world.entity.projectile.Arrow getPotionContents()Lnet/minecraft/world/item/alchemy/PotionContents; -public net.minecraft.world.entity.projectile.Arrow setPotionContents(Lnet/minecraft/world/item/alchemy/PotionContents;)V -public net.minecraft.world.entity.projectile.Arrow updateColor()V public net.minecraft.world.entity.projectile.EvokerFangs warmupDelayTicks public net.minecraft.world.entity.projectile.EyeOfEnder life public net.minecraft.world.entity.projectile.EyeOfEnder surviveAfterDeath @@ -471,7 +455,6 @@ public net.minecraft.world.entity.projectile.FishingHook setHookedEntity(Lnet/mi public net.minecraft.world.entity.projectile.FishingHook timeUntilHooked public net.minecraft.world.entity.projectile.FishingHook timeUntilLured public net.minecraft.world.entity.projectile.FishingHook$FishHookState -public net.minecraft.world.entity.projectile.LargeFireball explosionPower public net.minecraft.world.entity.projectile.Projectile hasBeenShot public net.minecraft.world.entity.projectile.Projectile leftOwner public net.minecraft.world.entity.projectile.Projectile owner @@ -480,12 +463,27 @@ public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaX public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaY public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ -public net.minecraft.world.entity.projectile.SpectralArrow duration -public net.minecraft.world.entity.projectile.ThrowableItemProjectile getDefaultItem()Lnet/minecraft/world/item/Item; -public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage -public net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V -public net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V -public net.minecraft.world.entity.projectile.windcharge.WindCharge explode(Lnet/minecraft/world/phys/Vec3;)V +public net.minecraft.world.entity.projectile.arrow.AbstractArrow baseDamage +public net.minecraft.world.entity.projectile.arrow.AbstractArrow firedFromWeapon +public net.minecraft.world.entity.projectile.arrow.AbstractArrow getHitGroundSoundEvent()Lnet/minecraft/sounds/SoundEvent; +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 numGroups public net.minecraft.world.entity.raid.Raid raidEvent @@ -494,17 +492,17 @@ 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.AbstractBoat getStatus()Lnet/minecraft/world/entity/vehicle/AbstractBoat$Status; -public net.minecraft.world.entity.vehicle.AbstractBoat status -public net.minecraft.world.entity.vehicle.AbstractMinecartContainer lootTable -public net.minecraft.world.entity.vehicle.AbstractMinecartContainer lootTableSeed -public net.minecraft.world.entity.vehicle.MinecartCommandBlock DATA_ID_COMMAND_NAME -public net.minecraft.world.entity.vehicle.MinecartFurnace fuel -public net.minecraft.world.entity.vehicle.MinecartTNT explode(Lnet/minecraft/world/damagesource/DamageSource;D)V -public net.minecraft.world.entity.vehicle.MinecartTNT explosionPowerBase -public net.minecraft.world.entity.vehicle.MinecartTNT explosionSpeedFactor -public net.minecraft.world.entity.vehicle.MinecartTNT fuse 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 @@ -520,16 +518,16 @@ public net.minecraft.world.inventory.AbstractContainerMenu synchronizeSlotToRemo public net.minecraft.world.inventory.AbstractContainerMenu triggerSlotListeners(ILnet/minecraft/world/item/ItemStack;Ljava/util/function/Supplier;)V public net.minecraft.world.inventory.AbstractCraftingMenu craftSlots public net.minecraft.world.inventory.AbstractCraftingMenu resultSlots +public net.minecraft.world.inventory.AbstractMountInventoryMenu SLOT_BODY_ARMOR +public net.minecraft.world.inventory.AbstractMountInventoryMenu SLOT_INVENTORY_START +public net.minecraft.world.inventory.AbstractMountInventoryMenu SLOT_SADDLE +public net.minecraft.world.inventory.AbstractMountInventoryMenu mount public net.minecraft.world.inventory.AnvilMenu cost 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.HorseInventoryMenu SLOT_BODY_ARMOR -public net.minecraft.world.inventory.HorseInventoryMenu SLOT_HORSE_INVENTORY_START -public net.minecraft.world.inventory.HorseInventoryMenu SLOT_SADDLE -public net.minecraft.world.inventory.HorseInventoryMenu horse public net.minecraft.world.inventory.MerchantContainer selectionHint public net.minecraft.world.inventory.Slot slot public net.minecraft.world.item.AdventureModePredicate predicates @@ -571,9 +569,6 @@ public net.minecraft.world.level.BaseSpawner spawnCount public net.minecraft.world.level.BaseSpawner spawnDelay public net.minecraft.world.level.BaseSpawner spawnPotentials public net.minecraft.world.level.BaseSpawner spawnRange -public net.minecraft.world.level.GameRules GAME_RULE_TYPES -public net.minecraft.world.level.GameRules$Value deserialize(Ljava/lang/String;)V -public net.minecraft.world.level.GameRules$Value onChanged(Lnet/minecraft/server/MinecraftServer;)V 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; @@ -718,6 +713,7 @@ public net.minecraft.world.level.dimension.end.EndDragonFight spawnExitPortal(Z) public net.minecraft.world.level.dimension.end.EndDragonFight spawnNewGateway(Lnet/minecraft/core/BlockPos;)V 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 @@ -738,8 +734,8 @@ public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement salt public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate entityInfoList public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate palettes -public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromGenerated(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/Optional; -public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromResource(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/Optional; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromGenerated(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager loadFromResource(Lnet/minecraft/resources/Identifier;)Ljava/util/Optional; public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager readStructure(Ljava/io/InputStream;)Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate; public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager structureRepository public net.minecraft.world.level.material.MapColor MATERIAL_COLORS @@ -764,7 +760,6 @@ 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.LivingEntity invulnerableDuration 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 diff --git a/gradle.properties b/gradle.properties index 4dbf5fe9db7e..86cbd02304f2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,12 @@ group=io.papermc.paper -version=1.21.10-R0.1-SNAPSHOT -mcVersion=1.21.10 +version=1.21.11-pre3-R0.1-SNAPSHOT +mcVersion=1.21.11-pre3 +# 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=1.21.11 # Set to true while updating Minecraft version -updatingMinecraft=false +updatingMinecraft=true org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60c75ab..f8e1ee3125fe 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e1113280ef1..bad7c2462f5a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index 1606e63a1492..99492a46bcc4 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -1,3 +1,5 @@ +import paper.libs.com.google.gson.Gson + plugins { `java-library` `maven-publish` @@ -136,20 +138,36 @@ configure { } } -val generateApiVersioningFile by tasks.registering { - inputs.property("version", project.version) - val pomProps = layout.buildDirectory.file("pom.properties") - outputs.file(pomProps) - val projectVersion = project.version - doLast { - pomProps.get().asFile.writeText("version=$projectVersion") +abstract class GenerateApiVersioningFile : DefaultTask() { + @get:OutputFile + abstract val outputFile: RegularFileProperty + + @get:Input + abstract val projectVersion: Property + + @get:Input + abstract val apiVersion: Property + + @TaskAction + fun generate() { + val file = outputFile.get().asFile + file.parentFile.mkdirs() + val map = mapOf( + "version" to projectVersion.get(), + "currentApiVersion" to apiVersion.get() + ) + file.writeText(Gson().toJson(map)) } } +val generateApiVersioningFile = tasks.register("generateApiVersioningFile") { + outputFile.set(layout.buildDirectory.file("apiVersioning.json")) + projectVersion.set(project.version.toString()) + apiVersion.set(rootProject.providers.gradleProperty("apiVersion")) +} + tasks.jar { - from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { - into("META-INF/maven/${project.group}/${project.name}") - } + from(generateApiVersioningFile.flatMap { it.outputFile }) manifest { attributes( "Automatic-Module-Name" to "org.bukkit" 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 a2a80b85d281..50f6443b5af0 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 @@ -70,6 +70,8 @@ @NullMarked @GeneratedClass public interface VanillaGoal extends Goal { + GoalKey HORSE_MOUNT_PANIC = create("horse_mount_panic", AbstractHorse.class); + GoalKey HORSE_RANDOM_STAND = create("horse_random_stand", AbstractHorse.class); GoalKey HORSE_RUN_AROUND_LIKE_CRAZY = create("horse_run_around_like_crazy", AbstractHorse.class); @@ -298,6 +300,8 @@ public interface VanillaGoal extends Goal { GoalKey RANGED_CROSSBOW_ATTACK = create("ranged_crossbow_attack", Monster.class); + GoalKey SPEAR_USE = create("spear_use", Monster.class); + GoalKey OCELOT_AVOID_ENTITY = create("ocelot_avoid_entity", Ocelot.class); GoalKey OCELOT_TEMPT = create("ocelot_tempt", Ocelot.class); 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 e2969894b0bf..5e878a9384df 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 @@ -284,6 +284,13 @@ public final class DamageTypeKeys { */ public static final TypedKey SONIC_BOOM = create(key("sonic_boom")); + /** + * {@code minecraft:spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPEAR = create(key("spear")); + /** * {@code minecraft:spit} * 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 bec9a32fcc91..a3d447f8cd6d 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 @@ -25,6 +25,13 @@ @NullMarked @GeneratedClass public final class DataComponentTypeKeys { + /** + * {@code minecraft:attack_range} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ATTACK_RANGE = create(key("attack_range")); + /** * {@code minecraft:attribute_modifiers} * @@ -214,6 +221,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey DAMAGE_RESISTANT = create(key("damage_resistant")); + /** + * {@code minecraft:damage_type} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DAMAGE_TYPE = create(key("damage_type")); + /** * {@code minecraft:death_protection} * @@ -354,6 +368,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey JUKEBOX_PLAYABLE = create(key("jukebox_playable")); + /** + * {@code minecraft:kinetic_weapon} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey KINETIC_WEAPON = create(key("kinetic_weapon")); + /** * {@code minecraft:llama/variant} * @@ -424,6 +445,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey MAX_STACK_SIZE = create(key("max_stack_size")); + /** + * {@code minecraft:minimum_attack_charge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MINIMUM_ATTACK_CHARGE = create(key("minimum_attack_charge")); + /** * {@code minecraft:mooshroom/variant} * @@ -459,6 +487,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey PARROT_VARIANT = create(key("parrot/variant")); + /** + * {@code minecraft:piercing_weapon} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PIERCING_WEAPON = create(key("piercing_weapon")); + /** * {@code minecraft:pig/variant} * @@ -578,6 +613,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey SUSPICIOUS_STEW_EFFECTS = create(key("suspicious_stew_effects")); + /** + * {@code minecraft:swing_animation} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SWING_ANIMATION = create(key("swing_animation")); + /** * {@code minecraft:tool} * @@ -641,6 +683,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey USE_COOLDOWN = create(key("use_cooldown")); + /** + * {@code minecraft:use_effects} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey USE_EFFECTS = create(key("use_effects")); + /** * {@code minecraft:use_remainder} * @@ -697,6 +746,13 @@ public final class DataComponentTypeKeys { */ public static final TypedKey WRITTEN_BOOK_CONTENT = create(key("written_book_content")); + /** + * {@code minecraft:zombie_nautilus/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ZOMBIE_NAUTILUS_VARIANT = create(key("zombie_nautilus/variant")); + private DataComponentTypeKeys() { } diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java index 69841708a839..f58723783bb3 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java @@ -172,6 +172,13 @@ public final class EnchantmentKeys { */ public static final TypedKey LUCK_OF_THE_SEA = create(key("luck_of_the_sea")); + /** + * {@code minecraft:lunge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LUNGE = create(key("lunge")); + /** * {@code minecraft:lure} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java new file mode 100644 index 000000000000..2d619b4129ef --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameRuleKeys.java @@ -0,0 +1,451 @@ +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.GameRule; +import org.bukkit.MinecraftExperimental; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#GAME_RULE}. + * + * @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 GameRuleKeys { + /** + * {@code minecraft:advance_time} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> ADVANCE_TIME = create(key("advance_time")); + + /** + * {@code minecraft:advance_weather} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> ADVANCE_WEATHER = create(key("advance_weather")); + + /** + * {@code minecraft:allow_entering_nether_using_portals} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> ALLOW_ENTERING_NETHER_USING_PORTALS = create(key("allow_entering_nether_using_portals")); + + /** + * {@code minecraft:block_drops} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> BLOCK_DROPS = create(key("block_drops")); + + /** + * {@code minecraft:block_explosion_drop_decay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> BLOCK_EXPLOSION_DROP_DECAY = create(key("block_explosion_drop_decay")); + + /** + * {@code minecraft:command_block_output} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> COMMAND_BLOCK_OUTPUT = create(key("command_block_output")); + + /** + * {@code minecraft:command_blocks_work} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> COMMAND_BLOCKS_WORK = create(key("command_blocks_work")); + + /** + * {@code minecraft:drowning_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> DROWNING_DAMAGE = create(key("drowning_damage")); + + /** + * {@code minecraft:elytra_movement_check} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> ELYTRA_MOVEMENT_CHECK = create(key("elytra_movement_check")); + + /** + * {@code minecraft:ender_pearls_vanish_on_death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> ENDER_PEARLS_VANISH_ON_DEATH = create(key("ender_pearls_vanish_on_death")); + + /** + * {@code minecraft:entity_drops} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> ENTITY_DROPS = create(key("entity_drops")); + + /** + * {@code minecraft:fall_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> FALL_DAMAGE = create(key("fall_damage")); + + /** + * {@code minecraft:fire_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> FIRE_DAMAGE = create(key("fire_damage")); + + /** + * {@code minecraft:fire_spread_radius_around_player} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> FIRE_SPREAD_RADIUS_AROUND_PLAYER = create(key("fire_spread_radius_around_player")); + + /** + * {@code minecraft:forgive_dead_players} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> FORGIVE_DEAD_PLAYERS = create(key("forgive_dead_players")); + + /** + * {@code minecraft:freeze_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> FREEZE_DAMAGE = create(key("freeze_damage")); + + /** + * {@code minecraft:global_sound_events} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> GLOBAL_SOUND_EVENTS = create(key("global_sound_events")); + + /** + * {@code minecraft:immediate_respawn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> IMMEDIATE_RESPAWN = create(key("immediate_respawn")); + + /** + * {@code minecraft:keep_inventory} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> KEEP_INVENTORY = create(key("keep_inventory")); + + /** + * {@code minecraft:lava_source_conversion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> LAVA_SOURCE_CONVERSION = create(key("lava_source_conversion")); + + /** + * {@code minecraft:limited_crafting} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> LIMITED_CRAFTING = create(key("limited_crafting")); + + /** + * {@code minecraft:locator_bar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> LOCATOR_BAR = create(key("locator_bar")); + + /** + * {@code minecraft:log_admin_commands} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> LOG_ADMIN_COMMANDS = create(key("log_admin_commands")); + + /** + * {@code minecraft:max_block_modifications} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MAX_BLOCK_MODIFICATIONS = create(key("max_block_modifications")); + + /** + * {@code minecraft:max_command_forks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MAX_COMMAND_FORKS = create(key("max_command_forks")); + + /** + * {@code minecraft:max_command_sequence_length} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MAX_COMMAND_SEQUENCE_LENGTH = create(key("max_command_sequence_length")); + + /** + * {@code minecraft:max_entity_cramming} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MAX_ENTITY_CRAMMING = create(key("max_entity_cramming")); + + /** + * {@code minecraft:max_minecart_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) + public static final TypedKey> MAX_MINECART_SPEED = create(key("max_minecart_speed")); + + /** + * {@code minecraft:max_snow_accumulation_height} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MAX_SNOW_ACCUMULATION_HEIGHT = create(key("max_snow_accumulation_height")); + + /** + * {@code minecraft:mob_drops} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MOB_DROPS = create(key("mob_drops")); + + /** + * {@code minecraft:mob_explosion_drop_decay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MOB_EXPLOSION_DROP_DECAY = create(key("mob_explosion_drop_decay")); + + /** + * {@code minecraft:mob_griefing} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> MOB_GRIEFING = create(key("mob_griefing")); + + /** + * {@code minecraft:natural_health_regeneration} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> NATURAL_HEALTH_REGENERATION = create(key("natural_health_regeneration")); + + /** + * {@code minecraft:player_movement_check} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> PLAYER_MOVEMENT_CHECK = create(key("player_movement_check")); + + /** + * {@code minecraft:players_nether_portal_creative_delay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = create(key("players_nether_portal_creative_delay")); + + /** + * {@code minecraft:players_nether_portal_default_delay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = create(key("players_nether_portal_default_delay")); + + /** + * {@code minecraft:players_sleeping_percentage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> PLAYERS_SLEEPING_PERCENTAGE = create(key("players_sleeping_percentage")); + + /** + * {@code minecraft:projectiles_can_break_blocks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> PROJECTILES_CAN_BREAK_BLOCKS = create(key("projectiles_can_break_blocks")); + + /** + * {@code minecraft:pvp} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> PVP = create(key("pvp")); + + /** + * {@code minecraft:raids} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> RAIDS = create(key("raids")); + + /** + * {@code minecraft:random_tick_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> RANDOM_TICK_SPEED = create(key("random_tick_speed")); + + /** + * {@code minecraft:reduced_debug_info} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> REDUCED_DEBUG_INFO = create(key("reduced_debug_info")); + + /** + * {@code minecraft:respawn_radius} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> RESPAWN_RADIUS = create(key("respawn_radius")); + + /** + * {@code minecraft:send_command_feedback} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SEND_COMMAND_FEEDBACK = create(key("send_command_feedback")); + + /** + * {@code minecraft:show_advancement_messages} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SHOW_ADVANCEMENT_MESSAGES = create(key("show_advancement_messages")); + + /** + * {@code minecraft:show_death_messages} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SHOW_DEATH_MESSAGES = create(key("show_death_messages")); + + /** + * {@code minecraft:spawn_mobs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPAWN_MOBS = create(key("spawn_mobs")); + + /** + * {@code minecraft:spawn_monsters} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPAWN_MONSTERS = create(key("spawn_monsters")); + + /** + * {@code minecraft:spawn_patrols} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPAWN_PATROLS = create(key("spawn_patrols")); + + /** + * {@code minecraft:spawn_phantoms} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPAWN_PHANTOMS = create(key("spawn_phantoms")); + + /** + * {@code minecraft:spawn_wandering_traders} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPAWN_WANDERING_TRADERS = create(key("spawn_wandering_traders")); + + /** + * {@code minecraft:spawn_wardens} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPAWN_WARDENS = create(key("spawn_wardens")); + + /** + * {@code minecraft:spawner_blocks_work} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPAWNER_BLOCKS_WORK = create(key("spawner_blocks_work")); + + /** + * {@code minecraft:spectators_generate_chunks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPECTATORS_GENERATE_CHUNKS = create(key("spectators_generate_chunks")); + + /** + * {@code minecraft:spread_vines} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> SPREAD_VINES = create(key("spread_vines")); + + /** + * {@code minecraft:tnt_explodes} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> TNT_EXPLODES = create(key("tnt_explodes")); + + /** + * {@code minecraft:tnt_explosion_drop_decay} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> TNT_EXPLOSION_DROP_DECAY = create(key("tnt_explosion_drop_decay")); + + /** + * {@code minecraft:universal_anger} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> UNIVERSAL_ANGER = create(key("universal_anger")); + + /** + * {@code minecraft:water_source_conversion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey> WATER_SOURCE_CONVERSION = create(key("water_source_conversion")); + + private GameRuleKeys() { + } + + private static TypedKey> create(final Key key) { + return TypedKey.create(RegistryKey.GAME_RULE, key); + } +} 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 f5fd056c76c6..33b92219df8b 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 @@ -1383,6 +1383,13 @@ public final class ItemTypeKeys { */ public static final TypedKey CALIBRATED_SCULK_SENSOR = create(key("calibrated_sculk_sensor")); + /** + * {@code minecraft:camel_husk_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CAMEL_HUSK_SPAWN_EGG = create(key("camel_husk_spawn_egg")); + /** * {@code minecraft:camel_spawn_egg} * @@ -2139,6 +2146,13 @@ public final class ItemTypeKeys { */ public static final TypedKey COPPER_LEGGINGS = create(key("copper_leggings")); + /** + * {@code minecraft:copper_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COPPER_NAUTILUS_ARMOR = create(key("copper_nautilus_armor")); + /** * {@code minecraft:copper_nugget} * @@ -2167,6 +2181,13 @@ public final class ItemTypeKeys { */ public static final TypedKey COPPER_SHOVEL = create(key("copper_shovel")); + /** + * {@code minecraft:copper_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COPPER_SPEAR = create(key("copper_spear")); + /** * {@code minecraft:copper_sword} * @@ -3063,6 +3084,13 @@ public final class ItemTypeKeys { */ public static final TypedKey DIAMOND_LEGGINGS = create(key("diamond_leggings")); + /** + * {@code minecraft:diamond_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DIAMOND_NAUTILUS_ARMOR = create(key("diamond_nautilus_armor")); + /** * {@code minecraft:diamond_ore} * @@ -3084,6 +3112,13 @@ public final class ItemTypeKeys { */ public static final TypedKey DIAMOND_SHOVEL = create(key("diamond_shovel")); + /** + * {@code minecraft:diamond_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DIAMOND_SPEAR = create(key("diamond_spear")); + /** * {@code minecraft:diamond_sword} * @@ -3952,6 +3987,13 @@ public final class ItemTypeKeys { */ public static final TypedKey GOLDEN_LEGGINGS = create(key("golden_leggings")); + /** + * {@code minecraft:golden_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOLDEN_NAUTILUS_ARMOR = create(key("golden_nautilus_armor")); + /** * {@code minecraft:golden_pickaxe} * @@ -3966,6 +4008,13 @@ public final class ItemTypeKeys { */ public static final TypedKey GOLDEN_SHOVEL = create(key("golden_shovel")); + /** + * {@code minecraft:golden_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOLDEN_SPEAR = create(key("golden_spear")); + /** * {@code minecraft:golden_sword} * @@ -4568,6 +4617,13 @@ public final class ItemTypeKeys { */ public static final TypedKey IRON_LEGGINGS = create(key("iron_leggings")); + /** + * {@code minecraft:iron_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IRON_NAUTILUS_ARMOR = create(key("iron_nautilus_armor")); + /** * {@code minecraft:iron_nugget} * @@ -4596,6 +4652,13 @@ public final class ItemTypeKeys { */ public static final TypedKey IRON_SHOVEL = create(key("iron_shovel")); + /** + * {@code minecraft:iron_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IRON_SPEAR = create(key("iron_spear")); + /** * {@code minecraft:iron_sword} * @@ -5940,6 +6003,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NAUTILUS_SHELL = create(key("nautilus_shell")); + /** + * {@code minecraft:nautilus_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NAUTILUS_SPAWN_EGG = create(key("nautilus_spawn_egg")); + /** * {@code minecraft:nether_brick} * @@ -6066,6 +6136,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NETHERITE_HOE = create(key("netherite_hoe")); + /** + * {@code minecraft:netherite_horse_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NETHERITE_HORSE_ARMOR = create(key("netherite_horse_armor")); + /** * {@code minecraft:netherite_ingot} * @@ -6080,6 +6157,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NETHERITE_LEGGINGS = create(key("netherite_leggings")); + /** + * {@code minecraft:netherite_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NETHERITE_NAUTILUS_ARMOR = create(key("netherite_nautilus_armor")); + /** * {@code minecraft:netherite_pickaxe} * @@ -6101,6 +6185,13 @@ public final class ItemTypeKeys { */ public static final TypedKey NETHERITE_SHOVEL = create(key("netherite_shovel")); + /** + * {@code minecraft:netherite_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NETHERITE_SPEAR = create(key("netherite_spear")); + /** * {@code minecraft:netherite_sword} * @@ -6710,6 +6801,13 @@ public final class ItemTypeKeys { */ public static final TypedKey PAPER = create(key("paper")); + /** + * {@code minecraft:parched_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PARCHED_SPAWN_EGG = create(key("parched_spawn_egg")); + /** * {@code minecraft:parrot_spawn_egg} * @@ -8733,6 +8831,13 @@ public final class ItemTypeKeys { */ public static final TypedKey STONE_SLAB = create(key("stone_slab")); + /** + * {@code minecraft:stone_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STONE_SPEAR = create(key("stone_spear")); + /** * {@code minecraft:stone_stairs} * @@ -10273,6 +10378,13 @@ public final class ItemTypeKeys { */ public static final TypedKey WOODEN_SHOVEL = create(key("wooden_shovel")); + /** + * {@code minecraft:wooden_spear} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WOODEN_SPEAR = create(key("wooden_spear")); + /** * {@code minecraft:wooden_sword} * @@ -10420,6 +10532,13 @@ public final class ItemTypeKeys { */ public static final TypedKey ZOMBIE_HORSE_SPAWN_EGG = create(key("zombie_horse_spawn_egg")); + /** + * {@code minecraft:zombie_nautilus_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ZOMBIE_NAUTILUS_SPAWN_EGG = create(key("zombie_nautilus_spawn_egg")); + /** * {@code minecraft:zombie_spawn_egg} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java index 7a4c53968010..7059e3566a5e 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java @@ -46,6 +46,13 @@ public final class MobEffectKeys { */ public static final TypedKey BLINDNESS = create(key("blindness")); + /** + * {@code minecraft:breath_of_the_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BREATH_OF_THE_NAUTILUS = create(key("breath_of_the_nautilus")); + /** * {@code minecraft:conduit_power} * 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 5608b4fe02ac..f12ba25ff870 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 @@ -6031,6 +6031,62 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_AXOLOTL_SWIM = create(key("entity.axolotl.swim")); + /** + * {@code minecraft:entity.baby_nautilus.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_AMBIENT = create(key("entity.baby_nautilus.ambient")); + + /** + * {@code minecraft:entity.baby_nautilus.ambient_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_AMBIENT_LAND = create(key("entity.baby_nautilus.ambient_land")); + + /** + * {@code minecraft:entity.baby_nautilus.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_DEATH = create(key("entity.baby_nautilus.death")); + + /** + * {@code minecraft:entity.baby_nautilus.death_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_DEATH_LAND = create(key("entity.baby_nautilus.death_land")); + + /** + * {@code minecraft:entity.baby_nautilus.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_EAT = create(key("entity.baby_nautilus.eat")); + + /** + * {@code minecraft:entity.baby_nautilus.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_HURT = create(key("entity.baby_nautilus.hurt")); + + /** + * {@code minecraft:entity.baby_nautilus.hurt_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_HURT_LAND = create(key("entity.baby_nautilus.hurt_land")); + + /** + * {@code minecraft:entity.baby_nautilus.swim} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_BABY_NAUTILUS_SWIM = create(key("entity.baby_nautilus.swim")); + /** * {@code minecraft:entity.bat.ambient} * @@ -6360,6 +6416,83 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_CAMEL_STEP_SAND = create(key("entity.camel.step_sand")); + /** + * {@code minecraft:entity.camel_husk.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_AMBIENT = create(key("entity.camel_husk.ambient")); + + /** + * {@code minecraft:entity.camel_husk.dash} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_DASH = create(key("entity.camel_husk.dash")); + + /** + * {@code minecraft:entity.camel_husk.dash_ready} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_DASH_READY = create(key("entity.camel_husk.dash_ready")); + + /** + * {@code minecraft:entity.camel_husk.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_DEATH = create(key("entity.camel_husk.death")); + + /** + * {@code minecraft:entity.camel_husk.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_EAT = create(key("entity.camel_husk.eat")); + + /** + * {@code minecraft:entity.camel_husk.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_HURT = create(key("entity.camel_husk.hurt")); + + /** + * {@code minecraft:entity.camel_husk.saddle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_SADDLE = create(key("entity.camel_husk.saddle")); + + /** + * {@code minecraft:entity.camel_husk.sit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_SIT = create(key("entity.camel_husk.sit")); + + /** + * {@code minecraft:entity.camel_husk.stand} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_STAND = create(key("entity.camel_husk.stand")); + + /** + * {@code minecraft:entity.camel_husk.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_STEP = create(key("entity.camel_husk.step")); + + /** + * {@code minecraft:entity.camel_husk.step_sand} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_CAMEL_HUSK_STEP_SAND = create(key("entity.camel_husk.step_sand")); + /** * {@code minecraft:entity.cat.ambient} * @@ -8481,6 +8614,97 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_MULE_JUMP = create(key("entity.mule.jump")); + /** + * {@code minecraft:entity.nautilus.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_AMBIENT = create(key("entity.nautilus.ambient")); + + /** + * {@code minecraft:entity.nautilus.ambient_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_AMBIENT_LAND = create(key("entity.nautilus.ambient_land")); + + /** + * {@code minecraft:entity.nautilus.dash} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH = create(key("entity.nautilus.dash")); + + /** + * {@code minecraft:entity.nautilus.dash_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH_LAND = create(key("entity.nautilus.dash_land")); + + /** + * {@code minecraft:entity.nautilus.dash_ready} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH_READY = create(key("entity.nautilus.dash_ready")); + + /** + * {@code minecraft:entity.nautilus.dash_ready_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DASH_READY_LAND = create(key("entity.nautilus.dash_ready_land")); + + /** + * {@code minecraft:entity.nautilus.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DEATH = create(key("entity.nautilus.death")); + + /** + * {@code minecraft:entity.nautilus.death_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_DEATH_LAND = create(key("entity.nautilus.death_land")); + + /** + * {@code minecraft:entity.nautilus.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_EAT = create(key("entity.nautilus.eat")); + + /** + * {@code minecraft:entity.nautilus.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_HURT = create(key("entity.nautilus.hurt")); + + /** + * {@code minecraft:entity.nautilus.hurt_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_HURT_LAND = create(key("entity.nautilus.hurt_land")); + + /** + * {@code minecraft:entity.nautilus.riding} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_RIDING = create(key("entity.nautilus.riding")); + + /** + * {@code minecraft:entity.nautilus.swim} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_NAUTILUS_SWIM = create(key("entity.nautilus.swim")); + /** * {@code minecraft:entity.ocelot.ambient} * @@ -8593,6 +8817,34 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PANDA_WORRIED_AMBIENT = create(key("entity.panda.worried_ambient")); + /** + * {@code minecraft:entity.parched.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_AMBIENT = create(key("entity.parched.ambient")); + + /** + * {@code minecraft:entity.parched.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_DEATH = create(key("entity.parched.death")); + + /** + * {@code minecraft:entity.parched.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_HURT = create(key("entity.parched.hurt")); + + /** + * {@code minecraft:entity.parched.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARCHED_STEP = create(key("entity.parched.step")); + /** * {@code minecraft:entity.parrot.ambient} * @@ -8649,6 +8901,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PARROT_IMITATE_BREEZE = create(key("entity.parrot.imitate.breeze")); + /** + * {@code minecraft:entity.parrot.imitate.camel_husk} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_CAMEL_HUSK = create(key("entity.parrot.imitate.camel_husk")); + /** * {@code minecraft:entity.parrot.imitate.creaking} * @@ -8740,6 +8999,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PARROT_IMITATE_MAGMA_CUBE = create(key("entity.parrot.imitate.magma_cube")); + /** + * {@code minecraft:entity.parrot.imitate.parched} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_PARCHED = create(key("entity.parrot.imitate.parched")); + /** * {@code minecraft:entity.parrot.imitate.phantom} * @@ -8873,6 +9139,20 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_PARROT_IMITATE_ZOMBIE = create(key("entity.parrot.imitate.zombie")); + /** + * {@code minecraft:entity.parrot.imitate.zombie_horse} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_ZOMBIE_HORSE = create(key("entity.parrot.imitate.zombie_horse")); + + /** + * {@code minecraft:entity.parrot.imitate.zombie_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_PARROT_IMITATE_ZOMBIE_NAUTILUS = create(key("entity.parrot.imitate.zombie_nautilus")); + /** * {@code minecraft:entity.parrot.imitate.zombie_villager} * @@ -11141,6 +11421,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_HORSE_AMBIENT = create(key("entity.zombie_horse.ambient")); + /** + * {@code minecraft:entity.zombie_horse.angry} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_HORSE_ANGRY = create(key("entity.zombie_horse.angry")); + /** * {@code minecraft:entity.zombie_horse.death} * @@ -11148,6 +11435,13 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_HORSE_DEATH = create(key("entity.zombie_horse.death")); + /** + * {@code minecraft:entity.zombie_horse.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_HORSE_EAT = create(key("entity.zombie_horse.eat")); + /** * {@code minecraft:entity.zombie_horse.hurt} * @@ -11155,6 +11449,90 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_ZOMBIE_HORSE_HURT = create(key("entity.zombie_horse.hurt")); + /** + * {@code minecraft:entity.zombie_nautilus.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_AMBIENT = create(key("entity.zombie_nautilus.ambient")); + + /** + * {@code minecraft:entity.zombie_nautilus.ambient_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_AMBIENT_LAND = create(key("entity.zombie_nautilus.ambient_land")); + + /** + * {@code minecraft:entity.zombie_nautilus.dash} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH = create(key("entity.zombie_nautilus.dash")); + + /** + * {@code minecraft:entity.zombie_nautilus.dash_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH_LAND = create(key("entity.zombie_nautilus.dash_land")); + + /** + * {@code minecraft:entity.zombie_nautilus.dash_ready} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH_READY = create(key("entity.zombie_nautilus.dash_ready")); + + /** + * {@code minecraft:entity.zombie_nautilus.dash_ready_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DASH_READY_LAND = create(key("entity.zombie_nautilus.dash_ready_land")); + + /** + * {@code minecraft:entity.zombie_nautilus.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DEATH = create(key("entity.zombie_nautilus.death")); + + /** + * {@code minecraft:entity.zombie_nautilus.death_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_DEATH_LAND = create(key("entity.zombie_nautilus.death_land")); + + /** + * {@code minecraft:entity.zombie_nautilus.eat} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_EAT = create(key("entity.zombie_nautilus.eat")); + + /** + * {@code minecraft:entity.zombie_nautilus.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_HURT = create(key("entity.zombie_nautilus.hurt")); + + /** + * {@code minecraft:entity.zombie_nautilus.hurt_land} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_HURT_LAND = create(key("entity.zombie_nautilus.hurt_land")); + + /** + * {@code minecraft:entity.zombie_nautilus.swim} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_ZOMBIE_NAUTILUS_SWIM = create(key("entity.zombie_nautilus.swim")); + /** * {@code minecraft:entity.zombie_villager.ambient} * @@ -11316,6 +11694,13 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_ARMOR_EQUIP_LEATHER = create(key("item.armor.equip_leather")); + /** + * {@code minecraft:item.armor.equip_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_ARMOR_EQUIP_NAUTILUS = create(key("item.armor.equip_nautilus")); + /** * {@code minecraft:item.armor.equip_netherite} * @@ -11337,6 +11722,13 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_ARMOR_EQUIP_WOLF = create(key("item.armor.equip_wolf")); + /** + * {@code minecraft:item.armor.unequip_nautilus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_ARMOR_UNEQUIP_NAUTILUS = create(key("item.armor.unequip_nautilus")); + /** * {@code minecraft:item.armor.unequip_wolf} * @@ -11806,6 +12198,20 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_MACE_SMASH_GROUND_HEAVY = create(key("item.mace.smash_ground_heavy")); + /** + * {@code minecraft:item.nautilus_saddle_equip} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_NAUTILUS_SADDLE_EQUIP = create(key("item.nautilus_saddle_equip")); + + /** + * {@code minecraft:item.nautilus_saddle_underwater_equip} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_NAUTILUS_SADDLE_UNDERWATER_EQUIP = create(key("item.nautilus_saddle_underwater_equip")); + /** * {@code minecraft:item.nether_wart.plant} * @@ -11855,6 +12261,69 @@ public final class SoundEventKeys { */ public static final TypedKey ITEM_SHOVEL_FLATTEN = create(key("item.shovel.flatten")); + /** + * {@code minecraft:item.spear.attack} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_ATTACK = create(key("item.spear.attack")); + + /** + * {@code minecraft:item.spear.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_HIT = create(key("item.spear.hit")); + + /** + * {@code minecraft:item.spear.lunge_1} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_LUNGE_1 = create(key("item.spear.lunge_1")); + + /** + * {@code minecraft:item.spear.lunge_2} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_LUNGE_2 = create(key("item.spear.lunge_2")); + + /** + * {@code minecraft:item.spear.lunge_3} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_LUNGE_3 = create(key("item.spear.lunge_3")); + + /** + * {@code minecraft:item.spear.use} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_USE = create(key("item.spear.use")); + + /** + * {@code minecraft:item.spear_wood.attack} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_WOOD_ATTACK = create(key("item.spear_wood.attack")); + + /** + * {@code minecraft:item.spear_wood.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_WOOD_HIT = create(key("item.spear_wood.hit")); + + /** + * {@code minecraft:item.spear_wood.use} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_SPEAR_WOOD_USE = create(key("item.spear_wood.use")); + /** * {@code minecraft:item.spyglass.stop_using} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ZombieNautilusVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ZombieNautilusVariantKeys.java new file mode 100644 index 000000000000..3e2cc8dc9a3a --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ZombieNautilusVariantKeys.java @@ -0,0 +1,54 @@ +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.ZombieNautilus; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#ZOMBIE_NAUTILUS_VARIANT}. + * + * @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 ZombieNautilusVariantKeys { + /** + * {@code minecraft:temperate} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEMPERATE = create(key("temperate")); + + /** + * {@code minecraft:warm} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WARM = create(key("warm")); + + private ZombieNautilusVariantKeys() { + } + + /** + * Creates a typed key for {@link ZombieNautilus.Variant} in the registry {@code minecraft:zombie_nautilus_variant}. + * + * @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.ZOMBIE_NAUTILUS_VARIANT, key); + } +} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java index a9034950da84..4d508a667878 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java @@ -39,13 +39,6 @@ public final class BiomeTagKeys { */ public static final TagKey ALLOWS_TROPICAL_FISH_SPAWNS_AT_ANY_HEIGHT = create(key("allows_tropical_fish_spawns_at_any_height")); - /** - * {@code #minecraft:has_closer_water_fog} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey HAS_CLOSER_WATER_FOG = create(key("has_closer_water_fog")); - /** * {@code #minecraft:has_structure/ancient_city} * @@ -284,13 +277,6 @@ public final class BiomeTagKeys { */ public static final TagKey HAS_STRUCTURE_WOODLAND_MANSION = create(key("has_structure/woodland_mansion")); - /** - * {@code #minecraft:increased_fire_burnout} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey INCREASED_FIRE_BURNOUT = create(key("increased_fire_burnout")); - /** * {@code #minecraft:is_badlands} * @@ -403,13 +389,6 @@ public final class BiomeTagKeys { */ public static final TagKey MORE_FREQUENT_DROWNED_SPAWNS = create(key("more_frequent_drowned_spawns")); - /** - * {@code #minecraft:plays_underwater_music} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey PLAYS_UNDERWATER_MUSIC = create(key("plays_underwater_music")); - /** * {@code #minecraft:polar_bears_spawn_on_alternate_blocks} * @@ -439,25 +418,25 @@ public final class BiomeTagKeys { public static final TagKey REQUIRED_OCEAN_MONUMENT_SURROUNDING = create(key("required_ocean_monument_surrounding")); /** - * {@code #minecraft:snow_golem_melts} + * {@code #minecraft:spawns_cold_variant_farm_animals} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TagKey SNOW_GOLEM_MELTS = create(key("snow_golem_melts")); + public static final TagKey SPAWNS_COLD_VARIANT_FARM_ANIMALS = create(key("spawns_cold_variant_farm_animals")); /** - * {@code #minecraft:spawns_cold_variant_farm_animals} + * {@code #minecraft:spawns_cold_variant_frogs} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TagKey SPAWNS_COLD_VARIANT_FARM_ANIMALS = create(key("spawns_cold_variant_farm_animals")); + public static final TagKey SPAWNS_COLD_VARIANT_FROGS = create(key("spawns_cold_variant_frogs")); /** - * {@code #minecraft:spawns_cold_variant_frogs} + * {@code #minecraft:spawns_coral_variant_zombie_nautilus} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TagKey SPAWNS_COLD_VARIANT_FROGS = create(key("spawns_cold_variant_frogs")); + public static final TagKey SPAWNS_CORAL_VARIANT_ZOMBIE_NAUTILUS = create(key("spawns_coral_variant_zombie_nautilus")); /** * {@code #minecraft:spawns_gold_rabbits} @@ -508,13 +487,6 @@ public final class BiomeTagKeys { */ public static final TagKey WATER_ON_MAP_OUTLINES = create(key("water_on_map_outlines")); - /** - * {@code #minecraft:without_patrol_spawns} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey WITHOUT_PATROL_SPAWNS = create(key("without_patrol_spawns")); - /** * {@code #minecraft:without_wandering_trader_spawns} * 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 82d3b953fa1a..4f1e44542145 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 @@ -242,6 +242,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey CAMPFIRES = create(key("campfires")); + /** + * {@code #minecraft:can_glide_through} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_GLIDE_THROUGH = create(key("can_glide_through")); + /** * {@code #minecraft:candle_cakes} * 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 95073a65d876..f24cd0efc90f 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 @@ -81,6 +81,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey BOAT = create(key("boat")); + /** + * {@code #minecraft:burn_in_daylight} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey BURN_IN_DAYLIGHT = create(key("burn_in_daylight")); + /** * {@code #minecraft:can_breathe_under_water} * @@ -102,6 +109,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey CAN_EQUIP_SADDLE = create(key("can_equip_saddle")); + /** + * {@code #minecraft:can_float_while_ridden} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_FLOAT_WHILE_RIDDEN = create(key("can_float_while_ridden")); + /** * {@code #minecraft:can_turn_in_boats} * @@ -116,6 +130,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey CAN_WEAR_HORSE_ARMOR = create(key("can_wear_horse_armor")); + /** + * {@code #minecraft:can_wear_nautilus_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_WEAR_NAUTILUS_ARMOR = create(key("can_wear_nautilus_armor")); + /** * {@code #minecraft:candidate_for_iron_golem_gift} * @@ -228,6 +249,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey INVERTED_HEALING_AND_HARM = create(key("inverted_healing_and_harm")); + /** + * {@code #minecraft:nautilus_hostiles} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_HOSTILES = create(key("nautilus_hostiles")); + /** * {@code #minecraft:no_anger_from_wind_charge} * 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 8145f5dda0c2..40202e9e23ad 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 @@ -172,6 +172,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey CAMEL_FOOD = create(key("camel_food")); + /** + * {@code #minecraft:camel_husk_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAMEL_HUSK_FOOD = create(key("camel_husk_food")); + /** * {@code #minecraft:candles} * @@ -487,6 +494,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey ENCHANTABLE_LEG_ARMOR = create(key("enchantable/leg_armor")); + /** + * {@code #minecraft:enchantable/lunge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey ENCHANTABLE_LUNGE = create(key("enchantable/lunge")); + /** * {@code #minecraft:enchantable/mace} * @@ -494,6 +508,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey ENCHANTABLE_MACE = create(key("enchantable/mace")); + /** + * {@code #minecraft:enchantable/melee_weapon} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey ENCHANTABLE_MELEE_WEAPON = create(key("enchantable/melee_weapon")); + /** * {@code #minecraft:enchantable/mining} * @@ -516,11 +537,11 @@ public final class ItemTypeTagKeys { public static final TagKey ENCHANTABLE_SHARP_WEAPON = create(key("enchantable/sharp_weapon")); /** - * {@code #minecraft:enchantable/sword} + * {@code #minecraft:enchantable/sweeping} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TagKey ENCHANTABLE_SWORD = create(key("enchantable/sword")); + public static final TagKey ENCHANTABLE_SWEEPING = create(key("enchantable/sweeping")); /** * {@code #minecraft:enchantable/trident} @@ -816,6 +837,27 @@ public final class ItemTypeTagKeys { */ public static final TagKey MEAT = create(key("meat")); + /** + * {@code #minecraft:nautilus_bucket_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_BUCKET_FOOD = create(key("nautilus_bucket_food")); + + /** + * {@code #minecraft:nautilus_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_FOOD = create(key("nautilus_food")); + + /** + * {@code #minecraft:nautilus_taming_items} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey NAUTILUS_TAMING_ITEMS = create(key("nautilus_taming_items")); + /** * {@code #minecraft:netherite_tool_materials} * @@ -1131,6 +1173,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey SOUL_FIRE_BASE_BLOCKS = create(key("soul_fire_base_blocks")); + /** + * {@code #minecraft:spears} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SPEARS = create(key("spears")); + /** * {@code #minecraft:spruce_logs} * @@ -1355,6 +1404,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey WOOL_CARPETS = create(key("wool_carpets")); + /** + * {@code #minecraft:zombie_horse_food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey ZOMBIE_HORSE_FOOD = create(key("zombie_horse_food")); + private ItemTypeTagKeys() { } 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 a748e78bbdd1..6b7ae470cf37 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -202,7 +202,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy */ public static final MaterialSetTag HORSE_ARMORS = new MaterialSetTag(keyFor("horse_armors")) .endsWith("_HORSE_ARMOR") - .ensureSize("HORSE_ARMORS", 5).lock(); + .ensureSize("HORSE_ARMORS", 6).lock(); /** * Covers the variants of infested blocks. @@ -340,7 +340,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", 83).lock(); + .ensureSize("SPAWN_EGGS", 87).lock(); /** * Covers all colors of stained glass. @@ -677,6 +677,7 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy .not(Material.COPPER_HORSE_ARMOR, Material.COPPER_GOLEM_SPAWN_EGG) .not(Material.COPPER_HELMET, Material.COPPER_CHESTPLATE, Material.COPPER_LEGGINGS, Material.COPPER_BOOTS) .not(Material.COPPER_AXE, Material.COPPER_HOE, Material.COPPER_PICKAXE, Material.COPPER_SHOVEL, Material.COPPER_SWORD) + .not(Material.COPPER_NAUTILUS_ARMOR, Material.COPPER_SPEAR) .ensureSize("UNAFFECTED_COPPER_BLOCKS", 30).lock(); /** @@ -738,49 +739,49 @@ private static MaterialSetTag replacedBy(Tag vanillaTag, String legacy * Covers all Wooden Tools. */ public static final MaterialSetTag WOODEN_TOOLS = new MaterialSetTag(keyFor("wooden_tools")) - .add(Material.WOODEN_AXE, Material.WOODEN_HOE, Material.WOODEN_PICKAXE, Material.WOODEN_SHOVEL, Material.WOODEN_SWORD) - .ensureSize("WOODEN_TOOLS", 5).lock(); + .add(Material.WOODEN_AXE, Material.WOODEN_HOE, Material.WOODEN_PICKAXE, Material.WOODEN_SHOVEL, Material.WOODEN_SWORD, Material.WOODEN_SPEAR) + .lock(); /** * Covers all Stone Tools. */ public static final MaterialSetTag STONE_TOOLS = new MaterialSetTag(keyFor("stone_tools")) - .add(Material.STONE_AXE, Material.STONE_HOE, Material.STONE_PICKAXE, Material.STONE_SHOVEL, Material.STONE_SWORD) - .ensureSize("STONE_TOOLS", 5).lock(); + .add(Material.STONE_AXE, Material.STONE_HOE, Material.STONE_PICKAXE, Material.STONE_SHOVEL, Material.STONE_SWORD, Material.STONE_SPEAR) + .lock(); /** * Covers all copper Tools. */ public static final MaterialSetTag COPPER_TOOLS = new MaterialSetTag(keyFor("copper_tools")) - .add(Material.COPPER_AXE, Material.COPPER_HOE, Material.COPPER_PICKAXE, Material.COPPER_SHOVEL, Material.COPPER_SWORD) - .ensureSize("COPPER_TOOLS", 5).lock(); + .add(Material.COPPER_AXE, Material.COPPER_HOE, Material.COPPER_PICKAXE, Material.COPPER_SHOVEL, Material.COPPER_SWORD, Material.COPPER_SPEAR) + .lock(); /** * Covers all Iron Tools. */ public static final MaterialSetTag IRON_TOOLS = new MaterialSetTag(keyFor("iron_tools")) - .add(Material.IRON_AXE, Material.IRON_HOE, Material.IRON_PICKAXE, Material.IRON_SHOVEL, Material.IRON_SWORD) - .ensureSize("IRON_TOOLS", 5).lock(); + .add(Material.IRON_AXE, Material.IRON_HOE, Material.IRON_PICKAXE, Material.IRON_SHOVEL, Material.IRON_SWORD, Material.IRON_SPEAR) + .lock(); /** * Covers all Gold Tools. */ public static final MaterialSetTag GOLDEN_TOOLS = new MaterialSetTag(keyFor("golden_tools")) - .add(Material.GOLDEN_AXE, Material.GOLDEN_HOE, Material.GOLDEN_PICKAXE, Material.GOLDEN_SHOVEL, Material.GOLDEN_SWORD) - .ensureSize("GOLDEN_TOOLS", 5).lock(); + .add(Material.GOLDEN_AXE, Material.GOLDEN_HOE, Material.GOLDEN_PICKAXE, Material.GOLDEN_SHOVEL, Material.GOLDEN_SWORD, Material.GOLDEN_SPEAR) + .lock(); /** * Covers all Diamond Tools. */ public static final MaterialSetTag DIAMOND_TOOLS = new MaterialSetTag(keyFor("diamond_tools")) - .add(Material.DIAMOND_AXE, Material.DIAMOND_HOE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SHOVEL, Material.DIAMOND_SWORD) - .ensureSize("DIAMOND_TOOLS", 5).lock(); + .add(Material.DIAMOND_AXE, Material.DIAMOND_HOE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SHOVEL, Material.DIAMOND_SWORD, Material.DIAMOND_SPEAR) + .lock(); /** * Covers all Netherite Tools. */ public static final MaterialSetTag NETHERITE_TOOLS = new MaterialSetTag(keyFor("netherite_tools")) - .add(Material.NETHERITE_AXE, Material.NETHERITE_HOE, Material.NETHERITE_PICKAXE, Material.NETHERITE_SHOVEL, Material.NETHERITE_SWORD) - .ensureSize("NETHERITE_TOOLS", 5).lock(); + .add(Material.NETHERITE_AXE, Material.NETHERITE_HOE, Material.NETHERITE_PICKAXE, Material.NETHERITE_SHOVEL, Material.NETHERITE_SWORD, Material.NETHERITE_SPEAR) + .lock(); } 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 3bc45d6c7bd5..609b4b1c7d97 100644 --- a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java @@ -5,8 +5,11 @@ import io.papermc.paper.datacomponent.item.ResolvableProfile; import io.papermc.paper.world.damagesource.CombatEntry; import io.papermc.paper.world.damagesource.FallLocationType; +import java.util.function.Function; +import java.util.function.Predicate; import net.kyori.adventure.text.Component; import net.kyori.adventure.util.Services; +import org.bukkit.GameRule; import org.bukkit.block.Biome; import org.bukkit.damage.DamageEffect; import org.bukkit.damage.DamageSource; @@ -16,8 +19,6 @@ import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.function.Predicate; - /** * Static bridge to the server internals. *

@@ -97,5 +98,6 @@ class Holder { SkinParts.Mutable allSkinParts(); Component defaultMannequinDescription(); -} + GameRule legacyGameRuleBridge(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass); +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterAction.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterAction.java new file mode 100644 index 000000000000..459a433dd763 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterAction.java @@ -0,0 +1,56 @@ +package io.papermc.paper.block.bed; + +import net.kyori.adventure.text.Component; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.Nullable; + +/** + * An action type that represents the action that will happen after + * {@link org.bukkit.event.player.PlayerBedEnterEvent} and that is + * happening during {@link io.papermc.paper.event.player.PlayerBedFailEnterEvent} + */ +@ApiStatus.NonExtendable +@ApiStatus.Experimental +public interface BedEnterAction { + + /** + * Gets if the player is allowed to sleep in the bed. + * This can be {@link BedRuleResult#ALLOWED} at the same time as {@link #canSetSpawn()} + *

+ * It is advised to check for {@link BedEnterProblem}s first, as if it returns anything but {@code null} + * the bed interaction is prevented + * + * @return whether the player is allowed to sleep + */ + BedRuleResult canSleep(); + + /** + * Gets if the player is allowed to save its spawn point in the bed. + * This can be {@link BedRuleResult#ALLOWED} at the same time as {@link #canSleep()} + *

+ * It is advised to check for {@link BedEnterProblem}s first, as if it returns anything but {@code null} + * the bed interaction is prevented + * + * @return whether the player is allowed to save its spawn point + */ + BedRuleResult canSetSpawn(); + + /** + * A problem is an issue that prevents the player from sleeping and from saving its spawn point. + * No problem being found doesn't mean the player successfully slept or set its spawn point, + * see {@link #canSleep()} and {@link #canSetSpawn()} for individual successes + * + * @return any of {@link BedEnterProblem}s if one is found, otherwise {@code null} + */ + @Nullable + BedEnterProblem problem(); + + /** + * Returns the default error message to be shown as an actionbar message to the player + * + * @return the error message + */ + @Nullable + Component errorMessage(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java new file mode 100644 index 000000000000..e2e4db862f89 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridge.java @@ -0,0 +1,27 @@ +package io.papermc.paper.block.bed; + +import java.util.Optional; +import java.util.ServiceLoader; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +interface BedEnterActionBridge { + + static BedEnterActionBridge instance() { + final class Holder { + static final Optional INSTANCE = ServiceLoader.load(BedEnterActionBridge.class, BedEnterActionBridge.class.getClassLoader()).findFirst(); + } + return Holder.INSTANCE.orElseThrow(); + } + + BedEnterProblem createTooFarAwayProblem(); + + BedEnterProblem createObstructedProblem(); + + BedEnterProblem createNotSafeProblem(); + + BedEnterProblem createExplosionProblem(); + + BedEnterProblem createOtherProblem(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterProblem.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterProblem.java new file mode 100644 index 000000000000..eb8135c8f84b --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedEnterProblem.java @@ -0,0 +1,63 @@ +package io.papermc.paper.block.bed; + +import net.kyori.adventure.text.Component; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.Nullable; + +/** + * Represents a problem that prevents a player from continuing + * the sleeping process, preventing it from sleeping and from setting + * its spawn point + */ +@ApiStatus.NonExtendable +@ApiStatus.Experimental +public interface BedEnterProblem { + + /** + * Happens when the bed is too far away from the player. + * Makes no explosion and has an error message + * + * @see #errorMessage() + */ + BedEnterProblem TOO_FAR_AWAY = BedEnterActionBridge.instance().createTooFarAwayProblem(); + + /** + * Happens when the bed has blocks one block above it. + * Makes no explosion and has an error message + * + * @see #errorMessage() + */ + BedEnterProblem OBSTRUCTED = BedEnterActionBridge.instance().createObstructedProblem(); + + /** + * Happens when there are monsters in a 16x10x16 box centered on the bed's head + * and the player is not in creative mode. Makes no explosion and has an error message + * + * @see #errorMessage() + */ + BedEnterProblem NOT_SAFE = BedEnterActionBridge.instance().createNotSafeProblem(); + + /** + * Happens when the bed is set to explode. This is defined in the environment attributes of the world. + * This doesn't have a fixed error message, see {@link BedEnterAction#errorMessage()} + */ + BedEnterProblem EXPLOSION = BedEnterActionBridge.instance().createExplosionProblem(); + + /** + * Happens when a player tries to sleep when an invalid state, for example when a player tries + * to sleep but is already sleeping or is dead. + * This doesn't have an error message at all, the interaction is simply discarded + */ + BedEnterProblem OTHER = BedEnterActionBridge.instance().createOtherProblem(); + + /** + * Returns the error message associated with this problem, if any. + * This component is sent to the client as an actionbar message + * when this problem occur + * + * @return the error message + */ + @Nullable + Component errorMessage(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResult.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResult.java new file mode 100644 index 000000000000..ebcb8cdf7bb6 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResult.java @@ -0,0 +1,37 @@ +package io.papermc.paper.block.bed; + +import org.jetbrains.annotations.ApiStatus; + +/** + * Represents the result of a bed rule during {@link org.bukkit.event.player.PlayerBedEnterEvent} + * and {@link io.papermc.paper.event.player.PlayerBedFailEnterEvent}. Bed rules are responsible + * for allowing players to sleep and to set their spawn point + */ +@ApiStatus.Experimental +public sealed interface BedRuleResult permits BedRuleResultImpl { + + /** + * Used when the bed rule is allowed + */ + BedRuleResult ALLOWED = new BedRuleResultImpl(true); + + /** + * Used when the bed rule is denied due to there + * being too much light. This is the case during + * daytime without thunderstorms + */ + BedRuleResult TOO_MUCH_LIGHT = new BedRuleResultImpl(false); + + /** + * Used when the bed rule is set to always be denied + */ + BedRuleResult NEVER = new BedRuleResultImpl(false); + + /** + * Returns {@code true} if this result is a success + * + * @return whether this result is a success + */ + boolean success(); + +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java new file mode 100644 index 000000000000..559049bd2c29 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/BedRuleResultImpl.java @@ -0,0 +1,9 @@ +package io.papermc.paper.block.bed; + +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +record BedRuleResultImpl( + boolean success +) implements BedRuleResult { +} diff --git a/paper-api/src/main/java/io/papermc/paper/block/bed/package-info.java b/paper-api/src/main/java/io/papermc/paper/block/bed/package-info.java new file mode 100644 index 000000000000..d7f5cbbb3e94 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/block/bed/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package io.papermc.paper.block.bed; + +import org.jspecify.annotations.NullMarked; 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 9e7ff539ee35..1fcdc62cff07 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 @@ -1,5 +1,6 @@ package io.papermc.paper.datacomponent; +import io.papermc.paper.datacomponent.item.AttackRange; import io.papermc.paper.datacomponent.item.BannerPatternLayers; import io.papermc.paper.datacomponent.item.BlockItemDataProperties; import io.papermc.paper.datacomponent.item.BlocksAttacks; @@ -21,27 +22,31 @@ import io.papermc.paper.datacomponent.item.ItemEnchantments; import io.papermc.paper.datacomponent.item.ItemLore; import io.papermc.paper.datacomponent.item.JukeboxPlayable; +import io.papermc.paper.datacomponent.item.KineticWeapon; import io.papermc.paper.datacomponent.item.LodestoneTracker; import io.papermc.paper.datacomponent.item.MapDecorations; import io.papermc.paper.datacomponent.item.MapId; import io.papermc.paper.datacomponent.item.MapItemColor; import io.papermc.paper.datacomponent.item.OminousBottleAmplifier; +import io.papermc.paper.datacomponent.item.PiercingWeapon; import io.papermc.paper.datacomponent.item.PotDecorations; import io.papermc.paper.datacomponent.item.PotionContents; 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.SuspiciousStewEffects; +import io.papermc.paper.datacomponent.item.SwingAnimation; import io.papermc.paper.datacomponent.item.Tool; import io.papermc.paper.datacomponent.item.TooltipDisplay; import io.papermc.paper.datacomponent.item.UseCooldown; +import io.papermc.paper.datacomponent.item.UseEffects; import io.papermc.paper.datacomponent.item.UseRemainder; import io.papermc.paper.datacomponent.item.Weapon; import io.papermc.paper.datacomponent.item.WritableBookContent; import io.papermc.paper.datacomponent.item.WrittenBookContent; import io.papermc.paper.item.MapPostProcessing; -import java.util.List; import io.papermc.paper.registry.tag.TagKey; +import java.util.List; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import org.bukkit.Art; @@ -51,6 +56,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.block.banner.PatternType; +import org.bukkit.damage.DamageType; import org.bukkit.entity.Axolotl; import org.bukkit.entity.Cat; import org.bukkit.entity.Chicken; @@ -67,6 +73,7 @@ import org.bukkit.entity.TropicalFish; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.inventory.ItemRarity; import org.bukkit.inventory.meta.trim.TrimMaterial; import org.checkerframework.checker.index.qual.NonNegative; @@ -111,12 +118,16 @@ public final class DataComponentTypes { * If set, the item will not lose any durability when used. */ public static final DataComponentType.NonValued UNBREAKABLE = unvalued("unbreakable"); + + public static final DataComponentType.Valued USE_EFFECTS = valued("use_effects"); /** * Custom name override for an item (as set by renaming with an Anvil). * * @see #ITEM_NAME */ public static final DataComponentType.Valued CUSTOM_NAME = valued("custom_name"); + public static final DataComponentType.Valued MINIMUM_ATTACK_CHARGE = valued("minimum_attack_charge"); + public static final DataComponentType.Valued DAMAGE_TYPE = valued("damage_type"); /** * When present, replaces default item name with contained chat component. *

@@ -210,6 +221,10 @@ public final class DataComponentTypes { public static final DataComponentType.Valued TOOLTIP_STYLE = valued("tooltip_style"); public static final DataComponentType.Valued DEATH_PROTECTION = valued("death_protection"); public static final DataComponentType.Valued BLOCKS_ATTACKS = valued("blocks_attacks"); + public static final DataComponentType.Valued PIERCING_WEAPON = valued("piercing_weapon"); + public static final DataComponentType.Valued KINETIC_WEAPON = valued("kinetic_weapon"); + public static final DataComponentType.Valued ATTACK_RANGE = valued("attack_range"); + public static final DataComponentType.Valued SWING_ANIMATION = valued("swing_animation"); /** * Stores list of enchantments and their levels for an Enchanted Book. * Unlike {@link #ENCHANTMENTS}, the effects provided by enchantments @@ -371,6 +386,7 @@ public final class DataComponentTypes { public static final DataComponentType.Valued PAINTING_VARIANT = valued("painting/variant"); public static final DataComponentType.Valued LLAMA_VARIANT = valued("llama/variant"); public static final DataComponentType.Valued AXOLOTL_VARIANT = valued("axolotl/variant"); + public static final DataComponentType.Valued ZOMBIE_NAUTILUS_VARIANT = valued("zombie_nautilus/variant"); public static final DataComponentType.Valued CAT_VARIANT = valued("cat/variant"); public static final DataComponentType.Valued CAT_COLLAR = valued("cat/collar"); public static final DataComponentType.Valued SHEEP_COLOR = valued("sheep/color"); diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java new file mode 100644 index 000000000000..3eefaf5dd558 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/AttackRange.java @@ -0,0 +1,55 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface AttackRange { + + /** + * Returns a new builder for creating an Attack Range. + * + * @return a builder instance + */ + @Contract(value = "-> new", pure = true) + static Builder attackRange() { + return ItemComponentTypesBridge.bridge().attackRange(); + } + + @Contract(pure = true) + @Range(from = 0, to = 64) float minReach(); + + @Contract(pure = true) + @Range(from = 0, to = 64) float maxReach(); + + @Contract(pure = true) + @Range(from = 0, to = 1) float hitboxMargin(); + + @Contract(pure = true) + @Range(from = 0, to = 2) float mobFactor(); + + /** + * Builder for {@link AttackRange}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder minReach(@Range(from = 0, to = 64) float minReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder maxReach(@Range(from = 0, to = 64) float maxReach); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitboxMargin(@Range(from = 0, to = 1) float hitboxMargin); + + @Contract(value = "_ -> this", mutates = "this") + Builder mobFactor(@Range(from = 0, to = 2) float mobFactor); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java index 5cfb65dfcfde..e36616f7ab30 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java @@ -7,6 +7,7 @@ import java.util.List; import net.kyori.adventure.key.Key; import org.bukkit.damage.DamageType; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jspecify.annotations.NullMarked; @@ -32,7 +33,8 @@ static Builder blocksAttacks() { * * @return the delay in seconds */ - float blockDelaySeconds(); + @Contract(pure = true) + @NonNegative float blockDelaySeconds(); /** * Gets the multiplier applied to the cooldown time for the item when attacked by a disabling attack (the multiplier for {@link Weapon#disableBlockingForSeconds()}). @@ -41,13 +43,15 @@ static Builder blocksAttacks() { * * @return the multiplier for the cooldown time */ - float disableCooldownScale(); + @Contract(pure = true) + @NonNegative float disableCooldownScale(); /** * Gets a list of {@link DamageReduction} of how much damage should be blocked in a given attack. * * @return a list of damage reductions */ + @Contract(pure = true) List damageReductions(); /** @@ -55,6 +59,7 @@ static Builder blocksAttacks() { * * @return the damage function */ + @Contract(pure = true) ItemDamageFunction itemDamage(); /** @@ -62,6 +67,7 @@ static Builder blocksAttacks() { * * @return a damage type tag key, or null if there is no such tag key */ + @Contract(pure = true) @Nullable TagKey bypassedBy(); /** @@ -69,6 +75,7 @@ static Builder blocksAttacks() { * * @return a key of the sound */ + @Contract(pure = true) @Nullable Key blockSound(); /** @@ -76,6 +83,7 @@ static Builder blocksAttacks() { * * @return a key of the sound */ + @Contract(pure = true) @Nullable Key disableSound(); /** @@ -86,10 +94,10 @@ static Builder blocksAttacks() { interface Builder extends DataComponentBuilder { @Contract(value = "_ -> this", mutates = "this") - Builder blockDelaySeconds(float delay); + Builder blockDelaySeconds(@NonNegative float delay); @Contract(value = "_ -> this", mutates = "this") - Builder disableCooldownScale(float scale); + Builder disableCooldownScale(@NonNegative float scale); @Contract(value = "_ -> this", mutates = "this") Builder addDamageReduction(DamageReduction reduction); diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java index 73f4c73dabb5..f1587b243d0a 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java @@ -15,7 +15,7 @@ @ApiStatus.NonExtendable public interface DyedItemColor { - @Contract(value = "_, _ -> new", pure = true) + @Contract(value = "_ -> new", pure = true) static DyedItemColor dyedItemColor(final Color color) { return dyedItemColor().color(color).build(); } 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 8ed4388b19a0..9a35d98bc101 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 @@ -117,4 +117,16 @@ static ItemComponentTypesBridge bridge() { TooltipDisplay.Builder tooltipDisplay(); Weapon.Builder weapon(); + + KineticWeapon.Builder kineticWeapon(); + + UseEffects.Builder useEffects(); + + PiercingWeapon.Builder piercingWeapon(); + + AttackRange.Builder attackRange(); + + SwingAnimation.Builder swingAnimation(); + + KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, float minSpeed, float minRelativeSpeed); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java index a36266df0f52..23115714ba2d 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java @@ -19,7 +19,7 @@ @ApiStatus.NonExtendable public interface ItemEnchantments { - @Contract(value = "_, _ -> new", pure = true) + @Contract(value = "_ -> new", pure = true) static ItemEnchantments itemEnchantments(final Map enchantments) { return itemEnchantments().addAll(enchantments).build(); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java new file mode 100644 index 000000000000..0be65fcca9fc --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/KineticWeapon.java @@ -0,0 +1,106 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import net.kyori.adventure.key.Key; +import org.checkerframework.checker.index.qual.NonNegative; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface KineticWeapon { + + /** + * Returns a new builder for creating a Kinetic Weapon. + * + * @return a builder instance + */ + @Contract(value = "-> new", pure = true) + static Builder kineticWeapon() { + return ItemComponentTypesBridge.bridge().kineticWeapon(); + } + + /** + * Creates a {@link Condition} object. + */ + @Contract(value = "_, _, _ -> new", pure = true) + static Condition condition(final @NonNegative int maxDurationTicks, final float minSpeed, final float minRelativeSpeed) { + return ItemComponentTypesBridge.bridge().kineticWeaponCondition(maxDurationTicks, minSpeed, minRelativeSpeed); + } + + @Contract(pure = true) + @NonNegative int contactCooldownTicks(); + + @Contract(pure = true) + @NonNegative int delayTicks(); + + @Contract(pure = true) + @Nullable Condition dismountConditions(); + + @Contract(pure = true) + @Nullable Condition knockbackConditions(); + + @Contract(pure = true) + @Nullable Condition damageConditions(); + + float forwardMovement(); + + float damageMultiplier(); + + @Contract(pure = true) + @Nullable Key sound(); + + @Contract(pure = true) + @Nullable Key hitSound(); + + interface Condition { + + @Contract(pure = true) + @NonNegative int maxDurationTicks(); + + @Contract(pure = true) + float minSpeed(); + + @Contract(pure = true) + float minRelativeSpeed(); + } + + /** + * Builder for {@link KineticWeapon}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder contactCooldownTicks(@NonNegative int ticks); + + @Contract(value = "_ -> this", mutates = "this") + Builder delayTicks(@NonNegative int ticks); + + @Contract(value = "_ -> this", mutates = "this") + Builder dismountConditions(@Nullable Condition condition); + + @Contract(value = "_ -> this", mutates = "this") + Builder knockbackConditions(@Nullable Condition condition); + + @Contract(value = "_ -> this", mutates = "this") + Builder damageConditions(@Nullable Condition condition); + + @Contract(value = "_ -> this", mutates = "this") + Builder forwardMovement(float forwardMovement); + + @Contract(value = "_ -> this", mutates = "this") + Builder damageMultiplier(float damageMultiplier); + + @Contract(value = "_ -> this", mutates = "this") + Builder sound(Key sound); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitSound(Key sound); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java new file mode 100644 index 000000000000..342151af60bc --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/PiercingWeapon.java @@ -0,0 +1,52 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import net.kyori.adventure.key.Key; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface PiercingWeapon { + + /** + * Returns a new builder for creating a Piercing Weapon. + * + * @return a builder instance + */ + static Builder piercingWeapon() { + return ItemComponentTypesBridge.bridge().piercingWeapon(); + } + + boolean dealsKnockback(); + + boolean dismounts(); + + @Nullable Key sound(); + + @Nullable Key hitSound(); + + /** + * Builder for {@link PiercingWeapon}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder dealsKnockback(boolean dealsKnockback); + + @Contract(value = "_ -> this", mutates = "this") + Builder dismounts(boolean dismounts); + + @Contract(value = "_ -> this", mutates = "this") + Builder sound(@Nullable Key sound); + + @Contract(value = "_ -> this", mutates = "this") + Builder hitSound(@Nullable Key sound); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java new file mode 100644 index 000000000000..83a4a44bc88a --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/SwingAnimation.java @@ -0,0 +1,60 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.checkerframework.checker.index.qual.Positive; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface SwingAnimation { + + @Contract(value = "-> new", pure = true) + static Builder swingAnimation() { + return ItemComponentTypesBridge.bridge().swingAnimation(); + } + + @Contract(pure = true) + Animation type(); + + @Contract(pure = true) + @Positive int duration(); + + enum Animation { + // Start generate - SwingAnimationType + NONE, + WHACK, + STAB; + // End generate - SwingAnimationType + } + + /** + * Builder for {@link SwingAnimation}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + /** + * Sets the swing animation type. + * + * @param type animation type + * @return the builder for chaining + * @see #type() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder type(Animation type); + + /** + * Sets the swing animation duration in ticks. + * + * @param duration duration (>= 0) + * @return the builder for chaining + * @see #duration() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder duration(@Positive int duration); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java index 85aaae68adcf..382a9038d686 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java @@ -2,12 +2,11 @@ import io.papermc.paper.datacomponent.DataComponentBuilder; import io.papermc.paper.datacomponent.DataComponentType; +import java.util.Set; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jspecify.annotations.NullMarked; -import java.util.Set; - @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java new file mode 100644 index 000000000000..31af577bda64 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/UseEffects.java @@ -0,0 +1,68 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface UseEffects { + + /** + * Returns a new builder for creating a UseEffects component. + * + * @return a builder instance. + */ + static Builder useEffects() { + return ItemComponentTypesBridge.bridge().useEffects(); + } + + @Contract(pure = true) + boolean canSprint(); + + @Contract(pure = true) + boolean interactVibrations(); + + @Contract(pure = true) + float speedMultiplier(); + + /** + * Builder for {@link UseEffects}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + /** + * Sets whether the player can sprint while using the item. + * + * @param canSprint true to allow sprinting + * @return the builder for chaining + * @see #canSprint() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder canSprint(boolean canSprint); + + /** + * Sets whether using the item generates interaction vibrations. + * + * @param interactVibrations true to generate vibrations + * @return the builder for chaining + * @see #interactVibrations() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder interactVibrations(boolean interactVibrations); + + /** + * Sets the speed multiplier while using the item. + * + * @param speedMultiplier multiplier (1.0 >= value >= 0.0) + * @return the builder for chaining + * @see #speedMultiplier() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder speedMultiplier(float speedMultiplier); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java index 8851e0e5770d..6de384922758 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java @@ -13,11 +13,12 @@ public enum ItemUseAnimation { DRINK, BLOCK, BOW, - SPEAR, + TRIDENT, CROSSBOW, SPYGLASS, TOOT_HORN, BRUSH, - BUNDLE; + BUNDLE, + SPEAR; // End generate - ItemUseAnimation } diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java index 393d127463a6..f20436a91b75 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java @@ -1,5 +1,6 @@ package io.papermc.paper.event.player; +import io.papermc.paper.block.bed.BedEnterAction; import net.kyori.adventure.text.Component; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -17,24 +18,41 @@ public class PlayerBedFailEnterEvent extends PlayerEvent implements Cancellable private final FailReason failReason; private final Block bed; + private final BedEnterAction enterAction; private boolean willExplode; private @Nullable Component message; private boolean cancelled; @ApiStatus.Internal - public PlayerBedFailEnterEvent(final Player player, final FailReason failReason, final Block bed, final boolean willExplode, final @Nullable Component message) { + public PlayerBedFailEnterEvent(final Player player, final FailReason failReason, final Block bed, final boolean willExplode, final @Nullable Component message, BedEnterAction enterAction) { super(player); this.failReason = failReason; this.bed = bed; + this.enterAction = enterAction; this.willExplode = willExplode; this.message = message; } + /** + * @deprecated This enum has been replaced with a system that better + * represents how beds work. See {@link #enterAction} + */ + @ApiStatus.Obsolete(since = "1.21.11") public FailReason getFailReason() { return this.failReason; } + /** + * This describes the default outcome of this event. + * + * @return the action representing the default outcome of this event + */ + @ApiStatus.Experimental + public BedEnterAction enterAction() { + return this.enterAction; + } + public Block getBed() { return this.bed; } @@ -80,10 +98,16 @@ public static HandlerList getHandlerList() { return HANDLER_LIST; } + /** + * @deprecated Enums no longer represents reliably how beds work and fail. This has been + * replaced with {@link BedEnterAction} that better fits the new beds + */ + @ApiStatus.Obsolete(since = "1.21.11") public enum FailReason { /** * The world doesn't allow sleeping (ex. Nether or The End). Entering - * the bed is prevented and the bed explodes. + * the bed is prevented but the bed doesn't explode. When the bed + * explodes, {@link #EXPLOSION} is used instead. */ NOT_POSSIBLE_HERE, /** @@ -110,6 +134,10 @@ public enum FailReason { /** * Entering the bed is prevented due to there being monsters nearby. */ - NOT_SAFE + NOT_SAFE, + /** + * Entering the bed is prevented and the bed explodes. + */ + EXPLOSION } } diff --git a/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java b/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java index 4d259e31c4b1..c44006faf327 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java @@ -19,7 +19,7 @@ public class WorldGameRuleChangeEvent extends WorldEvent implements Cancellable private static final HandlerList HANDLER_LIST = new HandlerList(); private final @Nullable CommandSender commandSender; - private final GameRule gameRule; + protected final GameRule gameRule; private String value; private boolean cancelled; diff --git a/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java b/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java index 3c168b3522c5..906f3912f9ba 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java @@ -1,10 +1,15 @@ package io.papermc.paper.event.world.border; +import com.google.common.base.Preconditions; +import io.papermc.paper.util.Tick; +import java.time.Duration; import org.bukkit.World; import org.bukkit.WorldBorder; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Range; import org.jspecify.annotations.NullMarked; /** @@ -63,16 +68,41 @@ public double getNewSize() { * @param newSize the new size */ public void setNewSize(final double newSize) { - this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize)); + this.newSize = Math.clamp(newSize, 1.0D, this.worldBorder.getMaxSize()); + } + + /** + * Gets the time in ticks for the change. Will be 0 if instant. + * + * @return the time in ticks for the change + */ + public @Range(from = 0, to = Integer.MAX_VALUE) long getDurationTicks() { + return this.duration; + } + + /** + * Sets the time in ticks for the change. Will change {@link #getType()} to return + * {@link Type#STARTED_MOVE}. + * + * @param duration the time in ticks for the change + */ + public void setDurationTicks(final @Range(from = 0, to = Integer.MAX_VALUE) long duration) { + Preconditions.checkArgument(duration >= 0 && duration <= Integer.MAX_VALUE, "duration must be between 0-%s", Integer.MAX_VALUE); + this.duration = duration; + if (this.type == Type.INSTANT_MOVE) { + this.type = Type.STARTED_MOVE; + } } /** * Gets the time in milliseconds for the change. Will be 0 if instant. * * @return the time in milliseconds for the change + * @deprecated in favor of {@link #getDurationTicks()} */ - public long getDuration() { - return this.duration; + @Deprecated(forRemoval = true, since = "1.21.11") + public @NonNegative long getDuration() { + return Tick.of(this.getDurationTicks()).toMillis(); } /** @@ -80,13 +110,11 @@ public long getDuration() { * {@link Type#STARTED_MOVE}. * * @param duration the time in milliseconds for the change + * @deprecated in favor of {@link #setDurationTicks(long)} */ - public void setDuration(final long duration) { - // PAIL: TODO: Magic Values - this.duration = Math.min(9223372036854775L, Math.max(0L, duration)); - if (duration >= 0 && this.type == Type.INSTANT_MOVE) { - this.type = Type.STARTED_MOVE; - } + @Deprecated(forRemoval = true, since = "1.21.11") + public void setDuration(final @NonNegative long duration) { + this.setDurationTicks(Tick.tick().fromDuration(Duration.ofMillis(duration))); } @Override 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 fe22a5fadc17..dcee3d88f5b7 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 @@ -9,6 +9,7 @@ import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.MusicInstrument; import org.bukkit.Particle; @@ -27,6 +28,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.entity.memory.MemoryKey; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; @@ -125,8 +127,11 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { * @see io.papermc.paper.registry.keys.DataComponentTypeKeys */ RegistryKey DATA_COMPONENT_TYPE = create("data_component_type"); - - + /** + * Built-in registry for game rules. + * @see io.papermc.paper.registry.keys.GameRuleKeys + */ + RegistryKey> GAME_RULE = create("game_rule"); /* ********************** * * Data-driven Registries * @@ -216,6 +221,11 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { * @see io.papermc.paper.registry.keys.PigVariantKeys */ RegistryKey PIG_VARIANT = create("pig_variant"); + /** + * Data-driven registry for zombie nautilus variants. + * @see io.papermc.paper.registry.keys.ZombieNautilusVariantKeys + */ + RegistryKey ZOMBIE_NAUTILUS_VARIANT = create("zombie_nautilus_variant"); /** * 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/EnchantmentRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/EnchantmentRegistryEntry.java index e5f851d427b0..d2e8eef232c2 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 @@ -157,7 +157,7 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder * a tag obtained via {@link RegistryComposeEvent#getOrCreateTag(TagKey)} with * tag keys found in {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys} such as * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_ARMOR} and - * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_SWORD}. + * {@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. @@ -174,7 +174,7 @@ interface Builder extends EnchantmentRegistryEntry, RegistryBuilder * {@link RegistryComposeEvent#getOrCreateTag(TagKey)} with * tag keys found in {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys} such as * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_ARMOR} and - * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_SWORD}. + * {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#ENCHANTABLE_MELEE_WEAPON}. *

* Defaults to {@code null} which means all {@link #supportedItems()} are considered primary items. * Additionally, the tag {@link io.papermc.paper.registry.keys.tags.EnchantmentTagKeys#IN_ENCHANTING_TABLE} defines diff --git a/paper-api/src/main/java/io/papermc/paper/registry/data/ZombieNautilusVariantRegistryEntry.java b/paper-api/src/main/java/io/papermc/paper/registry/data/ZombieNautilusVariantRegistryEntry.java new file mode 100644 index 000000000000..9aecc310792f --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/registry/data/ZombieNautilusVariantRegistryEntry.java @@ -0,0 +1,78 @@ +package io.papermc.paper.registry.data; + +import io.papermc.paper.registry.RegistryBuilder; +import io.papermc.paper.registry.data.client.ClientTextureAsset; +import org.bukkit.entity.ZombieNautilus; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +/** + * A data-centric version-specific registry entry for the {@link org.bukkit.entity.ZombieNautilus.Variant} type. + */ +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface ZombieNautilusVariantRegistryEntry { + + /** + * The model of the variant to render the configured texture on. + */ + enum Model { + /** + * The normal model. + */ + NORMAL, + + /** + * The warm model. + */ + WARM, + } + + /** + * Provides the client texture asset of the variant, which represents the texture to use. + * + * @return the client texture asset. + */ + ClientTextureAsset clientTextureAsset(); + + /** + * Provides the model of the variant. + * + * @return the model. + */ + Model model(); + + /** + * A mutable builder for the {@link ZombieNautilusVariantRegistryEntry} plugins may change in applicable registry events. + *

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

    + *
  • {@link #clientTextureAsset(ClientTextureAsset)}
  • + *
  • {@link #model(Model)}
  • + *
+ */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends ZombieNautilusVariantRegistryEntry, RegistryBuilder { + + /** + * Sets the client texture asset of the variant, which is the location of the texture to use. + * + * @param clientTextureAsset the client texture asset. + * @return this builder instance. + * @see ZombieNautilusVariantRegistryEntry#clientTextureAsset() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder clientTextureAsset(ClientTextureAsset clientTextureAsset); + + /** + * Sets the model to use for this variant. + * + * @param model the model. + * @return this builder instance. + * @see ZombieNautilusVariantRegistryEntry#model() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder model(Model model); + } +} 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 8890b8183b3d..6ae47dac3496 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 @@ -15,6 +15,7 @@ import io.papermc.paper.registry.data.PaintingVariantRegistryEntry; import io.papermc.paper.registry.data.PigVariantRegistryEntry; import io.papermc.paper.registry.data.WolfVariantRegistryEntry; +import io.papermc.paper.registry.data.ZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.DialogRegistryEntry; import org.bukkit.Art; import org.bukkit.GameEvent; @@ -29,6 +30,7 @@ import org.bukkit.entity.Frog; import org.bukkit.entity.Pig; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import static io.papermc.paper.registry.event.RegistryEventProviderImpl.create; @@ -52,6 +54,7 @@ public final class RegistryEvents { public static final RegistryEventProvider CHICKEN_VARIANT = create(RegistryKey.CHICKEN_VARIANT); 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 DIALOG = create(RegistryKey.DIALOG); // End generate - RegistryEvents diff --git a/paper-api/src/main/java/org/bukkit/Effect.java b/paper-api/src/main/java/org/bukkit/Effect.java index b044a45661cc..d2952c7750af 100644 --- a/paper-api/src/main/java/org/bukkit/Effect.java +++ b/paper-api/src/main/java/org/bukkit/Effect.java @@ -1,5 +1,6 @@ package org.bukkit; +import com.google.common.base.Enums; import com.google.common.collect.Maps; import java.util.Map; import org.bukkit.block.BlockFace; @@ -442,7 +443,6 @@ public enum Effect { SOUND_WITH_CHARGE_SHOT(1051, Type.SOUND), ; - private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper end private final int id; @@ -512,22 +512,13 @@ public static Effect getById(int id) { static { for (Effect effect : values()) { - if (!isDeprecated(effect)) // Paper + if (Enums.getField(effect).isAnnotationPresent(Deprecated.class)) { + continue; + } BY_ID.put(effect.id, effect); } } - // Paper start - private static boolean isDeprecated(Effect effect) { - try { - return Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class); - } catch (NoSuchFieldException e) { - LOGGER.error("Error getting effect enum field {}", effect.name(), e); - return false; - } - } - // Paper end - /** * Represents the type of an effect. * @deprecated not representative of what Effect does diff --git a/paper-api/src/main/java/org/bukkit/EntityEffect.java b/paper-api/src/main/java/org/bukkit/EntityEffect.java index 3a53a48472ae..84d2a21a68c7 100644 --- a/paper-api/src/main/java/org/bukkit/EntityEffect.java +++ b/paper-api/src/main/java/org/bukkit/EntityEffect.java @@ -60,6 +60,10 @@ public enum EntityEffect { * delay, only the speed at which the entity in the spawner spins. */ RESET_SPAWNER_MINECART_DELAY(1, SpawnerMinecart.class), + /** + * When a kinetic weapon hits an entity. + */ + HIT(2, LivingEntity.class), /** * When mobs get hurt. * diff --git a/paper-api/src/main/java/org/bukkit/ExplosionResult.java b/paper-api/src/main/java/org/bukkit/ExplosionResult.java index c875a10480e5..670b3ed55f59 100644 --- a/paper-api/src/main/java/org/bukkit/ExplosionResult.java +++ b/paper-api/src/main/java/org/bukkit/ExplosionResult.java @@ -11,7 +11,7 @@ public enum ExplosionResult { /** * Represents an explosion where no change took place. * - * This is the case when {@link org.bukkit.GameRule#MOB_GRIEFING} is + * This is the case when {@link org.bukkit.GameRules#MOB_GRIEFING} is * disabled. */ KEEP, @@ -19,8 +19,8 @@ public enum ExplosionResult { * Represents an explosion where all destroyed blocks drop their items. * * This is the case when - * {@link org.bukkit.GameRule#TNT_EXPLOSION_DROP_DECAY} or - * {@link org.bukkit.GameRule#BLOCK_EXPLOSION_DROP_DECAY} is disabled. + * {@link org.bukkit.GameRules#TNT_EXPLOSION_DROP_DECAY} or + * {@link org.bukkit.GameRules#BLOCK_EXPLOSION_DROP_DECAY} is disabled. */ DESTROY, /** diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index e48e17c45a59..032c64831f79 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -1,9 +1,10 @@ package org.bukkit; import com.google.common.base.Preconditions; +import io.papermc.paper.InternalAPIBridge; import io.papermc.paper.world.flag.FeatureDependant; -import java.util.HashMap; -import java.util.Map; +import java.util.function.UnaryOperator; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -15,343 +16,469 @@ * Wiki * * @param type of rule (Boolean or Integer) + * @see GameRules */ -public final class GameRule implements net.kyori.adventure.translation.Translatable, FeatureDependant { +@ApiStatus.NonExtendable +public abstract class GameRule implements net.kyori.adventure.translation.Translatable, FeatureDependant, Keyed { - private static Map> gameRules = new HashMap<>(); // Boolean rules /** * Toggles the announcing of advancements. + * + * @deprecated renamed to {@link GameRules#SHOW_ADVANCEMENT_MESSAGES} */ - public static final GameRule ANNOUNCE_ADVANCEMENTS = new GameRule<>("announceAdvancements", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ANNOUNCE_ADVANCEMENTS = GameRules.SHOW_ADVANCEMENT_MESSAGES; /** * Whether command blocks should notify admins when they perform commands. + * + * @deprecated renamed to {@link GameRules#COMMAND_BLOCK_OUTPUT} */ - public static final GameRule COMMAND_BLOCK_OUTPUT = new GameRule<>("commandBlockOutput", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule COMMAND_BLOCK_OUTPUT = GameRules.COMMAND_BLOCK_OUTPUT; /** * Whether the server should skip checking player speed. + * + * @deprecated renamed to {@link GameRules#PLAYER_MOVEMENT_CHECK} (inverted) */ - public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = new GameRule<>("disablePlayerMovementCheck", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DISABLE_PLAYER_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.PLAYER_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether the server should skip checking player speed when the player is * wearing elytra. + * + * @deprecated renamed to {@link GameRules#ELYTRA_MOVEMENT_CHECK} (inverted) */ - public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = new GameRule<>("disableElytraMovementCheck", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DISABLE_ELYTRA_MOVEMENT_CHECK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.ELYTRA_MOVEMENT_CHECK, inverseBool(), inverseBool(), Boolean.class); /** * Whether time progresses from the current moment. + * + * @deprecated renamed to {@link GameRules#ADVANCE_TIME} */ - public static final GameRule DO_DAYLIGHT_CYCLE = new GameRule<>("doDaylightCycle", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_DAYLIGHT_CYCLE = GameRules.ADVANCE_TIME; /** * Whether entities that are not mobs should have drops. + * + * @deprecated renamed to {@link GameRules#ENTITY_DROPS} */ - public static final GameRule DO_ENTITY_DROPS = new GameRule<>("doEntityDrops", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_ENTITY_DROPS = GameRules.ENTITY_DROPS; /** * Whether fire should spread and naturally extinguish. + * + * @deprecated use {@link GameRules#FIRE_SPREAD_RADIUS_AROUND_PLAYER} */ - public static final GameRule DO_FIRE_TICK = new GameRule<>("doFireTick", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_FIRE_TICK = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? 128 : 0, (value) -> value != 0, Boolean.class); /** * Whether players should only be able to craft recipes they've unlocked * first. + * + * @deprecated renamed to {@link GameRules#LIMITED_CRAFTING} */ - public static final GameRule DO_LIMITED_CRAFTING = new GameRule<>("doLimitedCrafting", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_LIMITED_CRAFTING = GameRules.LIMITED_CRAFTING; /** - * Whether mobs should drop items. + * Whether projectiles can break blocks. + * + * @deprecated renamed to {@link GameRules#PROJECTILES_CAN_BREAK_BLOCKS} */ - public static final GameRule DO_MOB_LOOT = new GameRule<>("doMobLoot", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = GameRules.PROJECTILES_CAN_BREAK_BLOCKS; /** - * Whether projectiles can break blocks. + * Whether mobs should drop items. + * + * @deprecated renamed to {@link GameRules#MOB_DROPS} */ - public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = new GameRule<>("projectilesCanBreakBlocks", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_MOB_LOOT = GameRules.MOB_DROPS; /** * Whether mobs should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_MOBS} */ - public static final GameRule DO_MOB_SPAWNING = new GameRule<>("doMobSpawning", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_MOB_SPAWNING = GameRules.SPAWN_MOBS; /** * Whether blocks should have drops. + * + * @deprecated renamed to {@link GameRules#BLOCK_DROPS} */ - public static final GameRule DO_TILE_DROPS = new GameRule<>("doTileDrops", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_TILE_DROPS = GameRules.BLOCK_DROPS; /** * Whether the weather will change from the current moment. + * + * @deprecated renamed to {@link GameRules#ADVANCE_WEATHER} */ - public static final GameRule DO_WEATHER_CYCLE = new GameRule<>("doWeatherCycle", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_WEATHER_CYCLE = GameRules.ADVANCE_WEATHER; /** * Whether the player should keep items in their inventory after death. + * + * @deprecated renamed to {@link GameRules#KEEP_INVENTORY} */ - public static final GameRule KEEP_INVENTORY = new GameRule<>("keepInventory", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule KEEP_INVENTORY = GameRules.KEEP_INVENTORY; /** * Whether to log admin commands to server log. + * + * @deprecated renamed to {@link GameRules#LOG_ADMIN_COMMANDS} */ - public static final GameRule LOG_ADMIN_COMMANDS = new GameRule<>("logAdminCommands", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule LOG_ADMIN_COMMANDS = GameRules.LOG_ADMIN_COMMANDS; /** * Whether mobs can pick up items or change blocks. + * + * @deprecated renamed to {@link GameRules#MOB_GRIEFING} */ - public static final GameRule MOB_GRIEFING = new GameRule<>("mobGriefing", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MOB_GRIEFING = GameRules.MOB_GRIEFING; /** * Whether players can regenerate health naturally through their hunger bar. + * + * @deprecated renamed to {@link GameRules#NATURAL_HEALTH_REGENERATION} */ - public static final GameRule NATURAL_REGENERATION = new GameRule<>("naturalRegeneration", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule NATURAL_REGENERATION = GameRules.NATURAL_HEALTH_REGENERATION; /** * Whether the debug screen shows all or reduced information. + * + * @deprecated renamed to {@link GameRules#REDUCED_DEBUG_INFO} */ - public static final GameRule REDUCED_DEBUG_INFO = new GameRule<>("reducedDebugInfo", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule REDUCED_DEBUG_INFO = GameRules.REDUCED_DEBUG_INFO; /** * Whether the feedback from commands executed by a player should show up in * chat. Also affects the default behavior of whether command blocks store * their output text. + * + * @deprecated renamed to {@link GameRules#SEND_COMMAND_FEEDBACK} */ - public static final GameRule SEND_COMMAND_FEEDBACK = new GameRule<>("sendCommandFeedback", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SEND_COMMAND_FEEDBACK = GameRules.SEND_COMMAND_FEEDBACK; /** * Whether a message appears in chat when a player dies. + * + * @deprecated renamed to {@link GameRules#SHOW_DEATH_MESSAGES} */ - public static final GameRule SHOW_DEATH_MESSAGES = new GameRule<>("showDeathMessages", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SHOW_DEATH_MESSAGES = GameRules.SHOW_DEATH_MESSAGES; /** * Whether players in spectator mode can generate chunks. + * + * @deprecated renamed to {@link GameRules#SPECTATORS_GENERATE_CHUNKS} */ - public static final GameRule SPECTATORS_GENERATE_CHUNKS = new GameRule<>("spectatorsGenerateChunks", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPECTATORS_GENERATE_CHUNKS = GameRules.SPECTATORS_GENERATE_CHUNKS; /** * Whether pillager raids are enabled or not. + * + * @deprecated renamed to {@link GameRules#RAIDS} (inverted) */ - public static final GameRule DISABLE_RAIDS = new GameRule<>("disableRaids", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DISABLE_RAIDS = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.RAIDS, inverseBool(), inverseBool(), Boolean.class); /** * Whether phantoms will appear without sleeping or not. + * + * @deprecated renamed to {@link GameRules#SPAWN_PHANTOMS} */ - public static final GameRule DO_INSOMNIA = new GameRule<>("doInsomnia", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_INSOMNIA = GameRules.SPAWN_PHANTOMS; /** * Whether clients will respawn immediately after death or not. + * + * @deprecated renamed to {@link GameRules#IMMEDIATE_RESPAWN} */ - public static final GameRule DO_IMMEDIATE_RESPAWN = new GameRule<>("doImmediateRespawn", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_IMMEDIATE_RESPAWN = GameRules.IMMEDIATE_RESPAWN; /** * Whether drowning damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#DROWNING_DAMAGE} */ - public static final GameRule DROWNING_DAMAGE = new GameRule<>("drowningDamage", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DROWNING_DAMAGE = GameRules.DROWNING_DAMAGE; /** * Whether fall damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#FALL_DAMAGE} */ - public static final GameRule FALL_DAMAGE = new GameRule<>("fallDamage", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FALL_DAMAGE = GameRules.FALL_DAMAGE; /** * Whether fire damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#FIRE_DAMAGE} */ - public static final GameRule FIRE_DAMAGE = new GameRule<>("fireDamage", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FIRE_DAMAGE = GameRules.FIRE_DAMAGE; /** * Whether freeze damage is enabled or not. + * + * @deprecated renamed to {@link GameRules#FREEZE_DAMAGE} */ - public static final GameRule FREEZE_DAMAGE = new GameRule<>("freezeDamage", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FREEZE_DAMAGE = GameRules.FREEZE_DAMAGE; /** * Whether patrols should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_PATROLS} */ - public static final GameRule DO_PATROL_SPAWNING = new GameRule<>("doPatrolSpawning", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_PATROL_SPAWNING = GameRules.SPAWN_PATROLS; /** * Whether traders should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_WANDERING_TRADERS} */ - public static final GameRule DO_TRADER_SPAWNING = new GameRule<>("doTraderSpawning", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_TRADER_SPAWNING = GameRules.SPAWN_WANDERING_TRADERS; /** * Whether wardens should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_WARDENS} */ - public static final GameRule DO_WARDEN_SPAWNING = new GameRule<>("doWardenSpawning", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_WARDEN_SPAWNING = GameRules.SPAWN_WARDENS; /** * Whether mobs should cease being angry at a player once they die. + * + * @deprecated renamed to {@link GameRules#FORGIVE_DEAD_PLAYERS} */ - public static final GameRule FORGIVE_DEAD_PLAYERS = new GameRule<>("forgiveDeadPlayers", Boolean.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule FORGIVE_DEAD_PLAYERS = GameRules.FORGIVE_DEAD_PLAYERS; /** * Whether mobs will target all player entities once angered. + * + * @deprecated renamed to {@link GameRules#UNIVERSAL_ANGER} */ - public static final GameRule UNIVERSAL_ANGER = new GameRule<>("universalAnger", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule UNIVERSAL_ANGER = GameRules.UNIVERSAL_ANGER; /** * Whether block explosions will destroy dropped items. + * + * @deprecated renamed to {@link GameRules#BLOCK_EXPLOSION_DROP_DECAY} */ - public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = new GameRule<>("blockExplosionDropDecay", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = GameRules.BLOCK_EXPLOSION_DROP_DECAY; /** * * Whether mob explosions will destroy dropped items. + * + * @deprecated renamed to {@link GameRules#MOB_EXPLOSION_DROP_DECAY} */ - public static final GameRule MOB_EXPLOSION_DROP_DECAY = new GameRule<>("mobExplosionDropDecay", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MOB_EXPLOSION_DROP_DECAY = GameRules.MOB_EXPLOSION_DROP_DECAY; /** * Whether tnt explosions will destroy dropped items. + * + * @deprecated renamed to {@link GameRules#TNT_EXPLOSION_DROP_DECAY} */ - public static final GameRule TNT_EXPLOSION_DROP_DECAY = new GameRule<>("tntExplosionDropDecay", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule TNT_EXPLOSION_DROP_DECAY = GameRules.TNT_EXPLOSION_DROP_DECAY; /** * Whether water blocks can convert into water source blocks. + * + * @deprecated renamed to {@link GameRules#WATER_SOURCE_CONVERSION} */ - public static final GameRule WATER_SOURCE_CONVERSION = new GameRule<>("waterSourceConversion", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule WATER_SOURCE_CONVERSION = GameRules.WATER_SOURCE_CONVERSION; /** * Whether lava blocks can convert into lava source blocks. + * + * @deprecated renamed to {@link GameRules#LAVA_SOURCE_CONVERSION} */ - public static final GameRule LAVA_SOURCE_CONVERSION = new GameRule<>("lavaSourceConversion", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule LAVA_SOURCE_CONVERSION = GameRules.LAVA_SOURCE_CONVERSION; /** * Whether global level events such as ender dragon, wither, and completed * end portal effects will propagate across the entire server. + * + * @deprecated renamed to {@link GameRules#GLOBAL_SOUND_EVENTS} */ - public static final GameRule GLOBAL_SOUND_EVENTS = new GameRule<>("globalSoundEvents", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule GLOBAL_SOUND_EVENTS = GameRules.GLOBAL_SOUND_EVENTS; /** * Whether vines will spread. + * + * @deprecated renamed to {@link GameRules#SPREAD_VINES} */ - public static final GameRule DO_VINES_SPREAD = new GameRule<>("doVinesSpread", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule DO_VINES_SPREAD = GameRules.SPREAD_VINES; /** * Whether ender pearls will vanish on player death. + * + * @deprecated renamed to {@link GameRules#ENDER_PEARLS_VANISH_ON_DEATH} */ - public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = new GameRule<>("enderPearlsVanishOnDeath", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = GameRules.ENDER_PEARLS_VANISH_ON_DEATH; /** * Whether fire will still propagate far away from players (8 chunks). + * + * @deprecated use {@link GameRules#FIRE_SPREAD_RADIUS_AROUND_PLAYER} */ - public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = new GameRule<>("allowFireTicksAwayFromPlayer", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = InternalAPIBridge.get().legacyGameRuleBridge(GameRules.FIRE_SPREAD_RADIUS_AROUND_PLAYER, (value) -> value ? -1 : 128, (value) -> value == -1, Boolean.class); /** * Whether primed tnt explodes. + * + * @deprecated renamed to {@link GameRules#TNT_EXPLODES} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule TNT_EXPLODES = GameRules.TNT_EXPLODES; + /** + * Configures if the world uses the locator bar. + * + * @deprecated renamed to {@link GameRules#LOCATOR_BAR} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule LOCATOR_BAR = GameRules.LOCATOR_BAR; + /** + * Whether player versus player combat is allowed. + * + * @deprecated renamed to {@link GameRules#PVP} */ - public static final GameRule TNT_EXPLODES = new GameRule<>("tntExplodes", Boolean.class); + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule PVP = GameRules.PVP; + /** + * Whether monsters should naturally spawn. + * + * @deprecated renamed to {@link GameRules#SPAWN_MONSTERS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPAWN_MONSTERS = GameRules.SPAWN_MONSTERS; + /** + * Whether players can enter the Nether using portals. + * + * @deprecated renamed to {@link GameRules#ALLOW_ENTERING_NETHER_USING_PORTALS} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = GameRules.ALLOW_ENTERING_NETHER_USING_PORTALS; + /** + * Whether command blocks are enabled. + * + * @deprecated renamed to {@link GameRules#COMMAND_BLOCKS_WORK} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule COMMAND_BLOCKS_ENABLED = GameRules.COMMAND_BLOCKS_WORK; + /** + * Whether spawner blocks are enabled. + * + * @deprecated renamed to {@link GameRules#SPAWNER_BLOCKS_WORK} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPAWNER_BLOCKS_ENABLED = GameRules.SPAWNER_BLOCKS_WORK; // Numerical rules /** * How often a random block tick occurs (such as plant growth, leaf decay, * etc.) per chunk section per game tick. 0 will disable random ticks, * higher numbers will increase random ticks. + * + * @deprecated renamed to {@link GameRules#RANDOM_TICK_SPEED} */ - public static final GameRule RANDOM_TICK_SPEED = new GameRule<>("randomTickSpeed", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule RANDOM_TICK_SPEED = GameRules.RANDOM_TICK_SPEED; /** * The number of blocks outward from the world spawn coordinates that a * player will spawn in when first joining a server or when dying without a * spawnpoint. + * + * @deprecated renamed to {@link GameRules#RESPAWN_RADIUS} */ - public static final GameRule SPAWN_RADIUS = new GameRule<>("spawnRadius", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SPAWN_RADIUS = GameRules.RESPAWN_RADIUS; /** * The maximum number of other pushable entities a mob or player can push, * before taking suffocation damage. *
* Setting to 0 disables this rule. + * + * @deprecated renamed to {@link GameRules#MAX_ENTITY_CRAMMING} */ - public static final GameRule MAX_ENTITY_CRAMMING = new GameRule<>("maxEntityCramming", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MAX_ENTITY_CRAMMING = GameRules.MAX_ENTITY_CRAMMING; /** * Determines the number at which the chain of command blocks act as a * "chain." *
* This is the maximum amount of command blocks that can be activated in a * single tick from a single chain. + * + * @deprecated renamed to {@link GameRules#MAX_COMMAND_SEQUENCE_LENGTH} */ - public static final GameRule MAX_COMMAND_CHAIN_LENGTH = new GameRule<>("maxCommandChainLength", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MAX_COMMAND_CHAIN_LENGTH = GameRules.MAX_COMMAND_SEQUENCE_LENGTH; /** * Determines the number of different commands/functions which execute * commands can fork into. + * + * @deprecated renamed to {@link GameRules#MAX_COMMAND_FORKS} */ - public static final GameRule MAX_COMMAND_FORK_COUNT = new GameRule<>("maxCommandForkCount", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MAX_COMMAND_FORK_COUNT = GameRules.MAX_COMMAND_FORKS; /** * Determines the maximum number of blocks which a command can modify. + * + * @deprecated renamed to {@link GameRules#MAX_BLOCK_MODIFICATIONS} */ - public static final GameRule COMMAND_MODIFICATION_BLOCK_LIMIT = new GameRule<>("commandModificationBlockLimit", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule COMMAND_MODIFICATION_BLOCK_LIMIT = GameRules.MAX_BLOCK_MODIFICATIONS; /** * The percentage of online players which must be sleeping for the night to * advance. + * + * @deprecated renamed to {@link GameRules#PLAYERS_SLEEPING_PERCENTAGE} */ - public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = new GameRule<>("playersSleepingPercentage", Integer.class); - public static final GameRule SNOW_ACCUMULATION_HEIGHT = new GameRule<>("snowAccumulationHeight", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = GameRules.PLAYERS_SLEEPING_PERCENTAGE; + /** + * @deprecated renamed to {@link GameRules#MAX_SNOW_ACCUMULATION_HEIGHT} + */ + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule SNOW_ACCUMULATION_HEIGHT = GameRules.MAX_SNOW_ACCUMULATION_HEIGHT; /** * The amount of time a player must stand in a nether portal before the * portal activates. + * + * @deprecated renamed to {@link GameRules#PLAYERS_NETHER_PORTAL_DEFAULT_DELAY} */ - public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = new GameRule<>("playersNetherPortalDefaultDelay", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = GameRules.PLAYERS_NETHER_PORTAL_DEFAULT_DELAY; /** * The amount of time a player in creative mode must stand in a nether * portal before the portal activates. + * + * @deprecated renamed to {@link GameRules#PLAYERS_NETHER_PORTAL_CREATIVE_DELAY} */ - public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = new GameRule<>("playersNetherPortalCreativeDelay", Integer.class); - + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = GameRules.PLAYERS_NETHER_PORTAL_CREATIVE_DELAY; /** * The maximum speed of minecarts (when the new movement algorithm is * enabled). + * + * @deprecated renamed to {@link GameRules#MAX_MINECART_SPEED} */ - @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation - public static final GameRule MINECART_MAX_SPEED = new GameRule<>("minecartMaxSpeed", Integer.class); - - /** - * Configures if the world uses the locator bar. - */ - public static final GameRule LOCATOR_BAR = new GameRule<>("locatorBar", Boolean.class); - - /** - * Whether player versus player combat is allowed. - */ - public static final GameRule PVP = new GameRule<>("pvp", Boolean.class); - - /** - * Whether monsters should naturally spawn. - */ - public static final GameRule SPAWN_MONSTERS = new GameRule<>("spawnMonsters", Boolean.class); - - /** - * Whether players can enter the Nether using portals. - */ - public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = new GameRule<>("allowEnteringNetherUsingPortals", Boolean.class); - - /** - * Whether command blocks are enabled. - */ - public static final GameRule COMMAND_BLOCKS_ENABLED = new GameRule<>("commandBlocksEnabled", Boolean.class); - - /** - * Whether spawner blocks are enabled. - */ - public static final GameRule SPAWNER_BLOCKS_ENABLED = new GameRule<>("spawnerBlocksEnabled", Boolean.class); - - // All GameRules instantiated above this for organizational purposes - private final String name; - private final Class type; + @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) + @ApiStatus.Experimental + @Deprecated(forRemoval = true, since = "1.21.11") + public static final GameRule MINECART_MAX_SPEED = GameRules.MAX_MINECART_SPEED; - private GameRule(@NotNull String name, @NotNull Class clazz) { - Preconditions.checkNotNull(name, "GameRule name cannot be null"); - Preconditions.checkNotNull(clazz, "GameRule type cannot be null"); - Preconditions.checkArgument(clazz == Boolean.class || clazz == Integer.class, "Must be of type Boolean or Integer. Found %s ", clazz.getName()); - this.name = name; - this.type = clazz; - gameRules.put(name, this); + private static UnaryOperator inverseBool() { + return operand -> !operand; } /** * Get the name of this GameRule. * * @return the name of this GameRule + * @deprecated Game rule is now a registry, use {@link #getKey()} instead */ @NotNull - public String getName() { - return name; - } + @Deprecated(since = "1.21.11", forRemoval = true) + public abstract String getName(); /** * Get the type of this rule. @@ -359,26 +486,7 @@ public String getName() { * @return the rule type; Integer or Boolean */ @NotNull - public Class getType() { - return type; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof GameRule)) { - return false; - } - GameRule other = (GameRule) obj; - return this.getName().equals(other.getName()) && this.getType() == other.getType(); - } - - @Override - public String toString() { - return "GameRule{" + "key=" + name + ", type=" + type + '}'; - } + public abstract Class getType(); /** * Get a {@link GameRule} by its name. @@ -386,26 +494,33 @@ public String toString() { * @param rule the name of the GameRule * @return the {@link GameRule} or null if no GameRule matches the given * name + * @deprecated Game rule is now a registry, fetch element from it */ @Nullable - public static GameRule getByName(@NotNull String rule) { - Preconditions.checkNotNull(rule, "Rule cannot be null"); - return gameRules.get(rule); + @Deprecated(since = "1.21.11", forRemoval = true) + public static GameRule getByName(@NotNull String rule) { + Preconditions.checkArgument(rule != null, "Rule cannot be null"); + NamespacedKey key = NamespacedKey.fromString(rule); + if (key == null) { + return null; + } + + return (GameRule) Registry.GAME_RULE.get(key); } /** * Get an immutable collection of {@link GameRule}s. * * @return an immutable collection containing all registered GameRules. + * @deprecated Game rule is now a registry, fetch elements from it */ @NotNull + @Deprecated(since = "1.21.11", forRemoval = true) public static GameRule[] values() { - return gameRules.values().toArray(new GameRule[gameRules.size()]); + return Registry.GAME_RULE.stream().toArray(GameRule[]::new); } @Override - public @NotNull String translationKey() { - return "gamerule." + this.name; - } + public abstract @NotNull String translationKey(); } diff --git a/paper-api/src/main/java/org/bukkit/GameRules.java b/paper-api/src/main/java/org/bukkit/GameRules.java new file mode 100644 index 000000000000..c1ad190d537b --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/GameRules.java @@ -0,0 +1,141 @@ +package org.bukkit; + +import net.kyori.adventure.key.KeyPattern; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +/** + * All the vanilla gamerules + */ +@NullMarked +public final class GameRules { + + // Start generate - GameRules + public static final GameRule ADVANCE_TIME = getRule("advance_time"); + + public static final GameRule ADVANCE_WEATHER = getRule("advance_weather"); + + public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = getRule("allow_entering_nether_using_portals"); + + public static final GameRule BLOCK_DROPS = getRule("block_drops"); + + public static final GameRule BLOCK_EXPLOSION_DROP_DECAY = getRule("block_explosion_drop_decay"); + + public static final GameRule COMMAND_BLOCK_OUTPUT = getRule("command_block_output"); + + public static final GameRule COMMAND_BLOCKS_WORK = getRule("command_blocks_work"); + + public static final GameRule DROWNING_DAMAGE = getRule("drowning_damage"); + + public static final GameRule ELYTRA_MOVEMENT_CHECK = getRule("elytra_movement_check"); + + public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = getRule("ender_pearls_vanish_on_death"); + + public static final GameRule ENTITY_DROPS = getRule("entity_drops"); + + public static final GameRule FALL_DAMAGE = getRule("fall_damage"); + + public static final GameRule FIRE_DAMAGE = getRule("fire_damage"); + + public static final GameRule FIRE_SPREAD_RADIUS_AROUND_PLAYER = getRule("fire_spread_radius_around_player"); + + public static final GameRule FORGIVE_DEAD_PLAYERS = getRule("forgive_dead_players"); + + public static final GameRule FREEZE_DAMAGE = getRule("freeze_damage"); + + public static final GameRule GLOBAL_SOUND_EVENTS = getRule("global_sound_events"); + + public static final GameRule IMMEDIATE_RESPAWN = getRule("immediate_respawn"); + + public static final GameRule KEEP_INVENTORY = getRule("keep_inventory"); + + public static final GameRule LAVA_SOURCE_CONVERSION = getRule("lava_source_conversion"); + + public static final GameRule LIMITED_CRAFTING = getRule("limited_crafting"); + + public static final GameRule LOCATOR_BAR = getRule("locator_bar"); + + public static final GameRule LOG_ADMIN_COMMANDS = getRule("log_admin_commands"); + + public static final GameRule MAX_BLOCK_MODIFICATIONS = getRule("max_block_modifications"); + + public static final GameRule MAX_COMMAND_FORKS = getRule("max_command_forks"); + + public static final GameRule MAX_COMMAND_SEQUENCE_LENGTH = getRule("max_command_sequence_length"); + + public static final GameRule MAX_ENTITY_CRAMMING = getRule("max_entity_cramming"); + + @MinecraftExperimental(MinecraftExperimental.Requires.MINECART_IMPROVEMENTS) + @ApiStatus.Experimental + public static final GameRule MAX_MINECART_SPEED = getRule("max_minecart_speed"); + + public static final GameRule MAX_SNOW_ACCUMULATION_HEIGHT = getRule("max_snow_accumulation_height"); + + public static final GameRule MOB_DROPS = getRule("mob_drops"); + + public static final GameRule MOB_EXPLOSION_DROP_DECAY = getRule("mob_explosion_drop_decay"); + + public static final GameRule MOB_GRIEFING = getRule("mob_griefing"); + + public static final GameRule NATURAL_HEALTH_REGENERATION = getRule("natural_health_regeneration"); + + public static final GameRule PLAYER_MOVEMENT_CHECK = getRule("player_movement_check"); + + public static final GameRule PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = getRule("players_nether_portal_creative_delay"); + + public static final GameRule PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = getRule("players_nether_portal_default_delay"); + + public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = getRule("players_sleeping_percentage"); + + public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = getRule("projectiles_can_break_blocks"); + + public static final GameRule PVP = getRule("pvp"); + + public static final GameRule RAIDS = getRule("raids"); + + public static final GameRule RANDOM_TICK_SPEED = getRule("random_tick_speed"); + + public static final GameRule REDUCED_DEBUG_INFO = getRule("reduced_debug_info"); + + public static final GameRule RESPAWN_RADIUS = getRule("respawn_radius"); + + public static final GameRule SEND_COMMAND_FEEDBACK = getRule("send_command_feedback"); + + public static final GameRule SHOW_ADVANCEMENT_MESSAGES = getRule("show_advancement_messages"); + + public static final GameRule SHOW_DEATH_MESSAGES = getRule("show_death_messages"); + + public static final GameRule SPAWN_MOBS = getRule("spawn_mobs"); + + public static final GameRule SPAWN_MONSTERS = getRule("spawn_monsters"); + + public static final GameRule SPAWN_PATROLS = getRule("spawn_patrols"); + + public static final GameRule SPAWN_PHANTOMS = getRule("spawn_phantoms"); + + public static final GameRule SPAWN_WANDERING_TRADERS = getRule("spawn_wandering_traders"); + + public static final GameRule SPAWN_WARDENS = getRule("spawn_wardens"); + + public static final GameRule SPAWNER_BLOCKS_WORK = getRule("spawner_blocks_work"); + + public static final GameRule SPECTATORS_GENERATE_CHUNKS = getRule("spectators_generate_chunks"); + + public static final GameRule SPREAD_VINES = getRule("spread_vines"); + + public static final GameRule TNT_EXPLODES = getRule("tnt_explodes"); + + public static final GameRule TNT_EXPLOSION_DROP_DECAY = getRule("tnt_explosion_drop_decay"); + + public static final GameRule UNIVERSAL_ANGER = getRule("universal_anger"); + + public static final GameRule WATER_SOURCE_CONVERSION = getRule("water_source_conversion"); + // End generate - GameRules + + private static GameRule getRule(@KeyPattern.Value String key) { + return (GameRule) Registry.GAME_RULE.getOrThrow(NamespacedKey.minecraft(key)); + } + + private GameRules() { + } +} diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 73cf04c20ff5..24acfb4f89a1 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -205,6 +205,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla BUCKET(-1, 16), BUNDLE(-1, 1), BURN_POTTERY_SHERD(-1), + CAMEL_HUSK_SPAWN_EGG(-1), CAMEL_SPAWN_EGG(-1), CARROT(-1), CARROT_ON_A_STICK(-1, 1), @@ -248,9 +249,11 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla COPPER_HORSE_ARMOR(-1, 1), COPPER_INGOT(-1), COPPER_LEGGINGS(-1, 1), + COPPER_NAUTILUS_ARMOR(-1, 1), COPPER_NUGGET(-1), COPPER_PICKAXE(-1, 1), COPPER_SHOVEL(-1, 1), + COPPER_SPEAR(-1, 1), COPPER_SWORD(-1, 1), COW_SPAWN_EGG(-1), CREAKING_SPAWN_EGG(-1), @@ -272,8 +275,10 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla DIAMOND_HOE(-1, 1), DIAMOND_HORSE_ARMOR(-1, 1), DIAMOND_LEGGINGS(-1, 1), + DIAMOND_NAUTILUS_ARMOR(-1, 1), DIAMOND_PICKAXE(-1, 1), DIAMOND_SHOVEL(-1, 1), + DIAMOND_SPEAR(-1, 1), DIAMOND_SWORD(-1, 1), DISC_FRAGMENT_5(-1), DOLPHIN_SPAWN_EGG(-1), @@ -340,8 +345,10 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla GOLDEN_HOE(-1, 1), GOLDEN_HORSE_ARMOR(-1, 1), GOLDEN_LEGGINGS(-1, 1), + GOLDEN_NAUTILUS_ARMOR(-1, 1), GOLDEN_PICKAXE(-1, 1), GOLDEN_SHOVEL(-1, 1), + GOLDEN_SPEAR(-1, 1), GOLDEN_SWORD(-1, 1), GRAY_BUNDLE(-1, 1), GRAY_DYE(-1), @@ -375,9 +382,11 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla IRON_HORSE_ARMOR(-1, 1), IRON_INGOT(-1), IRON_LEGGINGS(-1, 1), + IRON_NAUTILUS_ARMOR(-1, 1), IRON_NUGGET(-1), IRON_PICKAXE(-1, 1), IRON_SHOVEL(-1, 1), + IRON_SPEAR(-1, 1), IRON_SWORD(-1, 1), ITEM_FRAME(-1), JUNGLE_BOAT(-1, 1), @@ -446,6 +455,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla MUTTON(-1), NAME_TAG(-1), NAUTILUS_SHELL(-1), + NAUTILUS_SPAWN_EGG(-1), NETHER_BRICK(-1), NETHER_STAR(-1), NETHERITE_AXE(-1, 1), @@ -453,11 +463,14 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla NETHERITE_CHESTPLATE(-1, 1), NETHERITE_HELMET(-1, 1), NETHERITE_HOE(-1, 1), + NETHERITE_HORSE_ARMOR(-1, 1), NETHERITE_INGOT(-1), NETHERITE_LEGGINGS(-1, 1), + NETHERITE_NAUTILUS_ARMOR(-1, 1), NETHERITE_PICKAXE(-1, 1), NETHERITE_SCRAP(-1), NETHERITE_SHOVEL(-1, 1), + NETHERITE_SPEAR(-1, 1), NETHERITE_SWORD(-1, 1), NETHERITE_UPGRADE_SMITHING_TEMPLATE(-1), OAK_BOAT(-1, 1), @@ -473,6 +486,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla PALE_OAK_CHEST_BOAT(-1, 1), PANDA_SPAWN_EGG(-1), PAPER(-1), + PARCHED_SPAWN_EGG(-1), PARROT_SPAWN_EGG(-1), PHANTOM_MEMBRANE(-1), PHANTOM_SPAWN_EGG(-1), @@ -564,6 +578,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla STONE_HOE(-1, 1), STONE_PICKAXE(-1, 1), STONE_SHOVEL(-1, 1), + STONE_SPEAR(-1, 1), STONE_SWORD(-1, 1), STRAY_SPAWN_EGG(-1), STRIDER_SPAWN_EGG(-1), @@ -612,6 +627,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla WOODEN_HOE(-1, 1), WOODEN_PICKAXE(-1, 1), WOODEN_SHOVEL(-1, 1), + WOODEN_SPEAR(-1, 1), WOODEN_SWORD(-1, 1), WRITABLE_BOOK(-1, 1), WRITTEN_BOOK(-1, 16), @@ -620,6 +636,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla YELLOW_HARNESS(-1, 1), ZOGLIN_SPAWN_EGG(-1), ZOMBIE_HORSE_SPAWN_EGG(-1), + ZOMBIE_NAUTILUS_SPAWN_EGG(-1), ZOMBIE_SPAWN_EGG(-1), ZOMBIE_VILLAGER_SPAWN_EGG(-1), ZOMBIFIED_PIGLIN_SPAWN_EGG(-1), diff --git a/paper-api/src/main/java/org/bukkit/Registry.java b/paper-api/src/main/java/org/bukkit/Registry.java index f9774834e5a7..0859653089ac 100644 --- a/paper-api/src/main/java/org/bukkit/Registry.java +++ b/paper-api/src/main/java/org/bukkit/Registry.java @@ -348,7 +348,13 @@ public int size() { * * @see DataComponentType */ - Registry DATA_COMPONENT_TYPE = registryFor(RegistryKey.DATA_COMPONENT_TYPE); // Paper + Registry DATA_COMPONENT_TYPE = registryFor(RegistryKey.DATA_COMPONENT_TYPE); + /** + * Game rules. + * + * @see GameRule + */ + Registry> GAME_RULE = registryFor(RegistryKey.GAME_RULE); // /** @@ -557,7 +563,6 @@ default T getOrThrow(final NamespacedKey key) { * @deprecated this method's behavior is broken and not useful. If you want to get an object * based on its vanilla name, or a key, wrap it in a {@link NamespacedKey} object and use {@link #get(NamespacedKey)} */ - // Paper @Deprecated(forRemoval = true) default @Nullable T match(final String input) { Preconditions.checkArgument(input != null, "input must not be null"); diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 718861fccd0f..0ec885b97d65 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -243,7 +243,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * Separate from the portal game rule. * * @return whether this server allows the Nether or not - * @see GameRule#ALLOW_ENTERING_NETHER_USING_PORTALS + * @see GameRules#ALLOW_ENTERING_NETHER_USING_PORTALS */ public boolean getAllowNether(); diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index 0ceba9ca35ce..1ba2f4969419 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -1739,6 +1739,22 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_AXOLOTL_SWIM = getSound("entity.axolotl.swim"); + Sound ENTITY_BABY_NAUTILUS_AMBIENT = getSound("entity.baby_nautilus.ambient"); + + Sound ENTITY_BABY_NAUTILUS_AMBIENT_LAND = getSound("entity.baby_nautilus.ambient_land"); + + Sound ENTITY_BABY_NAUTILUS_DEATH = getSound("entity.baby_nautilus.death"); + + Sound ENTITY_BABY_NAUTILUS_DEATH_LAND = getSound("entity.baby_nautilus.death_land"); + + Sound ENTITY_BABY_NAUTILUS_EAT = getSound("entity.baby_nautilus.eat"); + + Sound ENTITY_BABY_NAUTILUS_HURT = getSound("entity.baby_nautilus.hurt"); + + Sound ENTITY_BABY_NAUTILUS_HURT_LAND = getSound("entity.baby_nautilus.hurt_land"); + + Sound ENTITY_BABY_NAUTILUS_SWIM = getSound("entity.baby_nautilus.swim"); + Sound ENTITY_BAT_AMBIENT = getSound("entity.bat.ambient"); Sound ENTITY_BAT_DEATH = getSound("entity.bat.death"); @@ -1833,6 +1849,28 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_CAMEL_STEP_SAND = getSound("entity.camel.step_sand"); + Sound ENTITY_CAMEL_HUSK_AMBIENT = getSound("entity.camel_husk.ambient"); + + Sound ENTITY_CAMEL_HUSK_DASH = getSound("entity.camel_husk.dash"); + + Sound ENTITY_CAMEL_HUSK_DASH_READY = getSound("entity.camel_husk.dash_ready"); + + Sound ENTITY_CAMEL_HUSK_DEATH = getSound("entity.camel_husk.death"); + + Sound ENTITY_CAMEL_HUSK_EAT = getSound("entity.camel_husk.eat"); + + Sound ENTITY_CAMEL_HUSK_HURT = getSound("entity.camel_husk.hurt"); + + Sound ENTITY_CAMEL_HUSK_SADDLE = getSound("entity.camel_husk.saddle"); + + Sound ENTITY_CAMEL_HUSK_SIT = getSound("entity.camel_husk.sit"); + + Sound ENTITY_CAMEL_HUSK_STAND = getSound("entity.camel_husk.stand"); + + Sound ENTITY_CAMEL_HUSK_STEP = getSound("entity.camel_husk.step"); + + Sound ENTITY_CAMEL_HUSK_STEP_SAND = getSound("entity.camel_husk.step_sand"); + Sound ENTITY_CAT_AMBIENT = getSound("entity.cat.ambient"); Sound ENTITY_CAT_BEG_FOR_FOOD = getSound("entity.cat.beg_for_food"); @@ -2439,6 +2477,32 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_MULE_JUMP = getSound("entity.mule.jump"); + Sound ENTITY_NAUTILUS_AMBIENT = getSound("entity.nautilus.ambient"); + + Sound ENTITY_NAUTILUS_AMBIENT_LAND = getSound("entity.nautilus.ambient_land"); + + Sound ENTITY_NAUTILUS_DASH = getSound("entity.nautilus.dash"); + + Sound ENTITY_NAUTILUS_DASH_LAND = getSound("entity.nautilus.dash_land"); + + Sound ENTITY_NAUTILUS_DASH_READY = getSound("entity.nautilus.dash_ready"); + + Sound ENTITY_NAUTILUS_DASH_READY_LAND = getSound("entity.nautilus.dash_ready_land"); + + Sound ENTITY_NAUTILUS_DEATH = getSound("entity.nautilus.death"); + + Sound ENTITY_NAUTILUS_DEATH_LAND = getSound("entity.nautilus.death_land"); + + Sound ENTITY_NAUTILUS_EAT = getSound("entity.nautilus.eat"); + + Sound ENTITY_NAUTILUS_HURT = getSound("entity.nautilus.hurt"); + + Sound ENTITY_NAUTILUS_HURT_LAND = getSound("entity.nautilus.hurt_land"); + + Sound ENTITY_NAUTILUS_RIDING = getSound("entity.nautilus.riding"); + + Sound ENTITY_NAUTILUS_SWIM = getSound("entity.nautilus.swim"); + Sound ENTITY_OCELOT_AMBIENT = getSound("entity.ocelot.ambient"); Sound ENTITY_OCELOT_DEATH = getSound("entity.ocelot.death"); @@ -2471,6 +2535,14 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PANDA_WORRIED_AMBIENT = getSound("entity.panda.worried_ambient"); + Sound ENTITY_PARCHED_AMBIENT = getSound("entity.parched.ambient"); + + Sound ENTITY_PARCHED_DEATH = getSound("entity.parched.death"); + + Sound ENTITY_PARCHED_HURT = getSound("entity.parched.hurt"); + + Sound ENTITY_PARCHED_STEP = getSound("entity.parched.step"); + Sound ENTITY_PARROT_AMBIENT = getSound("entity.parrot.ambient"); Sound ENTITY_PARROT_DEATH = getSound("entity.parrot.death"); @@ -2487,6 +2559,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PARROT_IMITATE_BREEZE = getSound("entity.parrot.imitate.breeze"); + Sound ENTITY_PARROT_IMITATE_CAMEL_HUSK = getSound("entity.parrot.imitate.camel_husk"); + Sound ENTITY_PARROT_IMITATE_CREAKING = getSound("entity.parrot.imitate.creaking"); Sound ENTITY_PARROT_IMITATE_CREEPER = getSound("entity.parrot.imitate.creeper"); @@ -2513,6 +2587,8 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PARROT_IMITATE_MAGMA_CUBE = getSound("entity.parrot.imitate.magma_cube"); + Sound ENTITY_PARROT_IMITATE_PARCHED = getSound("entity.parrot.imitate.parched"); + Sound ENTITY_PARROT_IMITATE_PHANTOM = getSound("entity.parrot.imitate.phantom"); Sound ENTITY_PARROT_IMITATE_PIGLIN = getSound("entity.parrot.imitate.piglin"); @@ -2551,6 +2627,10 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_PARROT_IMITATE_ZOMBIE = getSound("entity.parrot.imitate.zombie"); + Sound ENTITY_PARROT_IMITATE_ZOMBIE_HORSE = getSound("entity.parrot.imitate.zombie_horse"); + + Sound ENTITY_PARROT_IMITATE_ZOMBIE_NAUTILUS = getSound("entity.parrot.imitate.zombie_nautilus"); + Sound ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER = getSound("entity.parrot.imitate.zombie_villager"); Sound ENTITY_PARROT_STEP = getSound("entity.parrot.step"); @@ -3199,10 +3279,38 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ENTITY_ZOMBIE_HORSE_AMBIENT = getSound("entity.zombie_horse.ambient"); + Sound ENTITY_ZOMBIE_HORSE_ANGRY = getSound("entity.zombie_horse.angry"); + Sound ENTITY_ZOMBIE_HORSE_DEATH = getSound("entity.zombie_horse.death"); + Sound ENTITY_ZOMBIE_HORSE_EAT = getSound("entity.zombie_horse.eat"); + Sound ENTITY_ZOMBIE_HORSE_HURT = getSound("entity.zombie_horse.hurt"); + Sound ENTITY_ZOMBIE_NAUTILUS_AMBIENT = getSound("entity.zombie_nautilus.ambient"); + + Sound ENTITY_ZOMBIE_NAUTILUS_AMBIENT_LAND = getSound("entity.zombie_nautilus.ambient_land"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DASH = getSound("entity.zombie_nautilus.dash"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DASH_LAND = getSound("entity.zombie_nautilus.dash_land"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DASH_READY = getSound("entity.zombie_nautilus.dash_ready"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DASH_READY_LAND = getSound("entity.zombie_nautilus.dash_ready_land"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DEATH = getSound("entity.zombie_nautilus.death"); + + Sound ENTITY_ZOMBIE_NAUTILUS_DEATH_LAND = getSound("entity.zombie_nautilus.death_land"); + + Sound ENTITY_ZOMBIE_NAUTILUS_EAT = getSound("entity.zombie_nautilus.eat"); + + Sound ENTITY_ZOMBIE_NAUTILUS_HURT = getSound("entity.zombie_nautilus.hurt"); + + Sound ENTITY_ZOMBIE_NAUTILUS_HURT_LAND = getSound("entity.zombie_nautilus.hurt_land"); + + Sound ENTITY_ZOMBIE_NAUTILUS_SWIM = getSound("entity.zombie_nautilus.swim"); + Sound ENTITY_ZOMBIE_VILLAGER_AMBIENT = getSound("entity.zombie_villager.ambient"); Sound ENTITY_ZOMBIE_VILLAGER_CONVERTED = getSound("entity.zombie_villager.converted"); @@ -3249,12 +3357,16 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_ARMOR_EQUIP_LEATHER = getSound("item.armor.equip_leather"); + Sound ITEM_ARMOR_EQUIP_NAUTILUS = getSound("item.armor.equip_nautilus"); + Sound ITEM_ARMOR_EQUIP_NETHERITE = getSound("item.armor.equip_netherite"); Sound ITEM_ARMOR_EQUIP_TURTLE = getSound("item.armor.equip_turtle"); Sound ITEM_ARMOR_EQUIP_WOLF = getSound("item.armor.equip_wolf"); + Sound ITEM_ARMOR_UNEQUIP_NAUTILUS = getSound("item.armor.unequip_nautilus"); + Sound ITEM_ARMOR_UNEQUIP_WOLF = getSound("item.armor.unequip_wolf"); Sound ITEM_AXE_SCRAPE = getSound("item.axe.scrape"); @@ -3389,6 +3501,10 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_MACE_SMASH_GROUND_HEAVY = getSound("item.mace.smash_ground_heavy"); + Sound ITEM_NAUTILUS_SADDLE_EQUIP = getSound("item.nautilus_saddle_equip"); + + Sound ITEM_NAUTILUS_SADDLE_UNDERWATER_EQUIP = getSound("item.nautilus_saddle_underwater_equip"); + Sound ITEM_NETHER_WART_PLANT = getSound("item.nether_wart.plant"); Sound ITEM_OMINOUS_BOTTLE_DISPOSE = getSound("item.ominous_bottle.dispose"); @@ -3403,6 +3519,24 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. Sound ITEM_SHOVEL_FLATTEN = getSound("item.shovel.flatten"); + Sound ITEM_SPEAR_ATTACK = getSound("item.spear.attack"); + + Sound ITEM_SPEAR_HIT = getSound("item.spear.hit"); + + Sound ITEM_SPEAR_LUNGE_1 = getSound("item.spear.lunge_1"); + + Sound ITEM_SPEAR_LUNGE_2 = getSound("item.spear.lunge_2"); + + Sound ITEM_SPEAR_LUNGE_3 = getSound("item.spear.lunge_3"); + + Sound ITEM_SPEAR_USE = getSound("item.spear.use"); + + Sound ITEM_SPEAR_WOOD_ATTACK = getSound("item.spear_wood.attack"); + + Sound ITEM_SPEAR_WOOD_HIT = getSound("item.spear_wood.hit"); + + Sound ITEM_SPEAR_WOOD_USE = getSound("item.spear_wood.use"); + Sound ITEM_SPYGLASS_STOP_USING = getSound("item.spyglass.stop_using"); Sound ITEM_SPYGLASS_USE = getSound("item.spyglass.use"); diff --git a/paper-api/src/main/java/org/bukkit/Statistic.java b/paper-api/src/main/java/org/bukkit/Statistic.java index c290406fcbe9..fc3d04da1453 100644 --- a/paper-api/src/main/java/org/bukkit/Statistic.java +++ b/paper-api/src/main/java/org/bukkit/Statistic.java @@ -55,6 +55,7 @@ public enum Statistic implements Keyed { LEAVE_GAME, MINECART_ONE_CM, MOB_KILLS, + NAUTILUS_ONE_CM, OPEN_BARREL, CHEST_OPENED, ENDERCHEST_OPENED, diff --git a/paper-api/src/main/java/org/bukkit/Tag.java b/paper-api/src/main/java/org/bukkit/Tag.java index 7088f069facc..5fbb1ccaeb42 100644 --- a/paper-api/src/main/java/org/bukkit/Tag.java +++ b/paper-api/src/main/java/org/bukkit/Tag.java @@ -84,6 +84,8 @@ public interface Tag extends Keyed { Tag CAMPFIRES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("campfires"), Material.class); + Tag CAN_GLIDE_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("can_glide_through"), Material.class); + Tag CANDLE_CAKES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candle_cakes"), Material.class); Tag CANDLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candles"), Material.class); @@ -472,6 +474,8 @@ public interface Tag extends Keyed { Tag ITEMS_CAMEL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("camel_food"), Material.class); + Tag ITEMS_CAMEL_HUSK_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("camel_husk_food"), Material.class); + Tag ITEMS_CANDLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("candles"), Material.class); Tag ITEMS_CAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cat_food"), Material.class); @@ -562,15 +566,19 @@ public interface Tag extends Keyed { Tag ITEMS_ENCHANTABLE_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/leg_armor"), Material.class); + Tag ITEMS_ENCHANTABLE_LUNGE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/lunge"), Material.class); + Tag ITEMS_ENCHANTABLE_MACE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mace"), Material.class); + Tag ITEMS_ENCHANTABLE_MELEE_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/melee_weapon"), Material.class); + Tag ITEMS_ENCHANTABLE_MINING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining"), Material.class); Tag ITEMS_ENCHANTABLE_MINING_LOOT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining_loot"), Material.class); Tag ITEMS_ENCHANTABLE_SHARP_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sharp_weapon"), Material.class); - Tag ITEMS_ENCHANTABLE_SWORD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sword"), Material.class); + Tag ITEMS_ENCHANTABLE_SWEEPING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sweeping"), Material.class); Tag ITEMS_ENCHANTABLE_TRIDENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/trident"), Material.class); @@ -656,6 +664,12 @@ public interface Tag extends Keyed { Tag ITEMS_MEAT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("meat"), Material.class); + Tag ITEMS_NAUTILUS_BUCKET_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("nautilus_bucket_food"), Material.class); + + Tag ITEMS_NAUTILUS_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("nautilus_food"), Material.class); + + Tag ITEMS_NAUTILUS_TAMING_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("nautilus_taming_items"), Material.class); + Tag ITEMS_NETHERITE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("netherite_tool_materials"), Material.class); Tag ITEMS_NON_FLAMMABLE_WOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("non_flammable_wood"), Material.class); @@ -746,6 +760,8 @@ public interface Tag extends Keyed { Tag ITEMS_SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class); + Tag ITEMS_SPEARS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("spears"), Material.class); + Tag ITEMS_SPRUCE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("spruce_logs"), Material.class); Tag ITEMS_STAIRS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stairs"), Material.class); @@ -810,6 +826,8 @@ public interface Tag extends Keyed { Tag ITEMS_WOOL_CARPETS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool_carpets"), Material.class); + Tag ITEMS_ZOMBIE_HORSE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("zombie_horse_food"), Material.class); + String REGISTRY_FLUIDS = "fluids"; Tag FLUIDS_LAVA = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("lava"), Fluid.class); @@ -834,16 +852,22 @@ public interface Tag extends Keyed { Tag ENTITY_TYPES_BOAT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("boat"), EntityType.class); + Tag ENTITY_TYPES_BURN_IN_DAYLIGHT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("burn_in_daylight"), EntityType.class); + Tag ENTITY_TYPES_CAN_BREATHE_UNDER_WATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_breathe_under_water"), EntityType.class); Tag ENTITY_TYPES_CAN_EQUIP_HARNESS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_equip_harness"), EntityType.class); Tag ENTITY_TYPES_CAN_EQUIP_SADDLE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_equip_saddle"), EntityType.class); + Tag ENTITY_TYPES_CAN_FLOAT_WHILE_RIDDEN = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_float_while_ridden"), EntityType.class); + Tag ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class); Tag ENTITY_TYPES_CAN_WEAR_HORSE_ARMOR = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_wear_horse_armor"), EntityType.class); + Tag ENTITY_TYPES_CAN_WEAR_NAUTILUS_ARMOR = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_wear_nautilus_armor"), EntityType.class); + Tag ENTITY_TYPES_CANDIDATE_FOR_IRON_GOLEM_GIFT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("candidate_for_iron_golem_gift"), EntityType.class); Tag ENTITY_TYPES_CANNOT_BE_PUSHED_ONTO_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("cannot_be_pushed_onto_boats"), EntityType.class); @@ -876,6 +900,8 @@ public interface Tag extends Keyed { Tag ENTITY_TYPES_INVERTED_HEALING_AND_HARM = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("inverted_healing_and_harm"), EntityType.class); + Tag ENTITY_TYPES_NAUTILUS_HOSTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("nautilus_hostiles"), EntityType.class); + Tag ENTITY_TYPES_NO_ANGER_FROM_WIND_CHARGE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("no_anger_from_wind_charge"), EntityType.class); Tag ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class); diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 2cda5a030665..698f730efe1c 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -43,6 +43,7 @@ import org.bukkit.util.RayTraceResult; import org.bukkit.util.StructureSearchResult; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -2288,7 +2289,7 @@ default boolean createExplosion(double x, double y, double z, float power, boole *

* Note that if a non-null {@code source} Entity is provided and {@code * breakBlocks} is {@code true}, the value of {@code breakBlocks} will be - * ignored if {@link GameRule#MOB_GRIEFING} is {@code false} in the world + * ignored if {@link GameRules#MOB_GRIEFING} is {@code false} in the world * in which the explosion occurs. In other words, the mob griefing gamerule * will take priority over {@code breakBlocks} if explosions are not allowed. * @@ -2445,7 +2446,7 @@ default boolean createExplosion(@NotNull Location loc, float power, boolean setF *

* Note that if a non-null {@code source} Entity is provided and {@code * breakBlocks} is {@code true}, the value of {@code breakBlocks} will be - * ignored if {@link GameRule#MOB_GRIEFING} is {@code false} in the world + * ignored if {@link GameRules#MOB_GRIEFING} is {@code false} in the world * in which the explosion occurs. In other words, the mob griefing gamerule * will take priority over {@code breakBlocks} if explosions are not allowed. * @@ -2462,7 +2463,7 @@ default boolean createExplosion(@NotNull Location loc, float power, boolean setF * Gets the current PVP setting for this world. * * @return True if PVP is enabled - * @deprecated use {@link GameRule#PVP} instead + * @deprecated use {@link GameRules#PVP} instead */ @Deprecated(since = "1.21.9") public boolean getPVP(); @@ -2471,7 +2472,7 @@ default boolean createExplosion(@NotNull Location loc, float power, boolean setF * Sets the PVP setting for this world. * * @param pvp True/False whether PVP should be Enabled. - * @deprecated use {@link GameRule#PVP} instead + * @deprecated use {@link GameRules#PVP} instead */ @Deprecated(since = "1.21.9") public void setPVP(boolean pvp); @@ -2796,23 +2797,26 @@ default double getHumidity(int x, int z) { /** * Gets if this world is natural. - * - * When false, compasses spin randomly, and using a bed to set the respawn - * point or sleep, is disabled. When true, nether portals can spawn - * zombified piglins. + *

+ * When false, the moon is not visible and eyeblossoms do not open/close * * @return true if world is natural + * @deprecated replaced by the gameplay/eyeblossom_open and gameplay/creaking_active environment attributes */ + @Deprecated(since = "1.21.11") public boolean isNatural(); /** * Gets if beds work in this world. - * - * A non-working bed will blow up when trying to sleep. {@link #isNatural()} - * defines if a bed can be used to set spawn point. + *

+ * A non-working bed can blow up when trying to sleep, but that may + * not always be the case. * * @return true if beds work in this world + * @deprecated Due to 1.21.11 beds changes, a boolean no longer + * represents if they work. There is no replacement API yet */ + @ApiStatus.Obsolete(since = "1.21.11") public boolean isBedWorks(); /** @@ -2862,7 +2866,9 @@ default double getHumidity(int x, int z) { * * * @return true if this world has the above mechanics + * @deprecated as of 1.21.11, ultra warm is replaced by the WATER_EVAPORATES, FAST_LAVA, and DEFAULT_DRIPSTONE_PARTICLE environment attributes. */ + @Deprecated(since = "1.21.11") public boolean isUltraWarm(); /** @@ -3789,7 +3795,7 @@ default void playSound(@NotNull Entity entity, @NotNull String sound, float volu * @return String value of rule * @deprecated use {@link #getGameRuleValue(GameRule)} instead */ - @Deprecated(since = "1.13") + @Deprecated(since = "1.21.11", forRemoval = true) @Contract("null -> null; !null -> !null") @Nullable public String getGameRuleValue(@Nullable String rule); @@ -3807,7 +3813,7 @@ default void playSound(@NotNull Entity entity, @NotNull String sound, float volu * @return True if rule was set * @deprecated use {@link #setGameRule(GameRule, Object)} instead. */ - @Deprecated(since = "1.13") + @Deprecated(since = "1.13", forRemoval = true) public boolean setGameRuleValue(@NotNull String rule, @NotNull String value); /** diff --git a/paper-api/src/main/java/org/bukkit/WorldBorder.java b/paper-api/src/main/java/org/bukkit/WorldBorder.java index b1c08a7fc585..10e69cab2068 100644 --- a/paper-api/src/main/java/org/bukkit/WorldBorder.java +++ b/paper-api/src/main/java/org/bukkit/WorldBorder.java @@ -1,8 +1,13 @@ package org.bukkit; +import com.google.common.base.Preconditions; +import io.papermc.paper.util.Tick; +import java.time.Duration; import java.util.concurrent.TimeUnit; +import org.checkerframework.checker.index.qual.NonNegative; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Range; public interface WorldBorder { @@ -12,20 +17,19 @@ public interface WorldBorder { * @return the associated world, or null if this world border is not associated * with any specific world, such as those created via {@link Server#createWorldBorder()} */ - @Nullable - public World getWorld(); + @Nullable World getWorld(); /** * Resets the border to default values. */ - public void reset(); + void reset(); /** * Gets the current side length of the border. * * @return The current side length of the border. */ - public double getSize(); + double getSize(); /** * Sets the border to a square region with the specified side length in blocks. @@ -33,18 +37,35 @@ public interface WorldBorder { * @param newSize The new size of the border. * * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @see #changeSize(double, long) */ - public void setSize(double newSize); + void setSize(double newSize); /** * Sets the border to a square region with the specified side length in blocks. * * @param newSize The new side length of the border. - * @param seconds The time in seconds in which the border grows or shrinks from the previous size to that being set. + * @param ticks The time in ticks in which the border grows or shrinks from the previous size to that being set. * * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @throws IllegalArgumentException if ticks is out of range + * @see #setSize(double) + */ + void changeSize(double newSize, @Range(from = 0, to = Integer.MAX_VALUE) long ticks); + + /** + * Sets the border to a square region with the specified side length in blocks. + * + * @param newSize The new side length of the border. + * @param seconds The time in seconds in which the border grows or shrinks from the previous size to that being set. + * + * @throws IllegalArgumentException if seconds is out of range once converted in ticks + * @deprecated Use {@link #changeSize(double, long)} instead */ - public void setSize(double newSize, long seconds); + @Deprecated(since = "1.21.11", forRemoval = true) + default void setSize(double newSize, long seconds) { + this.changeSize(Math.clamp(newSize, 1.0D, this.getMaxSize()), Tick.tick().fromDuration(Duration.ofSeconds(seconds))); + } /** * Sets the border to a square region with the specified side length in blocks. @@ -53,17 +74,22 @@ public interface WorldBorder { * @param unit The time unit. * @param time The time in which the border grows or shrinks from the previous size to that being set. * - * @throws IllegalArgumentException if unit is null or newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @throws IllegalArgumentException if newSize is less than 1.0D or greater than {@link #getMaxSize()} + * @throws IllegalArgumentException if time is out of range once converted in ticks + * @deprecated Use {@link #changeSize(double, long)} instead */ - public void setSize(double newSize, @NotNull TimeUnit unit, long time); + @Deprecated(since = "1.21.11", forRemoval = true) + default void setSize(double newSize, @NotNull TimeUnit unit, @NonNegative long time) { + Preconditions.checkArgument(unit != null, "TimeUnit cannot be null."); + this.changeSize(newSize, Tick.tick().fromDuration(Duration.of(time, unit.toChronoUnit()))); + } /** * Gets the current border center. * * @return The current border center. */ - @NotNull - public Location getCenter(); + @NotNull Location getCenter(); /** * Sets the new border center. @@ -73,7 +99,7 @@ public interface WorldBorder { * * @throws IllegalArgumentException if the absolute value of x or z is higher than {@link #getMaxCenterCoordinate()} */ - public void setCenter(double x, double z); + void setCenter(double x, double z); /** * Sets the new border center. @@ -82,63 +108,87 @@ public interface WorldBorder { * * @throws IllegalArgumentException if location is null or the absolute value of {@link Location#getX()} or {@link Location#getZ()} is higher than {@link #getMaxCenterCoordinate()} */ - public void setCenter(@NotNull Location location); + void setCenter(@NotNull Location location); /** * Gets the current border damage buffer. * * @return The current border damage buffer. */ - public double getDamageBuffer(); + double getDamageBuffer(); /** * Sets the amount of blocks a player may safely be outside the border before taking damage. * * @param blocks The amount of blocks. (The default is 5 blocks.) */ - public void setDamageBuffer(double blocks); + void setDamageBuffer(double blocks); /** * Gets the current border damage amount. * * @return The current border damage amount. */ - public double getDamageAmount(); + double getDamageAmount(); /** * Sets the amount of damage a player takes when outside the border plus the border buffer. * * @param damage The amount of damage. (The default is 0.2 damage per second per block.) */ - public void setDamageAmount(double damage); + void setDamageAmount(double damage); /** * Gets the current border warning time in seconds. * * @return The current border warning time in seconds. + * @deprecated Use {@link #getWarningTimeTicks()} instead + */ + @Deprecated(since = "1.21.11", forRemoval = true) + default @NonNegative int getWarningTime() { + return (int) Tick.of(this.getWarningTimeTicks()).toSeconds(); + } + + /** + * Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time. + * + * @param seconds The amount of time in seconds. + * @deprecated Use {@link #setWarningTimeTicks(int)} instead + */ + @Deprecated(since = "1.21.11", forRemoval = true) + default void setWarningTime(@NonNegative int seconds) { + Preconditions.checkArgument(seconds >= 0, "seconds cannot be lower than 0"); + + this.setWarningTimeTicks(Tick.tick().fromDuration(Duration.ofSeconds(seconds))); + } + + /** + * Gets the current border warning time in ticks. + * + * @return The current border warning time in ticks. */ - public int getWarningTime(); + @NonNegative int getWarningTimeTicks(); /** * Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time. * - * @param seconds The amount of time in seconds. (The default is 15 seconds.) + * @param ticks The number of ticks. */ - public void setWarningTime(int seconds); + void setWarningTimeTicks(@NonNegative int ticks); /** * Gets the current border warning distance. * * @return The current border warning distance. */ - public int getWarningDistance(); + int getWarningDistance(); /** * Sets the warning distance that causes the screen to be tinted red when the player is within the specified number of blocks from the border. * * @param distance The distance in blocks. (The default is 5 blocks.) */ - public void setWarningDistance(int distance); + void setWarningDistance(int distance); /** * Check if the specified location is inside this border. @@ -146,14 +196,14 @@ public interface WorldBorder { * @param location the location to check * @return if this location is inside the border or not */ - public boolean isInside(@NotNull Location location); + boolean isInside(@NotNull Location location); /** * Gets the maximum possible size of a WorldBorder. * * @return The maximum size the WorldBorder */ - public double getMaxSize(); + double getMaxSize(); /** * Gets the absolute value of the maximum x/z center coordinate of a @@ -161,5 +211,5 @@ public interface WorldBorder { * * @return The absolute maximum center coordinate of the WorldBorder */ - public double getMaxCenterCoordinate(); + double getMaxCenterCoordinate(); } diff --git a/paper-api/src/main/java/org/bukkit/command/Command.java b/paper-api/src/main/java/org/bukkit/command/Command.java index e387ba67f0b6..3171a20c8fcf 100644 --- a/paper-api/src/main/java/org/bukkit/command/Command.java +++ b/paper-api/src/main/java/org/bukkit/command/Command.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Set; import org.bukkit.Bukkit; -import org.bukkit.GameRule; +import org.bukkit.GameRules; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.entity.Player; @@ -477,14 +477,14 @@ public static void broadcastCommandMessage(@NotNull CommandSender source, net.ky if (source instanceof BlockCommandSender) { BlockCommandSender blockCommandSender = (BlockCommandSender) source; - if (!blockCommandSender.getBlock().getWorld().getGameRuleValue(GameRule.COMMAND_BLOCK_OUTPUT)) { + if (!blockCommandSender.getBlock().getWorld().getGameRuleValue(GameRules.COMMAND_BLOCK_OUTPUT)) { Bukkit.getConsoleSender().sendMessage(result); return; } } else if (source instanceof CommandMinecart) { CommandMinecart commandMinecart = (CommandMinecart) source; - if (!commandMinecart.getWorld().getGameRuleValue(GameRule.COMMAND_BLOCK_OUTPUT)) { + if (!commandMinecart.getWorld().getGameRuleValue(GameRules.COMMAND_BLOCK_OUTPUT)) { Bukkit.getConsoleSender().sendMessage(result); return; } 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 8d1e681b820b..6f4a6cc6bbcc 100644 --- a/paper-api/src/main/java/org/bukkit/damage/DamageType.java +++ b/paper-api/src/main/java/org/bukkit/damage/DamageType.java @@ -93,6 +93,8 @@ public interface DamageType extends Keyed, Translatable { DamageType SONIC_BOOM = getDamageType("sonic_boom"); + DamageType SPEAR = getDamageType("spear"); + DamageType SPIT = getDamageType("spit"); DamageType STALAGMITE = getDamageType("stalagmite"); diff --git a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java index 4a6c44c65fa7..2f995a77e876 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -229,6 +229,11 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve */ public static final Enchantment SWIFT_SNEAK = getEnchantment("swift_sneak"); + /** + * Causes a jab attack from a spear to propel the user into the air + */ + public static final Enchantment LUNGE = getEnchantment("lunge"); + @NotNull private static Enchantment getEnchantment(@NotNull String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT).getOrThrow(NamespacedKey.minecraft(key)); diff --git a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java index 16d3a35de7a4..70f6c8428c66 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java @@ -82,12 +82,12 @@ public boolean includes(@NotNull Material item) { }, /** - * Allows the Enchantment to be placed on weapons (swords) + * Allows the Enchantment to be placed on weapons (swords, spears) */ WEAPON { @Override public boolean includes(@NotNull Material item) { - return Tag.ITEMS_ENCHANTABLE_SWORD.isTagged(item); + return Tag.ITEMS_ENCHANTABLE_SHARP_WEAPON.isTagged(item); } }, diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java new file mode 100644 index 000000000000..266e91b75521 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractNautilus.java @@ -0,0 +1,12 @@ +package org.bukkit.entity; + +import org.bukkit.inventory.ArmoredSaddledMountInventory; +import org.bukkit.inventory.InventoryHolder; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface AbstractNautilus extends Animals, InventoryHolder, Tameable { + + @Override + ArmoredSaddledMountInventory getInventory(); +} diff --git a/paper-api/src/main/java/org/bukkit/entity/CamelHusk.java b/paper-api/src/main/java/org/bukkit/entity/CamelHusk.java new file mode 100644 index 000000000000..3f1e5779d956 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/CamelHusk.java @@ -0,0 +1,8 @@ +package org.bukkit.entity; + +/** + * Represents a Camel Husk. + */ +public interface CamelHusk extends Camel { + +} 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 ce60b976bc0c..e84da0628407 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -66,6 +66,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans BREEZE("breeze", Breeze.class, -1), BREEZE_WIND_CHARGE("breeze_wind_charge", BreezeWindCharge.class, -1), CAMEL("camel", Camel.class, -1), + CAMEL_HUSK("camel_husk", CamelHusk.class, -1), CAT("cat", Cat.class, -1), CAVE_SPIDER("cave_spider", CaveSpider.class, 59), CHERRY_BOAT("cherry_boat", CherryBoat.class, -1), @@ -135,6 +136,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans MINECART("minecart", RideableMinecart.class, 42), MOOSHROOM("mooshroom", MushroomCow.class, 96), MULE("mule", Mule.class, 32), + NAUTILUS("nautilus", Nautilus.class, -1), OAK_BOAT("oak_boat", OakBoat.class, -1), OAK_CHEST_BOAT("oak_chest_boat", OakChestBoat.class, -1), OCELOT("ocelot", Ocelot.class, 98), @@ -143,6 +145,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans PALE_OAK_BOAT("pale_oak_boat", PaleOakBoat.class, -1), PALE_OAK_CHEST_BOAT("pale_oak_chest_boat", PaleOakChestBoat.class, -1), PANDA("panda", Panda.class, -1), + PARCHED("parched", Parched.class, -1), PARROT("parrot", Parrot.class, 105), PHANTOM("phantom", Phantom.class, -1), PIG("pig", Pig.class, 90), @@ -197,6 +200,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans ZOGLIN("zoglin", Zoglin.class, -1), ZOMBIE("zombie", Zombie.class, 54), ZOMBIE_HORSE("zombie_horse", ZombieHorse.class, 29), + ZOMBIE_NAUTILUS("zombie_nautilus", ZombieNautilus.class, -1), ZOMBIE_VILLAGER("zombie_villager", ZombieVillager.class, 27), ZOMBIFIED_PIGLIN("zombified_piglin", PigZombie.class, 57), // End generate - EntityType diff --git a/paper-api/src/main/java/org/bukkit/entity/Minecart.java b/paper-api/src/main/java/org/bukkit/entity/Minecart.java index 0e4163c9358d..86980343461b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Minecart.java +++ b/paper-api/src/main/java/org/bukkit/entity/Minecart.java @@ -1,6 +1,6 @@ package org.bukkit.entity; -import org.bukkit.GameRule; +import org.bukkit.GameRules; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.material.MaterialData; @@ -37,7 +37,7 @@ public interface Minecart extends Vehicle, io.papermc.paper.entity.Frictional { /** * Sets the maximum speed of a minecart. Must be nonnegative. Default is - * 0.4D or {@link GameRule#MINECART_MAX_SPEED}. + * 0.4D or {@link GameRules#MAX_MINECART_SPEED}. * * @param speed The max speed */ diff --git a/paper-api/src/main/java/org/bukkit/entity/Nautilus.java b/paper-api/src/main/java/org/bukkit/entity/Nautilus.java new file mode 100644 index 000000000000..667a1230e7ef --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Nautilus.java @@ -0,0 +1,7 @@ +package org.bukkit.entity; + +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface Nautilus extends AbstractNautilus { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Parched.java b/paper-api/src/main/java/org/bukkit/entity/Parched.java new file mode 100644 index 000000000000..e7aba9f66b61 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Parched.java @@ -0,0 +1,8 @@ +package org.bukkit.entity; + +/** + * Represents a parched Skeleton. + */ +public interface Parched extends AbstractSkeleton { + +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java index 42e1f5141b8d..e738e87c81a2 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java +++ b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java @@ -74,6 +74,10 @@ public enum SkeletonType { /** * Bogged skeleton. */ - BOGGED; + BOGGED, + /** + * Parched skeleton. + */ + PARCHED; } } diff --git a/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java b/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java new file mode 100644 index 000000000000..a12db166d2aa --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/ZombieNautilus.java @@ -0,0 +1,41 @@ +package org.bukkit.entity; + +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface ZombieNautilus extends AbstractNautilus { + + /** + * Gets the variant of this zombie nautilus. + * + * @return the variant + */ + Variant getVariant(); + + /** + * Sets the variant of this zombie nautilus. + * + * @param variant the variant + */ + void setVariant(Variant variant); + + /** + * Represents the variant of a Zombie Nautilus. + */ + interface Variant extends Keyed { + + // Start generate - ZombieNautilusVariant + Variant TEMPERATE = getVariant("temperate"); + + Variant WARM = getVariant("warm"); + // End generate - ZombieNautilusVariant + + private static Variant getVariant(String key) { + return RegistryAccess.registryAccess().getRegistry(RegistryKey.ZOMBIE_NAUTILUS_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); + } + } +} diff --git a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java index db4e51bfc1de..dc5ebe7cb492 100644 --- a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java +++ b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java @@ -57,8 +57,12 @@ public Class getMemoryClass() { public static final MemoryKey ATTACK_COOLING_DOWN = new MemoryKey<>(NamespacedKey.minecraft("attack_cooling_down"), Boolean.class); + public static final MemoryKey ATTACK_TARGET_COOLDOWN = new MemoryKey<>(NamespacedKey.minecraft("attack_target_cooldown"), Integer.class); + public static final MemoryKey CANT_REACH_WALK_TARGET_SINCE = new MemoryKey<>(NamespacedKey.minecraft("cant_reach_walk_target_since"), Long.class); + public static final MemoryKey CHARGE_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("charge_cooldown_ticks"), Integer.class); + public static final MemoryKey DANCING = new MemoryKey<>(NamespacedKey.minecraft("dancing"), Boolean.class); public static final MemoryKey DANGER_DETECTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("danger_detected_recently"), Boolean.class); @@ -117,6 +121,10 @@ public Class getMemoryClass() { public static final MemoryKey SNIFFER_HAPPY = new MemoryKey<>(NamespacedKey.minecraft("sniffer_happy"), Boolean.class); + public static final MemoryKey SPEAR_ENGAGE_TIME = new MemoryKey<>(NamespacedKey.minecraft("spear_engage_time"), Integer.class); + + public static final MemoryKey SPEAR_FLEEING_TIME = new MemoryKey<>(NamespacedKey.minecraft("spear_fleeing_time"), Integer.class); + public static final MemoryKey TEMPTATION_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("temptation_cooldown_ticks"), Integer.class); public static final MemoryKey TIME_TRYING_TO_REACH_ADMIRE_ITEM = new MemoryKey<>(NamespacedKey.minecraft("time_trying_to_reach_admire_item"), Integer.class); diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java index 96444dac986a..11d5e8b21e5a 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java @@ -16,7 +16,7 @@ * an air block. {@link #getExplodedBlockState()} should be used to get * information about the block state that exploded. *

- * The event isn't called if the {@link org.bukkit.GameRule#MOB_GRIEFING} + * The event isn't called if the {@link org.bukkit.GameRules#MOB_GRIEFING} * is disabled as no block interaction will occur. */ public class BlockExplodeEvent extends BlockEvent implements Cancellable { 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 4fa6689f53bd..456ca29c92b6 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 @@ -476,7 +476,7 @@ public enum DamageCause { CAMPFIRE, /** * Damage caused when an entity is colliding with too many entities due - * to the {@link org.bukkit.GameRule#MAX_ENTITY_CRAMMING}. + * to the {@link org.bukkit.GameRules#MAX_ENTITY_CRAMMING}. *

* Damage: 6 */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java index fc59cdaac369..f02c1c2e0882 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java @@ -134,6 +134,12 @@ public enum ExhaustionReason { * Player regenerated health */ REGEN, + /** + * Player was affected by an enchantment + * @see Minecraft Wiki: Enchantment Effects "apply_exhaustion" + */ + // TODO - snapshot - In release check if this Wiki URL exists + ENCHANTMENT_EFFECT, /** * Unknown exhaustion reason */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java index 9a8f5f6dca26..84950b371521 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java @@ -12,7 +12,7 @@ /** * Called when an entity explodes interacting with blocks. The - * event isn't called if the {@link org.bukkit.GameRule#MOB_GRIEFING} + * event isn't called if the {@link org.bukkit.GameRules#MOB_GRIEFING} * is disabled as no block interaction will occur. */ public class EntityExplodeEvent extends EntityEvent implements Cancellable { 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 054a38983f85..61ff80a91c39 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 @@ -218,6 +218,10 @@ public enum Cause { * When all effects are removed due to a bucket of milk. */ MILK, + /** + * When the entity gets the effect from a nautilus. + */ + NAUTILUS, /** * When a player gets bad omen after killing a patrol captain. * diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java index 6316a2f1d2dc..78497c423eda 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -92,7 +92,7 @@ public Player getEntity() { /** * Get whether the death message should be shown. - * By default, this is determined by {@link org.bukkit.GameRule#SHOW_DEATH_MESSAGES}. + * By default, this is determined by {@link org.bukkit.GameRules#SHOW_DEATH_MESSAGES}. * * @return whether the death message should be shown * @see #deathMessage() @@ -104,7 +104,7 @@ public boolean getShowDeathMessages() { /** * Set whether the death message should be shown. - * By default, this is determined by {@link org.bukkit.GameRule#SHOW_DEATH_MESSAGES}. + * By default, this is determined by {@link org.bukkit.GameRules#SHOW_DEATH_MESSAGES}. * * @param displayDeathMessage whether the death message should be shown * @see #deathMessage() diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java index 7641225bf430..4c05faf07f3e 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java @@ -50,8 +50,8 @@ public final HumanEntity getPlayer() { * This is only the title sent to the client in the open packet, this doesn't change * the title returned by {@link InventoryView#title()}, hence "override". *

- * NOTE: Horse inventories are a special case where setting this will - * have no effect. Horse inventory titles are set by the horse display name. + * NOTE: Horse and nautilus inventories are a special case where setting this will + * have no effect. These inventory titles are set by the entity's display name. * * @param titleOverride the title override or {@code null} */ diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java index 628a1bbfae71..5a5d1ca16f9c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.player; -import org.bukkit.World; +import io.papermc.paper.block.bed.BedEnterAction; +import io.papermc.paper.block.bed.BedRuleResult; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -17,19 +18,15 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { private final Block bed; private final BedEnterResult bedEnterResult; + private final @NotNull BedEnterAction enterAction; private Result useBed = Result.DEFAULT; @ApiStatus.Internal - public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult) { + public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult, @NotNull BedEnterAction enterAction) { super(player); this.bed = bed; this.bedEnterResult = bedEnterResult; - } - - @ApiStatus.Internal - @Deprecated(since = "1.13.2", forRemoval = true) - public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed) { - this(player, bed, BedEnterResult.OK); + this.enterAction = enterAction; } /** @@ -46,17 +43,30 @@ public Block getBed() { * This describes the default outcome of this event. * * @return the bed enter result representing the default outcome of this event + * @deprecated This enum has been replaced with a system that better + * represents how beds work. See {@link #enterAction} */ @NotNull + @ApiStatus.Obsolete(since = "1.21.11") public BedEnterResult getBedEnterResult() { return this.bedEnterResult; } + /** + * This describes the default outcome of this event. + * + * @return the action representing the default outcome of this event + */ + @ApiStatus.Experimental + public @NotNull BedEnterAction enterAction() { + return this.enterAction; + } + /** * This controls the action to take with the bed that was clicked on. *

* In case of {@link Result#DEFAULT}, the default outcome is described by - * {@link #getBedEnterResult()}. + * {@link #enterAction()}. * * @return the action to take with the interacted bed * @see #setUseBed(Result) @@ -70,13 +80,13 @@ public Result useBed() { * Sets the action to take with the interacted bed. *

* {@link Result#ALLOW} will result in the player sleeping, regardless of - * the default outcome described by {@link #getBedEnterResult()}. + * the default outcome described by {@link #enterAction()}. *
* {@link Result#DENY} will prevent the player from sleeping. This has the * same effect as canceling the event via {@link #setCancelled(boolean)}. *
* {@link Result#DEFAULT} will result in the outcome described by - * {@link #getBedEnterResult()}. + * {@link #enterAction()}. * * @param useBed the action to take with the interacted bed * @see #useBed() @@ -94,13 +104,13 @@ public void setUseBed(@NotNull Result useBed) { *

* For backwards compatibility reasons this also returns {@code true} if * {@link #useBed()} is {@link Result#DEFAULT} and the - * {@link #getBedEnterResult() default action} is to prevent bed entering. + * {@link #enterAction() default action} is to prevent bed entering. * * @return boolean cancellation state */ @Override public boolean isCancelled() { - return this.useBed == Result.DENY || this.useBed == Result.DEFAULT && this.bedEnterResult != BedEnterResult.OK; + return this.useBed == Result.DENY || this.useBed == Result.DEFAULT && this.enterAction.canSleep() != BedRuleResult.ALLOWED; } /** @@ -126,19 +136,23 @@ public static HandlerList getHandlerList() { /** * Represents the default possible outcomes of this event. + * + * @deprecated Enums no longer represents reliably how beds work and fail. This has been + * replaced with {@link BedEnterAction} that better fits the new beds */ + @ApiStatus.Obsolete(since = "1.21.11") public enum BedEnterResult { /** * The player will enter the bed. */ OK, /** - * The world doesn't allow sleeping or saving the spawn point (eg, - * Nether, The End or Custom Worlds). This is based on - * {@link World#isBedWorks()} and {@link World#isNatural()}. + * The world doesn't allow sleeping (eg, Nether, The End or Custom Worlds), but + * saving the spawn point may still be allowed. See {@link com.destroystokyo.paper.event.player.PlayerSetSpawnEvent}. + * for spawn point changes. This is only called when sleeping isn't allowed and the bed + * doesn't explode. When the bed explodes, {@link #EXPLOSION} is called instead. *

- * Entering the bed is prevented and if {@link World#isBedWorks()} is - * {@code false} then the bed explodes. + * Entering the bed is prevented */ NOT_POSSIBLE_HERE, /** @@ -165,6 +179,10 @@ public enum BedEnterResult { /** * Entering the bed is prevented due to there being some other problem. */ - OTHER_PROBLEM; + OTHER_PROBLEM, + /** + * Entering the bed is prevented and the bed explodes. + */ + EXPLOSION; } } diff --git a/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java b/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java index 93c1158f8d2e..c0dd0c7ed6f8 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/AbstractHorseInventory.java @@ -6,20 +6,11 @@ /** * An interface to the inventory of an {@link AbstractHorse}. */ -public interface AbstractHorseInventory extends Inventory { +public interface AbstractHorseInventory extends SaddledMountInventory { - /** - * Gets the item in the horse's saddle slot. - * - * @return the saddle item - */ - @Nullable - ItemStack getSaddle(); + @Override + @Nullable ItemStack getSaddle(); - /** - * Sets the item in the horse's saddle slot. - * - * @param stack the new item - */ + @Override void setSaddle(@Nullable ItemStack stack); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java b/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java index 994f34ac2062..3fa6a2a544bb 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ArmoredHorseInventory.java @@ -4,19 +4,11 @@ import org.jspecify.annotations.Nullable; @NullMarked -public interface ArmoredHorseInventory extends AbstractHorseInventory { +public interface ArmoredHorseInventory extends AbstractHorseInventory, ArmoredSaddledMountInventory { - /** - * Gets the item in the horse's armor slot. - * - * @return the armor item - */ + @Override @Nullable ItemStack getArmor(); - /** - * Sets the item in the horse's armor slot. - * - * @param stack the new item - */ + @Override void setArmor(@Nullable ItemStack stack); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ArmoredMountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/ArmoredMountInventory.java new file mode 100644 index 000000000000..d3ae959533a2 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/ArmoredMountInventory.java @@ -0,0 +1,22 @@ +package org.bukkit.inventory; + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public interface ArmoredMountInventory extends MountInventory { + + /** + * Gets the item in the mount's armor slot. + * + * @return the armor item + */ + @Nullable ItemStack getArmor(); + + /** + * Sets the item in the mount's armor slot. + * + * @param stack the new item + */ + void setArmor(@Nullable ItemStack stack); +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/ArmoredSaddledMountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/ArmoredSaddledMountInventory.java new file mode 100644 index 000000000000..fd8295ebeab1 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/ArmoredSaddledMountInventory.java @@ -0,0 +1,4 @@ +package org.bukkit.inventory; + +public interface ArmoredSaddledMountInventory extends ArmoredMountInventory, SaddledMountInventory { +} 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 d90159f41648..297ae0047857 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java +++ b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java @@ -13,11 +13,11 @@ public enum EquipmentSlot { CHEST(() -> EquipmentSlotGroup.CHEST), HEAD(() -> EquipmentSlotGroup.HEAD), /** - * Only for certain entities such as horses, happy ghasts and wolves. + * Only for certain entities such as horses, wolves, happy ghasts and nautiluses. */ BODY(() -> EquipmentSlotGroup.BODY), /** - * Only for certain entities such as pigs, horses, striders and copper golems. + * Only for certain entities such as pigs, horses, striders, copper golems and nautiluses. */ SADDLE(() -> EquipmentSlotGroup.SADDLE); 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 cfcfd7d72ef1..228d11a6d2bb 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemType.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemType.java @@ -94,7 +94,6 @@ interface Typed extends ItemType { // // Start generate - ItemType - // @GeneratedFrom 25w34b ItemType.Typed ACACIA_BOAT = getItemType("acacia_boat"); ItemType.Typed ACACIA_BUTTON = getItemType("acacia_button"); @@ -483,6 +482,8 @@ interface Typed extends ItemType { ItemType.Typed CALIBRATED_SCULK_SENSOR = getItemType("calibrated_sculk_sensor"); + ItemType.Typed CAMEL_HUSK_SPAWN_EGG = getItemType("camel_husk_spawn_egg"); + ItemType.Typed CAMEL_SPAWN_EGG = getItemType("camel_spawn_egg"); ItemType.Typed CAMPFIRE = getItemType("campfire"); @@ -699,6 +700,8 @@ interface Typed extends ItemType { ItemType.Typed COPPER_LEGGINGS = getItemType("copper_leggings"); + ItemType.Typed COPPER_NAUTILUS_ARMOR = getItemType("copper_nautilus_armor"); + ItemType.Typed COPPER_NUGGET = getItemType("copper_nugget"); ItemType.Typed COPPER_ORE = getItemType("copper_ore"); @@ -707,6 +710,8 @@ interface Typed extends ItemType { ItemType.Typed COPPER_SHOVEL = getItemType("copper_shovel"); + ItemType.Typed COPPER_SPEAR = getItemType("copper_spear"); + ItemType.Typed COPPER_SWORD = getItemType("copper_sword"); ItemType.Typed COPPER_TORCH = getItemType("copper_torch"); @@ -963,12 +968,16 @@ interface Typed extends ItemType { ItemType.Typed DIAMOND_LEGGINGS = getItemType("diamond_leggings"); + ItemType.Typed DIAMOND_NAUTILUS_ARMOR = getItemType("diamond_nautilus_armor"); + ItemType.Typed DIAMOND_ORE = getItemType("diamond_ore"); ItemType.Typed DIAMOND_PICKAXE = getItemType("diamond_pickaxe"); ItemType.Typed DIAMOND_SHOVEL = getItemType("diamond_shovel"); + ItemType.Typed DIAMOND_SPEAR = getItemType("diamond_spear"); + ItemType.Typed DIAMOND_SWORD = getItemType("diamond_sword"); ItemType.Typed DIORITE = getItemType("diorite"); @@ -1217,10 +1226,14 @@ interface Typed extends ItemType { ItemType.Typed GOLDEN_LEGGINGS = getItemType("golden_leggings"); + ItemType.Typed GOLDEN_NAUTILUS_ARMOR = getItemType("golden_nautilus_armor"); + ItemType.Typed GOLDEN_PICKAXE = getItemType("golden_pickaxe"); ItemType.Typed GOLDEN_SHOVEL = getItemType("golden_shovel"); + ItemType.Typed GOLDEN_SPEAR = getItemType("golden_spear"); + ItemType.Typed GOLDEN_SWORD = getItemType("golden_sword"); ItemType.Typed GRANITE = getItemType("granite"); @@ -1373,10 +1386,10 @@ interface Typed extends ItemType { ItemType.Typed IRON_BLOCK = getItemType("iron_block"); - ItemType.Typed IRON_CHAIN = getItemType("iron_chain"); - ItemType.Typed IRON_BOOTS = getItemType("iron_boots"); + ItemType.Typed IRON_CHAIN = getItemType("iron_chain"); + ItemType.Typed IRON_CHESTPLATE = getItemType("iron_chestplate"); ItemType.Typed IRON_DOOR = getItemType("iron_door"); @@ -1393,6 +1406,8 @@ interface Typed extends ItemType { ItemType.Typed IRON_LEGGINGS = getItemType("iron_leggings"); + ItemType.Typed IRON_NAUTILUS_ARMOR = getItemType("iron_nautilus_armor"); + ItemType.Typed IRON_NUGGET = getItemType("iron_nugget"); ItemType.Typed IRON_ORE = getItemType("iron_ore"); @@ -1401,6 +1416,8 @@ interface Typed extends ItemType { ItemType.Typed IRON_SHOVEL = getItemType("iron_shovel"); + ItemType.Typed IRON_SPEAR = getItemType("iron_spear"); + ItemType.Typed IRON_SWORD = getItemType("iron_sword"); ItemType.Typed IRON_TRAPDOOR = getItemType("iron_trapdoor"); @@ -1785,6 +1802,8 @@ interface Typed extends ItemType { ItemType.Typed NAUTILUS_SHELL = getItemType("nautilus_shell"); + ItemType.Typed NAUTILUS_SPAWN_EGG = getItemType("nautilus_spawn_egg"); + ItemType.Typed NETHER_BRICK = getItemType("nether_brick"); ItemType.Typed NETHER_BRICK_FENCE = getItemType("nether_brick_fence"); @@ -1821,16 +1840,22 @@ interface Typed extends ItemType { ItemType.Typed NETHERITE_HOE = getItemType("netherite_hoe"); + ItemType.Typed NETHERITE_HORSE_ARMOR = getItemType("netherite_horse_armor"); + ItemType.Typed NETHERITE_INGOT = getItemType("netherite_ingot"); ItemType.Typed NETHERITE_LEGGINGS = getItemType("netherite_leggings"); + ItemType.Typed NETHERITE_NAUTILUS_ARMOR = getItemType("netherite_nautilus_armor"); + ItemType.Typed NETHERITE_PICKAXE = getItemType("netherite_pickaxe"); ItemType.Typed NETHERITE_SCRAP = getItemType("netherite_scrap"); ItemType.Typed NETHERITE_SHOVEL = getItemType("netherite_shovel"); + ItemType.Typed NETHERITE_SPEAR = getItemType("netherite_spear"); + ItemType.Typed NETHERITE_SWORD = getItemType("netherite_sword"); ItemType.Typed NETHERITE_UPGRADE_SMITHING_TEMPLATE = getItemType("netherite_upgrade_smithing_template"); @@ -2005,6 +2030,8 @@ interface Typed extends ItemType { ItemType.Typed PAPER = getItemType("paper"); + ItemType.Typed PARCHED_SPAWN_EGG = getItemType("parched_spawn_egg"); + ItemType.Typed PARROT_SPAWN_EGG = getItemType("parrot_spawn_egg"); ItemType.Typed PEARLESCENT_FROGLIGHT = getItemType("pearlescent_froglight"); @@ -2583,6 +2610,8 @@ interface Typed extends ItemType { ItemType.Typed STONE_SLAB = getItemType("stone_slab"); + ItemType.Typed STONE_SPEAR = getItemType("stone_spear"); + ItemType.Typed STONE_STAIRS = getItemType("stone_stairs"); ItemType.Typed STONE_SWORD = getItemType("stone_sword"); @@ -3023,6 +3052,8 @@ interface Typed extends ItemType { ItemType.Typed WOODEN_SHOVEL = getItemType("wooden_shovel"); + ItemType.Typed WOODEN_SPEAR = getItemType("wooden_spear"); + ItemType.Typed WOODEN_SWORD = getItemType("wooden_sword"); ItemType.Typed WRITABLE_BOOK = getItemType("writable_book"); @@ -3065,6 +3096,8 @@ interface Typed extends ItemType { ItemType.Typed ZOMBIE_HORSE_SPAWN_EGG = getItemType("zombie_horse_spawn_egg"); + ItemType.Typed ZOMBIE_NAUTILUS_SPAWN_EGG = getItemType("zombie_nautilus_spawn_egg"); + ItemType.Typed ZOMBIE_SPAWN_EGG = getItemType("zombie_spawn_egg"); ItemType.Typed ZOMBIE_VILLAGER_SPAWN_EGG = getItemType("zombie_villager_spawn_egg"); diff --git a/paper-api/src/main/java/org/bukkit/inventory/MountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/MountInventory.java new file mode 100644 index 000000000000..10ebabb9ff8c --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/MountInventory.java @@ -0,0 +1,7 @@ +package org.bukkit.inventory; + +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface MountInventory extends Inventory { +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/SaddledMountInventory.java b/paper-api/src/main/java/org/bukkit/inventory/SaddledMountInventory.java new file mode 100644 index 000000000000..eb883bc01bd5 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/SaddledMountInventory.java @@ -0,0 +1,22 @@ +package org.bukkit.inventory; + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public interface SaddledMountInventory extends MountInventory { + + /** + * Gets the item in the mount's saddle slot. + * + * @return the saddle item + */ + @Nullable ItemStack getSaddle(); + + /** + * Sets the item in the mount's saddle slot. + * + * @param stack the new item + */ + void setSaddle(@Nullable ItemStack stack); +} diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java index 463093fc0c48..eddda8e149b8 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -220,6 +220,11 @@ public abstract class PotionEffectType implements Keyed, Translatable, net.kyori */ public static final PotionEffectType INFESTED = getPotionEffectType(39, "infested"); + /** + * Prevent the oxygen bar from depleting underwater. + */ + public static final PotionEffectType BREATH_OF_THE_NAUTILUS = getPotionEffectType(40, "breath_of_the_nautilus"); + @NotNull private static PotionEffectType getPotionEffectType(int typeId, @NotNull String key) { PotionEffectType potionEffectType = Registry.EFFECT.getOrThrow(NamespacedKey.minecraft(key)); diff --git a/paper-api/src/test/java/org/bukkit/EffectTest.java b/paper-api/src/test/java/org/bukkit/EffectTest.java deleted file mode 100644 index 615a4583ef8e..000000000000 --- a/paper-api/src/test/java/org/bukkit/EffectTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.bukkit; - -import static org.bukkit.support.MatcherAssert.*; -import static org.hamcrest.CoreMatchers.*; -import org.junit.jupiter.api.Test; - -public class EffectTest { - private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper - - @Test - public void getById() { - for (Effect effect : Effect.values()) { - if (!isDeprecated(effect)) // Paper - assertThat(Effect.getById(effect.getId()), is(effect)); - } - } - - // Paper start - private static boolean isDeprecated(Effect effect) { - try { - return Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class); - } catch (NoSuchFieldException e) { - LOGGER.error("Error getting effect enum field {}", effect.name(), e); - return false; - } - } - // Paper end -} diff --git a/paper-generator/build.gradle.kts b/paper-generator/build.gradle.kts index b520750adb69..d305a18dc35e 100644 --- a/paper-generator/build.gradle.kts +++ b/paper-generator/build.gradle.kts @@ -23,10 +23,10 @@ dependencies { implementation("io.papermc.typewriter:typewriter:1.0.1") { isTransitive = false // paper-api already have everything } - implementation("info.picocli:picocli:4.7.6") - implementation("io.github.classgraph:classgraph:4.8.47") - implementation("org.jetbrains:annotations:26.0.1") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") + implementation("info.picocli:picocli:4.7.7") + implementation("io.github.classgraph:classgraph:4.8.179") + implementation("org.jetbrains:annotations:26.0.2") + testImplementation("org.junit.jupiter:junit-jupiter:5.12.2") testRuntimeOnly("org.junit.platform:junit-platform-launcher") serverRuntimeClasspath(project(":paper-server", "runtimeConfiguration")) diff --git a/paper-generator/src/main/java/io/papermc/generator/Generators.java b/paper-generator/src/main/java/io/papermc/generator/Generators.java index ae7353b5b400..a2152b4a3423 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Generators.java +++ b/paper-generator/src/main/java/io/papermc/generator/Generators.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import net.minecraft.Util; +import net.minecraft.util.Util; import org.jspecify.annotations.NullMarked; @NullMarked diff --git a/paper-generator/src/main/java/io/papermc/generator/Main.java b/paper-generator/src/main/java/io/papermc/generator/Main.java index 0b5564a7cc66..3a1ab1537111 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Main.java +++ b/paper-generator/src/main/java/io/papermc/generator/Main.java @@ -17,14 +17,14 @@ import java.util.function.Consumer; import java.util.stream.Stream; import net.minecraft.SharedConstants; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.commands.Commands; import net.minecraft.core.HolderLookup; import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.RegistryDataLoader; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.Bootstrap; import net.minecraft.server.MinecraftServer; import net.minecraft.server.RegistryLayer; @@ -34,6 +34,7 @@ import net.minecraft.server.packs.repository.ServerPacksSource; import net.minecraft.server.packs.resources.CloseableResourceManager; import net.minecraft.server.packs.resources.MultiPackResourceManager; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.tags.TagKey; import net.minecraft.tags.TagLoader; import net.minecraft.world.flag.FeatureFlagSet; @@ -78,7 +79,7 @@ public static CompletableFuture bootStrap(boolean withTags) { PackRepository packRepository = ServerPacksSource.createVanillaTrustedRepository(); FeatureFlagSet flags = FeatureFlags.REGISTRY.allFlags(); - MinecraftServer.configurePackRepository(packRepository, new WorldDataConfiguration(new DataPackConfig(FeatureFlags.REGISTRY.toNames(flags).stream().map(ResourceLocation::getPath).toList(), List.of()), flags), true, false); + MinecraftServer.configurePackRepository(packRepository, new WorldDataConfiguration(new DataPackConfig(FeatureFlags.REGISTRY.toNames(flags).stream().map(Identifier::getPath).toList(), List.of()), flags), true, false); CloseableResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, packRepository.openAllSelected()); LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); @@ -97,7 +98,7 @@ public static CompletableFuture bootStrap(boolean withTags) { pendingTags, flags, Commands.CommandSelection.DEDICATED, - Commands.LEVEL_GAMEMASTERS, + LevelBasedPermissionSet.GAMEMASTER, Util.backgroundExecutor(), Runnable::run ).whenComplete((result, ex) -> { 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 38e81b3a7831..6a337d533bff 100644 --- a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -23,6 +23,7 @@ import io.papermc.generator.rewriter.types.simple.trial.VillagerProfessionRewriter; import io.papermc.generator.types.goal.MobGoalNames; import io.papermc.generator.utils.Formatting; +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.world.WeatheringCopperState; @@ -36,16 +37,19 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.server.level.ParticleStatus; import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.player.ChatVisiblity; import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.SwingAnimationType; import net.minecraft.world.level.block.WeatheringCopper; import org.bukkit.Art; import org.bukkit.FeatureFlag; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRules; import org.bukkit.JukeboxSong; import org.bukkit.Material; import org.bukkit.MusicInstrument; @@ -73,6 +77,7 @@ import org.bukkit.entity.TropicalFish; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.entity.memory.MemoryKey; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; @@ -121,18 +126,18 @@ protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.scores.DisplayS } }) .register("SnifferState", Sniffer.State.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.sniffer.Sniffer.State.class)) - .register("PandaGene", Panda.Gene.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Panda.Gene.class) { + .register("PandaGene", Panda.Gene.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.panda.Panda.Gene.class) { @Override - protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.Panda.Gene gene) { + protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.panda.Panda.Gene gene) { return super.rewriteEnumValue(gene).argument(String.valueOf(gene.isRecessive())); } }) .register("CookingBookCategory", CookingBookCategory.class, new EnumCloneRewriter<>(net.minecraft.world.item.crafting.CookingBookCategory.class)) .register("CraftingBookCategory", CraftingBookCategory.class, new EnumCloneRewriter<>(net.minecraft.world.item.crafting.CraftingBookCategory.class)) - .register("TropicalFishPattern", TropicalFish.Pattern.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.TropicalFish.Pattern.class)) - .register("BoatStatus", Boat.Status.class, new EnumCloneRewriter<>(net.minecraft.world.entity.vehicle.Boat.Status.class)) - .register("FoxType", Fox.Type.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Fox.Variant.class)) - .register("SalmonVariant", Salmon.Variant.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Salmon.Variant.class)) + .register("TropicalFishPattern", TropicalFish.Pattern.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.fish.TropicalFish.Pattern.class)) + .register("BoatStatus", Boat.Status.class, new EnumCloneRewriter<>(net.minecraft.world.entity.vehicle.boat.Boat.Status.class)) + .register("FoxType", Fox.Type.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.fox.Fox.Variant.class)) + .register("SalmonVariant", Salmon.Variant.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.fish.Salmon.Variant.class)) .register("ArmadilloState", Armadillo.State.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState.class)) .register("SoundCategory", SoundCategory.class, new EnumCloneRewriter<>(SoundSource.class)) .register("AttributeSentiment", Attribute.Sentiment.class, new EnumCloneRewriter<>(net.minecraft.world.entity.ai.attributes.Attribute.Sentiment.class)) @@ -141,17 +146,18 @@ protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.P holder("ChatVisibility", ClientOption.ChatVisibility.class, new EnumCloneRewriter<>(ChatVisiblity.class) { @Override protected EnumValue.Builder rewriteEnumValue(ChatVisiblity visibility) { - return super.rewriteEnumValue(visibility).argument(quoted(visibility.getKey())); + return super.rewriteEnumValue(visibility).argument(quoted(((TranslatableContents) visibility.caption().getContents()).getKey())); } }.reachEnd(false)), holder("ParticleVisibility", ClientOption.ParticleVisibility.class, new EnumCloneRewriter<>(ParticleStatus.class) { @Override protected EnumValue.Builder rewriteEnumValue(ParticleStatus status) { - return super.rewriteEnumValue(status).argument(quoted(status.getKey())); + return super.rewriteEnumValue(status).argument(quoted(((TranslatableContents) status.caption().getContents()).getKey())); } }) )) .register("ItemUseAnimation", ItemUseAnimation.class, new EnumCloneRewriter<>(net.minecraft.world.item.ItemUseAnimation.class)) + .register("SwingAnimationType", SwingAnimation.Animation.class, new EnumCloneRewriter<>(SwingAnimationType.class)) .register("ItemRarity", ItemRarity.class, new EnumCloneRewriter<>(Rarity.class) { @Override protected EnumValue.Builder rewriteEnumValue(Rarity rarity) { @@ -185,6 +191,14 @@ protected String rewriteFieldName(Holder.Reference(Registries.GAME_RULE, "getRule") { + @Override + protected String rewriteFieldType(Holder.Reference> reference) { + return "%s<%s>".formatted( + this.registryEntry.apiClass().getSimpleName(), this.importCollector.getShortName(reference.value().valueClass()) + ); + } + }) .register("DamageTypeTags", DamageTypeTags.class, new RegistryTagRewriter<>(Registries.DAMAGE_TYPE, DamageType.class)) .register("MapCursorType", MapCursor.Type.class, new RegistryFieldRewriter<>(Registries.MAP_DECORATION_TYPE, "getType")) .register("Structure", Structure.class, new RegistryFieldRewriter<>(Registries.STRUCTURE, "getStructure")) @@ -207,6 +221,7 @@ protected String rewriteFieldName(Holder.Reference(Registries.CHICKEN_VARIANT, "getVariant")) .register("CowVariant", Cow.Variant.class, new RegistryFieldRewriter<>(Registries.COW_VARIANT, "getVariant")) .register("PigVariant", Pig.Variant.class, new RegistryFieldRewriter<>(Registries.PIG_VARIANT, "getVariant")) + .register("ZombieNautilusVariant", ZombieNautilus.Variant.class, new RegistryFieldRewriter<>(Registries.ZOMBIE_NAUTILUS_VARIANT, "getVariant")) .register("Dialog", Dialog.class, new RegistryFieldRewriter<>(Registries.DIALOG, "getDialog")) .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 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 a4e46283c758..0a9f1e9a68f7 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.PigVariantRegistryEntry; import io.papermc.paper.registry.data.SoundEventRegistryEntry; import io.papermc.paper.registry.data.WolfVariantRegistryEntry; +import io.papermc.paper.registry.data.ZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.DialogRegistryEntry; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -42,16 +43,17 @@ import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.memory.MemoryModuleType; -import net.minecraft.world.entity.animal.CatVariants; -import net.minecraft.world.entity.animal.ChickenVariants; -import net.minecraft.world.entity.animal.CowVariants; -import net.minecraft.world.entity.animal.PigVariants; +import net.minecraft.world.entity.animal.feline.CatVariants; +import net.minecraft.world.entity.animal.chicken.ChickenVariants; +import net.minecraft.world.entity.animal.cow.CowVariants; +import net.minecraft.world.entity.animal.pig.PigVariants; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariants; import net.minecraft.world.entity.animal.frog.FrogVariants; import net.minecraft.world.entity.animal.wolf.WolfSoundVariants; import net.minecraft.world.entity.animal.wolf.WolfVariants; -import net.minecraft.world.entity.decoration.PaintingVariants; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.world.entity.decoration.painting.PaintingVariants; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerType; import net.minecraft.world.item.Instruments; import net.minecraft.world.item.Items; import net.minecraft.world.item.JukeboxSongs; @@ -62,12 +64,14 @@ import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BannerPatterns; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.levelgen.structure.BuiltinStructures; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.saveddata.maps.MapDecorationTypes; import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.Keyed; import org.bukkit.MusicInstrument; @@ -87,6 +91,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.entity.memory.MemoryKey; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; @@ -164,7 +169,8 @@ private static RegistryEntry inconsistentEntry(ResourceKey> DATA_DRIVEN = List.of( @@ -185,6 +191,7 @@ private static RegistryEntry inconsistentEntry(ResourceKey> getValues() { @Override protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { - EnumValue.Builder value = EnumValue.builder(Formatting.formatKeyAsField(reference.key().location().getPath())); + EnumValue.Builder value = EnumValue.builder(Formatting.formatKeyAsField(reference.key().identifier().getPath())); if (this.hasKeyArgument) { - value.argument(quoted(reference.key().location().getPath())); + value.argument(quoted(reference.key().identifier().getPath())); } return value; } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java index ede08c4a00fa..8447a56bebd8 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java @@ -7,7 +7,7 @@ import io.papermc.typewriter.replace.SearchReplaceRewriter; import java.util.Iterator; import java.util.Map; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureFlag; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -37,10 +37,10 @@ public boolean registerFor(SourceFile file) { @Override protected void insert(SearchMetadata metadata, StringBuilder builder) { - Iterator> flagIterator = FeatureFlags.REGISTRY.names.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().getPath())).iterator(); + Iterator> flagIterator = FeatureFlags.REGISTRY.names.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().getPath())).iterator(); while (flagIterator.hasNext()) { - Map.Entry entry = flagIterator.next(); - ResourceLocation name = entry.getKey(); + Map.Entry entry = flagIterator.next(); + Identifier name = entry.getKey(); if (FeatureFlags.isExperimental(FeatureFlagSet.of(entry.getValue()))) { builder.append(metadata.indent()).append(annotation(ApiStatus.Experimental.class, this.importCollector)).append('\n'); } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java index 06287f65a0c8..8f21f8306b6e 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java @@ -4,7 +4,7 @@ import io.papermc.typewriter.replace.SearchMetadata; import io.papermc.typewriter.replace.SearchReplaceRewriter; import java.util.Iterator; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureFlags; import org.bukkit.FeatureFlag; import org.jspecify.annotations.NullMarked; @@ -14,10 +14,10 @@ public class PaperFeatureFlagMapping extends SearchReplaceRewriter { @Override protected void insert(SearchMetadata metadata, StringBuilder builder) { - Iterator flagIterator = FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags()).stream().sorted(Formatting.alphabeticKeyOrder(ResourceLocation::getPath)).iterator(); + Iterator flagIterator = FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags()).stream().sorted(Formatting.alphabeticKeyOrder(Identifier::getPath)).iterator(); while (flagIterator.hasNext()) { - ResourceLocation name = flagIterator.next(); + Identifier name = flagIterator.next(); String keyedName = Formatting.formatKeyAsField(name.getPath()); builder.append(metadata.indent()); builder.append("%s.%s, %s.%s".formatted(FeatureFlag.class.getSimpleName(), keyedName, FeatureFlags.class.getSimpleName(), keyedName)); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java index 599356eba752..0ebef90e86ef 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java @@ -30,7 +30,7 @@ private void appendEntry(String indent, StringBuilder builder, RegistryEntry if (apiOnly) { builder.append("apiOnly("); if (entry.apiClass().isEnum()) { - builder.append(this.importCollector.getShortName(Types.PAPER_SIMPLE_REGISTRY)).append("::").append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.registryKey().location().getPath())); + builder.append(this.importCollector.getShortName(Types.PAPER_SIMPLE_REGISTRY)).append("::").append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.registryKey().identifier().getPath())); } else { builder.append("() -> "); builder.append(Registry.class.getCanonicalName()).append('.').append(entry.apiRegistryField().orElse(entry.registryKeyField())); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java index bce5e9e254ff..c258717d961e 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java @@ -118,11 +118,11 @@ protected String rewriteFieldType(Holder.Reference reference) { } protected String rewriteFieldName(Holder.Reference reference) { - return Formatting.formatKeyAsField(reference.key().location().getPath()); + return Formatting.formatKeyAsField(reference.key().identifier().getPath()); } protected String rewriteFieldValue(Holder.Reference reference) { - return "%s(%s)".formatted(this.fetchMethod, quoted(reference.key().location().getPath())); + return "%s(%s)".formatted(this.fetchMethod, quoted(reference.key().identifier().getPath())); } protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { 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 2fd4d0c69fdd..4b3f2abf9b4e 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 @@ -10,10 +10,10 @@ public class CraftBlockEntityStateMapping extends SearchReplaceRewriter { @Override protected void insert(SearchMetadata metadata, StringBuilder builder) { - BlockEntityMapping.MAPPING.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().location().getPath())).forEach(entry -> { + 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().location().getPath()), + BlockEntityType.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/CraftPotionUtilRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java index df57fadbc810..08e8a84de610 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java @@ -5,7 +5,7 @@ import io.papermc.typewriter.replace.SearchReplaceRewriter; import java.util.Locale; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.potion.PotionType; @Deprecated(forRemoval = true) @@ -22,7 +22,7 @@ protected void insert(SearchMetadata metadata, StringBuilder builder) { String upperStatePrefix = this.statePrefix.toUpperCase(Locale.ENGLISH); BuiltInRegistries.POTION.keySet().stream() .filter(key -> BuiltInRegistries.POTION.containsKey(key.withPath(path -> this.statePrefix + "_" + path))) - .sorted(Formatting.alphabeticKeyOrder(ResourceLocation::getPath)).forEach(key -> { + .sorted(Formatting.alphabeticKeyOrder(Identifier::getPath)).forEach(key -> { String keyedName = Formatting.formatKeyAsField(key.getPath()); builder.append(metadata.indent()); builder.append(".put(%s.%s, %s.%s_%s)".formatted(PotionType.class.getSimpleName(), keyedName, PotionType.class.getSimpleName(), upperStatePrefix, keyedName)); 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 dd4994fd369d..3b8785d64dee 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 @@ -15,7 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; @@ -150,7 +150,7 @@ public EntityTypeRewriter() { @Override protected EnumValue.Builder rewriteEnumValue(Holder.Reference> reference) { - String path = reference.key().location().getPath(); + String path = reference.key().identifier().getPath(); List arguments = new ArrayList<>(4); arguments.add(quoted(path)); arguments.add(toBukkitClass(reference).concat(".class")); @@ -168,9 +168,9 @@ private String toBukkitClass(Holder.Reference> reference) { return this.importCollector.getShortName(MobGoalNames.BUKKIT_BRIDGE.get((Class) internalClass)); } - String className = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, reference.key().location().getPath()); // use the key instead of the internal class name since name match a bit more + String className = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, reference.key().identifier().getPath()); // use the key instead of the internal class name since name match a bit more ClassNamed resolvedClass = this.classNamedView.tryFindFirst(CLASS_RENAMES.getOrDefault(className, className)) - .orElseThrow(() -> new IllegalStateException("Could not find entity class for " + reference.key().location())) + .orElseThrow(() -> new IllegalStateException("Could not find entity class for " + reference.key().identifier())) .resolve(runtime); Preconditions.checkArgument(org.bukkit.entity.Entity.class.isAssignableFrom(resolvedClass.knownClass()), "Generic type must be an entity"); return this.importCollector.getShortName(this.classNamedView.findFirst(CLASS_RENAMES.getOrDefault(className, className)).resolve(runtime)); diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java index 764fa4a50623..98b079f4d057 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java @@ -39,7 +39,7 @@ protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) if (BlockStateMapping.MAPPING.containsKey(block.getClass())) { // some block can also be represented as item in that enum // doing a double job - Optional equivalentItem = BuiltInRegistries.ITEM.getOptional(reference.key().location()); + Optional equivalentItem = BuiltInRegistries.ITEM.getOptional(reference.key().identifier()); if (equivalentItem.isEmpty() && block instanceof WallSignBlock) { // wall sign block stack size is 16 for some reason like the sign item? @@ -84,7 +84,7 @@ public Items() { @Override protected Iterable> getValues() { - return BuiltInRegistries.ITEM.listElements().filter(reference -> BuiltInRegistries.BLOCK.getOptional(reference.key().location()).isEmpty() || reference.value().equals(net.minecraft.world.item.Items.AIR)) + return BuiltInRegistries.ITEM.listElements().filter(reference -> BuiltInRegistries.BLOCK.getOptional(reference.key().identifier()).isEmpty() || reference.value().equals(net.minecraft.world.item.Items.AIR)) .sorted(Formatting.HOLDER_ORDER)::iterator; } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java index 92e20b37509c..265c6f432e18 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java @@ -16,6 +16,7 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ai.behavior.PositionTracker; +import net.minecraft.world.entity.ai.behavior.SpearAttack; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities; import net.minecraft.world.entity.ai.memory.WalkTarget; @@ -46,6 +47,7 @@ public MemoryKeyRewriter() { NearestVisibleLivingEntities.class, WalkTarget.class, PositionTracker.class, + SpearAttack.SpearStatus.class, Path.class, DamageSource.class, Vec3.class, @@ -109,8 +111,8 @@ protected String rewriteFieldValue(Holder.Reference> referen return "new %s<>(%s.minecraft(%s), %s.class)".formatted( this.registryEntry.apiClass().getSimpleName(), NamespacedKey.class.getSimpleName(), - quoted(reference.key().location().getPath()), - this.apiMemoryType.getSimpleName() // assume the type is already import (see above in rewriteFieldType) + quoted(reference.key().identifier().getPath()), + io.papermc.typewriter.util.ClassHelper.retrieveFullNestedName(this.apiMemoryType) // assume the type is already imported (see above in rewriteFieldType) ); } } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java index f082536d4668..fa2b6d42a38c 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java @@ -9,7 +9,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.stats.StatType; import net.minecraft.stats.Stats; import net.minecraft.world.entity.EntityType; @@ -57,19 +57,19 @@ public class StatisticRewriter { .put("OPEN_SHULKER_BOX", "SHULKER_BOX_OPENED") .buildOrThrow(); - public static class Custom extends EnumRegistryRewriter { + public static class Custom extends EnumRegistryRewriter { public Custom() { super(Registries.CUSTOM_STAT, false); } @Override - protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { return super.rewriteEnumValue(reference).rename(name -> FIELD_RENAMES.getOrDefault(name, name)); } } - public static class CraftCustom extends EnumRegistryRewriter { + public static class CraftCustom extends EnumRegistryRewriter { private static final Map INTERNAL_FIELD_RENAMES = Map.of( "SNEAK_TIME", "CROUCH_TIME" @@ -80,8 +80,8 @@ public CraftCustom() { } @Override - protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { - String keyedName = Formatting.formatKeyAsField(reference.key().location().getPath()); + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + String keyedName = Formatting.formatKeyAsField(reference.key().identifier().getPath()); return super.rewriteEnumValue(reference) .rename(name -> FIELD_RENAMES.getOrDefault(name, name)) @@ -137,7 +137,7 @@ protected Iterable>> getValues() { protected EnumValue.Builder rewriteEnumValue(Holder.Reference> reference) { return super.rewriteEnumValue(reference) .rename(name -> FIELD_RENAMES.getOrDefault(name, name)) - .argument("%s.withDefaultNamespace(%s)".formatted(ResourceLocation.class.getSimpleName(), quoted(reference.key().location().getPath()))); + .argument("%s.withDefaultNamespace(%s)".formatted(Identifier.class.getSimpleName(), quoted(reference.key().identifier().getPath()))); } } } 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 52884792aa78..e23548e36c9c 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 @@ -15,7 +15,7 @@ import java.util.function.Predicate; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerProfession; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public class VillagerProfessionRewriter extends RegistryFieldRewriter { 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 474c4fa3963f..77f75a900573 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 @@ -15,7 +15,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.monster.RangedAttackMob; import org.apache.commons.lang3.math.NumberUtils; @@ -34,94 +34,94 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class); map.put(net.minecraft.world.entity.animal.Animal.class, Animals.class); map.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class); - map.put(net.minecraft.world.entity.animal.Bee.class, Bee.class); + map.put(net.minecraft.world.entity.animal.bee.Bee.class, Bee.class); map.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class); - map.put(net.minecraft.world.entity.animal.Cat.class, Cat.class); - map.put(net.minecraft.world.entity.monster.CaveSpider.class, CaveSpider.class); - map.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class); - map.put(net.minecraft.world.entity.animal.Cod.class, Cod.class); - map.put(net.minecraft.world.entity.animal.Cow.class, Cow.class); + map.put(net.minecraft.world.entity.animal.feline.Cat.class, Cat.class); + map.put(net.minecraft.world.entity.monster.spider.CaveSpider.class, CaveSpider.class); + map.put(net.minecraft.world.entity.animal.chicken.Chicken.class, Chicken.class); + map.put(net.minecraft.world.entity.animal.fish.Cod.class, Cod.class); + map.put(net.minecraft.world.entity.animal.cow.Cow.class, Cow.class); map.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class); map.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class); - map.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class); - map.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class); + map.put(net.minecraft.world.entity.animal.dolphin.Dolphin.class, Dolphin.class); + map.put(net.minecraft.world.entity.monster.zombie.Drowned.class, Drowned.class); map.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class); map.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class); map.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class); - map.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class); - map.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class); - map.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class); - map.put(net.minecraft.world.entity.animal.Fox.class, Fox.class); + map.put(net.minecraft.world.entity.monster.illager.Evoker.class, Evoker.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractFish.class, Fish.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractSchoolingFish.class, SchoolableFish.class); + map.put(net.minecraft.world.entity.animal.fox.Fox.class, Fox.class); map.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class); map.put(net.minecraft.world.entity.monster.Giant.class, Giant.class); - map.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class); + map.put(net.minecraft.world.entity.animal.golem.AbstractGolem.class, Golem.class); map.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class); map.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class); - map.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class); - map.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class); - map.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class); - map.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class); - map.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Horse.class, Horse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractHorse.class, AbstractHorse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractChestedHorse.class, ChestedHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Donkey.class, Donkey.class); + map.put(net.minecraft.world.entity.animal.equine.Mule.class, Mule.class); + map.put(net.minecraft.world.entity.animal.equine.SkeletonHorse.class, SkeletonHorse.class); + map.put(net.minecraft.world.entity.animal.equine.ZombieHorse.class, ZombieHorse.class); map.put(net.minecraft.world.entity.animal.camel.Camel.class, org.bukkit.entity.Camel.class); - map.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class); - map.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class); - map.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class); - map.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class); - map.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class); - map.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class); + map.put(net.minecraft.world.entity.monster.illager.AbstractIllager.class, Illager.class); + map.put(net.minecraft.world.entity.monster.illager.Illusioner.class, Illusioner.class); + map.put(net.minecraft.world.entity.monster.illager.SpellcasterIllager.class, Spellcaster.class); + 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.Monster.class, Monster.class); map.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); // close enough - map.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class); - map.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class); - map.put(net.minecraft.world.entity.animal.Panda.class, Panda.class); - map.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class); - map.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class); // close enough + map.put(net.minecraft.world.entity.animal.cow.MushroomCow.class, MushroomCow.class); + map.put(net.minecraft.world.entity.animal.feline.Ocelot.class, Ocelot.class); + map.put(net.minecraft.world.entity.animal.panda.Panda.class, Panda.class); + map.put(net.minecraft.world.entity.animal.parrot.Parrot.class, Parrot.class); + map.put(net.minecraft.world.entity.animal.parrot.ShoulderRidingEntity.class, Parrot.class); // close enough map.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class); - map.put(net.minecraft.world.entity.animal.Pig.class, Pig.class); - map.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class); - map.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class); - map.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class); - map.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class); - map.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class); + map.put(net.minecraft.world.entity.animal.pig.Pig.class, Pig.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombifiedPiglin.class, PigZombie.class); + map.put(net.minecraft.world.entity.monster.illager.Pillager.class, Pillager.class); + map.put(net.minecraft.world.entity.animal.polarbear.PolarBear.class, PolarBear.class); + map.put(net.minecraft.world.entity.animal.fish.Pufferfish.class, PufferFish.class); + map.put(net.minecraft.world.entity.animal.rabbit.Rabbit.class, Rabbit.class); map.put(net.minecraft.world.entity.raid.Raider.class, Raider.class); map.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class); - map.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class); + map.put(net.minecraft.world.entity.animal.fish.Salmon.class, Salmon.class); map.put(net.minecraft.world.entity.animal.sheep.Sheep.class, Sheep.class); map.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class); map.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class); - map.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class); - map.put(net.minecraft.world.entity.monster.AbstractSkeleton.class, AbstractSkeleton.class); - map.put(net.minecraft.world.entity.monster.Stray.class, Stray.class); - map.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.Skeleton.class, Skeleton.class); + 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.animal.SnowGolem.class, Snowman.class); - map.put(net.minecraft.world.entity.monster.Spider.class, Spider.class); - map.put(net.minecraft.world.entity.animal.Squid.class, Squid.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); map.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class); - map.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class); - map.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class); + map.put(net.minecraft.world.entity.animal.fish.TropicalFish.class, TropicalFish.class); + map.put(net.minecraft.world.entity.animal.turtle.Turtle.class, Turtle.class); map.put(net.minecraft.world.entity.monster.Vex.class, Vex.class); - map.put(net.minecraft.world.entity.npc.Villager.class, Villager.class); - map.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class); - map.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class); - map.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class); - map.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class); + map.put(net.minecraft.world.entity.npc.villager.Villager.class, Villager.class); + map.put(net.minecraft.world.entity.npc.villager.AbstractVillager.class, AbstractVillager.class); + map.put(net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader.class, WanderingTrader.class); + map.put(net.minecraft.world.entity.monster.illager.Vindicator.class, Vindicator.class); + map.put(net.minecraft.world.entity.animal.fish.WaterAnimal.class, WaterMob.class); map.put(net.minecraft.world.entity.monster.Witch.class, Witch.class); map.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class); map.put(net.minecraft.world.entity.animal.wolf.Wolf.class, Wolf.class); - map.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class); - map.put(net.minecraft.world.entity.monster.Husk.class, Husk.class); - map.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class); + map.put(net.minecraft.world.entity.monster.zombie.Zombie.class, Zombie.class); + map.put(net.minecraft.world.entity.monster.zombie.Husk.class, Husk.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombieVillager.class, ZombieVillager.class); map.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class); map.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class); map.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class); map.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class); map.put(net.minecraft.world.entity.monster.Strider.class, Strider.class); map.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class); - map.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class); + map.put(net.minecraft.world.entity.animal.squid.GlowSquid.class, GlowSquid.class); map.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class); map.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class); map.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class); @@ -131,12 +131,17 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s map.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class); map.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class); map.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class); - map.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class); + map.put(net.minecraft.world.entity.monster.skeleton.Bogged.class, Bogged.class); map.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class); map.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class); // close enough - map.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); - map.put(net.minecraft.world.entity.animal.HappyGhast.class, HappyGhast.class); - map.put(net.minecraft.world.entity.animal.coppergolem.CopperGolem.class, org.bukkit.entity.CopperGolem.class); + map.put(net.minecraft.world.entity.animal.cow.AbstractCow.class, AbstractCow.class); + map.put(net.minecraft.world.entity.animal.happyghast.HappyGhast.class, HappyGhast.class); + map.put(net.minecraft.world.entity.animal.golem.CopperGolem.class, org.bukkit.entity.CopperGolem.class); + map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, org.bukkit.entity.AbstractNautilus.class); + map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, org.bukkit.entity.Nautilus.class); + 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); // }); diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java index 6aeb4c897911..a69ac7e3afad 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java @@ -62,7 +62,7 @@ private MethodSpec.Builder createMethod(TypeName returnType) { .addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, this.entry.registryKeyField(), keyParam) .returns(returnType); if (publicCreateKeyMethod) { - create.addJavadoc(Javadocs.CREATE_TYPED_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().location().toString()); + create.addJavadoc(Javadocs.CREATE_TYPED_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().identifier().toString()); } return create; } @@ -98,7 +98,7 @@ protected TypeSpec getTypeSpec() { boolean allExperimental = true; for (Holder.Reference reference : this.entry.registry().listElements().sorted(Formatting.HOLDER_ORDER).toList()) { ResourceKey key = reference.key(); - String keyPath = key.location().getPath(); + String keyPath = key.identifier().getPath(); String fieldName = Formatting.formatKeyAsField(keyPath); if (!SourceVersion.isIdentifier(fieldName) && this.entry.getFieldNames().containsKey(key)) { fieldName = this.entry.getFieldNames().get(key); @@ -106,7 +106,7 @@ protected TypeSpec getTypeSpec() { FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKeyType, fieldName, PUBLIC, STATIC, FINAL) .initializer("$N(key($S))", createMethod.build(), keyPath) - .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString()); + .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.identifier().toString()); SingleFlagHolder requiredFeature = this.getRequiredFeature(reference); if (requiredFeature != null) { diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java index 10bef7f38de6..1d8810710c81 100644 --- a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java @@ -50,7 +50,7 @@ private MethodSpec.Builder createMethod(TypeName returnType) { .addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, this.entry.registryKeyField(), keyParam) .returns(returnType); if (publicCreateKeyMethod) { - create.addJavadoc(Javadocs.CREATED_TAG_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().location().toString()); + create.addJavadoc(Javadocs.CREATED_TAG_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().identifier().toString()); } return create; } diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java b/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java index d8d7d0f56ab9..7637c8cf866b 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java @@ -26,7 +26,7 @@ public final class BlockEntityMapping { static { Map>, String> mapping = new IdentityHashMap<>(); BuiltInRegistries.BLOCK_ENTITY_TYPE.registryKeySet().forEach(key -> { - String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, key.location().getPath()); + String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, key.identifier().getPath()); String implName = "Craft".concat(name); mapping.put(key, RENAMES.getOrDefault(implName, implName)); diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java b/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java index 7009304f573d..4178e5c83053 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java @@ -75,7 +75,7 @@ public static String stripWordOfCamelCaseName(String name, String word, boolean return newName; } - public static final Comparator> HOLDER_ORDER = alphabeticKeyOrder(reference -> reference.key().location().getPath()); + public static final Comparator> HOLDER_ORDER = alphabeticKeyOrder(reference -> reference.key().identifier().getPath()); public static final Comparator> TAG_ORDER = alphabeticKeyOrder(tagKey -> tagKey.location().getPath()); public static Comparator alphabeticKeyOrder(Function pathConverter) { diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java index 1472ebb5949b..41da83548651 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java @@ -3,7 +3,7 @@ import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.flag.FeatureFlag; import net.minecraft.world.flag.FeatureFlags; import org.bukkit.MinecraftExperimental; diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java index 497805310fe1..9312547b4609 100644 --- a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java @@ -4,7 +4,7 @@ import com.google.common.collect.HashBiMap; import java.util.HashMap; import java.util.Map; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureFlag; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -15,7 +15,7 @@ public record SingleFlagHolder(FeatureFlag flag) implements FlagHolder { // todo support multiple flags? private static final Map FEATURE_FLAG_CACHE = new HashMap<>(); - private static final Map FEATURE_FLAG_NAME = HashBiMap.create(FeatureFlags.REGISTRY.names).inverse(); + private static final Map FEATURE_FLAG_NAME = HashBiMap.create(FeatureFlags.REGISTRY.names).inverse(); static SingleFlagHolder fromValue(FeatureFlag flag) { return new SingleFlagHolder(flag); @@ -35,7 +35,7 @@ public static SingleFlagHolder fromSet(FeatureFlagSet standaloneSet) { public static SingleFlagHolder fromName(String name) { return fromValue(FEATURE_FLAG_CACHE.computeIfAbsent(name, key -> { - return FeatureFlags.REGISTRY.names.get(ResourceLocation.withDefaultNamespace(key)); + return FeatureFlags.REGISTRY.names.get(Identifier.withDefaultNamespace(key)); })); } diff --git a/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java b/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java index 61a2648438e9..defb55285dc5 100644 --- a/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java +++ b/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java @@ -27,7 +27,7 @@ public void testBuiltInToDataDriven() { Set migratedRegistries = new HashSet<>(); for (RegistryEntry entry : RegistryEntries.BUILT_IN) { ResourceKey> key = entry.registryKey(); - if (!BuiltInRegistries.REGISTRY.containsKey(key.location())) { + if (!BuiltInRegistries.REGISTRY.containsKey(key.identifier())) { migratedRegistries.add(key.toString()); } } @@ -40,7 +40,7 @@ public void testDataDrivenToBuiltIn() { // shouldn't really happen but just in c Set migratedRegistries = new HashSet<>(); for (RegistryEntry entry : RegistryEntries.DATA_DRIVEN) { ResourceKey> key = entry.registryKey(); - if (BuiltInRegistries.REGISTRY.containsKey(key.location())) { + if (BuiltInRegistries.REGISTRY.containsKey(key.identifier())) { migratedRegistries.add(key.toString()); } } diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index 7405e4959c9d..3319d83929ce 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -14,9 +14,8 @@ plugins { val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:1.21.10+build.9") + mache("io.papermc:mache:1.21.11-pre3+build.3") paperclip("io.papermc:paperclip:3.0.3") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } paperweight { @@ -24,7 +23,7 @@ paperweight { gitFilePatches = false spigot { - enabled = true + enabled = false buildDataRef = "42d18d4c4653ffc549778dbe223f6994a031d69e" packageVersion = "v1_21_R6" // also needs to be updated in MappingEnvironment } @@ -40,6 +39,10 @@ paperweight { "org.bukkit.craftbukkit", "org.spigotmc", ) + + updatingMinecraft { + // oldPaperCommit = "c82b438b5b4ea0b230439b8e690e34708cd11ab3" + } } tasks.generateDevelopmentBundle { @@ -50,30 +53,27 @@ tasks.generateDevelopmentBundle { } abstract class Services { - @get:Inject - abstract val softwareComponentFactory: SoftwareComponentFactory - @get:Inject abstract val archiveOperations: ArchiveOperations } val services = objects.newInstance() if (project.providers.gradleProperty("publishDevBundle").isPresent) { - val devBundleComponent = services.softwareComponentFactory.adhoc("devBundle") + val devBundleComponent = publishing.softwareComponentFactory.adhoc("devBundle") components.add(devBundleComponent) val devBundle = configurations.consumable("devBundle") { attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.ZIP)) outgoing.artifact(tasks.generateDevelopmentBundle.flatMap { it.devBundleFile }) } - devBundleComponent.addVariantsFromConfiguration(devBundle.get()) {} + devBundleComponent.addVariantsFromConfiguration(devBundle) {} val runtime = configurations.consumable("serverRuntimeClasspath") { attributes.attribute(DevBundleOutput.ATTRIBUTE, objects.named(DevBundleOutput.SERVER_DEPENDENCIES)) attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) extendsFrom(configurations.runtimeClasspath.get()) } - devBundleComponent.addVariantsFromConfiguration(runtime.get()) { + devBundleComponent.addVariantsFromConfiguration(runtime) { mapToMavenScope("runtime") } @@ -82,7 +82,7 @@ if (project.providers.gradleProperty("publishDevBundle").isPresent) { attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_API)) extendsFrom(configurations.compileClasspath.get()) } - devBundleComponent.addVariantsFromConfiguration(compile.get()) { + devBundleComponent.addVariantsFromConfiguration(compile) { mapToMavenScope("compile") } @@ -163,6 +163,7 @@ dependencies { } testImplementation("io.github.classgraph:classgraph:4.8.179") // For mob goal test + testRuntimeOnly("org.junit.platform:junit-platform-launcher") testImplementation("org.junit.jupiter:junit-jupiter:5.12.2") testImplementation("org.junit.platform:junit-platform-suite-engine:1.12.2") testImplementation("org.hamcrest:hamcrest:2.2") @@ -361,7 +362,7 @@ fill { version(paperweight.minecraftVersion) build { - channel = BuildChannel.STABLE + channel = BuildChannel.ALPHA downloads { register("server:default") { 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/0017-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch similarity index 100% rename from paper-server/patches/features/0017-Improve-exact-choice-recipe-ingredients.patch rename to paper-server/patches/features-unapplied/0017-Improve-exact-choice-recipe-ingredients.patch diff --git a/paper-server/patches/features/0031-DataConverter-Fixes.patch b/paper-server/patches/features-unapplied/0031-DataConverter-Fixes.patch similarity index 100% rename from paper-server/patches/features/0031-DataConverter-Fixes.patch rename to paper-server/patches/features-unapplied/0031-DataConverter-Fixes.patch diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index bb3b428fc387..8286ae41fe15 100644 --- a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -297,7 +297,7 @@ index 0000000000000000000000000000000000000000..1b8193587814225c2ef2c5d9e667436e + } +} diff --git a/ca/spottedleaf/moonrise/paper/PaperHooks.java b/ca/spottedleaf/moonrise/paper/PaperHooks.java -index e4f0653c575c33b1ef8160b6c88e29ee9fb44508..05b65330c1566e7e0045ea87e2111e8ff04b2333 100644 +index c50f13c735c97b0418cfe97d7d99b74bfb08b842..a91bcda9d6d8c8d75bce45373944743c55a1b4a5 100644 --- a/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/ca/spottedleaf/moonrise/paper/PaperHooks.java @@ -13,6 +13,7 @@ import net.minecraft.server.level.ChunkHolder; @@ -306,7 +306,7 @@ index e4f0653c575c33b1ef8160b6c88e29ee9fb44508..05b65330c1566e7e0045ea87e2111e8f import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.TicketType; import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.boss.EnderDragonPart; + import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import net.minecraft.world.level.BlockGetter; @@ -150,7 +151,15 @@ public final class PaperHooks extends BaseChunkSystemHooks implements PlatformHo @@ -334,13 +334,6 @@ index e4f0653c575c33b1ef8160b6c88e29ee9fb44508..05b65330c1566e7e0045ea87e2111e8f } } -@@ -252,4 +261,4 @@ public final class PaperHooks extends BaseChunkSystemHooks implements PlatformHo - public boolean addTicketForEnderPearls(final ServerLevel world) { - return !world.paperConfig().misc.legacyEnderPearlBehavior; - } --} -\ No newline at end of file -+} diff --git a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java index ce81e9f4f1e80be3b4f0cbdd95609990f9006534..3e7b616cbd196f56393719e84c7118ab47308337 100644 --- a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java @@ -1120,7 +1113,7 @@ index 0000000000000000000000000000000000000000..f77ba1b6aaedf6c8c1e0c49ff2779eb4 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/entity/ChunkSystemEntity.java b/ca/spottedleaf/moonrise/patches/chunk_system/entity/ChunkSystemEntity.java new file mode 100644 -index 0000000000000000000000000000000000000000..1d2498e33b9cd5a22cb348a213be3d75281b6d24 +index 0000000000000000000000000000000000000000..c351a80c5c47f3f5148dec93219e1a7ee22e9056 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/entity/ChunkSystemEntity.java @@ -0,0 +1,45 @@ @@ -1129,10 +1122,10 @@ index 0000000000000000000000000000000000000000..1d2498e33b9cd5a22cb348a213be3d75 +import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData; +import net.minecraft.server.level.FullChunkStatus; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.animal.HappyGhast; ++import net.minecraft.world.entity.animal.happyghast.HappyGhast; +import net.minecraft.world.entity.monster.Shulker; -+import net.minecraft.world.entity.vehicle.AbstractMinecart; -+import net.minecraft.world.entity.vehicle.Boat; ++import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; ++import net.minecraft.world.entity.vehicle.boat.Boat; + +public interface ChunkSystemEntity { + @@ -2703,24 +2696,22 @@ index 0000000000000000000000000000000000000000..344e155420de9148cd402f626af11d4c +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/ChunkDataController.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/ChunkDataController.java new file mode 100644 -index 0000000000000000000000000000000000000000..a36ab89f5c37f5f9ab0152f087bb4cf3560f8581 +index 0000000000000000000000000000000000000000..633e85bf7824fec10c81b2a64756a7ef756cd481 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/ChunkDataController.java -@@ -0,0 +1,50 @@ +@@ -0,0 +1,48 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller; + +import ca.spottedleaf.moonrise.patches.chunk_system.io.ChunkSystemRegionFileStorage; +import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO; +import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemChunkMap; +import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler; -+import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemChunkStorage; ++import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemSimpleRegionStorage; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.storage.RegionFileStorage; +import java.io.IOException; -+import java.util.concurrent.CompletableFuture; -+import java.util.concurrent.CompletionException; + +public final class ChunkDataController extends MoonriseRegionFileIO.RegionDataController { + @@ -2733,7 +2724,7 @@ index 0000000000000000000000000000000000000000..a36ab89f5c37f5f9ab0152f087bb4cf3 + + @Override + public RegionFileStorage getCache() { -+ return ((ChunkSystemChunkStorage)this.world.getChunkSource().chunkMap).moonrise$getRegionStorage(); ++ return ((ChunkSystemSimpleRegionStorage)this.world.getChunkSource().chunkMap).moonrise$getRegionStorage(); + } + + @Override @@ -3164,7 +3155,7 @@ index 0000000000000000000000000000000000000000..59cbbf65c9df5c680b803f6dd6436a35 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java new file mode 100644 -index 0000000000000000000000000000000000000000..c380487a97f626163e1f13d87231d64ce2ea4b24 +index 0000000000000000000000000000000000000000..c2363cfa5e93942fe837efd9f39478698f6d1a98 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java @@ -0,0 +1,591 @@ @@ -3189,7 +3180,7 @@ index 0000000000000000000000000000000000000000..c380487a97f626163e1f13d87231d64c +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityType; -+import net.minecraft.world.entity.boss.EnderDragonPart; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; @@ -5027,7 +5018,7 @@ index 0000000000000000000000000000000000000000..2ff58cf753c60913ee73aae015182e9c +} 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 new file mode 100644 -index 0000000000000000000000000000000000000000..a2fbc13105673e926cbaed69221826ebd392140f +index 0000000000000000000000000000000000000000..2bc436cdf5180a7943c45fabb9fbbedae6f7db56 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java @@ -0,0 +1,166 @@ @@ -5047,7 +5038,7 @@ index 0000000000000000000000000000000000000000..a2fbc13105673e926cbaed69221826eb +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.TicketType; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.projectile.ThrownEnderpearl; ++import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; +import net.minecraft.world.level.entity.LevelCallback; + +public final class ServerEntityLookup extends EntityLookup { @@ -5490,7 +5481,7 @@ index 0000000000000000000000000000000000000000..003a857e70ead858e8437e3c1bfaf22f +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java new file mode 100644 -index 0000000000000000000000000000000000000000..8697528095ebed543ee1bb3b6b617a26a800bd5d +index 0000000000000000000000000000000000000000..7129c5e1920008ac54f3a8ac83f5589396f4e4e9 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java @@ -0,0 +1,1093 @@ @@ -5529,10 +5520,10 @@ index 0000000000000000000000000000000000000000..8697528095ebed543ee1bb3b6b617a26 +import net.minecraft.server.level.TicketType; +import net.minecraft.server.network.PlayerChunkSender; +import net.minecraft.world.level.ChunkPos; -+import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; ++import net.minecraft.world.level.gamerules.GameRules; +import net.minecraft.world.level.levelgen.BelowZeroRetrogen; +import java.lang.invoke.VarHandle; +import java.util.ArrayDeque; @@ -6055,7 +6046,7 @@ index 0000000000000000000000000000000000000000..8697528095ebed543ee1bb3b6b617a26 + } + + private boolean canPlayerGenerateChunks() { -+ return !this.player.isSpectator() || this.world.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS); ++ return !this.player.isSpectator() || this.world.getGameRules().get(GameRules.SPECTATORS_GENERATE_CHUNKS); + } + + private double getMaxChunkLoadRate() { @@ -13171,7 +13162,7 @@ index 0000000000000000000000000000000000000000..4538ccfaea83d217ed85eaf16e82393c +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkLoadTask.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkLoadTask.java new file mode 100644 -index 0000000000000000000000000000000000000000..d1d68bacc86e4a4e785e3180b9aeb766c025eccb +index 0000000000000000000000000000000000000000..7463cf5bf871033a0e5f6d54dd0d427c474d7cd4 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkLoadTask.java @@ -0,0 +1,494 @@ @@ -13517,7 +13508,7 @@ index 0000000000000000000000000000000000000000..d1d68bacc86e4a4e785e3180b9aeb766 + + try { + // run converters -+ final CompoundTag converted = this.world.getChunkSource().chunkMap.upgradeChunkTag(data, new ChunkPos(this.chunkX, this.chunkZ)); // Paper ++ final CompoundTag converted = this.world.getChunkSource().chunkMap.upgradeChunkTag(data); + + // unpack the data + final SerializableChunkData chunkData = SerializableChunkData.parse( @@ -14729,21 +14720,6 @@ index 0000000000000000000000000000000000000000..51c126735ace8fdde89ad97b5cab62f2 + + public void moonrise$write(final RegionFile regionFile) throws IOException; +} -diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkStorage.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkStorage.java -new file mode 100644 -index 0000000000000000000000000000000000000000..129a35ff2db5b3bb6736810fc180796ce55e1875 ---- /dev/null -+++ b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkStorage.java -@@ -0,0 +1,9 @@ -+package ca.spottedleaf.moonrise.patches.chunk_system.storage; -+ -+import net.minecraft.world.level.chunk.storage.RegionFileStorage; -+ -+public interface ChunkSystemChunkStorage { -+ -+ public RegionFileStorage moonrise$getRegionStorage(); -+ -+} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemRegionFile.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemRegionFile.java new file mode 100644 index 0000000000000000000000000000000000000000..3bd1b59250dbab15097a64d515999b278636795a @@ -14762,6 +14738,21 @@ index 0000000000000000000000000000000000000000..3bd1b59250dbab15097a64d515999b27 + public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(final CompoundTag data, final ChunkPos pos) throws IOException; + +} +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemSimpleRegionStorage.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemSimpleRegionStorage.java +new file mode 100644 +index 0000000000000000000000000000000000000000..76a480dea1cfe1cf118c1a0b10ca5c5718917420 +--- /dev/null ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemSimpleRegionStorage.java +@@ -0,0 +1,9 @@ ++package ca.spottedleaf.moonrise.patches.chunk_system.storage; ++ ++import net.minecraft.world.level.chunk.storage.RegionFileStorage; ++ ++public interface ChunkSystemSimpleRegionStorage { ++ ++ public RegionFileStorage moonrise$getRegionStorage(); ++ ++} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicket.java b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicket.java new file mode 100644 index 0000000000000000000000000000000000000000..4536f675a8496c3b1681278cf56453a21d656cfe @@ -15623,7 +15614,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..2082b7506a403ed6815076cbd0d3b7eecd7225a0 +index 0000000000000000000000000000000000000000..817e4ffd597938697f0c4dca16068f8d20c088b3 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -0,0 +1,2190 @@ @@ -15643,7 +15634,7 @@ index 0000000000000000000000000000000000000000..2082b7506a403ed6815076cbd0d3b7ee +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.vehicle.AbstractMinecart; ++import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.CollisionGetter; +import net.minecraft.world.level.Level; @@ -22265,7 +22256,7 @@ index 0000000000000000000000000000000000000000..95154636727366adfb4fb67e7db8b09f + private SaveUtil() {} +} diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 6f97231787dd422d2462135b11092aa6339332ac..045778402404d46610165d15d8d430d6ae968688 100644 +index 61c526263cfbd1871f6b8548ed4431a76ee95a31..485413cb6b20c4bd20fbc29a0db43c051993fe79 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -1,6 +1,9 @@ @@ -22471,7 +22462,7 @@ index 6f97231787dd422d2462135b11092aa6339332ac..045778402404d46610165d15d8d430d6 } public static java.util.concurrent.Executor getWorldgenExecutor() { -- return net.minecraft.Util.backgroundExecutor(); +- return net.minecraft.util.Util.backgroundExecutor(); + return Runnable::run; // Paper - rewrite chunk system } @@ -22490,8 +22481,9 @@ index 6f97231787dd422d2462135b11092aa6339332ac..045778402404d46610165d15d8d430d6 + ((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..2dca7afbd93cfbb8686f336fcd3b45dd01fba0fc @@ -22914,12 +22906,12 @@ index 0000000000000000000000000000000000000000..8424cf9d4617b4732d44cc460d25b044 + +} diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java -index f8d2e0f2e21668dd34bd61455b34c0b2b818ddb1..cbb743ce94f08b624a64555d057ed04286094ba9 100644 +index 3a5aad2acd2a7ac1f0fc3c33f1705c5d737cb10c..9926682586fda91017e3e1ab079296a8c4a88879 100644 --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java -@@ -29,7 +29,7 @@ import org.joml.Quaternionf; - import org.joml.Vector3f; +@@ -29,7 +29,7 @@ import org.joml.Vector3f; import org.joml.Vector3fc; + import org.jspecify.annotations.Nullable; -public enum Direction implements StringRepresentable { +public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.patches.collisions.util.CollisionDirection { // Paper - optimise collisions @@ -23004,7 +22996,7 @@ index f8d2e0f2e21668dd34bd61455b34c0b2b818ddb1..cbb743ce94f08b624a64555d057ed042 } public Direction getClockWise(Direction.Axis axis) { -@@ -633,4 +672,17 @@ public enum Direction implements StringRepresentable { +@@ -629,4 +668,17 @@ public enum Direction implements StringRepresentable { return this.faces.length; } } @@ -23023,10 +23015,10 @@ index f8d2e0f2e21668dd34bd61455b34c0b2b818ddb1..cbb743ce94f08b624a64555d057ed042 + // Paper end - optimise collisions } diff --git a/net/minecraft/core/MappedRegistry.java b/net/minecraft/core/MappedRegistry.java -index 737f61ba5ff7752e94f3c8316f823db60e35bc3f..1610198bd96e0d79debdeddc360500e98cd28504 100644 +index fd09226af661a6970062ee11d38f6e69464fb74b..ad1558693564ebd18f5e16b85ae552d2af95efef 100644 --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -57,6 +57,19 @@ public class MappedRegistry implements WritableRegistry { +@@ -56,6 +56,19 @@ public class MappedRegistry implements WritableRegistry { return this.getTags(); } @@ -23046,32 +23038,32 @@ index 737f61ba5ff7752e94f3c8316f823db60e35bc3f..1610198bd96e0d79debdeddc360500e9 public MappedRegistry(ResourceKey> key, Lifecycle registryLifecycle) { this(key, registryLifecycle, false); } -@@ -122,6 +135,7 @@ public class MappedRegistry implements WritableRegistry { +@@ -121,6 +134,7 @@ public class MappedRegistry implements WritableRegistry { this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); - this.temporaryUnfrozenMap.put(key.location(), value); // Paper - support pre-filling in registry mod API + this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API + this.injectFluidRegister(key, value); // Paper - fluid method optimisations return reference; } } diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index 13424bce076493f146bdc5fd0b1f2e09805bd5e7..2de7072c8ccc005e514673bba494b64d42e95a15 100644 +index cda915fcb4822689f42b25280eb99aee082ddb74..094d2d528cb74b8f1d277cd780bba7f438dbe764 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -301,6 +301,7 @@ public class Main { +@@ -299,6 +299,7 @@ public class Main { levelStorageAccess.saveDataTag(frozen, worldData); */ -+ Class.forName(net.minecraft.world.entity.npc.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async ++ Class.forName(net.minecraft.world.entity.npc.villager.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async final DedicatedServer dedicatedServer = MinecraftServer.spin( thread1 -> { DedicatedServer dedicatedServer1 = new DedicatedServer( diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index ab95014e66a7e217024ad9845669cc77fbbb13c2..40730d5775ed81bd715960b2c7dd710ca11dcb0e 100644 +index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3cb4037ede 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -177,7 +177,7 @@ import net.minecraft.world.phys.Vec2; - import net.minecraft.world.phys.Vec3; +@@ -185,7 +185,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, ChunkIOErrorReporter { @@ -23079,7 +23071,7 @@ index ab95014e66a7e217024ad9845669cc77fbbb13c2..40730d5775ed81bd715960b2c7dd710c 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 -@@ -393,6 +393,93 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); -+ // Paper start - rewrite chunk system -+ final Throwable crash = this.chunkSystemCrash; -+ if (crash != null) { -+ this.chunkSystemCrash = null; -+ throw new RuntimeException("Chunk system crash propagated to tick()", crash); -+ } -+ // Paper end - rewrite chunk system - this.tickFrame.end(); - this.recordEndOfTick(); // Paper - improve tick loop - profilerFiller.popPush("nextTickWait"); -@@ -1399,6 +1514,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); ++ // Paper start - rewrite chunk system ++ final Throwable crash = this.chunkSystemCrash; ++ if (crash != null) { ++ this.chunkSystemCrash = null; ++ throw new RuntimeException("Chunk system crash propagated to tick()", crash); ++ } ++ // Paper end - rewrite chunk system + this.tickFrame.end(); + this.recordEndOfTick(); // Paper - improve tick loop + profilerFiller.pop(); +@@ -2559,6 +2678,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> getTickingChunkFuture() { @@ -23536,8 +23523,7 @@ index b95de132c53f82d270de396787dda3be8bc6c910..656041c9539b6834b4d37b353eb6b810 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - public final LevelChunk getTickingChunk() { // Paper - final for inline + public final @Nullable LevelChunk getTickingChunk() { // Paper - final for inline - return this.getTickingChunkFuture().getNow(UNLOADED_LEVEL_CHUNK).orElse(null); + // Paper start - rewrite chunk system + if (this.newChunkHolder.isTickingReady()) { @@ -23549,8 +23535,7 @@ index b95de132c53f82d270de396787dda3be8bc6c910..656041c9539b6834b4d37b353eb6b810 + // Paper end - rewrite chunk system } - @Nullable - public LevelChunk getChunkToSend() { + public @Nullable LevelChunk getChunkToSend() { - return !this.sendSync.isDone() ? null : this.getTickingChunk(); + // Paper start - rewrite chunk system + final LevelChunk ret = this.moonrise$getFullChunk(); @@ -23833,34 +23818,32 @@ index b95de132c53f82d270de396787dda3be8bc6c910..656041c9539b6834b4d37b353eb6b810 @FunctionalInterface diff --git a/net/minecraft/server/level/ChunkLevel.java b/net/minecraft/server/level/ChunkLevel.java -index e823b8aac00158892538083bc877ccf99895909a..7d871318065f19540748363809de82652613e733 100644 +index 3a6fb3b46d94e23357be8af241340e3de06b7c7c..a5ce3593e92e6771f3c8df23ba1bf4d7872c9304 100644 --- a/net/minecraft/server/level/ChunkLevel.java +++ b/net/minecraft/server/level/ChunkLevel.java -@@ -7,8 +7,8 @@ import net.minecraft.world.level.chunk.status.ChunkStep; - import org.jetbrains.annotations.Contract; +@@ -8,7 +8,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 FULL_CHUNK_LEVEL = 33; + 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 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d4f31d69a 100644 +index 8519ad77190ef51acdd940794faf73e292169c63..b0b4e5c96498eef48fe0cb2637faed73409941ad 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -102,7 +102,7 @@ import net.minecraft.world.phys.Vec3; - import org.apache.commons.lang3.mutable.MutableBoolean; +@@ -108,7 +108,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; --public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap { -+public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemChunkMap { // Paper - rewrite chunk system +-public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap { ++public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerProvider, GeneratingChunkMap, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemChunkMap { // Paper - rewrite chunk system private static final ChunkResult> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range"); private static final CompletableFuture>> UNLOADED_CHUNK_LIST_FUTURE = CompletableFuture.completedFuture( UNLOADED_CHUNK_LIST_RESULT -@@ -118,10 +118,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -124,10 +124,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP public static final int MIN_VIEW_DISTANCE = 2; public static final int MAX_VIEW_DISTANCE = 32; public static final int FORCED_TICKET_LEVEL = ChunkLevel.byStatus(FullChunkStatus.ENTITY_TICKING); @@ -23872,7 +23855,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d public final ServerLevel level; private final ThreadedLevelLightEngine lightEngine; private final BlockableEventLoop mainThreadExecutor; -@@ -132,20 +129,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -137,20 +134,16 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP private final PoiManager poiManager; public final LongSet toDrop = new LongOpenHashSet(); private boolean modified; @@ -23896,7 +23879,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() public final CallbackExecutor callbackExecutor = new CallbackExecutor(); -@@ -170,9 +163,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -175,9 +168,16 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP // Paper start public final ChunkHolder getUnloadingChunkHolder(int chunkX, int chunkZ) { @@ -23908,13 +23891,13 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + @Override + public final void moonrise$writeFinishCallback(final ChunkPos pos) throws IOException { + // see ChunkStorage#write -+ this.handleLegacyStructureIndex(pos); ++ this.markChunkDone(pos); + } + // Paper end - rewrite chunk system public ChunkMap( ServerLevel level, -@@ -217,10 +217,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -224,10 +224,9 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP ConsecutiveExecutor consecutiveExecutor = new ConsecutiveExecutor(dispatcher, "worldgen"); this.chunkStatusListener = chunkStatusListener; ConsecutiveExecutor consecutiveExecutor1 = new ConsecutiveExecutor(dispatcher, "light"); @@ -23926,8 +23909,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + lightChunk, this, this.level.dimensionType().hasSkyLight(), consecutiveExecutor1, null // Paper - rewrite chunk system ); this.distanceManager = new ChunkMap.DistanceManager(ticketStorage, dispatcher, mainThreadExecutor); - this.overworldDataStorage = overworldDataStorage; -@@ -235,11 +234,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + this.ticketStorage = ticketStorage; +@@ -241,11 +240,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP level ); this.setServerViewDistance(serverViewDistance); @@ -23941,7 +23924,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } // Paper start -@@ -261,23 +260,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -267,23 +266,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public boolean isChunkTracked(ServerPlayer player, int x, int z) { @@ -23967,10 +23950,10 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } protected ThreadedLevelLightEngine getLightEngine() { -@@ -286,12 +273,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -291,11 +278,17 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + } - @Nullable - public ChunkHolder getUpdatingChunkIfPresent(long chunkPos) { + public @Nullable ChunkHolder getUpdatingChunkIfPresent(long chunkPos) { - return this.updatingChunkMap.get(chunkPos); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos); @@ -23978,8 +23961,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + // Paper end - rewrite chunk system } - @Nullable - public ChunkHolder getVisibleChunkIfPresent(long chunkPos) { + public @Nullable ChunkHolder getVisibleChunkIfPresent(long chunkPos) { - return this.visibleChunkMap.get(chunkPos); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos); @@ -23987,8 +23969,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + // Paper end - rewrite chunk system } - @Nullable -@@ -301,12 +294,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + public @Nullable ChunkStatus getLatestStatus(long chunkPos) { +@@ -304,12 +297,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } protected IntSupplier getChunkQueueLevel(long chunkPos) { @@ -24002,7 +23984,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } public String getChunkDebugData(ChunkPos pos) { -@@ -332,47 +320,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -335,47 +323,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } CompletableFuture>> getChunkRangeFuture(ChunkHolder chunkHolder, int range, IntFunction statusGetter) { @@ -24051,7 +24033,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } public ReportedException debugFuturesAndCreateReportedException(IllegalStateException exception, String details) { -@@ -404,93 +352,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -407,92 +355,28 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public CompletableFuture> prepareEntityTickingChunk(ChunkHolder chunk) { @@ -24060,8 +24042,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel) { + @Nullable ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel) { - if (!ChunkLevel.isLoaded(oldLevel) && !ChunkLevel.isLoaded(newLevel)) { - return holder; - } else { @@ -24137,7 +24118,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d - - this.poiManager.flushAll(); - this.processUnloads(() -> true); -- this.flushWorker(); +- this.synchronize(true).join(); - } else { - this.nextChunkSaveTime.clear(); - long millis = Util.getMillis(); @@ -24154,7 +24135,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } protected void tick(BooleanSupplier hasMoreTime) { -@@ -506,129 +390,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -508,129 +392,28 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public boolean hasWork() { @@ -24291,7 +24272,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } private ChunkAccess handleChunkLoadFailure(Throwable exception, ChunkPos chunkPos) { -@@ -666,230 +449,129 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -665,230 +448,134 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP @Override public GenerationChunkHolder acquireGeneration(long chunkPos) { @@ -24548,8 +24529,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d private static void dropChunk(ServerPlayer player, ChunkPos chunkPos) { - player.connection.chunkSender.dropChunk(player, chunkPos); + // Paper - rewrite chunk system - } - ++ } ++ + // Paper start - rewrite chunk system + @Override + public CompletableFuture> read(final ChunkPos pos) { @@ -24576,25 +24557,33 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionFileType.CHUNK_DATA + ); + return null; -+ } -+ + } + + @Override -+ public void flushWorker() { -+ ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.flush(this.level); ++ public CompletableFuture synchronize(boolean flush) { ++ try { ++ ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.flush(this.level); ++ return CompletableFuture.completedFuture(null); ++ } catch (final Exception ex) { ++ return CompletableFuture.failedFuture(ex); ++ } + } + // Paper end - rewrite chunk system + - @Nullable - public LevelChunk getChunkToSend(long chunkPos) { + public @Nullable LevelChunk getChunkToSend(long chunkPos) { ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(chunkPos); -@@ -971,28 +653,71 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + return visibleChunkIfPresent == null ? null : visibleChunkIfPresent.getChunkToSend(); +@@ -968,7 +655,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + return this.read(pos).thenApplyAsync(optional -> optional.map(this::upgradeChunkTag), Util.backgroundExecutor().forName("upgradeChunk")); } - // CraftBukkit start -- private CompoundTag upgradeChunkTag(CompoundTag tag, ChunkPos pos) { -+ public CompoundTag upgradeChunkTag(CompoundTag tag, ChunkPos pos) { // Paper - public - return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, tag, this.generator().getTypeNameForDataFixer(), pos, this.level); - // CraftBukkit end +- private CompoundTag upgradeChunkTag(CompoundTag tag) { ++ public CompoundTag upgradeChunkTag(CompoundTag tag) { // Paper - rewrite chunk system - public + return this.upgradeChunkTag(tag, -1, getChunkDataFixContextTag(this.level.getTypeKey(), this.generator().getTypeNameForDataFixer()), this.level); // CraftBukkit + } + +@@ -979,23 +666,66 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP + return compoundTag; } + // Paper start - optimise chunk tick iteration @@ -24669,7 +24658,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d if (chunkHolder != null) { LevelChunk tickingChunk = chunkHolder.getTickingChunk(); if (tickingChunk != null) { -@@ -1008,8 +733,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1011,8 +741,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos, boolean reducedRange) { @@ -24680,7 +24669,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d // Spigot end } -@@ -1021,7 +746,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1036,7 +766,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkPos, boolean reducedRange) { double blockRange; // Paper - use from event // Spigot end @@ -24702,7 +24691,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d // Paper start - PlayerNaturallySpawnCreaturesEvent com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event; blockRange = 16384.0D; -@@ -1037,26 +775,41 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1052,26 +795,41 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } return false; @@ -24755,7 +24744,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d if (player.isSpectator()) { return false; } else { -@@ -1085,18 +838,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1109,18 +867,20 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.updatePlayerPos(player); if (!flag) { this.distanceManager.addPlayer(SectionPos.of(player), player); @@ -24778,7 +24767,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } } -@@ -1106,13 +861,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1130,13 +890,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void move(ServerPlayer player) { @@ -24793,7 +24782,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d SectionPos lastSectionPos = player.getLastSectionPos(); SectionPos sectionPos = SectionPos.of(player); -@@ -1121,6 +870,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1145,6 +899,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP boolean flag2 = lastSectionPos.asLong() != sectionPos.asLong(); if (flag2 || flag != flag1) { this.updatePlayerPos(player); @@ -24801,7 +24790,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d if (!flag) { this.distanceManager.removePlayer(lastSectionPos, player); } -@@ -1137,49 +887,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1161,49 +916,29 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP this.playerMap.unIgnorePlayer(player); } @@ -24862,7 +24851,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d } public void addEntity(Entity entity) { -@@ -1203,6 +933,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1227,6 +962,12 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } else { ChunkMap.TrackedEntity trackedEntity = new ChunkMap.TrackedEntity(entity, i, updateInterval, type.trackDeltas()); this.entityMap.put(entity.getId(), trackedEntity); @@ -24875,7 +24864,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d trackedEntity.updatePlayers(this.level.players()); if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, true); -@@ -1232,12 +968,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1256,12 +997,38 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP if (trackedEntity1 != null) { trackedEntity1.broadcastRemoved(); } @@ -24916,7 +24905,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d List list = Lists.newArrayList(); List list1 = this.level.players(); -@@ -1335,17 +1097,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1359,17 +1126,11 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void waitForLightBeforeSending(ChunkPos chunkPos, int range) { @@ -24936,7 +24925,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d LevelChunk chunkToSend = chunkHolder.getChunkToSend(); if (chunkToSend != null) { action.accept(chunkToSend); -@@ -1353,14 +1109,21 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1377,14 +1138,21 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -24959,8 +24948,8 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable -@@ -1376,13 +1139,96 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + @Override +@@ -1398,13 +1166,96 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -25058,7 +25047,7 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d 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; -@@ -1492,17 +1338,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1514,17 +1365,24 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } private int getEffectiveRange() { @@ -25092,11 +25081,11 @@ index 16ff2443545b051357e86d84bea8d7e312cf1cda..5807ae8e9e612c0c926d87cdefd3df4d public void updatePlayers(List playersList) { diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java -index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f5b3bbf5b 100644 +index d444c29800e103de55bfb99fd8671ee69b003419..8a5c37cf572abc6b9526648d3c8ec92b7af37e3d 100644 --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -31,30 +31,63 @@ import net.minecraft.world.level.TicketStorage; - import net.minecraft.world.level.chunk.LevelChunk; +@@ -31,96 +31,79 @@ import net.minecraft.world.level.chunk.LevelChunk; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class DistanceManager { @@ -25129,6 +25118,9 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + this.ticketStorage.moonrise$setChunkMap(this.moonrise$getChunkMap()); // Paper - rewrite chunk system } +- protected abstract boolean isChunkToRemove(long chunkPos); +- +- protected abstract @Nullable ChunkHolder getChunk(long chunkPos); + // Paper start - rewrite chunk system + @Override + public final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager moonrise$getChunkHolderManager() { @@ -25144,13 +25136,22 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + this.spawnChunkTracker.add(player, pos.x(), pos.z(), ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants.PLAYER_SPAWN_TRACK_RANGE); + // Note: Cannot do narrow tracking on Paper due to custom spawn range + } -+ + +- protected abstract @Nullable ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); + @Override + public final void moonrise$removePlayer(final ServerPlayer player, final SectionPos pos) { + this.spawnChunkTracker.remove(player); + // Note: Cannot do narrow tracking on Paper due to custom spawn range + } -+ + +- public boolean runAllUpdates(ChunkMap chunkMap) { +- this.naturalSpawnChunkCounter.runAllUpdates(); +- this.simulationChunkTracker.runAllUpdates(); +- this.playerTicketManager.runAllUpdates(); +- int i = Integer.MAX_VALUE - this.loadingChunkTracker.runDistanceUpdates(Integer.MAX_VALUE); +- boolean flag = i != 0; +- if (flag && SharedConstants.DEBUG_VERBOSE_SERVER_EVENTS) { +- LOGGER.debug("DMU {}", i); + @Override + public final void moonrise$updatePlayer(final ServerPlayer player, + final SectionPos oldPos, final SectionPos newPos, @@ -25161,31 +25162,9 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + } else { + this.spawnChunkTracker.addOrUpdate(player, newPos.x(), newPos.z(), ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants.PLAYER_SPAWN_TRACK_RANGE); + // Note: Cannot do narrow tracking on Paper due to custom spawn range -+ } -+ } -+ -+ @Override -+ public final boolean moonrise$hasAnyNearbyNarrow(final int chunkX, final int chunkZ) { -+ throw new UnsupportedOperationException(); // Note: Cannot do narrow tracking on Paper due to custom spawn range + } + } -+ -+ // Paper end - chunk tick iteration optimisation - protected abstract boolean isChunkToRemove(long chunkPos); - - @Nullable -@@ -64,65 +97,15 @@ public abstract class DistanceManager { - protected abstract ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); - public boolean runAllUpdates(ChunkMap chunkMap) { -- this.naturalSpawnChunkCounter.runAllUpdates(); -- this.simulationChunkTracker.runAllUpdates(); -- this.playerTicketManager.runAllUpdates(); -- int i = Integer.MAX_VALUE - this.loadingChunkTracker.runDistanceUpdates(Integer.MAX_VALUE); -- boolean flag = i != 0; -- if (flag && SharedConstants.DEBUG_VERBOSE_SERVER_EVENTS) { -- LOGGER.debug("DMU {}", i); -- } -- - if (!this.chunksToUpdateFutures.isEmpty()) { - // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus - for (final ChunkHolder chunkHolder : this.chunksToUpdateFutures) { @@ -25206,7 +25185,11 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f - } else { - if (!this.ticketsToRelease.isEmpty()) { - LongIterator longIterator = this.ticketsToRelease.iterator(); -- ++ @Override ++ public final boolean moonrise$hasAnyNearbyNarrow(final int chunkX, final int chunkZ) { ++ throw new UnsupportedOperationException(); // Note: Cannot do narrow tracking on Paper due to custom spawn range ++ } + - while (longIterator.hasNext()) { - long l = longIterator.nextLong(); - if (this.ticketStorage.getTickets(l).stream().anyMatch(ticket -> ticket.getType() == TicketType.PLAYER_LOADING)) { @@ -25214,19 +25197,24 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f - if (updatingChunkIfPresent == null) { - throw new IllegalStateException(); - } -- ++ // Paper end - chunk tick iteration optimisation ++ protected abstract boolean isChunkToRemove(long chunkPos); + - CompletableFuture> entityTickingChunkFuture = updatingChunkIfPresent.getEntityTickingChunkFuture(); - entityTickingChunkFuture.thenAccept( - chunkResult -> this.mainThreadExecutor.execute(() -> this.ticketDispatcher.release(l, () -> {}, false)) - ); - } - } -- ++ protected abstract @Nullable ChunkHolder getChunk(long chunkPos); + - this.ticketsToRelease.clear(); - } -- ++ protected abstract @Nullable ChunkHolder updateChunkScheduling(long chunkPos, int newLevel, @Nullable ChunkHolder holder, int oldLevel); + - return flag; - } ++ public boolean runAllUpdates(ChunkMap chunkMap) { + return this.moonrise$getChunkHolderManager().processTicketUpdates(); // Paper - rewrite chunk system } @@ -25242,7 +25230,7 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f } public void removePlayer(SectionPos sectionPos, ServerPlayer player) { -@@ -134,71 +117,79 @@ public abstract class DistanceManager { +@@ -132,71 +115,79 @@ public abstract class DistanceManager { if (set == null || set.isEmpty()) { // Paper end - some state corruption happens here, don't crash, clean up gracefully this.playersPerChunk.remove(packedChunkPos); @@ -25352,7 +25340,7 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f } public boolean hasTickets() { -@@ -250,6 +241,7 @@ public abstract class DistanceManager { +@@ -248,6 +239,7 @@ public abstract class DistanceManager { } } @@ -25360,7 +25348,7 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f class PlayerTicketTracker extends DistanceManager.FixedPlayerDistanceChunkTracker { private int viewDistance; private final Long2IntMap queueLevels = Long2IntMaps.synchronize(new Long2IntOpenHashMap()); -@@ -328,5 +320,5 @@ public abstract class DistanceManager { +@@ -326,5 +318,5 @@ public abstract class DistanceManager { private boolean haveTicketFor(int level) { return level <= this.viewDistance; } @@ -25368,25 +25356,24 @@ index e17a9be152e9e22c95ec8204cca59b501b5125b2..d03d075d5c56b7d2beb5f0aafecbb69f + }*/ // Paper - rewrite chunk system } diff --git a/net/minecraft/server/level/GenerationChunkHolder.java b/net/minecraft/server/level/GenerationChunkHolder.java -index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a816ed4cbe9 100644 +index abbba6fbff118e8dc273a95243567f805cdaf3b7..3a7fbbb92c6960d30b981895e0d24f7676efc8ec 100644 --- a/net/minecraft/server/level/GenerationChunkHolder.java +++ b/net/minecraft/server/level/GenerationChunkHolder.java -@@ -27,13 +27,7 @@ public abstract class GenerationChunkHolder { +@@ -27,12 +27,7 @@ public abstract class GenerationChunkHolder { public static final ChunkResult UNLOADED_CHUNK = ChunkResult.error("Unloaded chunk"); public static final CompletableFuture> UNLOADED_CHUNK_FUTURE = CompletableFuture.completedFuture(UNLOADED_CHUNK); protected final ChunkPos pos; -- @Nullable -- private volatile ChunkStatus highestAllowedStatus; -- private final AtomicReference startedWork = new AtomicReference<>(); -- private final AtomicReferenceArray>> futures = new AtomicReferenceArray<>(CHUNK_STATUSES.size()); -- private final AtomicReference task = new AtomicReference<>(); +- private volatile @Nullable ChunkStatus highestAllowedStatus; +- private final AtomicReference<@Nullable ChunkStatus> startedWork = new AtomicReference<>(); +- private final AtomicReferenceArray<@Nullable CompletableFuture>> futures = new AtomicReferenceArray<>(CHUNK_STATUSES.size()); +- private final AtomicReference<@Nullable ChunkGenerationTask> task = new AtomicReference<>(); - private final AtomicInteger generationRefCount = new AtomicInteger(); - private volatile CompletableFuture generationSaveSyncFuture = CompletableFuture.completedFuture(null); + // Paper - rewrite chunk system public GenerationChunkHolder(ChunkPos pos) { this.pos = pos; -@@ -43,243 +37,96 @@ public abstract class GenerationChunkHolder { +@@ -42,238 +37,91 @@ public abstract class GenerationChunkHolder { } public CompletableFuture> scheduleChunkGenerationTask(ChunkStatus targetStatus, ChunkMap chunkMap) { @@ -25548,8 +25535,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - private ChunkStatus findHighestStatusWithPendingFuture(@Nullable ChunkStatus generationStatus) { + private @Nullable ChunkStatus findHighestStatusWithPendingFuture(@Nullable ChunkStatus generationStatus) { - if (generationStatus == null) { - return null; - } else { @@ -25615,8 +25601,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable - public ChunkAccess getChunkIfPresentUnchecked(ChunkStatus status) { + public @Nullable ChunkAccess getChunkIfPresentUnchecked(ChunkStatus status) { - CompletableFuture> completableFuture = this.futures.get(status.getIndex()); - return completableFuture == null ? null : completableFuture.getNow(NOT_DONE_YET).orElse(null); + // Paper start - rewrite chunk system @@ -25624,16 +25609,14 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + // Paper end - rewrite chunk system } - @Nullable - public ChunkAccess getChunkIfPresent(ChunkStatus status) { + public @Nullable ChunkAccess getChunkIfPresent(ChunkStatus status) { - return this.isStatusDisallowed(status) ? null : this.getChunkIfPresentUnchecked(status); + // Paper start - rewrite chunk system + return ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)(Object)this).moonrise$getRealChunkHolder().getChunkIfPresent(status); + // Paper end - rewrite chunk system } - @Nullable - public ChunkAccess getLatestChunk() { + public @Nullable ChunkAccess getLatestChunk() { - ChunkStatus chunkStatus = this.startedWork.get(); - if (chunkStatus == null) { - return null; @@ -25647,8 +25630,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + // Paper end - rewrite chunk system } - @Nullable - public ChunkStatus getPersistedStatus() { + public @Nullable ChunkStatus getPersistedStatus() { - CompletableFuture> completableFuture = this.futures.get(ChunkStatus.EMPTY.getIndex()); - ChunkAccess chunkAccess = completableFuture == null ? null : completableFuture.getNow(NOT_DONE_YET).orElse(null); - return chunkAccess == null ? null : chunkAccess.getPersistedStatus(); @@ -25659,7 +25641,7 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 } public ChunkPos getPos() { -@@ -287,7 +134,7 @@ public abstract class GenerationChunkHolder { +@@ -281,7 +129,7 @@ public abstract class GenerationChunkHolder { } public FullChunkStatus getFullStatus() { @@ -25668,10 +25650,10 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 } public abstract int getTicketLevel(); -@@ -296,24 +143,15 @@ public abstract class GenerationChunkHolder { +@@ -290,23 +138,14 @@ public abstract class GenerationChunkHolder { @VisibleForDebug - public List>>> getAllFutures() { + public List>>> getAllFutures() { - List>>> list = new ArrayList<>(); - - for (int i = 0; i < CHUNK_STATUSES.size(); i++) { @@ -25682,9 +25664,8 @@ index 23ba9efc83b55ac39dfd9e5ffd04914f7dea0f5b..da1366fdc4889d6a3befd43d81a19a81 + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } - @Nullable @VisibleForDebug - public ChunkStatus getLatestStatus() { + public @Nullable ChunkStatus getLatestStatus() { - ChunkStatus chunkStatus = this.startedWork.get(); - if (chunkStatus == null) { - return null; @@ -25712,7 +25693,7 @@ index 302841522cf990c38b1493b716048c0f2db40726..7932a6676db7b652d63be5ae4dcf9bcf } } diff --git a/net/minecraft/server/level/PlayerSpawnFinder.java b/net/minecraft/server/level/PlayerSpawnFinder.java -index fbbddc9ae0ed4e28602ab1103d860e4639f19c8f..f637d14b0188728192b543d7841e99a98f0c5269 100644 +index d930750ae2ccfe72ff4fa574a49a024cb5f67baa..b5332b1632716679dcba2b36a9d4bb0070d9db88 100644 --- a/net/minecraft/server/level/PlayerSpawnFinder.java +++ b/net/minecraft/server/level/PlayerSpawnFinder.java @@ -122,9 +122,7 @@ public class PlayerSpawnFinder { @@ -25727,11 +25708,11 @@ index fbbddc9ae0ed4e28602ab1103d860e4639f19c8f..f637d14b0188728192b543d7841e99a9 if (throwable == null) { try { diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b43cd0ea6 100644 +index 4bf684986cadfa25ae475be4d54f0359e94b9e11..75fe6e026e3f91b66dcf5b97a86491d5277f7661 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -56,7 +56,7 @@ import net.minecraft.world.level.storage.DimensionDataStorage; - import net.minecraft.world.level.storage.LevelStorageSource; +@@ -55,7 +55,7 @@ import net.minecraft.world.level.storage.LevelStorageSource; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ServerChunkCache extends ChunkSource { @@ -25739,7 +25720,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b private static final Logger LOGGER = LogUtils.getLogger(); private final DistanceManager distanceManager; private final ServerLevel level; -@@ -85,6 +85,106 @@ public class ServerChunkCache extends ChunkSource { +@@ -83,6 +83,106 @@ public class ServerChunkCache extends ChunkSource { } long chunkFutureAwaitCounter; // Paper end @@ -25818,7 +25799,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b + private final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom shuffleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(0L); + private void iterateTickingChunksFaster() { + final ServerLevel world = this.level; -+ final int randomTickSpeed = world.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); ++ final int randomTickSpeed = world.getGameRules().get(GameRules.RANDOM_TICK_SPEED); + + // TODO check on update: impl of forEachBlockTickingChunk will only iterate ENTITY ticking chunks! + // TODO check on update: consumer just runs tickChunk @@ -25846,7 +25827,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b public ServerChunkCache( ServerLevel level, -@@ -143,13 +243,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -141,13 +241,7 @@ public class ServerChunkCache extends ChunkSource { } // CraftBukkit end // Paper start @@ -25861,10 +25842,10 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b @Nullable public ChunkAccess getChunkAtImmediately(int x, int z) { -@@ -216,68 +310,42 @@ public class ServerChunkCache extends ChunkSource { - @Nullable +@@ -212,67 +306,41 @@ public class ServerChunkCache extends ChunkSource { + @Override - public ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { + public @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { - if (Thread.currentThread() != this.mainThread) { - return CompletableFuture.supplyAsync(() -> this.getChunk(x, z, chunkStatus, requireChunk), this.mainThreadProcessor).join(); - } else { @@ -25906,9 +25887,8 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b + // Paper end - rewrite chunk system } - @Nullable @Override - public LevelChunk getChunkNow(int chunkX, int chunkZ) { + public @Nullable LevelChunk getChunkNow(int chunkX, int chunkZ) { - if (Thread.currentThread() != this.mainThread) { - return null; - } else { @@ -25955,7 +25935,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } private void clearCache() { -@@ -303,54 +371,59 @@ public class ServerChunkCache extends ChunkSource { +@@ -298,53 +366,58 @@ public class ServerChunkCache extends ChunkSource { } private CompletableFuture> getChunkFutureMainThread(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { @@ -26035,9 +26015,8 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b + return this.getChunkNow(x, z) != null; // Paper - rewrite chunk system } - @Nullable @Override - public LightChunk getChunkForLighting(int chunkX, int chunkZ) { + public @Nullable LightChunk getChunkForLighting(int chunkX, int chunkZ) { - long packedChunkPos = ChunkPos.asLong(chunkX, chunkZ); - ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(packedChunkPos); - return visibleChunkIfPresent == null ? null : visibleChunkIfPresent.getChunkIfPresentUnchecked(ChunkStatus.INITIALIZE_LIGHT.getParent()); @@ -26051,7 +26030,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } @Override -@@ -363,28 +436,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -357,28 +430,18 @@ public class ServerChunkCache extends ChunkSource { } public boolean runDistanceManagerUpdates() { @@ -26086,7 +26065,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b this.chunkMap.saveAllChunks(flush); } -@@ -395,17 +458,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -389,17 +452,15 @@ public class ServerChunkCache extends ChunkSource { } public void close(boolean save) throws IOException { @@ -26107,7 +26086,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b ProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("purge"); -@@ -429,6 +490,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -423,6 +484,7 @@ public class ServerChunkCache extends ChunkSource { this.runDistanceManagerUpdates(); profilerFiller.popPush("chunks"); if (tickChunks) { @@ -26115,7 +26094,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b this.tickChunks(); this.chunkMap.tick(); } -@@ -461,7 +523,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -455,7 +517,7 @@ public class ServerChunkCache extends ChunkSource { profiler.push("broadcast"); for (ChunkHolder chunkHolder : this.chunkHoldersToBroadcast) { @@ -26124,7 +26103,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b if (tickingChunk != null) { chunkHolder.broadcastChanges(tickingChunk); } -@@ -502,7 +564,10 @@ public class ServerChunkCache extends ChunkSource { +@@ -496,7 +558,10 @@ public class ServerChunkCache extends ChunkSource { profiler.popPush("filteringSpawningChunks"); this.chunkMap.collectSpawningChunks(list); profiler.popPush("shuffleSpawningChunks"); @@ -26136,16 +26115,16 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b profiler.popPush("tickSpawningChunks"); for (LevelChunk levelChunk : list) { -@@ -513,7 +578,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -507,7 +572,7 @@ public class ServerChunkCache extends ChunkSource { } profiler.popPush("tickTickingChunks"); -- this.chunkMap.forEachBlockTickingChunk(levelChunk1 -> this.level.tickChunk(levelChunk1, _int)); -+ this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations - if (_boolean) { +- this.chunkMap.forEachBlockTickingChunk(levelChunk1 -> this.level.tickChunk(levelChunk1, i)); ++ this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimizations + if (flag) { profiler.popPush("customSpawners"); this.level.tickCustomSpawners(this.spawnEnemies); -@@ -525,22 +590,25 @@ public class ServerChunkCache extends ChunkSource { +@@ -519,22 +584,25 @@ public class ServerChunkCache extends ChunkSource { private void tickSpawningChunk(LevelChunk chunk, long timeInhabited, List spawnCategories, NaturalSpawner.SpawnState spawnState) { ChunkPos pos = chunk.getPos(); chunk.incrementInhabitedTime(timeInhabited); @@ -26176,7 +26155,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } @Override -@@ -598,17 +666,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -592,17 +660,11 @@ public class ServerChunkCache extends ChunkSource { } public CompletableFuture addTicketAndLoadWithRadius(TicketType ticketType, ChunkPos chunkPos, int radius) { @@ -26199,7 +26178,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } public void addTicketWithRadius(TicketType ticketType, ChunkPos chunkPos, int radius) { -@@ -658,6 +720,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -652,6 +714,12 @@ public class ServerChunkCache extends ChunkSource { this.chunkMap.setServerViewDistance(viewDistance); } @@ -26212,7 +26191,7 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b public void setSimulationDistance(int simulationDistance) { this.distanceManager.updateSimulationDistance(simulationDistance); } -@@ -743,18 +811,14 @@ public class ServerChunkCache extends ChunkSource { +@@ -736,18 +804,14 @@ public class ServerChunkCache extends ChunkSource { @Override public boolean pollTask() { @@ -26237,10 +26216,10 @@ index 0a1c3017e43a2bc30660fbf5bacdf35ba2724395..9238182528b26f60001f6588b202a58b } } diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 9dbb7c744030fb8d6891780a0928c8cca2a2b68d..f019f1330f9f1e6aa98ef3f914833769cbadea16 100644 +index 182e7468a01e76a22c7af3c081469b4f84f87558..b7915685026e9a944f42440e4a95215f927f385e 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -89,6 +89,11 @@ public class ServerEntity { +@@ -88,6 +88,11 @@ public class ServerEntity { } public void sendChanges() { @@ -26249,15 +26228,15 @@ index 9dbb7c744030fb8d6891780a0928c8cca2a2b68d..f019f1330f9f1e6aa98ef3f914833769 + this.teleportDelay = 9999; + } + // Paper end - optimise collisions + this.entity.updateDataBeforeSync(); List passengers = this.entity.getPassengers(); if (!passengers.equals(this.lastPassengers)) { - this.synchronizer diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09e68aa979 100644 +index f25d50bcccf9b35ae70f8162c6b2b67fffcd319a..5494b92ab1c3c202a640e483e8a4bcb64395ed99 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -175,7 +175,7 @@ import net.minecraft.world.ticks.LevelTicks; - import net.minecraft.world.waypoints.WaypointTransmitter; +@@ -181,7 +181,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLevel { @@ -26265,16 +26244,16 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 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); -@@ -190,7 +190,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type +@@ -197,7 +197,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; + private final EnvironmentAttributeSystem environmentAttributes; - public final PersistentEntitySectionManager entityManager; + // Paper - rewrite chunk system private final GameEventDispatcher gameEventDispatcher; public boolean noSave; private final SleepStatus sleepStatus; -@@ -264,12 +264,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -270,12 +270,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final void loadChunksForMoveAsync(AABB box, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -26288,7 +26267,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 int minBlockX = Mth.floor(box.minX - 1.0E-7D) - 3; int minBlockZ = Mth.floor(box.minZ - 1.0E-7D) - 3; -@@ -288,30 +283,171 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -294,30 +289,171 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final void loadChunks(int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -26476,7 +26455,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } } } -@@ -325,16 +461,135 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -331,16 +467,135 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } } @@ -26619,7 +26598,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 public ServerLevel( MinecraftServer server, -@@ -381,18 +636,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -387,18 +642,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit end boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); @@ -26639,7 +26618,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.chunkSource = new ServerChunkCache( this, levelStorageAccess, -@@ -403,7 +647,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -409,7 +653,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.spigotConfig.viewDistance, // Spigot this.spigotConfig.simulationDistance, // Spigot flag, @@ -26648,10 +26627,10 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 () -> server.overworld().getDataStorage() ); this.chunkSource.getGeneratorState().ensureStructuresGenerated(); -@@ -439,6 +683,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - this.gameEventDispatcher = new GameEventDispatcher(this); - this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); +@@ -449,6 +693,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.waypointManager = new ServerWaypointManager(); + this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); + this.updateSkyBrightness(); + // Paper start - rewrite chunk system + this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks())); + this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this); @@ -26669,7 +26648,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } -@@ -565,8 +823,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -580,8 +838,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.push("checkDespawn"); entity.checkDespawn(); profilerFiller.pop(); @@ -26679,7 +26658,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 Entity vehicle = entity.getVehicle(); if (vehicle != null) { if (!vehicle.isRemoved() && vehicle.hasPassenger(entity)) { -@@ -590,7 +847,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -605,7 +862,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } profilerFiller.push("entityManagement"); @@ -26688,7 +26667,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 profilerFiller.pop(); profilerFiller.push("debugSynchronizers"); if (this.debugSynchronizers.hasAnySubscriberFor(DebugSubscriptions.NEIGHBOR_UPDATES)) { -@@ -606,7 +863,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -622,7 +879,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public boolean shouldTickBlocksAt(long chunkPos) { @@ -26700,7 +26679,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } protected void tickTime() { -@@ -637,7 +897,60 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -657,7 +917,60 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.players.stream().filter(LivingEntity::isSleeping).collect(Collectors.toList()).forEach(player -> player.stopSleepInBed(false, false)); } @@ -26761,7 +26740,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 ChunkPos pos = chunk.getPos(); int minBlockX = pos.getMinBlockX(); int minBlockZ = pos.getMinBlockZ(); -@@ -646,7 +959,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -666,7 +979,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow for (int i = 0; i < randomTickSpeed; i++) { @@ -26770,7 +26749,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.tickPrecipitation(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); } } -@@ -654,33 +967,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -674,33 +987,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { @@ -26805,7 +26784,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } profilerFiller.pop(); -@@ -975,6 +1262,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1013,6 +1300,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (fluidState.is(fluid)) { fluidState.tick(this, pos, blockState); } @@ -26818,7 +26797,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } private void tickBlock(BlockPos pos, Block block) { -@@ -982,6 +1275,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1020,6 +1313,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (blockState.is(block)) { blockState.tick(this, pos, this.random); } @@ -26831,7 +26810,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } // Paper start - log detailed entity tick information -@@ -1066,6 +1365,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1104,6 +1403,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { @@ -26843,7 +26822,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(this.getWorld())); // CraftBukkit -@@ -1078,13 +1382,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1116,13 +1420,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe progress.progressStage(Component.translatable("menu.savingChunks")); } @@ -26867,7 +26846,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 // CraftBukkit start - moved from MinecraftServer#saveAllChunks ServerLevel serverLevel1 = this; -@@ -1214,7 +1523,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1251,7 +1560,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -26876,7 +26855,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } // CraftBukkit start -@@ -1245,7 +1554,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1282,7 +1591,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // CraftBukkit end @@ -26885,7 +26864,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } } -@@ -1256,7 +1565,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1293,7 +1602,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean tryAddFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { // CraftBukkit end @@ -26894,7 +26873,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 return false; } else { this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit -@@ -2009,7 +2318,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2039,7 +2348,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } @@ -26903,7 +26882,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 bufferedWriter.write(String.format(Locale.ROOT, "block_entity_tickers: %d\n", this.blockEntityTickers.size())); bufferedWriter.write(String.format(Locale.ROOT, "block_ticks: %d\n", this.getBlockTicks().count())); bufferedWriter.write(String.format(Locale.ROOT, "fluid_ticks: %d\n", this.getFluidTicks().count())); -@@ -2027,13 +2336,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2057,13 +2366,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe Path path1 = path.resolve("chunks.csv"); try (Writer bufferedWriter2 = Files.newBufferedWriter(path1)) { @@ -26919,7 +26898,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } Path path3 = path.resolve("entities.csv"); -@@ -2130,8 +2439,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2159,8 +2468,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe Locale.ROOT, "players: %s, entities: %s [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), @@ -26930,7 +26909,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 this.blockEntityTickers.size(), getTypeCount(this.blockEntityTickers, TickingBlockEntity::getType), this.getBlockTicks().count(), -@@ -2163,15 +2472,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2192,15 +2501,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public LevelEntityGetter getEntities() { org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot @@ -26959,7 +26938,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } public void startTickingChunk(LevelChunk chunk) { -@@ -2188,8 +2507,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2217,8 +2536,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public void waitForEntities(ChunkPos chunkPos, int radius) { List list = ChunkPos.rangeClosed(chunkPos, radius).toList(); @@ -26970,7 +26949,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 for (ChunkPos chunkPos1 : list) { if (!this.areEntitiesLoaded(chunkPos1.toLong())) { -@@ -2208,28 +2527,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2239,28 +2558,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public void close() throws IOException { super.close(); @@ -27015,7 +26994,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } public boolean anyPlayerCloseEnoughForSpawning(BlockPos pos) { -@@ -2241,7 +2570,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2277,7 +2606,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } public boolean canSpawnEntitiesInChunk(ChunkPos chunkPos) { @@ -27027,7 +27006,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } @Override -@@ -2296,7 +2628,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2332,7 +2664,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); @@ -27037,11 +27016,11 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09 } diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db74f04cea7 100644 +index b09e6a9fa5fbe9a0d3df615d02109992612b4416..8688d1eb7427b8d07757af84d615781867a34288 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -202,7 +202,7 @@ import net.minecraft.world.scores.Team; - import net.minecraft.world.scores.criteria.ObjectiveCriteria; +@@ -201,7 +201,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ServerPlayer extends Player { @@ -27049,9 +27028,9 @@ index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db7 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; -@@ -438,6 +438,36 @@ public class ServerPlayer extends Player { - public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent - public @Nullable org.bukkit.event.player.PlayerQuitEvent.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 +@@ -428,6 +428,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 + // Paper start - rewrite chunk system + private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; @@ -27086,7 +27065,7 @@ index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db7 public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); this.server = server; -@@ -460,7 +490,7 @@ public class ServerPlayer extends Player { +@@ -450,7 +480,7 @@ public class ServerPlayer extends Player { @Override public BlockPos adjustSpawnLocation(ServerLevel level, BlockPos pos) { CompletableFuture completableFuture = PlayerSpawnFinder.findSpawn(level, pos); @@ -27096,11 +27075,11 @@ index 8ecbcfb5f4e2d1cfcde694e9c57b74bbae4b2ac9..8b3efe83166e73dea6545384883c8db7 } diff --git a/net/minecraft/server/level/ThreadedLevelLightEngine.java b/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 664d1aaf0fffd5ca649476966da2d950858279d8..db960cb5397a8840c145f200a753e5507688957b 100644 +index 6acaf953df4f2775a73ff6b5168e6b7cdfc702f2..c33edee3c8a32507f01fc025135d57af0b41b10d 100644 --- a/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/net/minecraft/server/level/ThreadedLevelLightEngine.java -@@ -23,23 +23,151 @@ import net.minecraft.world.level.chunk.LightChunkGetter; - import net.minecraft.world.level.lighting.LevelLightEngine; +@@ -23,23 +23,151 @@ import net.minecraft.world.level.lighting.LevelLightEngine; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCloseable { @@ -27450,12 +27429,12 @@ index 664d1aaf0fffd5ca649476966da2d950858279d8..db960cb5397a8840c145f200a753e550 static enum TaskType { diff --git a/net/minecraft/server/level/Ticket.java b/net/minecraft/server/level/Ticket.java -index a663c84c756bc59aaddbceda939f552e8a422e60..c3a923b7292e970cbfcde7b9fedcbb6eab02c866 100644 +index c86c72b384ade21165d61958119a21f2128ffdf8..481321fe20adc967d41959258e1915f7fbe8e63c 100644 --- a/net/minecraft/server/level/Ticket.java +++ b/net/minecraft/server/level/Ticket.java -@@ -7,7 +7,7 @@ import net.minecraft.Util; - import net.minecraft.core.registries.BuiltInRegistries; +@@ -7,7 +7,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.ExtraCodecs; + import net.minecraft.util.Util; -public class Ticket { +public class Ticket implements Comparable, ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket { // Paper - rewrite chunk system @@ -27554,14 +27533,14 @@ index a663c84c756bc59aaddbceda939f552e8a422e60..c3a923b7292e970cbfcde7b9fedcbb6e public TicketType getType() { diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java -index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94db06b28a9 100644 +index f501cf98260742fc9e3e4bfba1faade49e4d6db6..b2914cbe1ba89ef23f3ca41a98d0c8679198ce4c 100644 --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -3,7 +3,45 @@ package net.minecraft.server.level; +@@ -7,7 +7,45 @@ import java.lang.annotation.Target; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; --public record TicketType(long timeout, int flags) { +-public record TicketType(long timeout, @TicketType.Flags int flags) { +public final class TicketType implements ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType { // Paper - rewrite chunk system + // Paper start - rewrite chunk system + private static final java.util.concurrent.atomic.AtomicLong ID_GENERATOR = new java.util.concurrent.atomic.AtomicLong(); @@ -27602,9 +27581,9 @@ index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94d + // Paper end - rewrite chunk system + public static final long NO_TIMEOUT = 0L; - public static final int FLAG_PERSIST = 1; - public static final int FLAG_LOADING = 2; -@@ -21,7 +59,7 @@ public record TicketType(long timeout, int flags) { + // Paper start - diff on change - all listed in Flags annotation + public static final int FLAG_PERSIST = 1; // Paper - diff on change - all listed in Flags annotation +@@ -27,7 +65,7 @@ public record TicketType(long timeout, @TicketType.Flags int flags) { public static final TicketType UNKNOWN = register("unknown", 1L, FLAG_CAN_EXPIRE_IF_UNLOADED | FLAG_LOADING); public static final TicketType PLUGIN = register("plugin", 0L, FLAG_LOADING | FLAG_SIMULATION); // CraftBukkit public static final TicketType POST_TELEPORT = register("post_teleport", 5L, FLAG_LOADING | FLAG_SIMULATION); // Paper @@ -27613,8 +27592,8 @@ index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94d 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 -@@ -49,9 +87,44 @@ public record TicketType(long timeout, int flags) { - return (this.flags & 16) != 0; +@@ -55,9 +93,44 @@ public record TicketType(long timeout, @TicketType.Flags int flags) { + return (this.flags & FLAG_CAN_EXPIRE_IF_UNLOADED) != 0; } + // Paper start - rewrite chunk system - convert to class @@ -27660,12 +27639,12 @@ index e78d33adda88ed2b58e0bd1c4133d260f126970d..82adb0a0831478b999274fdabab8f94d 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 ea9a2c391df81930f85106c85daa9386a03868b2..b8be39ae633e466d764f329f614620f1a2e1ef3f 100644 +index f7bd29f062baa396ba25d987149159571ee8fa8a..bf5e460b89d7c0fcdcb8826ba693bd23761df430 100644 --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java @@ -78,6 +78,36 @@ public class WorldGenRegion implements WorldGenLevel { private final AtomicLong subTickCount = new AtomicLong(); - private static final ResourceLocation WORLDGEN_REGION_RANDOM = ResourceLocation.withDefaultNamespace("worldgen_region_random"); + private static final Identifier WORLDGEN_REGION_RANDOM = Identifier.withDefaultNamespace("worldgen_region_random"); + // Paper start - rewrite chunk system + /** @@ -27714,19 +27693,19 @@ index f41ddc6f23786d3d3def15aa32ab3782d4839e5f..c65b274b965b95eae33690e63c5da2d5 // 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 4367d84309e6dbae6637cb465332896304db5b5a..384289f5d898fef2f791edcbe0716ed057be62e6 100644 +index 4016d26304a0bf3894eed2bef72113b2ca2d7a6f..5014840bf5d7ef53a4fea8aa6f3b25eb4033ff96 100644 --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -168,7 +168,7 @@ public class PrepareSpawnTask implements ConfigurationTask { - @Nullable - private CompletableFuture chunkLoadFuture; +@@ -166,7 +166,7 @@ public class PrepareSpawnTask implements ConfigurationTask { + private Vec2 spawnAngle; // Paper - remove final + private @Nullable CompletableFuture chunkLoadFuture; private @Nullable CompletableFuture eventFuture; // Paper - private final ChunkLoadCounter chunkLoadCounter = new ChunkLoadCounter(); + private final ChunkLoadCounter chunkLoadCounter = new ca.spottedleaf.moonrise.patches.chunk_system.MoonriseChunkLoadCounter(); // Paper - rewrite chunk system Preparing(final ServerLevel spawnLevel, final CompletableFuture spawnPosition, final Vec2 spawnAngle) { this.spawnLevel = spawnLevel; -@@ -232,11 +232,7 @@ public class PrepareSpawnTask implements ConfigurationTask { +@@ -229,11 +229,7 @@ public class PrepareSpawnTask implements ConfigurationTask { } // Paper end - PlayerSpawnLocationEvent ChunkPos chunkPos = new ChunkPos(BlockPos.containing(vec3)); @@ -27740,10 +27719,10 @@ index 4367d84309e6dbae6637cb465332896304db5b5a..384289f5d898fef2f791edcbe0716ed0 PrepareSpawnTask.this.loadListener.updateFocus(this.spawnLevel.dimension(), chunkPos); } diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index f0a231faba60cd00bdfeb2db01c3d2af53812ea9..3939b5333e3f2f0c1771a3fba04d75445eaba14f 100644 +index 3f3fc8617d37e8653e6e64e6d405372496284258..12ab84ddce4868ddb9e480a2bb8f322bc3346cce 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1182,7 +1182,7 @@ public abstract class PlayerList { +@@ -1195,7 +1195,7 @@ public abstract class PlayerList { public void setViewDistance(int viewDistance) { this.viewDistance = viewDistance; @@ -27751,8 +27730,8 @@ index f0a231faba60cd00bdfeb2db01c3d2af53812ea9..3939b5333e3f2f0c1771a3fba04d7544 + //this.broadcastAll(new ClientboundSetChunkCacheRadiusPacket(viewDistance)); // Paper - rewrite chunk system for (ServerLevel serverLevel : this.server.getAllLevels()) { - if (serverLevel != null) { -@@ -1193,7 +1193,7 @@ public abstract class PlayerList { + serverLevel.getChunkSource().setViewDistance(viewDistance); +@@ -1204,7 +1204,7 @@ public abstract class PlayerList { public void setSimulationDistance(int simulationDistance) { this.simulationDistance = simulationDistance; @@ -27760,7 +27739,7 @@ index f0a231faba60cd00bdfeb2db01c3d2af53812ea9..3939b5333e3f2f0c1771a3fba04d7544 + //this.broadcastAll(new ClientboundSetSimulationDistancePacket(simulationDistance)); // Paper - rewrite chunk system for (ServerLevel serverLevel : this.server.getAllLevels()) { - if (serverLevel != null) { + serverLevel.getChunkSource().setSimulationDistance(simulationDistance); diff --git a/net/minecraft/util/BitStorage.java b/net/minecraft/util/BitStorage.java index 32fe9b22e1d3a422dd80c64d61156dbc7241ba20..02502d50f0255f5bbcc0ecb965abb48cc1a112da 100644 --- a/net/minecraft/util/BitStorage.java @@ -27798,12 +27777,12 @@ index 32fe9b22e1d3a422dd80c64d61156dbc7241ba20..02502d50f0255f5bbcc0ecb965abb48c + // Paper end - block counting } diff --git a/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java b/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java -index c21f1816159b54e97f4ac4ab88bc54399579359a..bb8b1081356674c89663cee95cf5990e1b8e5c38 100644 +index 4d406af549764de9827274cd0875e5a71b63cba2..d134400dcf2dee5a918fd5ededda802086dd5bbb 100644 --- a/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java +++ b/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java @@ -7,7 +7,7 @@ import java.util.Iterator; - import javax.annotation.Nullable; import net.minecraft.core.IdMap; + import org.jspecify.annotations.Nullable; -public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { +public class CrudeIncrementalIntIdentityHashBiMap implements IdMap, ca.spottedleaf.moonrise.patches.fast_palette.FastPalette { // Paper - optimise palette reads @@ -27827,7 +27806,7 @@ index c21f1816159b54e97f4ac4ab88bc54399579359a..bb8b1081356674c89663cee95cf5990e private CrudeIncrementalIntIdentityHashBiMap(int size) { this.keys = (K[])(new Object[size]); this.values = new int[size]; -@@ -88,6 +98,12 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { +@@ -87,6 +97,12 @@ public class CrudeIncrementalIntIdentityHashBiMap implements IdMap { this.byId = crudeIncrementalIntIdentityHashBiMap.byId; this.nextId = crudeIncrementalIntIdentityHashBiMap.nextId; this.size = crudeIncrementalIntIdentityHashBiMap.size; @@ -27841,7 +27820,7 @@ index c21f1816159b54e97f4ac4ab88bc54399579359a..bb8b1081356674c89663cee95cf5990e public void addMapping(K object, int intKey) { diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java -index 6fb3a3f167d8cbaa78135af0c180b592661e2c1d..e6306a68c8652d4c5d22d5ecb1416f5f931f76ee 100644 +index 82b13c0aa0762ff9aa3a9adb7227531804094712..08af7687cdbf395116c2ae0c40befa518b796846 100644 --- a/net/minecraft/util/SimpleBitStorage.java +++ b/net/minecraft/util/SimpleBitStorage.java @@ -208,6 +208,20 @@ public class SimpleBitStorage implements BitStorage { @@ -28014,12 +27993,12 @@ index 6fb3a3f167d8cbaa78135af0c180b592661e2c1d..e6306a68c8652d4c5d22d5ecb1416f5f InitializationException(String message) { super(message); diff --git a/net/minecraft/util/SortedArraySet.java b/net/minecraft/util/SortedArraySet.java -index 0b50a8a7ce28742b272ba61d0cf9b7971b4e867d..62c643febe5d642f5741ac2dcec1606a844593be 100644 +index 2da05663f659b1e36c2c9ebe5e68b95779aa2789..2f13822f830ccb208a96e0b00f5b28109448ea2f 100644 --- a/net/minecraft/util/SortedArraySet.java +++ b/net/minecraft/util/SortedArraySet.java -@@ -9,12 +9,88 @@ import java.util.NoSuchElementException; - import javax.annotation.Nullable; - import net.minecraft.Util; +@@ -8,12 +8,88 @@ import java.util.Iterator; + import java.util.NoSuchElementException; + import org.jspecify.annotations.Nullable; -public class SortedArraySet extends AbstractSet { +public class SortedArraySet extends AbstractSet implements ca.spottedleaf.moonrise.patches.chunk_system.util.ChunkSystemSortedArraySet { // Paper - rewrite chunk system @@ -28135,19 +28114,19 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896 + // Paper end - block counting } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf4b672617 100644 +index 262ac42b02b2809439aec5b9e8f4bc3fba04e7fe..9cd31bf05ef7e5b14696cb33bbf995a9405481e3 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -149,7 +149,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; - import org.jetbrains.annotations.Contract; +@@ -152,7 +152,7 @@ import org.jetbrains.annotations.Contract; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter { -+public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker +-public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter { ++public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker // CraftBukkit start private static final int CURRENT_LEVEL = 2; static boolean isLevelAtLeast(ValueInput input, int level) { -@@ -158,7 +158,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -161,7 +161,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name // Paper start - Share random for entities to make them more random public static RandomSource SHARED_RANDOM = new RandomRandomSource(); @@ -28166,7 +28145,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf private boolean locked = false; @Override -@@ -171,61 +181,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -174,61 +184,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } } @@ -28228,8 +28207,8 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf + // Paper - replace random } // Paper end - Share random for entities to make them more random - public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason -@@ -418,6 +374,156 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + public org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason +@@ -419,6 +375,156 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return this.dimensions.makeBoundingBox(x, y, z); } // Paper end @@ -28386,7 +28365,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf public Entity(EntityType type, Level level) { this.type = type; -@@ -1370,35 +1476,77 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1385,35 +1491,77 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return list.isEmpty() ? distance : -Shapes.collide(Direction.Axis.Y, boundingBox, list, -distance); } @@ -28488,7 +28467,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf } private static float[] collectCandidateStepUpHeights(AABB box, List colliders, float deltaY, float maxUpStep) { -@@ -2696,21 +2844,110 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -2709,21 +2857,110 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public boolean isInWall() { @@ -28610,7 +28589,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf } public InteractionResult interact(Player player, InteractionHand hand) { -@@ -4298,15 +4535,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4314,15 +4551,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public Iterable getIndirectPassengers() { @@ -28636,7 +28615,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf } public int countPlayerPassengers() { -@@ -4449,77 +4688,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4471,77 +4710,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return Mth.lerp(partialTick, this.yRotO, this.yRot); } @@ -28821,7 +28800,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf public boolean touchingUnloadedChunk() { AABB aabb = this.getBoundingBox().inflate(1.0); -@@ -4675,6 +4963,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4701,6 +4989,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { @@ -28837,10 +28816,10 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf if (!checkPosition(this, x, y, z)) { return; } -@@ -4826,6 +5123,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4850,6 +5147,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name @Override - public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause + public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause + // Paper start - rewrite chunk system + if (!((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this.level).moonrise$getEntityLookup().canRemoveEntity((Entity)(Object)this)) { + LOGGER.warn("Entity " + this + " is currently prevented from being removed from the world since it is processing section status updates", new Throwable()); @@ -28850,7 +28829,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { -@@ -4836,7 +5139,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4860,7 +5163,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.stopRiding(); } @@ -28859,7 +28838,7 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); // Paper start - Folia schedulers -@@ -4870,7 +5173,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4894,7 +5197,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name public boolean shouldBeSaved() { return (this.removalReason == null || this.removalReason.shouldSave()) && !this.isPassenger() @@ -28869,12 +28848,12 @@ index a91d8e7d26cea116b0f58d84c84854bbd8cee05c..d5a38c3464539b05453ead3dfd77f4cf @Override diff --git a/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c7a538aca 100644 +index 436da1efde31d5f1103ecbf04cac9c82928c372a..e2b05800736d29f6061a9f2117e51c8a0d5bfeb6 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.RegionStorageInfo; - import net.minecraft.world.level.chunk.storage.SectionStorage; +@@ -40,12 +40,137 @@ import net.minecraft.world.level.chunk.storage.SectionStorage; import net.minecraft.world.level.chunk.storage.SimpleRegionStorage; + import org.jspecify.annotations.Nullable; -public class PoiManager extends SectionStorage { +public class PoiManager extends SectionStorage implements ca.spottedleaf.moonrise.patches.chunk_system.level.poi.ChunkSystemPoiManager { // Paper - rewrite chunk system @@ -29018,8 +28997,8 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c + this.world = (net.minecraft.server.level.ServerLevel)levelHeightAccessor; // Paper - rewrite chunk system } - @Nullable -@@ -200,8 +326,10 @@ public class PoiManager extends SectionStorage { + public @Nullable PoiRecord add(BlockPos pos, Holder type) { +@@ -198,8 +324,10 @@ public class PoiManager extends SectionStorage { } public int sectionsToVillage(SectionPos sectionPos) { @@ -29032,7 +29011,7 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c } boolean isVillageCenter(long chunkPos) { -@@ -215,19 +343,26 @@ public class PoiManager extends SectionStorage { +@@ -213,19 +341,26 @@ public class PoiManager extends SectionStorage { @Override public void tick(BooleanSupplier aheadOfTime) { @@ -29065,7 +29044,7 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c } public void checkConsistencyWithBlocks(SectionPos sectionPos, LevelChunkSection levelChunkSection) { -@@ -266,7 +401,7 @@ public class PoiManager extends SectionStorage { +@@ -264,7 +399,7 @@ public class PoiManager extends SectionStorage { .map(sectionPos -> Pair.of(sectionPos, this.getOrLoad(sectionPos.asLong()))) .filter(pair -> !pair.getSecond().map(PoiSection::isValid).orElse(false)) .map(pair -> pair.getFirst().chunk()) @@ -29075,11 +29054,11 @@ index 5efaf3a1eb1cefc2e925af94ce7064103f0f56f5..f67fbc8b6f5f0374f41180ec36de355c } diff --git a/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index 4a566870695d0b4974cb2ef6804798208c2536cf..bba84a390e46a1288cc3cb36ba01941e47a1fec2 100644 +index 080fcef99f5407685181c2fb7bdb41b14481f6f7..f209696e0158df5cd32e9949b3054452d6a3e5cd 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.VisibleForDebug; - import net.minecraft.util.debug.DebugPoiInfo; +@@ -25,13 +25,27 @@ import net.minecraft.util.debug.DebugPoiInfo; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class PoiSection { @@ -29108,7 +29087,7 @@ index 4a566870695d0b4974cb2ef6804798208c2536cf..bba84a390e46a1288cc3cb36ba01941e this(setDirty, true, ImmutableList.of()); } diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 5d4d01fdc75ffe256545df0b8d9cc9037c4d9b87..15479a9fc47cca3d6627b42c31ba8ff114bbe362 100644 +index 8a6dfb642c89264386ad9302a8bb190ce5e23a26..79ae039d1908830e81912d230b3540a4920e2017 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -204,7 +204,7 @@ public class ArmorStand extends LivingEntity { @@ -29121,10 +29100,10 @@ index 5d4d01fdc75ffe256545df0b8d9cc9037c4d9b87..15479a9fc47cca3d6627b42c31ba8ff1 entity.push(this); } diff --git a/net/minecraft/world/level/ClipContext.java b/net/minecraft/world/level/ClipContext.java -index 628ed83e198dd67c4384c51f98253547d59b5219..9f3187728c0bc69572f27194754016682913e385 100644 +index 3d317880a257bf431f110048d305ddd2a06880d7..25f2e74e229fa12a2d7f1ff43c6cb12a84788ba2 100644 --- a/net/minecraft/world/level/ClipContext.java +++ b/net/minecraft/world/level/ClipContext.java -@@ -21,7 +21,7 @@ public class ClipContext { +@@ -22,7 +22,7 @@ public class ClipContext { private final Vec3 from; private final Vec3 to; private final ClipContext.Block block; @@ -29134,12 +29113,12 @@ index 628ed83e198dd67c4384c51f98253547d59b5219..9f3187728c0bc69572f2719475401668 public ClipContext(Vec3 from, Vec3 to, ClipContext.Block block, ClipContext.Fluid fluid, Entity entity) { diff --git a/net/minecraft/world/level/EntityGetter.java b/net/minecraft/world/level/EntityGetter.java -index 300f3ed58109219d97846082941b860585f66fed..9175a7e4e6076626cb46144c5858c2f2474f1858 100644 +index d4c78c7f521b31ea9ce0cf7d62978b8e324b5d10..bcbe39eed2d254861689c95f7040f27b6ff2d438 100644 --- a/net/minecraft/world/level/EntityGetter.java +++ b/net/minecraft/world/level/EntityGetter.java -@@ -15,7 +15,7 @@ import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.Shapes; +@@ -15,7 +15,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public interface EntityGetter { +public interface EntityGetter extends ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system @@ -29257,7 +29236,7 @@ index 300f3ed58109219d97846082941b860585f66fed..9175a7e4e6076626cb46144c5858c2f2 // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520bfb97cf3 100644 +index 48158dafe7b937ff5089ac741da3e1e1bdde00ec..ef09aaebf4fc7fcd24a736434cd0a860d6b97905 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -82,6 +82,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -29267,16 +29246,16 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 +import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.scores.Scoreboard; import org.apache.commons.lang3.mutable.MutableBoolean; - -@@ -95,7 +96,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; + import org.jspecify.annotations.Nullable; +@@ -96,7 +97,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.entity.SpawnCategory; // CraftBukkit end -public abstract class Level implements LevelAccessor, AutoCloseable { +public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel, ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system // Paper - optimise collisions public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); - public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); - public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); + 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")); @@ -124,7 +125,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public float rainLevel; protected float oThunderLevel; @@ -29932,7 +29911,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = generator; -@@ -226,6 +859,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -225,6 +858,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.registryAccess = registryAccess; this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); @@ -29940,7 +29919,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } // Paper start - Cancel hit for vanished players -@@ -499,7 +1133,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -496,7 +1130,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.setBlocksDirty(pos, blockState, blockState1); } @@ -29949,7 +29928,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 this.sendBlockUpdated(pos, blockState, state, flags); } -@@ -762,6 +1396,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -747,6 +1381,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Spigot start boolean runsNormally = this.tickRateManager().runsNormally(); @@ -29957,7 +29936,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet(); // Paper - Fix MC-117075; use removeAll toRemove.add(null); // Paper - Fix MC-117075 for (this.tileTickPosition = 0; this.tileTickPosition < this.blockEntityTickers.size(); this.tileTickPosition++) { // Paper - Disable tick limiters -@@ -771,6 +1406,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -756,6 +1391,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) { tickingBlockEntity.tick(); @@ -29969,7 +29948,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } } this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 -@@ -790,6 +1430,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -775,6 +1415,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 } @@ -29977,7 +29956,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -797,7 +1438,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -782,7 +1423,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; @@ -29993,7 +29972,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -933,7 +1581,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -917,7 +1565,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (this.isOutsideBuildHeight(pos)) { return null; } else { @@ -30002,7 +29981,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); } -@@ -1027,22 +1675,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1007,22 +1655,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public List getEntities(@Nullable Entity entity, AABB boundingBox, Predicate predicate) { Profiler.get().incrementCounter("getEntities"); List list = Lists.newArrayList(); @@ -30033,7 +30012,7 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 } @Override -@@ -1056,33 +1698,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1036,33 +1678,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE); } @@ -30149,16 +30128,15 @@ index 2a25f07c536890cf73dfce01bf043c5ec36480c3..39947ac2fae9a088d1fbc5c72d6ac520 public boolean hasEntities(EntityTypeTest entityTypeTest, AABB bounds, Predicate predicate) { Profiler.get().incrementCounter("hasEntities"); diff --git a/net/minecraft/world/level/LevelReader.java b/net/minecraft/world/level/LevelReader.java -index 93110c815abe7baef61b1eaacfe28ebb1fc821f7..564c5064ec105a4f59476f2d21d3664b76e0aa55 100644 +index 60be05520f1093e3edc7dbfcf5bd01601d5e6e7b..fd5a38a9f24c26f8eca738f78180446d354ff3ac 100644 --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -22,7 +22,18 @@ import net.minecraft.world.level.dimension.DimensionType; - import net.minecraft.world.level.levelgen.Heightmap; +@@ -23,7 +23,16 @@ import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.phys.AABB; + import org.jspecify.annotations.Nullable; -public interface LevelReader extends BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource { +public interface LevelReader extends ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevelReader, BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource { // Paper - rewrite chunk system -+ + // Paper start - rewrite chunk system + @Override + public default ChunkAccess moonrise$syncLoadNonFull(final int chunkX, final int chunkZ, final ChunkStatus status) { @@ -30168,12 +30146,11 @@ index 93110c815abe7baef61b1eaacfe28ebb1fc821f7..564c5064ec105a4f59476f2d21d3664b + return ((LevelReader)this).getChunk(chunkX, chunkZ, status, true); + } + // Paper end - rewrite chunk system -+ - @Nullable - ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); + @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); + @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 c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e521ac3ae5c 100644 +index ebbf5ceab837675ffa6a5380c0c54bc1dd788348..6279596058f76f113d238be3201cb0c6e6b49566 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java @@ -62,6 +62,249 @@ public class ServerExplosion implements Explosion { @@ -30466,17 +30443,6 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 - f -= (blockExplosionResistance.get() + 0.3F) * 0.3F; - } + final Vec3 center = this.center; -+ -+ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache = this.directMappedBlockCache; -+ -+ // use initial cache value that is most likely to be used: the source position -+ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache initialCache; -+ { -+ final int blockX = Mth.floor(center.x); -+ final int blockY = Mth.floor(center.y); -+ final int blockZ = Mth.floor(center.z); -+ -+ final long key = BlockPos.asLong(blockX, blockY, blockZ); - if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) { - set.add(blockPos); @@ -30487,6 +30453,17 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 - net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); - set.add(blockPos.relative(direction.getOpposite())); - } ++ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[] blockCache = this.directMappedBlockCache; ++ ++ // use initial cache value that is most likely to be used: the source position ++ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache initialCache; ++ { ++ final int blockX = Mth.floor(center.x); ++ final int blockY = Mth.floor(center.y); ++ final int blockZ = Mth.floor(center.z); ++ ++ final long key = BlockPos.asLong(blockX, blockY, blockZ); ++ + initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true); + } + @@ -30576,7 +30553,7 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 } private void hurtEntities() { -@@ -346,6 +628,14 @@ public class ServerExplosion implements Explosion { +@@ -350,6 +632,14 @@ public class ServerExplosion implements Explosion { } public int explode() { @@ -30591,7 +30568,7 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); this.hurtEntities(); -@@ -360,6 +650,13 @@ public class ServerExplosion implements Explosion { +@@ -364,6 +654,13 @@ public class ServerExplosion implements Explosion { this.createFire(list); } @@ -30605,7 +30582,7 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 return list.size(); } -@@ -449,12 +746,12 @@ public class ServerExplosion implements Explosion { +@@ -447,12 +744,12 @@ public class ServerExplosion implements Explosion { // Paper start - Optimize explosions private float getBlockDensity(Vec3 vec3d, Entity entity) { if (!this.level.paperConfig().environment.optimizeExplosions) { @@ -30621,11 +30598,11 @@ index c132a3bfff7cf020e7fe4be616daa763b83e4b25..1c521f9f32340cf75310686c90777e52 } diff --git a/net/minecraft/world/level/TicketStorage.java b/net/minecraft/world/level/TicketStorage.java -index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7f22ff8c4 100644 +index ad5c9c32be4be9324a313fbd9e099c9dd3f68253..b1c663187720d308c4cf3a5352879262183a9ce2 100644 --- a/net/minecraft/world/level/TicketStorage.java +++ b/net/minecraft/world/level/TicketStorage.java -@@ -29,7 +29,7 @@ import net.minecraft.world.level.saveddata.SavedData; - import net.minecraft.world.level.saveddata.SavedDataType; +@@ -29,7 +29,7 @@ import net.minecraft.world.level.saveddata.SavedDataType; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class TicketStorage extends SavedData { @@ -30633,7 +30610,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 private static final int INITIAL_TICKET_LIST_CAPACITY = 4; private static final Logger LOGGER = LogUtils.getLogger(); private static final Codec> TICKET_ENTRY = Codec.mapPair(ChunkPos.CODEC.fieldOf("chunk_pos"), Ticket.CODEC).codec(); -@@ -38,18 +38,32 @@ public class TicketStorage extends SavedData { +@@ -38,16 +38,30 @@ public class TicketStorage extends SavedData { .apply(instance, TicketStorage::fromPacked) ); public static final SavedDataType TYPE = new SavedDataType<>("chunks", TicketStorage::new, CODEC, DataFixTypes.SAVED_DATA_FORCED_CHUNKS); @@ -30642,10 +30619,8 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 private final Long2ObjectOpenHashMap> deactivatedTickets; - private LongSet chunksWithForcedTickets = new LongOpenHashSet(); + // Paper - rewrite chunk system - @Nullable - private TicketStorage.ChunkUpdated loadingChunkUpdatedListener; - @Nullable - private TicketStorage.ChunkUpdated simulationChunkUpdatedListener; + private TicketStorage.@Nullable ChunkUpdated loadingChunkUpdatedListener; + private TicketStorage.@Nullable ChunkUpdated simulationChunkUpdatedListener; + // Paper start - rewrite chunk system + private ChunkMap chunkMap; @@ -30670,7 +30645,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public TicketStorage() { -@@ -78,8 +92,32 @@ public class TicketStorage extends SavedData { +@@ -76,8 +90,32 @@ public class TicketStorage extends SavedData { return list; } @@ -30704,15 +30679,15 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 forEachTicket(action, this.deactivatedTickets); } -@@ -104,35 +142,34 @@ public class TicketStorage extends SavedData { +@@ -102,35 +140,34 @@ public class TicketStorage extends SavedData { } - public void setLoadingChunkUpdatedListener(@Nullable TicketStorage.ChunkUpdated loadingChunkUpdatedListener) { + public void setLoadingChunkUpdatedListener(TicketStorage.@Nullable ChunkUpdated loadingChunkUpdatedListener) { - this.loadingChunkUpdatedListener = loadingChunkUpdatedListener; + // Paper - rewrite chunk system } - public void setSimulationChunkUpdatedListener(@Nullable TicketStorage.ChunkUpdated simulationChunkUpdatedListener) { + public void setSimulationChunkUpdatedListener(TicketStorage.@Nullable ChunkUpdated simulationChunkUpdatedListener) { - this.simulationChunkUpdatedListener = simulationChunkUpdatedListener; + // Paper - rewrite chunk system } @@ -30753,7 +30728,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public void addTicketWithRadius(TicketType ticketType, ChunkPos chunkPos, int radius) { -@@ -145,37 +182,14 @@ public class TicketStorage extends SavedData { +@@ -143,37 +180,14 @@ public class TicketStorage extends SavedData { } public boolean addTicket(long chunkPos, Ticket ticket) { @@ -30797,7 +30772,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } private static boolean isTicketSameTypeAndLevel(Ticket first, Ticket second) { -@@ -222,53 +236,20 @@ public class TicketStorage extends SavedData { +@@ -219,53 +233,20 @@ public class TicketStorage extends SavedData { } public boolean removeTicket(long chunkPos, Ticket ticket) { @@ -30860,7 +30835,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public String getTicketDebugString(long chunkPos, boolean requireSimulation) { -@@ -278,14 +259,7 @@ public class TicketStorage extends SavedData { +@@ -275,14 +256,7 @@ public class TicketStorage extends SavedData { } public void purgeStaleTickets(ChunkMap map) { @@ -30876,7 +30851,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 this.setDirty(); } -@@ -301,82 +275,15 @@ public class TicketStorage extends SavedData { +@@ -298,82 +272,15 @@ public class TicketStorage extends SavedData { } public void deactivateTicketsOnClosing() { @@ -30962,7 +30937,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } public boolean updateChunkForced(ChunkPos chunkPos, boolean add) { -@@ -385,22 +292,29 @@ public class TicketStorage extends SavedData { +@@ -382,22 +289,29 @@ public class TicketStorage extends SavedData { } public LongSet getForceLoadedChunks() { @@ -31005,7 +30980,7 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 } @FunctionalInterface -@@ -424,7 +338,7 @@ public class TicketStorage extends SavedData { +@@ -421,7 +335,7 @@ public class TicketStorage extends SavedData { } public void removeAllPluginRegionTickets(TicketType ticketType, int ticketLevel, org.bukkit.plugin.Plugin ticketIdentifier) { @@ -31015,10 +30990,10 @@ index 7387817a57bd03814d5c3c89eb379a5c975418a2..d4b0f07375a0fe2773c71885f2f35de7 // Paper end } diff --git a/net/minecraft/world/level/biome/Biome.java b/net/minecraft/world/level/biome/Biome.java -index 4370a7fd33cc3fcd511a3ccaf48b6648c78d408c..91fd52eeb410cf6b4c8de1ed9d41d60506bf8dd1 100644 +index dfc24fd23e26010274e02cc26666c1801ef811c0..a253b02bb6e07ba4cdbd9320445a6b6c3e54ada2 100644 --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -118,20 +118,7 @@ public final class Biome { +@@ -123,20 +123,7 @@ public final class Biome { @Deprecated public float getTemperature(BlockPos pos, int seaLevel) { @@ -31055,10 +31030,10 @@ index 8d98cba3830dc5dfb5cae9a6f5fedfffee0d2cd8..73962e79a0f3d892e3155443a1b84508 public interface NoiseBiomeSource { diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index 6a6e83bc61de06c75b7a8b677c616c00ea936710..572fcb33b14d16334e2ab92ddf8699f1ba975aff 100644 +index f1340eb90e22772114a1303ef3f3f905fe101351..ab08211e0f64a14a335e3cc4479bcf1f82e25cdd 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -344,7 +344,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -355,7 +355,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public static boolean isShapeFullBlock(VoxelShape shape) { @@ -31068,10 +31043,10 @@ index 6a6e83bc61de06c75b7a8b677c616c00ea936710..572fcb33b14d16334e2ab92ddf8699f1 public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c05023370df8cd3 100644 +index fd626256ffcf0372f85666e2ee1bd5c7bdcb105a..c5953d5751e655e121e459aaab35e7719948e69e 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -416,7 +416,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -415,7 +415,7 @@ public abstract class BlockBehaviour implements FeatureElement { return this.properties.destroyTime; } @@ -31080,7 +31055,7 @@ index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c050233 private static final Direction[] DIRECTIONS = Direction.values(); private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], shape -> Arrays.fill(shape, Shapes.empty())); private static final VoxelShape[] FULL_BLOCK_OCCLUSION_SHAPES = Util.make( -@@ -455,6 +455,76 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -452,6 +452,76 @@ public abstract class BlockBehaviour implements FeatureElement { private boolean propagatesSkylightDown; private int lightBlock; @@ -31157,7 +31132,7 @@ index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c050233 protected BlockStateBase(Block owner, Reference2ObjectArrayMap, Comparable> values, MapCodec propertiesCodec) { super(owner, values, propertiesCodec); BlockBehaviour.Properties properties = owner.properties; -@@ -533,6 +603,41 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -529,6 +599,41 @@ public abstract class BlockBehaviour implements FeatureElement { this.propagatesSkylightDown = this.owner.propagatesSkylightDown(this.asState()); this.lightBlock = this.owner.getLightBlock(this.asState()); @@ -31200,12 +31175,12 @@ index 0b19272315a8598c2e132a0f8d3c4a6ceec46e16..d31da50baeb7f47f0e1d81ee3c050233 public Block getBlock() { diff --git a/net/minecraft/world/level/block/state/StateHolder.java b/net/minecraft/world/level/block/state/StateHolder.java -index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed905011e969a4 100644 +index abb2189902af888ac30510d5088ea77fb9e0c542..c020d1944a25e2cd247e30a97c35bf93731d694a 100644 --- a/net/minecraft/world/level/block/state/StateHolder.java +++ b/net/minecraft/world/level/block/state/StateHolder.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; - import javax.annotation.Nullable; import net.minecraft.world.level.block.state.properties.Property; + import org.jspecify.annotations.Nullable; -public abstract class StateHolder { +public abstract class StateHolder implements ca.spottedleaf.moonrise.patches.blockstate_propertyaccess.PropertyAccessStateHolder { // Paper - optimise blockstate property access @@ -31271,10 +31246,10 @@ index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed9050 } public > Optional getOptionalValue(Property property) { -@@ -103,22 +118,30 @@ public abstract class StateHolder { +@@ -102,22 +117,30 @@ public abstract class StateHolder { + } - @Nullable - private > T getNullableValue(Property property) { + private > @Nullable T getNullableValue(Property property) { - Comparable comparable = this.values.get(property); - return comparable == null ? null : property.getValueClass().cast(comparable); + return property == null ? null : this.optimisedTable.get(this.tableIndex, property); // Paper - optimise blockstate property access @@ -31311,7 +31286,7 @@ index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed9050 } private , V extends T> S setValueInternal(Property property, V value, Comparable comparable) { -@@ -135,21 +158,27 @@ public abstract class StateHolder { +@@ -134,21 +157,27 @@ public abstract class StateHolder { } public void populateNeighbours(Map, Comparable>, S> possibleStateMap) { @@ -31352,7 +31327,7 @@ index e9bf5e2c43ff0945c8f2eb40ed381ac061abd0d4..040919c61ed29b3eda73b5d0f8ed9050 } private Map, Comparable> makeNeighbourValues(Property property, Comparable value) { -@@ -159,7 +188,11 @@ public abstract class StateHolder { +@@ -158,7 +187,11 @@ public abstract class StateHolder { } public Map, Comparable> getValues() { @@ -31495,19 +31470,19 @@ index 28a15908420cb239c317d58f7e3a1df3c6278b33..b7543eb5a8f87bc7bd275ed9d46a6807 @Override diff --git a/net/minecraft/world/level/block/state/properties/Property.java b/net/minecraft/world/level/block/state/properties/Property.java -index 92350434746f06bbf4a161c6bc42602de7b45220..1c24f38d21da1be9740512981f219924c5d3cf76 100644 +index aa836c652aecda582772c016e62abfce32d32fe5..1200466d8718fb35205894fc09584d5104e56f43 100644 --- a/net/minecraft/world/level/block/state/properties/Property.java +++ b/net/minecraft/world/level/block/state/properties/Property.java @@ -10,7 +10,7 @@ import java.util.stream.Stream; - import javax.annotation.Nullable; import net.minecraft.world.level.block.state.StateHolder; + import org.jspecify.annotations.Nullable; -public abstract class Property> { +public abstract class Property> implements ca.spottedleaf.moonrise.patches.blockstate_propertyaccess.PropertyAccess { // Paper - optimise blockstate property access private final Class clazz; private final String name; - @Nullable -@@ -24,9 +24,38 @@ public abstract class Property> { + private @Nullable Integer hashCode; +@@ -23,9 +23,38 @@ public abstract class Property> { ); private final Codec> valueCodec = this.codec.xmap(this::value, Property.Value::value); @@ -31547,11 +31522,11 @@ index 92350434746f06bbf4a161c6bc42602de7b45220..1c24f38d21da1be9740512981f219924 public Property.Value value(T value) { diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec498bf443d 100644 +index 9dc13a5b6cc1afc118a261802c71da25ae577fe5..a49a06662de4062a77112e358f536d45d65bf91f 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.SavedTick; - import net.minecraft.world.ticks.TickContainerAccess; +@@ -57,7 +57,7 @@ import net.minecraft.world.ticks.TickContainerAccess; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess { @@ -31559,16 +31534,16 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 public static final int NO_FILLED_SECTION = -1; private static final Logger LOGGER = LogUtils.getLogger(); private static final LongSet EMPTY_REFERENCE_SET = new LongOpenHashSet(); -@@ -75,7 +75,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh - @Nullable - protected BlendingData blendingData; +@@ -72,7 +72,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh + protected final UpgradeData upgradeData; + protected @Nullable BlendingData blendingData; public final Map heightmaps = Maps.newEnumMap(Heightmap.Types.class); - protected ChunkSkyLightSources skyLightSources; + // Paper - rewrite chunk system private final Map structureStarts = Maps.newHashMap(); private final Map structuresRefences = Maps.newHashMap(); protected final Map pendingBlockEntities = Maps.newHashMap(); -@@ -87,6 +87,57 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -84,6 +84,57 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY); // CraftBukkit end @@ -31626,7 +31601,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 public ChunkAccess( ChunkPos chunkPos, UpgradeData upgradeData, -@@ -104,7 +155,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -101,7 +152,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh this.inhabitedTime = inhabitedTime; this.postProcessing = new ShortList[levelHeightAccessor.getSectionsCount()]; this.blendingData = blendingData; @@ -31635,7 +31610,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 if (sections != null) { if (this.sections.length == sections.length) { System.arraycopy(sections, 0, this.sections, 0, this.sections.length); -@@ -114,6 +165,16 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -111,6 +162,16 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh } replaceMissingSections(containerFactory, this.sections); @@ -31652,7 +31627,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 } private static void replaceMissingSections(PalettedContainerFactory containerFactory, LevelChunkSection[] sections) { -@@ -442,18 +503,22 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -433,18 +494,22 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh @Override public Holder getNoiseBiome(int x, int y, int z) { @@ -31686,7 +31661,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 } // CraftBukkit start public void setBiome(int x, int y, int z, Holder biome) { -@@ -503,12 +568,12 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -493,12 +558,12 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh } public void initializeLightSources() { @@ -31702,7 +31677,7 @@ index a5199906f1ca63e66c9547d85d40f86b506a1c7f..71aa0220309e418fbbda66c2fa14fec4 public static ProblemReporter.PathElement problemPath(ChunkPos pos) { diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index a935380b544e12a06a8152085a82b0fa16522331..4e4a5595ccbadf7e2df0f6de1c8e2ceb00b9ec90 100644 +index 2acee7d7211c4e7b9ac02e9a48d6c3ea239e6949..78600f4c583056403c93e72ec0996b00ec6d1284 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java @@ -116,7 +116,7 @@ public abstract class ChunkGenerator { @@ -31714,7 +31689,7 @@ index a935380b544e12a06a8152085a82b0fa16522331..4e4a5595ccbadf7e2df0f6de1c8e2ceb } public abstract void applyCarvers( -@@ -318,7 +318,7 @@ public abstract class ChunkGenerator { +@@ -314,7 +314,7 @@ public abstract class ChunkGenerator { return Pair.of(placement.getLocatePos(chunkPos), holder); } @@ -31724,19 +31699,19 @@ index a935380b544e12a06a8152085a82b0fa16522331..4e4a5595ccbadf7e2df0f6de1c8e2ceb if (startForStructure != null && startForStructure.isValid() && (!skipKnownStructures || tryAddReference(structureManager, startForStructure))) { return Pair.of(placement.getLocatePos(startForStructure.getChunkPos()), holder); diff --git a/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -index 0de3316ee56116b9fbabb7970b8e6dd7520229cf..b7cf517a87c7c03cf53cc91697157ee087af1cf7 100644 +index 4925c35f89b2e9ec099c66168621521129dd9035..bb8c2e1fb91a5921b5fe35c78c584f81f0189e13 100644 --- a/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -@@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.material.FluidState; +@@ -14,7 +14,7 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; + import org.jspecify.annotations.Nullable; -public class EmptyLevelChunk extends LevelChunk { +public class EmptyLevelChunk extends LevelChunk implements ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk { // Paper - rewrite chunk system private final Holder biome; public EmptyLevelChunk(Level level, ChunkPos pos, Holder biome) { -@@ -21,6 +21,40 @@ public class EmptyLevelChunk extends LevelChunk { +@@ -22,6 +22,40 @@ public class EmptyLevelChunk extends LevelChunk { this.biome = biome; } @@ -31801,12 +31776,12 @@ index 0841918bd2c7b95151baa5cfabc9d44b37b0c588..5b9346b25aa01db9f3c36e243f46846b 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 ab33c5dc6f4d70c1edf0377478110881aadafd3d..7d739e72c9a47776d1cc19204a4e13d9f6c43e19 100644 +index 8c5585c5a961b03853849f92e2811425391e5405..ba91dc3b8b4d70af32b7d9323f22c1fafabe913f 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.level.material.FluidState; - import net.minecraft.world.ticks.BlackholeTickAccess; +@@ -29,7 +29,7 @@ import net.minecraft.world.ticks.BlackholeTickAccess; import net.minecraft.world.ticks.TickContainerAccess; + import org.jspecify.annotations.Nullable; -public class ImposterProtoChunk extends ProtoChunk { +public class ImposterProtoChunk extends ProtoChunk implements ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk { // Paper - rewrite chunk system @@ -31859,15 +31834,15 @@ index ab33c5dc6f4d70c1edf0377478110881aadafd3d..7d739e72c9a47776d1cc19204a4e13d9 + } + // Paper end - rewrite chunk system + - @Nullable @Override - public BlockEntity getBlockEntity(BlockPos pos) { + public @Nullable BlockEntity getBlockEntity(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 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e064958038da44bf 100644 +index d95fb59650cf5018902321cc7be895b7e7de7f25..356a89ef2396f245e438d59d65edd0445693cb8b 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -62,7 +62,7 @@ import net.minecraft.world.ticks.LevelChunkTicks; - import net.minecraft.world.ticks.TickContainerAccess; +@@ -63,7 +63,7 @@ import net.minecraft.world.ticks.TickContainerAccess; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class LevelChunk extends ChunkAccess implements DebugValueSource { @@ -31875,7 +31850,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -103,6 +103,39 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -102,6 +102,39 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { // Paper start boolean loadedTicketLevel; // Paper end @@ -31915,7 +31890,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 public LevelChunk(Level level, ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -132,6 +165,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -131,6 +164,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.postLoad = postLoad; this.blockTicks = blockTicks; this.fluidTicks = fluidTicks; @@ -31929,8 +31904,8 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 + // Paper end - get block chunk optimisation } - public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) { -@@ -169,13 +210,19 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { + public LevelChunk(ServerLevel level, ProtoChunk chunk, LevelChunk.@Nullable PostLoadProcessor postLoad) { +@@ -168,13 +209,19 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } } @@ -31951,7 +31926,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 } public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) { -@@ -347,7 +394,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -345,7 +392,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { if (LightEngine.hasDifferentLightProperties(blockState, state)) { ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("updateSkyLightSources"); @@ -31960,7 +31935,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 profilerFiller.popPush("queueCheckLight"); this.level.getChunkSource().getLightEngine().checkBlock(pos); profilerFiller.pop(); -@@ -594,11 +641,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -588,11 +635,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { // CraftBukkit start public void loadCallback() { @@ -31974,7 +31949,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 if (server != null) { /* * If it's a new world, the first few chunks are generated inside -@@ -607,6 +655,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -601,6 +649,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)); @@ -31982,7 +31957,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 if (this.needsDecoration) { this.needsDecoration = false; -@@ -633,13 +682,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -627,13 +676,15 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { } public void unloadCallback() { @@ -32000,7 +31975,7 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 // Paper start this.loadedTicketLevel = false; // Paper end -@@ -647,8 +698,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -641,8 +692,31 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { @Override public boolean isUnsaved() { @@ -32033,14 +32008,14 @@ index 6b50d77c3e9f304c2baf58ecff91e1884c13b048..4be0c11b3066bc56ac2b8658e0649580 // CraftBukkit end public boolean isEmpty() { -@@ -726,6 +800,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { +@@ -721,6 +795,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource { this.pendingBlockEntities.clear(); this.upgradeData.upgrade(this); + this.postProcessingDone = true; // Paper - rewrite chunk system } - @Nullable + private @Nullable BlockEntity promotePendingBlockEntity(BlockPos pos, CompoundTag tag) { diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java index c721edb770a46403da38a5cdcff241a1c50cb32d..5a76746a27d04cc095585655f2ef19ac10528071 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -32297,10 +32272,10 @@ index 8ac6109c37cd83c87e4257ed2f33b2352d072702..43679751e0251f9ccab9d617be672854 boolean maybeHas(Predicate filter); diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 3644acef852d1ae0ff6daf6208b1a4422b003d7b..49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7 100644 +index 889d2db9ae9a8d5ca7b150431f1d3c4892a241d9..0740775f2fa49c4313c1de6dd00f0a39fe2e0463 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -24,7 +24,7 @@ import net.minecraft.util.ZeroBitStorage; +@@ -24,7 +24,7 @@ import org.jspecify.annotations.Nullable; public class PalettedContainer implements PaletteResize, PalettedContainerRO { private static final int MIN_PALETTE_BITS = 0; @@ -32359,7 +32334,7 @@ index 3644acef852d1ae0ff6daf6208b1a4422b003d7b..49c00586c1ae55e5e85787fa7cd4b84e + this.updateData(this.data); // Paper - optimise palette reads } - private PalettedContainer.Data createOrReuseData(@Nullable PalettedContainer.Data data, int bits) { + private PalettedContainer.Data createOrReuseData(PalettedContainer.@Nullable Data data, int bits) { @@ -98,6 +128,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer PalettedContainer.Data data1 = this.createOrReuseData(data, bits); data1.copyFrom(data.palette, data.storage); @@ -32454,10 +32429,10 @@ index 3644acef852d1ae0ff6daf6208b1a4422b003d7b..49c00586c1ae55e5e85787fa7cd4b84e PaletteResize paletteResize = PaletteResize.noResizeExpected(); diff --git a/net/minecraft/world/level/chunk/ProtoChunk.java b/net/minecraft/world/level/chunk/ProtoChunk.java -index 6868cb3ba98b10e32fcee32719f53f90eae59ec3..456d301d45350fb15de5ab663c482257e607f3aa 100644 +index ff2a34c83fbcc27e87a85bcaab411b042c85dc0b..fd923d89d4456f0b13d97ef6fa90815a27e2e734 100644 --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -158,7 +158,7 @@ public class ProtoChunk extends ChunkAccess { +@@ -154,7 +154,7 @@ public class ProtoChunk extends ChunkAccess { } if (LightEngine.hasDifferentLightProperties(blockState, state)) { @@ -32467,17 +32442,16 @@ index 6868cb3ba98b10e32fcee32719f53f90eae59ec3..456d301d45350fb15de5ab663c482257 } } diff --git a/net/minecraft/world/level/chunk/SingleValuePalette.java b/net/minecraft/world/level/chunk/SingleValuePalette.java -index 6e7462fbe6a973a5d2d9f89ac2abc72e1f78d882..9759285f029ba62ac80b9783ddb1f278ec88bf70 100644 +index 18a006890c466b84c32537745ea249662ac2aaf0..e0ed8499a90eb350cc483001ea10f2c8e9173875 100644 --- a/net/minecraft/world/level/chunk/SingleValuePalette.java +++ b/net/minecraft/world/level/chunk/SingleValuePalette.java -@@ -8,10 +8,22 @@ import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.VarInt; +@@ -8,9 +8,21 @@ import net.minecraft.network.VarInt; import org.apache.commons.lang3.Validate; + import org.jspecify.annotations.Nullable; -public class SingleValuePalette implements Palette { +public class SingleValuePalette implements Palette, ca.spottedleaf.moonrise.patches.fast_palette.FastPalette { // Paper - optimise palette reads - @Nullable - private T value; + private @Nullable T value; + // Paper start - optimise palette reads + private T[] rawPalette; @@ -32492,9 +32466,9 @@ index 6e7462fbe6a973a5d2d9f89ac2abc72e1f78d882..9759285f029ba62ac80b9783ddb1f278 + // Paper end - optimise palette reads + public SingleValuePalette(List values) { - if (values.size() > 0) { + if (!values.isEmpty()) { Validate.isTrue(values.size() <= 1, "Can't initialize SingleValuePalette with %d values.", (long)values.size()); -@@ -29,6 +41,11 @@ public class SingleValuePalette implements Palette { +@@ -28,6 +40,11 @@ public class SingleValuePalette implements Palette { return resizeHandler.onResize(1, state); } else { this.value = state; @@ -32506,7 +32480,7 @@ index 6e7462fbe6a973a5d2d9f89ac2abc72e1f78d882..9759285f029ba62ac80b9783ddb1f278 return 0; } } -@@ -54,6 +71,11 @@ public class SingleValuePalette implements Palette { +@@ -53,6 +70,11 @@ public class SingleValuePalette implements Palette { @Override public void read(FriendlyByteBuf buffer, IdMap map) { this.value = map.byIdOrThrow(buffer.readVarInt()); @@ -32532,12 +32506,12 @@ index 9c6f4aa173fa25f9c8a3852d91a4585e069236b6..b14001afe0bf841dac7d0a1d1568fd10 .step(ChunkStatus.FULL, builder -> builder.setTask(ChunkStatusTasks::full)) .build(); diff --git a/net/minecraft/world/level/chunk/status/ChunkStatus.java b/net/minecraft/world/level/chunk/status/ChunkStatus.java -index f2aa944dedf917f01d669a703a9b9f4f35af78c2..116efc09663cac3b0f4b8c157e93201e8cc9b7a4 100644 +index 204b99f48ba8e2fd724a43ede73abc41a4147872..a04f20297c984a31216cbeb1c8d049728c9b6a65 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStatus.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatus.java -@@ -12,7 +12,7 @@ import net.minecraft.resources.ResourceLocation; +@@ -12,7 +12,7 @@ import net.minecraft.resources.Identifier; import net.minecraft.world.level.levelgen.Heightmap; - import org.jetbrains.annotations.VisibleForTesting; + import org.jspecify.annotations.Nullable; -public class ChunkStatus { +public class ChunkStatus implements ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkStatus { // Paper - rewrite chunk system @@ -32644,12 +32618,12 @@ index 98e85820ac5aad77a003be4b6f7a59346524ae81..d620862e95abf9f098bb53a76825883f } } diff --git a/net/minecraft/world/level/chunk/status/ChunkStep.java b/net/minecraft/world/level/chunk/status/ChunkStep.java -index 7a4d299d2ce36982204e30de9278ddfd5b37c3df..b8348976e80578d9eff64eea68c04c603fed49ad 100644 +index e29ad470f868fd26259bc0c2dbd6e0c1eb97bae4..aa8c40d49756611537e2698b7f2a861c303ef842 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStep.java +++ b/net/minecraft/world/level/chunk/status/ChunkStep.java -@@ -11,9 +11,50 @@ import net.minecraft.util.profiling.jfr.callback.ProfiledDuration; - import net.minecraft.world.level.chunk.ChunkAccess; +@@ -11,9 +11,50 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ProtoChunk; + import org.jspecify.annotations.Nullable; -public record ChunkStep( - ChunkStatus targetStatus, ChunkDependencies directDependencies, ChunkDependencies accumulatedDependencies, int blockStateWriteRadius, ChunkStatusTask task @@ -32757,137 +32731,12 @@ index 7a4d299d2ce36982204e30de9278ddfd5b37c3df..b8348976e80578d9eff64eea68c04c60 + public static class Builder { private final ChunkStatus status; - @Nullable -diff --git a/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index 8c1417c659ea0e079e99b9bfa79e1cf6ba9b712b..8847fc3b164bb011cea24217623c59f5b78f787b 100644 ---- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -@@ -22,20 +22,30 @@ import net.minecraft.world.level.chunk.ChunkGenerator; - import net.minecraft.world.level.levelgen.structure.LegacyStructureDataHandler; - import net.minecraft.world.level.storage.DimensionDataStorage; - --public class ChunkStorage implements AutoCloseable { -+public class ChunkStorage implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemChunkStorage { // Paper - rewrite chunk system - public static final int LAST_MONOLYTH_STRUCTURE_DATA_VERSION = 1493; -- private final IOWorker worker; -+ // Paper - rewrite chunk system - protected final DataFixer fixerUpper; - @Nullable - private volatile LegacyStructureDataHandler legacyStructureHandler; - -+ // Paper start - rewrite chunk system -+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); -+ private final RegionFileStorage storage; -+ -+ @Override -+ public final RegionFileStorage moonrise$getRegionStorage() { -+ return this.storage; -+ } -+ // Paper end - rewrite chunk system -+ - public ChunkStorage(RegionStorageInfo info, Path folder, DataFixer fixerUpper, boolean sync) { - this.fixerUpper = fixerUpper; -- this.worker = new IOWorker(info, folder, sync); -+ this.storage = new IOWorker(info, folder, sync).storage; // Paper - rewrite chunk system - } - - public boolean isOldChunkAround(ChunkPos pos, int radius) { -- return this.worker.isOldChunkAround(pos, radius); -+ return true; // Paper - rewrite chunk system - } - - // CraftBukkit start -@@ -66,7 +76,9 @@ public class ChunkStorage implements AutoCloseable { - chunkData = DataFixTypes.CHUNK.update(this.fixerUpper, chunkData, version, 1493); - if (chunkData.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { - LegacyStructureDataHandler legacyStructureHandler = this.getLegacyStructureHandler(levelKey, storage); -+ synchronized (legacyStructureHandler) { // Paper - rewrite chunk system - chunkData = legacyStructureHandler.updateFromLegacy(chunkData); -+ } - } - } - -@@ -130,7 +142,13 @@ public class ChunkStorage implements AutoCloseable { - } - - public CompletableFuture> read(ChunkPos chunkPos) { -- return this.worker.loadAsync(chunkPos); -+ // Paper start - rewrite chunk system -+ try { -+ return CompletableFuture.completedFuture(Optional.ofNullable(this.storage.read(chunkPos))); -+ } catch (final Throwable throwable) { -+ return CompletableFuture.failedFuture(throwable); -+ } -+ // Paper end - rewrite chunk system - } - - public CompletableFuture write(ChunkPos pos, Supplier tagSupplier) { -@@ -146,29 +164,54 @@ public class ChunkStorage implements AutoCloseable { - }; - // Paper end - guard against possible chunk pos desync - this.handleLegacyStructureIndex(pos); -- return this.worker.store(pos, guardedPosCheck); // Paper - guard against possible chunk pos desync -+ // Paper start - rewrite chunk system -+ try { -+ this.storage.write(pos, guardedPosCheck.get()); -+ return CompletableFuture.completedFuture(null); -+ } catch (final Throwable throwable) { -+ return CompletableFuture.failedFuture(throwable); -+ } -+ // Paper end - rewrite chunk system - } - - protected void handleLegacyStructureIndex(ChunkPos chunkPos) { - if (this.legacyStructureHandler != null) { -+ synchronized (this.legacyStructureHandler) { // Paper - rewrite chunk system - this.legacyStructureHandler.removeIndex(chunkPos.toLong()); -+ } // Paper - rewrite chunk system - } - } - - public void flushWorker() { -- this.worker.synchronize(true).join(); -+ // Paper start - rewrite chunk system -+ try { -+ this.storage.flush(); -+ } catch (final IOException ex) { -+ LOGGER.error("Failed to flush chunk storage", ex); -+ } -+ // Paper end - rewrite chunk system - } - - @Override - public void close() throws IOException { -- this.worker.close(); -+ this.storage.close(); // Paper - rewrite chunk system - } - - public ChunkScanAccess chunkScanner() { -- return this.worker; -+ // Paper start - rewrite chunk system -+ // TODO ChunkMap implementation? -+ return (chunkPos, streamTagVisitor) -> { -+ try { -+ this.storage.scanChunk(chunkPos, streamTagVisitor); -+ return java.util.concurrent.CompletableFuture.completedFuture(null); -+ } catch (IOException e) { -+ throw new RuntimeException(e); -+ } -+ }; -+ // Paper end - rewrite chunk system - } - -- protected RegionStorageInfo storageInfo() { -- return this.worker.storageInfo(); -+ public RegionStorageInfo storageInfo() { // Paper - public -+ return this.storage.info(); // Paper - rewrite chunk system - } - } + 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 d0de56609f6f22dded474d7693935180761d2cb5..27e1edbd8d8ffd80c1a3df17bc47f4a6936619f7 100644 +index 17c91f6aa109b3cba51637e8499602d47e7a8649..b2b7c20a25bdefd42e8a36eb29935b8d5b24925d 100644 --- a/net/minecraft/world/level/chunk/storage/IOWorker.java +++ b/net/minecraft/world/level/chunk/storage/IOWorker.java -@@ -30,7 +30,7 @@ public class IOWorker implements ChunkScanAccess, AutoCloseable { +@@ -31,7 +31,7 @@ public class IOWorker implements ChunkScanAccess, AutoCloseable { private static final Logger LOGGER = LogUtils.getLogger(); private final AtomicBoolean shutdownRequested = new AtomicBoolean(); private final PriorityConsecutiveExecutor consecutiveExecutor; @@ -32897,11 +32746,11 @@ index d0de56609f6f22dded474d7693935180761d2cb5..27e1edbd8d8ffd80c1a3df17bc47f4a6 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 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845c31641a1 100644 +index f5d24254c84876f85d89e33381fae484817acf04..99bbae1f8f681950f410b2bfe9af037164d8dcb7 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.util.profiling.jfr.JvmProfiler; - import net.minecraft.world.level.ChunkPos; +@@ -22,7 +22,7 @@ import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class RegionFile implements AutoCloseable { @@ -32931,10 +32780,13 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 public RegionFile(RegionStorageInfo info, Path path, Path externalFileDir, boolean sync) throws IOException { this(info, path, externalFileDir, RegionFileVersion.getCompressionFormat(), sync); // Paper - Configurable region compression format } -@@ -203,6 +218,16 @@ public class RegionFile implements AutoCloseable { +@@ -199,7 +214,17 @@ public class RegionFile implements AutoCloseable { + } + } - @Nullable - private DataInputStream createExternalChunkInputStream(ChunkPos chunkPos, byte versionByte) throws IOException { +- private @Nullable DataInputStream createExternalChunkInputStream(ChunkPos chunkPos, byte versionByte) throws IOException { ++ @Nullable ++ private DataInputStream createExternalChunkInputStream(ChunkPos chunkPos, byte versionByte) throws IOException { + // Paper start - rewrite chunk system + final DataInputStream is = this.createExternalChunkInputStream0(chunkPos, versionByte); + if (is == null) { @@ -32942,13 +32794,12 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 + } + return new ca.spottedleaf.moonrise.patches.chunk_system.util.stream.ExternalChunkStreamMarker(is); + } -+ @Nullable -+ private DataInputStream createExternalChunkInputStream0(ChunkPos chunkPos, byte versionByte) throws IOException { ++ private @Nullable DataInputStream createExternalChunkInputStream0(ChunkPos chunkPos, byte versionByte) throws IOException { + // Paper end - rewrite chunk system Path externalChunkPath = this.getExternalChunkPath(chunkPos); if (!Files.isRegularFile(externalChunkPath)) { LOGGER.error("External chunk path {} is not file", externalChunkPath); -@@ -397,9 +422,28 @@ public class RegionFile implements AutoCloseable { +@@ -394,9 +419,28 @@ public class RegionFile implements AutoCloseable { } } @@ -32978,7 +32829,7 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 public ChunkBuffer(final ChunkPos pos) { super(8096); super.write(0); -@@ -416,7 +460,7 @@ public class RegionFile implements AutoCloseable { +@@ -413,7 +457,7 @@ public class RegionFile implements AutoCloseable { int i = this.count - 5 + 1; JvmProfiler.INSTANCE.onRegionFileWrite(RegionFile.this.info, this.pos, RegionFile.this.version, i); byteBuffer.putInt(0, i); @@ -32988,12 +32839,12 @@ index 43d38cf26224919cd53d7479753d658f4ab40dbc..07c2e2170af5820acdcb64f2c7978845 } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f485dcf6d 100644 +index 95a717797dc1bba5595e8305f21b193b2e1702cc..5d9168242f7a7ca4dd888f32fecb27457fd89456 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.nbt.StreamTagVisitor; - import net.minecraft.util.ExceptionCollector; +@@ -15,7 +15,7 @@ import net.minecraft.util.FileUtil; import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; -public final class RegionFileStorage implements AutoCloseable { +public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.io.ChunkSystemRegionFileStorage { // Paper - rewrite chunk system @@ -33230,8 +33081,8 @@ index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f + // Paper end - rewrite chunk system } - @Nullable -@@ -84,9 +273,15 @@ public final class RegionFileStorage implements AutoCloseable { + public @Nullable CompoundTag read(ChunkPos chunkPos) throws IOException { +@@ -83,9 +272,15 @@ public final class RegionFileStorage implements AutoCloseable { } } @@ -33249,7 +33100,7 @@ index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f if (chunkData == null) { regionFile.clear(chunkPos); } else { -@@ -99,23 +294,36 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -98,23 +293,36 @@ public final class RegionFileStorage implements AutoCloseable { @Override public void close() throws IOException { @@ -33298,11 +33149,11 @@ index 54ac20dede33a20231476d433f39cadc40c9fa49..263ab4a8056ed9115c293484fef13e6f public RegionStorageInfo info() { diff --git a/net/minecraft/world/level/chunk/storage/SectionStorage.java b/net/minecraft/world/level/chunk/storage/SectionStorage.java -index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c34f4a004 100644 +index 7514737caf11630433752206fd614ee221f3523e..42699c82321233eaa3647ca0ac4d1f24b6a6227f 100644 --- a/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SectionStorage.java -@@ -40,10 +40,10 @@ import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.LevelHeightAccessor; +@@ -40,10 +40,10 @@ import net.minecraft.world.level.LevelHeightAccessor; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class SectionStorage implements AutoCloseable { @@ -33346,11 +33197,11 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c this.registryAccess = registryAccess; this.errorReporter = errorReporter; this.levelHeightAccessor = levelHeightAccessor; -+ this.regionStorage = simpleRegionStorage.worker.storage; // Paper - rewrite chunk system ++ this.regionStorage = ((ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemSimpleRegionStorage)simpleRegionStorage).moonrise$getRegionStorage(); // Paper - rewrite chunk system } protected void tick(BooleanSupplier aheadOfTime) { -@@ -188,65 +201,15 @@ public class SectionStorage implements AutoCloseable { +@@ -187,65 +200,15 @@ public class SectionStorage implements AutoCloseable { } private CompletableFuture>> tryRead(ChunkPos chunkPos) { @@ -33379,7 +33230,7 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c + throw new IllegalStateException("Only chunk system can write state, offending class:" + this.getClass().getName()); // Paper - rewrite chunk system } - private void unpackChunk(ChunkPos pos, @Nullable SectionStorage.PackedChunk

packedChunk) { + private void unpackChunk(ChunkPos pos, SectionStorage.@Nullable PackedChunk

packedChunk) { - if (packedChunk == null) { - for (int sectionY = this.levelHeightAccessor.getMinSectionY(); sectionY <= this.levelHeightAccessor.getMaxSectionY(); sectionY++) { - this.storage.put(getKey(pos, sectionY), Optional.empty()); @@ -33407,8 +33258,8 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c - RegistryOps registryOps = this.registryAccess.createSerializationContext(NbtOps.INSTANCE); - Dynamic dynamic = this.writeChunk(pos, registryOps); - Tag tag = dynamic.getValue(); -- if (tag instanceof CompoundTag) { -- this.simpleRegionStorage.write(pos, (CompoundTag)tag).exceptionally(throwable -> { +- if (tag instanceof CompoundTag compoundTag) { +- this.simpleRegionStorage.write(pos, compoundTag).exceptionally(throwable -> { - this.errorReporter.reportChunkSaveFailure(throwable, this.simpleRegionStorage.storageInfo(), pos); - return null; - }); @@ -33419,7 +33270,7 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c } private Dynamic writeChunk(ChunkPos pos, DynamicOps ops) { -@@ -282,7 +245,7 @@ public class SectionStorage implements AutoCloseable { +@@ -281,7 +244,7 @@ public class SectionStorage implements AutoCloseable { protected void onSectionLoad(long sectionKey) { } @@ -33428,7 +33279,7 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c Optional optional = this.storage.get(sectionPos); if (optional != null && !optional.isEmpty()) { this.dirtyChunks.add(ChunkPos.asLong(SectionPos.x(sectionPos), SectionPos.z(sectionPos))); -@@ -299,7 +262,7 @@ public class SectionStorage implements AutoCloseable { +@@ -298,7 +261,7 @@ public class SectionStorage implements AutoCloseable { @Override public void close() throws IOException { @@ -33438,10 +33289,10 @@ index 06cf2363218eddacc6cdfd95dcfd9dfc55403b88..afac559b3c38c4a175070ed823dc8f2c record PackedChunk(Int2ObjectMap sectionsByY, boolean versionChanged) { diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19794343b1 100644 +index 7fe16da65d6cf5019fa854324d43e0f97bb0b016..b2363fa364be15d0a28f5966615131282b7aaa8f 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -144,7 +144,7 @@ public record SerializableChunkData( +@@ -143,7 +143,7 @@ public record SerializableChunkData( long longOr1 = tag.getLongOr("InhabitedTime", 0L); ChunkStatus chunkStatus = tag.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); UpgradeData upgradeData = tag.getCompound("UpgradeData").map(compoundTag1 -> new UpgradeData(compoundTag1, level)).orElse(UpgradeData.EMPTY); @@ -33450,16 +33301,16 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 BlendingData.Packed packed = tag.read("blending_data", BlendingData.Packed.CODEC).orElse(null); BelowZeroRetrogen belowZeroRetrogen = tag.read("below_zero_retrogen", BelowZeroRetrogen.CODEC).orElse(null); long[] longs = tag.getLongArray("carving_mask").orElse(null); -@@ -182,7 +182,7 @@ public record SerializableChunkData( - for (int i2 = 0; i2 < listOrEmpty2.size(); i2++) { - Optional compound = listOrEmpty2.getCompound(i2); +@@ -183,7 +183,7 @@ public record SerializableChunkData( + for (int i2 = 0; i2 < listOrEmpty1.size(); i2++) { + Optional compound = listOrEmpty1.getCompound(i2); if (!compound.isEmpty()) { - CompoundTag compoundTag = compound.get(); + CompoundTag compoundTag = compound.get(); final CompoundTag sectionData = compoundTag; // Paper - OBFHELPER int byteOr = compoundTag.getByteOr("Y", (byte)0); LevelChunkSection levelChunkSection; if (byteOr >= level.getMinSectionY() && byteOr <= level.getMaxSectionY()) { -@@ -207,7 +207,17 @@ public record SerializableChunkData( +@@ -208,7 +208,17 @@ public record SerializableChunkData( DataLayer dataLayer = compoundTag.getByteArray("BlockLight").map(DataLayer::new).orElse(null); DataLayer dataLayer1 = compoundTag.getByteArray("SkyLight").map(DataLayer::new).orElse(null); @@ -33478,7 +33329,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } } -@@ -235,6 +245,59 @@ public record SerializableChunkData( +@@ -236,6 +246,59 @@ public record SerializableChunkData( } } @@ -33538,7 +33389,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 public ProtoChunk read(ServerLevel level, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos pos) { if (!Objects.equals(pos, this.chunkPos)) { LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", pos, pos, this.chunkPos); -@@ -253,7 +316,7 @@ public record SerializableChunkData( +@@ -254,7 +317,7 @@ public record SerializableChunkData( SectionPos sectionPos = SectionPos.of(pos, sectionData.y); if (sectionData.chunkSection != null) { levelChunkSections[level.getSectionIndexFromSectionY(sectionData.y)] = sectionData.chunkSection; @@ -33547,7 +33398,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } boolean flag1 = sectionData.blockLight != null; -@@ -342,7 +405,7 @@ public record SerializableChunkData( +@@ -346,7 +409,7 @@ public record SerializableChunkData( } if (chunkType == ChunkType.LEVELCHUNK) { @@ -33556,7 +33407,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } else { ProtoChunk protoChunk1 = (ProtoChunk)chunkAccess; -@@ -358,7 +421,7 @@ public record SerializableChunkData( +@@ -362,7 +425,7 @@ public record SerializableChunkData( protoChunk1.setCarvingMask(new CarvingMask(this.carvingMask, chunkAccess.getMinY())); } @@ -33565,7 +33416,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } } -@@ -371,22 +434,48 @@ public record SerializableChunkData( +@@ -375,22 +438,48 @@ public record SerializableChunkData( throw new IllegalArgumentException("Chunk can't be serialized: " + chunk); } else { ChunkPos pos = chunk.getPos(); @@ -33625,7 +33476,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 List list1 = new ArrayList<>(chunk.getBlockEntitiesPos().size()); -@@ -473,7 +562,7 @@ public record SerializableChunkData( +@@ -477,7 +566,7 @@ public record SerializableChunkData( Codec>> codec1 = this.containerFactory.biomeContainerCodec(); for (SerializableChunkData.SectionData sectionData : this.sectionData) { @@ -33634,7 +33485,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 LevelChunkSection levelChunkSection = sectionData.chunkSection; if (levelChunkSection != null) { compoundTag1.store("block_states", codec, levelChunkSection.getStates()); -@@ -488,6 +577,19 @@ public record SerializableChunkData( +@@ -492,6 +581,19 @@ public record SerializableChunkData( compoundTag1.putByteArray("SkyLight", sectionData.skyLight.getData()); } @@ -33654,7 +33505,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 if (!compoundTag1.isEmpty()) { compoundTag1.putByte("Y", (byte)sectionData.y); listTag.add(compoundTag1); -@@ -522,6 +624,14 @@ public record SerializableChunkData( +@@ -526,6 +628,14 @@ public record SerializableChunkData( compoundTag.put("ChunkBukkitValues", this.persistentDataContainer); } // CraftBukkit end @@ -33669,7 +33520,7 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 return compoundTag; } -@@ -667,6 +777,66 @@ public record SerializableChunkData( +@@ -670,6 +780,66 @@ public record SerializableChunkData( } } @@ -33738,30 +33589,147 @@ index b71be4e06a849117b11eb10870c08266bed20eae..0994145addaa06c0094cfd6601d1cc19 } } diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -index bc4adf91ca8aa0160a1e3940f1396e62207fcc74..a30cbccae6d6cf2f7248501c1b1de3c124688b5e 100644 +index ab5ee9d343ef3b3930eadf9bc17c202215c15121..ba620dafb862dd59fff85da0619dc66cc1c2cb20 100644 --- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -@@ -14,7 +14,7 @@ import net.minecraft.util.datafix.DataFixTypes; +@@ -19,8 +19,9 @@ import net.minecraft.util.datafix.DataFixTypes; import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; - public class SimpleRegionStorage implements AutoCloseable { +-public class SimpleRegionStorage implements AutoCloseable { - private final IOWorker worker; -+ public final IOWorker worker; // Paper - public ++public class SimpleRegionStorage implements ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemSimpleRegionStorage, AutoCloseable { // Paper - rewrite chunk system ++ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getClassLogger(); // Paper - rewrite chunk system ++ private final RegionFileStorage storage; // Paper - rewrite chunk system private final DataFixer fixerUpper; private final DataFixTypes dataFixType; + private final Supplier legacyFixer; +@@ -34,16 +35,29 @@ public class SimpleRegionStorage implements AutoCloseable { + ) { + this.fixerUpper = fixerUpper; + this.dataFixType = dataFixType; +- this.worker = new IOWorker(info, folder, sync); ++ this.storage = new IOWorker(info, folder, sync).storage; // Paper - rewrite chunk system + this.legacyFixer = Suppliers.memoize(legacyFixer::get); + } ++ // Paper start - rewrite chunk system ++ @Override ++ public final RegionFileStorage moonrise$getRegionStorage() { ++ return this.storage; ++ } ++ // Paper end - rewrite chunk system ++ + public boolean isOldChunkAround(ChunkPos chunkPos, int radius) { +- return this.worker.isOldChunkAround(chunkPos, radius); ++ return true; // Paper - rewrite chunk system + } + + public CompletableFuture> read(ChunkPos chunkPos) { +- return this.worker.loadAsync(chunkPos); ++ // Paper start - rewrite chunk system ++ try { ++ return CompletableFuture.completedFuture(Optional.ofNullable(this.storage.read(chunkPos))); ++ } catch (final Throwable throwable) { ++ return CompletableFuture.failedFuture(throwable); ++ } ++ // Paper end - rewrite chunk system + } + + public CompletableFuture write(ChunkPos chunkPos, CompoundTag data) { +@@ -64,7 +78,14 @@ public class SimpleRegionStorage implements AutoCloseable { + }; + // Paper end - guard against possible chunk pos desync + this.markChunkDone(chunkPos); +- return this.worker.store(chunkPos, guardedPosCheck); // Paper - guard against possible chunk pos desync ++ // Paper - rewrite chunk system ++ try { ++ this.storage.write(chunkPos, guardedPosCheck.get()); ++ return CompletableFuture.completedFuture(null); ++ } catch (final Throwable throwable) { ++ return CompletableFuture.failedFuture(throwable); ++ } ++ // Paper end - rewrite chunk system + } + + public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag, net.minecraft.world.level.@Nullable LevelAccessor levelAccessor) { // CraftBukkit +@@ -73,7 +94,12 @@ public class SimpleRegionStorage implements AutoCloseable { + return tag; + } else { + try { +- tag = this.legacyFixer.get().applyFix(tag); ++ // Paper start - rewrite chunk system ++ final net.minecraft.world.level.chunk.storage.LegacyTagFixer legacyFixer = this.legacyFixer.get(); ++ synchronized (legacyFixer) { ++ tag = legacyFixer.applyFix(tag); ++ } ++ // Paper end - rewrite chunk system + // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty + boolean stopBelowZero = false; + final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; +@@ -123,23 +149,46 @@ public class SimpleRegionStorage implements AutoCloseable { + } + + protected void markChunkDone(ChunkPos chunkPos) { +- this.legacyFixer.get().markChunkDone(chunkPos); ++ // Paper start - rewrite chunk system ++ final net.minecraft.world.level.chunk.storage.LegacyTagFixer legacyFixer = this.legacyFixer.get(); ++ synchronized (legacyFixer) { ++ legacyFixer.markChunkDone(chunkPos); ++ } ++ // Paper end - rewrite chunk system + } + + public CompletableFuture synchronize(boolean flushStorage) { +- return this.worker.synchronize(flushStorage); ++ // Paper start - rewrite chunk system ++ try { ++ this.storage.flush(); ++ return CompletableFuture.completedFuture(null); ++ } catch (final IOException ex) { ++ LOGGER.error("Failed to flush chunk storage", ex); ++ return CompletableFuture.failedFuture(ex); ++ } ++ // Paper end - rewrite chunk system + } + + @Override + public void close() throws IOException { +- this.worker.close(); ++ this.storage.close(); // Paper - rewrite chunk system + } + + public ChunkScanAccess chunkScanner() { +- return this.worker; ++ // Paper start - rewrite chunk system ++ // TODO ChunkMap implementation? ++ return (chunkPos, streamTagVisitor) -> { ++ try { ++ this.storage.scanChunk(chunkPos, streamTagVisitor); ++ return java.util.concurrent.CompletableFuture.completedFuture(null); ++ } catch (IOException e) { ++ throw new RuntimeException(e); ++ } ++ }; ++ // Paper end - rewrite chunk system + } + + public RegionStorageInfo storageInfo() { +- return this.worker.storageInfo(); ++ return this.storage.info(); // Paper - rewrite chunk system + } + } diff --git a/net/minecraft/world/level/entity/EntityTickList.java b/net/minecraft/world/level/entity/EntityTickList.java -index 342c83309b19c64d86e0dd97c1756c96be52772b..423779a2b690f387a4f0bd07b97b50e0baefda76 100644 +index 3861282e2e55c28bd4fa0169373ce5d8b914802e..79a34ce6c888a611115719412d9a9bbcc0be498a 100644 --- a/net/minecraft/world/level/entity/EntityTickList.java +++ b/net/minecraft/world/level/entity/EntityTickList.java -@@ -9,52 +9,38 @@ import javax.annotation.Nullable; - import net.minecraft.world.entity.Entity; +@@ -9,51 +9,38 @@ import net.minecraft.world.entity.Entity; + import org.jspecify.annotations.Nullable; public class EntityTickList { - private Int2ObjectMap active = new Int2ObjectLinkedOpenHashMap<>(); - private Int2ObjectMap passive = new Int2ObjectLinkedOpenHashMap<>(); -- @Nullable -- private Int2ObjectMap iterated; +- private @Nullable Int2ObjectMap iterated; + private final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system private void ensureActiveIsNotIterated() { @@ -33823,10 +33791,10 @@ index 342c83309b19c64d86e0dd97c1756c96be52772b..423779a2b690f387a4f0bd07b97b50e0 } } diff --git a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -index 2b98932e69271571e6e9350c55c82edc858d76f6..c8980c50713e1526c526ed181fb2ad9486bab353 100644 +index b25fdc2562d6710da698b5d2532304e8e47bd535..cf1f2ed003a94156cf688071aeea53c7ad22b700 100644 --- a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java +++ b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -@@ -27,6 +27,14 @@ public class DynamicGameEventListener { +@@ -26,6 +26,14 @@ public class DynamicGameEventListener { public void remove(ServerLevel level) { ifChunkExists(level, this.lastSection, listenerRegistry -> listenerRegistry.unregister(this.listener)); @@ -33842,10 +33810,10 @@ index 2b98932e69271571e6e9350c55c82edc858d76f6..c8980c50713e1526c526ed181fb2ad94 public void move(ServerLevel level) { diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -index 613c7d730ba0ffd61b0525c2a772b837f7a39e3d..576749f5088e6ec49a79b440aa109822e0be33c8 100644 +index b619bfcdc53fb1fc325dc1093695c13ea3bab1ae..d1068a122e5dbd5af274d0f8178ca9f5fa49f930 100644 --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -83,7 +83,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { +@@ -85,7 +85,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { return CompletableFuture.supplyAsync(() -> { this.doCreateBiomes(blender, randomState, structureManager, chunk); return chunk; @@ -33854,7 +33822,7 @@ index 613c7d730ba0ffd61b0525c2a772b837f7a39e3d..576749f5088e6ec49a79b440aa109822 } private void doCreateBiomes(Blender blender, RandomState random, StructureManager structureManager, ChunkAccess chunk) { -@@ -325,7 +325,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { +@@ -327,7 +327,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { } return var20; @@ -33864,10 +33832,10 @@ index 613c7d730ba0ffd61b0525c2a772b837f7a39e3d..576749f5088e6ec49a79b440aa109822 private ChunkAccess doFill(Blender blender, StructureManager structureManager, RandomState random, ChunkAccess chunk, int minCellY, int cellCountY) { diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b048d778564 100644 +index 97d9e4d3e47dd568f624b96ce4e27f3abcd23678..5198894e7a9b4fffa5ee9d9e4d8fad173c2294cd 100644 --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -48,8 +48,13 @@ public class StructureCheck { +@@ -50,8 +50,13 @@ public class StructureCheck { private final BiomeSource biomeSource; private final long seed; private final DataFixer fixerUpper; @@ -33883,7 +33851,7 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 public StructureCheck( ChunkScanAccess storageAccess, -@@ -91,7 +96,7 @@ public class StructureCheck { +@@ -93,7 +98,7 @@ public class StructureCheck { public StructureCheckResult checkStart(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) { long packedChunkPos = chunkPos.toLong(); @@ -33892,7 +33860,7 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 if (map != null) { return this.checkStructureInfo(map, structure, skipKnownStructures); } else { -@@ -101,9 +106,11 @@ public class StructureCheck { +@@ -103,9 +108,11 @@ public class StructureCheck { } else if (!placement.applyAdditionalChunkRestrictions(chunkPos.x, chunkPos.z, this.seed, this.getSaltOverride(structure))) { // Paper - add missing structure seed configs return StructureCheckResult.START_NOT_PRESENT; } else { @@ -33907,7 +33875,7 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 return !flag ? StructureCheckResult.START_NOT_PRESENT : StructureCheckResult.CHUNK_LOAD_NEEDED; } } -@@ -222,15 +229,25 @@ public class StructureCheck { +@@ -224,15 +231,25 @@ public class StructureCheck { } private void storeFullResults(long chunkPos, Object2IntMap structureChunks) { @@ -33938,22 +33906,20 @@ index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b04 map.computeInt(structure, (structure1, integer) -> integer == null ? 1 : integer + 1); return map; diff --git a/net/minecraft/world/level/lighting/LevelLightEngine.java b/net/minecraft/world/level/lighting/LevelLightEngine.java -index e67d7915748e55e1f7244902e9f8f73666dcb67b..d1ebecde6d3fe741f819ae0eb1df63426aa0c146 100644 +index dbf0a3a30070ad5c8d4084cd4fcd9941b50e98f8..51c9462d091a42192989dee08738caa25e88b1a2 100644 --- a/net/minecraft/world/level/lighting/LevelLightEngine.java +++ b/net/minecraft/world/level/lighting/LevelLightEngine.java -@@ -9,151 +9,111 @@ import net.minecraft.world.level.LightLayer; - import net.minecraft.world.level.chunk.DataLayer; +@@ -9,149 +9,111 @@ import net.minecraft.world.level.chunk.DataLayer; import net.minecraft.world.level.chunk.LightChunkGetter; + import org.jspecify.annotations.Nullable; -public class LevelLightEngine implements LightEventListener { +public class LevelLightEngine implements LightEventListener, ca.spottedleaf.moonrise.patches.starlight.light.StarLightLightingProvider { // Paper - rewrite chunk system public static final int LIGHT_SECTION_PADDING = 1; public static final LevelLightEngine EMPTY = new LevelLightEngine(); protected final LevelHeightAccessor levelHeightAccessor; -- @Nullable -- private final LightEngine blockEngine; -- @Nullable -- private final LightEngine skyEngine; +- private final @Nullable LightEngine blockEngine; +- private final @Nullable LightEngine skyEngine; + // Paper start - rewrite chunk system + protected final ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface lightEngine; + @@ -34312,12 +34278,12 @@ index 41bea92e2ce834ddb2e5d62d0a0008ef662b77b4..85e9ec8061fc01d39977f6db314da14b protected abstract boolean canConvertToSource(ServerLevel level); diff --git a/net/minecraft/world/level/material/FluidState.java b/net/minecraft/world/level/material/FluidState.java -index 9dda7d19f3f6ca9b402ebe0e4b042ff859b5dcbd..0a5ae623a636923f3bbd3c01974497f39b7c4b62 100644 +index c460de79f14cab6c7de4ba28e359762382d7c972..3e5ada4a84bc1da06102dfacb0d3d45a4fc6db8a 100644 --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java -@@ -25,12 +25,30 @@ import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; +@@ -25,12 +25,30 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public final class FluidState extends StateHolder { +public final class FluidState extends StateHolder implements ca.spottedleaf.moonrise.patches.fluid.FluidFluidState { // Paper - fluid method optimisations @@ -34397,22 +34363,26 @@ index 9dda7d19f3f6ca9b402ebe0e4b042ff859b5dcbd..0a5ae623a636923f3bbd3c01974497f3 + // Paper end - fluid method optimisations } - @Nullable + public @Nullable ParticleOptions getDripParticle() { diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java -index d410f88d6810046d8fca92afe198f04fdf0a9aca..cffb3b7d480f72cdb9ed535f362fa60f30597523 100644 +index 26f807a2fadabfdd7a7144e1c1146e7a2577190a..e6ba6447616ee70b4dd5baa467650da450450f1e 100644 --- a/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java -@@ -319,7 +319,7 @@ public class AABB { +@@ -317,9 +317,10 @@ public class AABB { + } } - @Nullable -- private static Direction getDirection(AABB aabb, Vec3 start, double[] minDistance, @Nullable Direction facing, double deltaX, double deltaY, double deltaZ) { -+ public static Direction getDirection(AABB aabb, Vec3 start, double[] minDistance, @Nullable Direction facing, double deltaX, double deltaY, double deltaZ) { // Paper - optimise collisions - public +- private static @Nullable Direction getDirection( ++ ++ public static @Nullable Direction getDirection( + AABB aabb, Vec3 start, double[] minDistance, @Nullable Direction facing, double deltaX, double deltaY, double deltaZ +- ) { ++ ) { // Paper - optimise collisions - public return getDirection(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ, start, minDistance, facing, deltaX, deltaY, deltaZ); } diff --git a/net/minecraft/world/phys/shapes/ArrayVoxelShape.java b/net/minecraft/world/phys/shapes/ArrayVoxelShape.java -index 4f79538b8127207eae988dfb137d643b7969aafc..31664aeaffd0d891d954a7058e9a49985e23ba02 100644 +index 91a8124a302594eedad0833a50eeb95d291b3674..3506d7db68d4428497126d5ebd29106d5816bcfe 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 { @@ -34607,12 +34577,12 @@ index f6b6481591e009de80f6b6318d35f193aabb7df3..e9b5069dcd572966b2f5aa220cef30e7 @Override diff --git a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -index 8f4c93832c26322c0051043cbd405729075d6e3a..f4efe69ed6c85ea499eefd0bae863ba70ed2d722 100644 +index aad858a5a1bf50b1e3121cfd5bfb9660dca7b8e7..c60fbd10cae82f75566ffc2c9cc1abd94a6086f4 100644 --- a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java +++ b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -@@ -4,12 +4,79 @@ import com.mojang.math.OctahedralGroup; - import net.minecraft.core.AxisCycle; +@@ -5,12 +5,79 @@ import net.minecraft.core.AxisCycle; import net.minecraft.core.Direction; + import org.joml.Vector3i; -public abstract class DiscreteVoxelShape { +public abstract class DiscreteVoxelShape implements ca.spottedleaf.moonrise.patches.collisions.shape.CollisionDiscreteVoxelShape { // Paper - optimise collisions @@ -34707,10 +34677,10 @@ index ac1488875537421b74f0c491c9b7a40e75539c92..9eb27eb8d6dcaad6ce02f8ce4546acc2 public OffsetDoubleList(DoubleList delegate, double offset) { this.delegate = delegate; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414ce6f069d0 100644 +index b17ffae691eaaedf6b1371adae02adf92147056e..ac4bb789df88c07ea38d20700dccb6571e3ea58d 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java -@@ -22,9 +22,15 @@ public final class Shapes { +@@ -21,9 +21,15 @@ public final class Shapes { public static final double EPSILON = 1.0E-7; public static final double BIG_EPSILON = 1.0E-6; private static final VoxelShape BLOCK = Util.make(() -> { @@ -34729,7 +34699,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c }); private static final Vec3 BLOCK_CENTER = new Vec3(0.5, 0.5, 0.5); public static final VoxelShape INFINITY = box( -@@ -50,6 +56,30 @@ public final class Shapes { +@@ -49,6 +55,30 @@ public final class Shapes { return BLOCK; } @@ -34760,7 +34730,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c public static VoxelShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { if (!(minX > maxX) && !(minY > maxY) && !(minZ > maxZ)) { return create(minX, minY, minZ, maxX, maxY, maxZ); -@@ -59,39 +89,42 @@ public final class Shapes { +@@ -58,39 +88,42 @@ public final class Shapes { } public static VoxelShape create(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { @@ -34829,7 +34799,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c } public static VoxelShape create(AABB aabb) { -@@ -127,85 +160,52 @@ public final class Shapes { +@@ -126,85 +159,52 @@ public final class Shapes { } public static VoxelShape or(VoxelShape shape1, VoxelShape... others) { @@ -34952,7 +34922,7 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c } private static boolean joinIsNotEmpty( -@@ -237,52 +237,113 @@ public final class Shapes { +@@ -236,52 +236,113 @@ public final class Shapes { return desiredOffset; } @@ -35091,11 +35061,11 @@ index 2d3a58a256689132747013acd57251c85e3477d5..608dcf0e486c1cf2303e2039221e414c + return ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)shape1).moonrise$occludesFullBlock(); + } -- public static boolean faceShapeOccludes(VoxelShape voxelShape1, VoxelShape voxelShape2) { -- return voxelShape1 == block() -- || voxelShape2 == block() -- || (!voxelShape1.isEmpty() || !voxelShape2.isEmpty()) -- && !joinIsNotEmpty(block(), joinUnoptimized(voxelShape1, voxelShape2, BooleanOp.OR), BooleanOp.ONLY_FIRST); +- public static boolean faceShapeOccludes(VoxelShape shape, VoxelShape adjacentShape) { +- return shape == block() +- || adjacentShape == block() +- || (!shape.isEmpty() || !adjacentShape.isEmpty()) +- && !joinIsNotEmpty(block(), joinUnoptimized(shape, adjacentShape, BooleanOp.OR), BooleanOp.ONLY_FIRST); + return mergedMayOccludeBlock(shape1, shape2) && ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)shape1).moonrise$orUnoptimized(shape2)).moonrise$occludesFullBlock(); + // Paper end - optimise collisions } @@ -35114,19 +35084,18 @@ index 79f7f04207891dd98cc0b2d93ecb2e07c8baa7b6..7ca12213c10f962ff597a8d51413a17b private static DiscreteVoxelShape makeSlice(DiscreteVoxelShape shape, Direction.Axis axis, int index) { diff --git a/net/minecraft/world/phys/shapes/VoxelShape.java b/net/minecraft/world/phys/shapes/VoxelShape.java -index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70f6b9dd73 100644 +index 72727d38d1de7ae82b0fc755aacbc600cb811078..59ca209aa0c545c4288c89ea5ff18842cf10fceb 100644 --- a/net/minecraft/world/phys/shapes/VoxelShape.java +++ b/net/minecraft/world/phys/shapes/VoxelShape.java -@@ -16,61 +16,546 @@ import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.BlockHitResult; - import net.minecraft.world.phys.Vec3; +@@ -18,60 +18,545 @@ import net.minecraft.world.phys.Vec3; + import org.apache.commons.lang3.mutable.MutableObject; + import org.jspecify.annotations.Nullable; -public abstract class VoxelShape { - protected final DiscreteVoxelShape shape; +public abstract class VoxelShape implements ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape { // Paper - optimise collisions + public final DiscreteVoxelShape shape; // Paper - optimise collisions - public - @Nullable - private VoxelShape[] faces; + private @Nullable VoxelShape @Nullable [] faces; + // Paper start - optimise collisions + private double offsetX; @@ -35693,7 +35662,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public VoxelShape move(Vec3 offset) { -@@ -82,20 +567,96 @@ public abstract class VoxelShape { +@@ -83,20 +568,96 @@ public abstract class VoxelShape { } public VoxelShape move(double xOffset, double yOffset, double zOffset) { @@ -35801,7 +35770,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public void forAllEdges(Shapes.DoubleLineConsumer action) { -@@ -127,9 +688,24 @@ public abstract class VoxelShape { +@@ -128,9 +689,24 @@ public abstract class VoxelShape { } public List toAabbs() { @@ -35829,7 +35798,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public double min(Direction.Axis axis, double primaryPosition, double secondaryPosition) { -@@ -151,46 +727,92 @@ public abstract class VoxelShape { +@@ -152,46 +728,91 @@ public abstract class VoxelShape { } protected int findIndex(Direction.Axis axis, double position) { @@ -35862,8 +35831,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 + // Paper end - optimise collisions } - @Nullable - public BlockHitResult clip(Vec3 startVec, Vec3 endVec, BlockPos pos) { + public @Nullable BlockHitResult clip(Vec3 startVec, Vec3 endVec, BlockPos pos) { - if (this.isEmpty()) { + // Paper start - optimise collisions + if (this.isEmpty) { @@ -35916,16 +35884,17 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 + if (this.isEmpty) { return Optional.empty(); - } else { -- Vec3[] vec3s = new Vec3[1]; +- MutableObject mutableObject = new MutableObject<>(); - this.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { - double d = Mth.clamp(point.x(), x1, x2); - double d1 = Mth.clamp(point.y(), y1, y2); - double d2 = Mth.clamp(point.z(), z1, z2); -- if (vec3s[0] == null || point.distanceToSqr(d, d1, d2) < point.distanceToSqr(vec3s[0])) { -- vec3s[0] = new Vec3(d, d1, d2); +- Vec3 vec3 = mutableObject.get(); +- if (vec3 == null || point.distanceToSqr(d, d1, d2) < point.distanceToSqr(vec3)) { +- mutableObject.setValue(new Vec3(d, d1, d2)); - } - }); -- return Optional.of(vec3s[0]); +- return Optional.of(Objects.requireNonNull(mutableObject.get())); } + + Vec3 ret = null; @@ -35950,7 +35919,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } public VoxelShape getFaceShape(Direction side) { -@@ -213,19 +835,23 @@ public abstract class VoxelShape { +@@ -214,19 +835,23 @@ public abstract class VoxelShape { } private VoxelShape calculateFace(Direction side) { @@ -35985,7 +35954,7 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 } protected boolean isCubeLike() { -@@ -243,9 +869,30 @@ public abstract class VoxelShape { +@@ -244,9 +869,30 @@ public abstract class VoxelShape { return coords.size() == 2 && DoubleMath.fuzzyEquals(coords.getDouble(0), 0.0, 1.0E-7) && DoubleMath.fuzzyEquals(coords.getDouble(1), 1.0, 1.0E-7); } @@ -36019,21 +35988,19 @@ index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70 protected double collideX(AxisCycle movementAxis, AABB collisionBox, double desiredOffset) { if (this.isEmpty()) { diff --git a/net/minecraft/world/ticks/LevelChunkTicks.java b/net/minecraft/world/ticks/LevelChunkTicks.java -index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8d36fbb4a 100644 +index 5fa7b312bf3bdd1ea0900dc7c599f88542115329..0b13971259f58876b778c0d28ad20c3510ed46ad 100644 --- a/net/minecraft/world/ticks/LevelChunkTicks.java +++ b/net/minecraft/world/ticks/LevelChunkTicks.java -@@ -13,7 +13,7 @@ import java.util.stream.Stream; - import javax.annotation.Nullable; +@@ -13,12 +13,36 @@ import java.util.stream.Stream; import net.minecraft.core.BlockPos; + import org.jspecify.annotations.Nullable; -public class LevelChunkTicks implements SerializableTickContainer, TickContainerAccess { +public class LevelChunkTicks implements SerializableTickContainer, TickContainerAccess, ca.spottedleaf.moonrise.patches.chunk_system.ticks.ChunkSystemLevelChunkTicks { // Paper - rewrite chunk system private final Queue> tickQueue = new PriorityQueue<>(ScheduledTick.DRAIN_ORDER); - @Nullable - private List> pendingTicks; -@@ -21,6 +21,30 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon - @Nullable - private BiConsumer, ScheduledTick> onTickAdded; + private @Nullable List> pendingTicks; + private final Set> ticksPerPosition = new ObjectOpenCustomHashSet<>(ScheduledTick.UNIQUE_TICK_HASH); + private @Nullable BiConsumer, ScheduledTick> onTickAdded; + // Paper start - rewrite chunk system + /* @@ -36062,8 +36029,8 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 public LevelChunkTicks() { } -@@ -45,7 +69,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon - public ScheduledTick poll() { +@@ -41,7 +65,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon + public @Nullable ScheduledTick poll() { ScheduledTick scheduledTick = this.tickQueue.poll(); if (scheduledTick != null) { - this.ticksPerPosition.remove(scheduledTick); @@ -36071,7 +36038,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 } return scheduledTick; -@@ -54,7 +78,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -50,7 +74,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon @Override public void schedule(ScheduledTick tick) { if (this.ticksPerPosition.add(tick)) { @@ -36080,7 +36047,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 } } -@@ -76,7 +100,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -72,7 +96,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon while (iterator.hasNext()) { ScheduledTick scheduledTick = iterator.next(); if (predicate.test(scheduledTick)) { @@ -36089,7 +36056,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 this.ticksPerPosition.remove(scheduledTick); } } -@@ -93,6 +117,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -89,6 +113,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon @Override public List> pack(long gameTime) { @@ -36097,7 +36064,7 @@ index 9334c5dcc4fa71cac38eed9ed18b50def313bcb4..2e28cc201e4557ff603aba7a6ed997b8 List> list = new ArrayList<>(this.tickQueue.size()); if (this.pendingTicks != null) { list.addAll(this.pendingTicks); -@@ -107,6 +132,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -103,6 +128,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon public void unpack(long gameTime) { if (this.pendingTicks != null) { diff --git a/paper-server/patches/features/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/paper-server/patches/features/0002-Optimize-Network-Manager-and-add-advanced-packet-sup.patch similarity index 93% rename from paper-server/patches/features/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch rename to paper-server/patches/features/0002-Optimize-Network-Manager-and-add-advanced-packet-sup.patch index 5bf1a407b9e2..bd8a743b0fdf 100644 --- a/paper-server/patches/features/0003-Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/paper-server/patches/features/0002-Optimize-Network-Manager-and-add-advanced-packet-sup.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 d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d8a2d2e16 100644 +index 68b081ef1b0bf9a58564d900569bc7a5dfef2a32..8817a2d6500d1bdce96d87dc8f7f364ccfa390e5 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -84,7 +84,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,10 +40,10 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d public Channel channel; public SocketAddress address; // Spigot start -@@ -147,6 +147,10 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -123,6 +123,10 @@ public class Connection extends SimpleChannelInboundHandler> { public boolean handledLegacyLoginEvent; // Paper - playerloginevent - public @Nullable net.minecraft.server.level.ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent - public @Nullable org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper + public net.minecraft.server.level.@Nullable ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent + public org.bukkit.event.player.PlayerResourcePackStatusEvent.@Nullable Status resourcePackStatus; // Paper + // Paper start - Optimize network + public boolean isPending = true; + public boolean queueImmunity; @@ -51,7 +51,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d public Connection(PacketFlow receiving) { this.receiving = receiving; -@@ -419,11 +423,38 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -395,11 +399,38 @@ public class Connection extends SimpleChannelInboundHandler> { } public void send(Packet packet, @Nullable ChannelFutureListener sendListener, boolean flush) { @@ -93,7 +93,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } } -@@ -432,7 +463,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -408,7 +439,7 @@ public class Connection extends SimpleChannelInboundHandler> { this.flushQueue(); action.accept(this); } else { @@ -102,7 +102,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } } -@@ -446,21 +477,41 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -422,21 +453,41 @@ public class Connection extends SimpleChannelInboundHandler> { } private void doSendPacket(Packet packet, @Nullable ChannelFutureListener sendListener, boolean flush) { @@ -148,7 +148,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } } -@@ -472,16 +523,57 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -448,16 +499,57 @@ public class Connection extends SimpleChannelInboundHandler> { } } @@ -211,7 +211,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d 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 -@@ -551,6 +643,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -527,6 +619,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void disconnect(DisconnectionDetails disconnectionDetails) { this.preparing = false; // Spigot @@ -219,7 +219,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d if (this.channel == null) { this.delayedDisconnect = disconnectionDetails; } -@@ -739,7 +832,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -703,7 +796,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void handleDisconnection() { if (this.channel != null && !this.channel.isOpen()) { if (this.disconnectionHandled) { @@ -228,7 +228,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d } else { this.disconnectionHandled = true; PacketListener packetListener = this.getPacketListener(); -@@ -750,7 +843,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -714,7 +807,7 @@ public class Connection extends SimpleChannelInboundHandler> { ); packetListener1.onDisconnect(disconnectionDetails); } @@ -237,7 +237,7 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d // Paper start - Add PlayerConnectionCloseEvent if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) { /* Player was logged in, either game listener or configuration listener */ -@@ -785,4 +878,97 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -749,4 +842,96 @@ public class Connection extends SimpleChannelInboundHandler> { public void setBandwidthLogger(LocalSampleLogger bandwidthLogger) { this.bandwidthDebugMonitor = new BandwidthDebugMonitor(bandwidthLogger); } @@ -256,10 +256,9 @@ index d849daa8d6517e177ac9b1e075ca9f2c09c922e5..c48d0a951f36e4449e9474994a21596d + this.pendingActions.clear(); + } + -+ private static class InnerUtil { // Attempt to hide these methods from ProtocolLib, so it doesn't accidently pick them up. ++ private static final class InnerUtil { // Attempt to hide these methods from ProtocolLib, so it doesn't accidently pick them up. + -+ @Nullable -+ private static java.util.List> buildExtraPackets(final Packet packet) { ++ private static java.util.@Nullable List> buildExtraPackets(final Packet packet) { + final java.util.List> extra = packet.getExtraPackets(); + if (extra == null || extra.isEmpty()) { + return null; @@ -373,10 +372,10 @@ index 65ff8b9112ec76eeac48c679044fc02ae7d4ffeb..062fd531edf6dfebb42dbaeee7bbda52 + // Paper end } diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java -index 16719b3eaec6fc261d227f47e82afc0506a6524d..deefad689070750a3ae033a3e54dd8f5c849e794 100644 +index c080b4eccb94551eefd7016200431e37221232b5..309845b28306dfa5946e79b80e5b1dde82dd68cd 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -67,11 +67,13 @@ public class ServerConnectionListener { +@@ -50,11 +50,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<>(); @@ -390,7 +389,7 @@ index 16719b3eaec6fc261d227f47e82afc0506a6524d..deefad689070750a3ae033a3e54dd8f5 } } // Paper end - prevent blocking on adding a new connection while the server is ticking -@@ -121,6 +123,7 @@ public class ServerConnectionListener { +@@ -86,6 +88,7 @@ public class ServerConnectionListener { } catch (ChannelException var5) { } diff --git a/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features/0003-Allow-Saving-of-Oversized-Chunks.patch similarity index 94% rename from paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch rename to paper-server/patches/features/0003-Allow-Saving-of-Oversized-Chunks.patch index 9b30daaf094d..7cf5f74712b2 100644 --- a/paper-server/patches/features/0004-Allow-Saving-of-Oversized-Chunks.patch +++ b/paper-server/patches/features/0003-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 07c2e2170af5820acdcb64f2c7978845c31641a1..984db72272d552c7210bd6f437ea88694ddd2828 100644 +index 99bbae1f8f681950f410b2bfe9af037164d8dcb7..944a01c34d19225d8366f6f97cbc3cacbb5d5498 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 @@ -42,7 +42,7 @@ index 07c2e2170af5820acdcb64f2c7978845c31641a1..984db72272d552c7210bd6f437ea8869 if (!Files.isDirectory(externalFileDir)) { throw new IllegalArgumentException("Expected directory, got " + externalFileDir.toAbsolutePath()); } else { -@@ -467,4 +468,75 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -464,4 +465,75 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche interface CommitOp { void run() throws IOException; } @@ -119,7 +119,7 @@ index 07c2e2170af5820acdcb64f2c7978845c31641a1..984db72272d552c7210bd6f437ea8869 + // Paper end } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 263ab4a8056ed9115c293484fef13e6f485dcf6d..283f73e633e32585530458545bf54fc6a644c830 100644 +index 5d9168242f7a7ca4dd888f32fecb27457fd89456..98b3f20c720d70293c6fcf77fdc081b44c71dd6b 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -237,6 +237,43 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -163,10 +163,10 @@ index 263ab4a8056ed9115c293484fef13e6f485dcf6d..283f73e633e32585530458545bf54fc6 + } + // Paper end + - @Nullable - public CompoundTag read(ChunkPos chunkPos) throws IOException { + public @Nullable CompoundTag read(ChunkPos chunkPos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing -@@ -245,6 +282,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + RegionFile regionFile = this.getRegionFile(chunkPos, true); +@@ -244,6 +281,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise return null; } // CraftBukkit end @@ -179,7 +179,7 @@ index 263ab4a8056ed9115c293484fef13e6f485dcf6d..283f73e633e32585530458545bf54fc6 CompoundTag var4; try (DataInputStream chunkDataInputStream = regionFile.getChunkDataInputStream(chunkPos)) { -@@ -287,6 +330,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -286,6 +329,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } else { try (DataOutputStream chunkDataOutputStream = regionFile.getChunkDataOutputStream(chunkPos)) { NbtIo.write(chunkData, chunkDataOutputStream); diff --git a/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0004-Entity-Activation-Range-2.0.patch similarity index 90% rename from paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch rename to paper-server/patches/features/0004-Entity-Activation-Range-2.0.patch index 8d64e6029c0c..6b47b9641cc2 100644 --- a/paper-server/patches/features/0005-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0004-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..ae2bb9a73106febfe5f0d090abd4252bbb5fd27e +index 0000000000000000000000000000000000000000..c18823746ab2edcab536cb1589b7720e3af07e0f --- /dev/null +++ b/io/papermc/paper/entity/activation/ActivationRange.java @@ -0,0 +1,334 @@ @@ -32,29 +32,29 @@ index 0000000000000000000000000000000000000000..ae2bb9a73106febfe5f0d090abd4252b +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.ai.Brain; +import net.minecraft.world.entity.animal.Animal; -+import net.minecraft.world.entity.animal.Bee; ++import net.minecraft.world.entity.animal.bee.Bee; ++import net.minecraft.world.entity.animal.equine.Llama; +import net.minecraft.world.entity.animal.sheep.Sheep; -+import net.minecraft.world.entity.animal.horse.Llama; -+import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EndCrystal; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.entity.item.FallingBlockEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.entity.monster.Creeper; -+import net.minecraft.world.entity.monster.Pillager; -+import net.minecraft.world.entity.npc.Villager; ++import net.minecraft.world.entity.monster.illager.Pillager; ++import net.minecraft.world.entity.npc.villager.Villager; +import net.minecraft.world.entity.player.Player; -+import net.minecraft.world.entity.projectile.AbstractArrow; -+import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.projectile.EyeOfEnder; +import net.minecraft.world.entity.projectile.FireworkRocketEntity; +import net.minecraft.world.entity.projectile.ThrowableProjectile; -+import net.minecraft.world.entity.projectile.ThrownTrident; ++import net.minecraft.world.entity.projectile.arrow.AbstractArrow; ++import net.minecraft.world.entity.projectile.arrow.ThrownTrident; ++import net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.schedule.Activity; -+import net.minecraft.world.entity.vehicle.AbstractBoat; -+import net.minecraft.world.entity.vehicle.AbstractMinecart; ++import net.minecraft.world.entity.vehicle.boat.AbstractBoat; ++import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import org.spigotmc.SpigotWorldConfig; @@ -354,10 +354,10 @@ index 0000000000000000000000000000000000000000..ae2bb9a73106febfe5f0d090abd4252b + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff218985978ab5 100644 +index 5494b92ab1c3c202a640e483e8a4bcb64395ed99..d7238270a6df8d1182874b46b588b971ca6f7a0e 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -815,6 +815,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -830,6 +830,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.pop(); } @@ -365,7 +365,7 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 this.entityTickList .forEach( entity -> { -@@ -1309,12 +1310,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1347,12 +1348,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe entity.totalEntityAge++; // Paper - age-like counter for all entities profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString()); profilerFiller.incrementCounter("tickNonPassenger"); @@ -382,7 +382,7 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 } // Paper start - log detailed entity tick information } finally { -@@ -1325,7 +1329,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1363,7 +1367,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - log detailed entity tick information } @@ -391,7 +391,7 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 if (passengerEntity.isRemoved() || passengerEntity.getVehicle() != ridingEntity) { passengerEntity.stopRiding(); } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { -@@ -1335,12 +1339,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1373,12 +1377,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(passengerEntity.getType()).toString()); profilerFiller.incrementCounter("tickPassenger"); @@ -415,10 +415,10 @@ index 5e305c9a64e856de70ed787901c01d09e68aa979..ce6f83c83b0235d59b4cadd248ff2189 } } diff --git a/net/minecraft/world/entity/AgeableMob.java b/net/minecraft/world/entity/AgeableMob.java -index 1d4a0319c92478185d0bc1aaa56c40e7f837cd1a..0adfd1cd5c21f8a7823cd1bf7c9aa91dd2654150 100644 +index 1cd4f112cf97bce414a73fa49c210534578eeba8..ffe7b73dafa81ab96c24198d83474fd9af542476 100644 --- a/net/minecraft/world/entity/AgeableMob.java +++ b/net/minecraft/world/entity/AgeableMob.java -@@ -131,6 +131,23 @@ public abstract class AgeableMob extends PathfinderMob { +@@ -129,6 +129,23 @@ public abstract class AgeableMob extends PathfinderMob { super.onSyncedDataUpdated(key); } @@ -443,10 +443,10 @@ index 1d4a0319c92478185d0bc1aaa56c40e7f837cd1a..0adfd1cd5c21f8a7823cd1bf7c9aa91d public void aiStep() { super.aiStep(); diff --git a/net/minecraft/world/entity/AreaEffectCloud.java b/net/minecraft/world/entity/AreaEffectCloud.java -index 35e852c4bb5e632ac4e1dc8c9e89f7a366ba7c09..f500e724034b330b590825c07b7dd61571335302 100644 +index 5461bd9a39bb20ad29d3bc110c38860cf35a770a..75f80787966cdda6f51f55a8f6cb22183fbf91ea 100644 --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java -@@ -142,6 +142,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { +@@ -140,6 +140,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { this.duration = duration; } @@ -464,10 +464,10 @@ index 35e852c4bb5e632ac4e1dc8c9e89f7a366ba7c09..f500e724034b330b590825c07b7dd615 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2254c6ad3 100644 +index 9cd31bf05ef7e5b14696cb33bbf995a9405481e3..e491170cd817b5f2a6951456d36b4ca1bf45c15f 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -367,6 +367,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -368,6 +368,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name 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 @@ -483,7 +483,7 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 // CraftBukkit end // Paper start -@@ -532,6 +541,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -533,6 +542,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.position = Vec3.ZERO; this.blockPosition = BlockPos.ZERO; this.chunkPosition = ChunkPos.ZERO; @@ -497,7 +497,7 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 SynchedEntityData.Builder builder = new SynchedEntityData.Builder(this); builder.define(DATA_SHARED_FLAGS_ID, (byte)0); builder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply()); -@@ -1100,6 +1116,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1115,6 +1131,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.minorHorizontalCollision = false; } else { if (type == MoverType.PISTON) { @@ -508,7 +508,7 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -1116,6 +1136,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1131,6 +1151,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.stuckSpeedMultiplier = Vec3.ZERO; this.setDeltaMovement(Vec3.ZERO); } @@ -523,11 +523,11 @@ index d5a38c3464539b05453ead3dfd77f4cf4b672617..7ab250350027543adc3926632b0d68a2 movement = this.maybeBackOffFromEdge(movement, type); Vec3 vec3 = this.collide(movement); diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 712983c9f55f4a5c120cda8b95ec16ce815fa205..025ef0b83e5d481c8b2ef25206cafd30897caabd 100644 +index b89e05476fca18847d86d953039e66613a1a9976..0a2f85bbab4f464ee4e2357b20f93ddeaabea262 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3255,6 +3255,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - return false; +@@ -3318,6 +3318,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + protected void playAttackSound() { } + // Paper start - EAR 2 @@ -542,7 +542,7 @@ index 712983c9f55f4a5c120cda8b95ec16ce815fa205..025ef0b83e5d481c8b2ef25206cafd30 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 93f56d5d8b4af495c16bf0d953098cde574674d9..f2a321d94ddc9247a3820d42f4a04290ea3ce6f6 100644 +index 6ab728f46369d11bc97f3bc44fb1a30ea88a9854..9c754488ac24222b10b093f66e8492dfa5fe48f7 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -217,6 +217,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @@ -641,10 +641,10 @@ index 3f780276be6766ef253c50212e06fd93a96b0caa..7e70c7bee633c54497d1cd2854dd60f4 } } diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index c02c27a8cc931b2e5fdb29b7b615e5a292d13bf2..6be576368695c902a0d6da74b1d77d3018b4585a 100644 +index 768adc0205a2ec5221045c9c2ca0fdeec9f734b6..e82bb8f2d2b0e771dc371fd7e709116e1f5f204f 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -120,6 +120,29 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -117,6 +117,29 @@ public class ItemEntity extends Entity implements TraceableEntity { return 0.04; } @@ -674,10 +674,10 @@ index c02c27a8cc931b2e5fdb29b7b615e5a292d13bf2..6be576368695c902a0d6da74b1d77d30 @Override public void tick() { if (this.getItem().isEmpty()) { -diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java -index 135d44fe54d45d3e3f4310f603d0f406f3729b6b..d10a407bef7da29a24582e48d8ee599c981384c5 100644 ---- a/net/minecraft/world/entity/npc/Villager.java -+++ b/net/minecraft/world/entity/npc/Villager.java +diff --git a/net/minecraft/world/entity/npc/villager/Villager.java b/net/minecraft/world/entity/npc/villager/Villager.java +index 10a66bb3c093a1d31f3c985b418acb9232cc882c..89844d7e804cc8a2110b694e448bc5993991bea7 100644 +--- a/net/minecraft/world/entity/npc/villager/Villager.java ++++ b/net/minecraft/world/entity/npc/villager/Villager.java @@ -269,11 +269,35 @@ public class Villager extends AbstractVillager implements ReputationEventHandler return this.assignProfessionWhenSpawned; } @@ -732,32 +732,11 @@ index 135d44fe54d45d3e3f4310f603d0f406f3729b6b..d10a407bef7da29a24582e48d8ee599c super.customServerAiStep(level); } -diff --git a/net/minecraft/world/entity/projectile/Arrow.java b/net/minecraft/world/entity/projectile/Arrow.java -index df8e4830f5be29c64ef5e6350a77ad7527e5d612..bbe2773bf789a42cc5cd9f847bdb5c4b51dfb9f2 100644 ---- a/net/minecraft/world/entity/projectile/Arrow.java -+++ b/net/minecraft/world/entity/projectile/Arrow.java -@@ -70,6 +70,16 @@ public class Arrow extends AbstractArrow { - builder.define(ID_EFFECT_COLOR, -1); - } - -+ // Paper start - EAR 2 -+ @Override -+ public void inactiveTick() { -+ if (this.isInGround()) { -+ this.life++; -+ } -+ super.inactiveTick(); -+ } -+ // Paper end -+ - @Override - public void tick() { - super.tick(); diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index e7c1e11cc6709e34ec2c59d545cfba23c35b829d..145ed3c5f5823c7505767b6d7f4f4d16cc863948 100644 +index 3ba7d5bcaa76442adbd681a15175ba178297e704..1b633d2eb77704fd9a6358f09ed368fab2a5b212 100644 --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -108,6 +108,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -107,6 +107,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { return super.shouldRender(x, y, z) && !this.isAttachedToEntity(); } @@ -779,11 +758,32 @@ index e7c1e11cc6709e34ec2c59d545cfba23c35b829d..145ed3c5f5823c7505767b6d7f4f4d16 @Override public void tick() { super.tick(); -diff --git a/net/minecraft/world/entity/vehicle/MinecartHopper.java b/net/minecraft/world/entity/vehicle/MinecartHopper.java -index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3c30d8f7a 100644 ---- a/net/minecraft/world/entity/vehicle/MinecartHopper.java -+++ b/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -49,6 +49,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +diff --git a/net/minecraft/world/entity/projectile/arrow/Arrow.java b/net/minecraft/world/entity/projectile/arrow/Arrow.java +index acef4aee02169a155fb2cc5195c33fb5fe29fa4d..bbbdf0048db1e806642ad96cce66818e524acc62 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 { + builder.define(ID_EFFECT_COLOR, -1); + } + ++ // Paper start - EAR 2 ++ @Override ++ public void inactiveTick() { ++ if (this.isInGround()) { ++ this.life++; ++ } ++ super.inactiveTick(); ++ } ++ // Paper end ++ + @Override + public void tick() { + super.tick(); +diff --git a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java +index 4a6384a668546371f4ffa13927be4bd462d47c60..3c961b76769f16160caedce8ec32bb2a2561163f 100644 +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java +@@ -50,6 +50,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper if (flag != this.isEnabled()) { this.setEnabled(flag); } @@ -791,7 +791,7 @@ index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3 } public boolean isEnabled() { -@@ -102,11 +103,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -103,11 +104,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public boolean suckInItems() { if (HopperBlockEntity.suckInItems(this.level(), this)) { @@ -805,7 +805,7 @@ index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3 return true; } } -@@ -141,4 +144,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -142,4 +145,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public AbstractContainerMenu createMenu(int id, Inventory playerInventory) { return new HopperMenu(id, playerInventory, this); } @@ -818,7 +818,7 @@ index d5cb27dd5bff34890ee431d4b301a0be0167dd37..681dab5e26f8fb359f101f22ac85aac3 + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 39947ac2fae9a088d1fbc5c72d6ac520bfb97cf3..439abba4f371343dfd8e5ede7c20050ca049fcd2 100644 +index ef09aaebf4fc7fcd24a736434cd0a860d6b97905..fd8b41b3f1ee64ec30895d787c282eaf108ea402 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -150,6 +150,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl diff --git a/paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch similarity index 96% rename from paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch rename to paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch index 131539ee7e57..af74127d7157 100644 --- a/paper-server/patches/features/0006-Use-Velocity-compression-and-cipher-natives.patch +++ b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch @@ -267,10 +267,10 @@ index 35b8a2bddeefff2b1ba8ed75ec780c41d59ce92f..1baa8daf880c5f87f1d72ecf0e1b93c7 + // Paper end - Use Velocity cipher } diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index c48d0a951f36e4449e9474994a21596d8a2d2e16..14addbaf68b7ad80490187d12d9c9b00891e2ce1 100644 +index 095e8040df7786bf92d9a7ad59fd8ef21235b945..8bded92b1002e292dfb053109d1683690aa45139 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -762,11 +762,22 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -728,11 +728,22 @@ public class Connection extends SimpleChannelInboundHandler> { return connection; } @@ -297,7 +297,7 @@ index c48d0a951f36e4449e9474994a21596d8a2d2e16..14addbaf68b7ad80490187d12d9c9b00 public boolean isEncrypted() { return this.encrypted; -@@ -805,16 +816,17 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -769,16 +780,17 @@ public class Connection extends SimpleChannelInboundHandler> { // Paper end - add proper async disconnect public void setupCompression(int threshold, boolean validateDecompressed) { if (threshold >= 0) { @@ -319,10 +319,10 @@ index c48d0a951f36e4449e9474994a21596d8a2d2e16..14addbaf68b7ad80490187d12d9c9b00 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 deefad689070750a3ae033a3e54dd8f5c849e794..36e05fc720b5ea3884d9d52823c7f9c14c007061 100644 +index 309845b28306dfa5946e79b80e5b1dde82dd68cd..33e1cdb00d648c992af03a976899253141314b27 100644 --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -109,6 +109,10 @@ public class ServerConnectionListener { +@@ -75,6 +75,11 @@ 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. @@ -330,14 +330,15 @@ index deefad689070750a3ae033a3e54dd8f5c849e794..36e05fc720b5ea3884d9d52823c7f9c1 + ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.compress.getLoadedVariant() + " compression from Velocity."); + ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.cipher.getLoadedVariant() + " cipher from Velocity."); + // Paper end - Use Velocity cipher - ++ this.channels .add( + new ServerBootstrap() diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index bb418174ce67f0aa05fd90ce2d5332d853e957e4..c5d071c591c844b11667013131d1d3bae8e3bac6 100644 +index ec5bd4568872c48addd26dd652868e0e5df57038..31bc0a105152a7f24a4126542bea7dbebc3e037c 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -244,11 +244,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -245,11 +245,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, } SecretKey secretKey = packet.getSecretKey(_private); diff --git a/paper-server/patches/features/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/paper-server/patches/features/0006-Optimize-GoalSelector-Goal.Flag-Set-operations.patch similarity index 98% rename from paper-server/patches/features/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch rename to paper-server/patches/features/0006-Optimize-GoalSelector-Goal.Flag-Set-operations.patch index 79957e9faa04..028ebc23a06c 100644 --- a/paper-server/patches/features/0007-Optimize-GoalSelector-Goal.Flag-Set-operations.patch +++ b/paper-server/patches/features/0006-Optimize-GoalSelector-Goal.Flag-Set-operations.patch @@ -154,7 +154,7 @@ index 674966c580220a4e0c83a628c763aaea8bfd0b1c..859b859d29b637200cf7c9a0bd52d9f7 public void setControlFlag(Goal.Flag flag, boolean enabled) { diff --git a/net/minecraft/world/entity/ai/goal/WrappedGoal.java b/net/minecraft/world/entity/ai/goal/WrappedGoal.java -index 4bdbd323b642ed3422948fe24780be8b503602dc..2c2ab6a1df9d3d23773e44ce4041cc1c21b55163 100644 +index d0249ae3fee041245445a087dee2bb15a4067fc6..44a7c97164ac7ee731068f909372218350a8682d 100644 --- a/net/minecraft/world/entity/ai/goal/WrappedGoal.java +++ b/net/minecraft/world/entity/ai/goal/WrappedGoal.java @@ -69,7 +69,7 @@ public class WrappedGoal extends Goal { diff --git a/paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch b/paper-server/patches/features/0007-Optimize-Voxel-Shape-Merging.patch similarity index 96% rename from paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch rename to paper-server/patches/features/0007-Optimize-Voxel-Shape-Merging.patch index 4f4c5692daf6..bafbe6886916 100644 --- a/paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch +++ b/paper-server/patches/features/0007-Optimize-Voxel-Shape-Merging.patch @@ -67,10 +67,10 @@ index 60b56a5086b8aad0fad693f686b89138b3a4c80d..5b079ec43c259368d0eed4e838588071 this.firstIndices = new int[i]; this.secondIndices = new int[i]; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index 881455dd3d576528adc68e00c00eb2819ccd4f0c..3205cc111b1165cd98705bb70d65c858961abc33 100644 +index ac4bb789df88c07ea38d20700dccb6571e3ea58d..fc2b393d24fef8ce3a74d38d0937bfe5604eae87 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java -@@ -347,9 +347,22 @@ public final class Shapes { +@@ -346,9 +346,22 @@ public final class Shapes { } @VisibleForTesting @@ -94,7 +94,7 @@ index 881455dd3d576528adc68e00c00eb2819ccd4f0c..3205cc111b1165cd98705bb70d65c858 if (list1 instanceof CubePointRange && list2 instanceof CubePointRange) { long l = lcm(i, i1); if (size * l <= 256L) { -@@ -357,14 +370,21 @@ public final class Shapes { +@@ -356,14 +369,21 @@ public final class Shapes { } } diff --git a/paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch b/paper-server/patches/features/0008-Handle-Oversized-block-entities-in-chunks.patch similarity index 94% rename from paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch rename to paper-server/patches/features/0008-Handle-Oversized-block-entities-in-chunks.patch index d1f3ce49f7b9..2b04a30e0fb3 100644 --- a/paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch +++ b/paper-server/patches/features/0008-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 de234f220ba09ad9b5e0c8215b49d20ca51d0ac7..e216a9d70be5a3da7c03ee99a8986391ef2dbd5b 100644 +index 7cdac4a18b13805aea60495d369ee7cdd1db784f..919eaac837298c1936ec7aa06375c72a7acd2daa 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -32,6 +32,14 @@ public class ClientboundLevelChunkPacketData { @@ -47,7 +47,7 @@ index de234f220ba09ad9b5e0c8215b49d20ca51d0ac7..e216a9d70be5a3da7c03ee99a8986391 } } diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java -index 3a384175f8e7f204234bbaf3081bdc20c47a0d4b..fdd164cd45a26c7ef25f1153ab8985ba50c01b14 100644 +index 8475c1c3d79e7fae9ab83dea1ac18f7a28ff60bb..3c0f0a612cc57c9f03abfb0ccb1f891305d03d45 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java @@ -71,4 +71,11 @@ public class ClientboundLevelChunkWithLightPacket implements Packet targets, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { -+ private Path findPath(Node node, List> positions, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { // Paper - optimize collection +- private @Nullable Path findPath(Node node, Map targets, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { ++ private @Nullable Path findPath(Node node, List> positions, float maxRange, int reachRange, float maxVisitedNodesMultiplier) { // Paper - optimize collection ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("find_path"); profilerFiller.markForCharting(MetricCategory.PATH_FINDING); @@ -59,7 +58,7 @@ index 1a9d8e6dd55ce30aca1c65b32417d61fd0a10f84..5894260481ea395c26a5b506e38530f7 int i1 = (int)(this.maxVisitedNodes * maxVisitedNodesMultiplier); while (!this.openSet.isEmpty()) { -@@ -81,14 +85,18 @@ public class PathFinder { +@@ -79,14 +83,18 @@ public class PathFinder { Node node1 = this.openSet.pop(); node1.closed = true; @@ -81,7 +80,7 @@ index 1a9d8e6dd55ce30aca1c65b32417d61fd0a10f84..5894260481ea395c26a5b506e38530f7 break; } -@@ -107,7 +115,7 @@ public class PathFinder { +@@ -105,7 +113,7 @@ public class PathFinder { if (node2.walkedDistance < maxRange && (!node2.inOpenSet() || f1 < node2.g)) { node2.cameFrom = node1; node2.g = f1; @@ -90,7 +89,7 @@ index 1a9d8e6dd55ce30aca1c65b32417d61fd0a10f84..5894260481ea395c26a5b506e38530f7 if (node2.inOpenSet()) { this.openSet.changeCost(node2, node2.g + node2.h); } else { -@@ -119,34 +127,41 @@ public class PathFinder { +@@ -117,34 +125,41 @@ public class PathFinder { } } diff --git a/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features/0013-Fix-entity-tracker-desync-when-new-players-are-added.patch similarity index 89% rename from paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch rename to paper-server/patches/features/0013-Fix-entity-tracker-desync-when-new-players-are-added.patch index e0f798b50629..3f3e1ff79b86 100644 --- a/paper-server/patches/features/0014-Fix-entity-tracker-desync-when-new-players-are-added.patch +++ b/paper-server/patches/features/0013-Fix-entity-tracker-desync-when-new-players-are-added.patch @@ -48,10 +48,10 @@ index 2a86ca1de6920017be6cd4a3a5251e892067f07c..f571ff64ae1007f8f0632febd2dcca70 serverEntity.getLastSentYRot(), entity.getType(), diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 032d164284ebc8fd4cfbc96f1381e8627edd1605..30c26d1f79621ac89d5dfd4652e627062af57956 100644 +index b0b4e5c96498eef48fe0cb2637faed73409941ad..dfd7a60192c46f01d245045adf86dec42eec4da7 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1326,6 +1326,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1353,6 +1353,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP ChunkMap.this.level.debugSynchronizers().startTrackingEntity(player, this.entity); } // Paper end - entity tracking events @@ -60,10 +60,10 @@ index 032d164284ebc8fd4cfbc96f1381e8627edd1605..30c26d1f79621ac89d5dfd4652e62706 } else { this.removePlayer(player); diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index f019f1330f9f1e6aa98ef3f914833769cbadea16..638432a2e6506d3db6a25c068a33eeafb13cf0d6 100644 +index b7915685026e9a944f42440e4a95215f927f385e..3a817c92147bb78c60238f3ddc1644b721aed7a2 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -88,6 +88,13 @@ public class ServerEntity { +@@ -87,6 +87,13 @@ public class ServerEntity { this.trackedDataValues = entity.getEntityData().getNonDefaultValues(); } @@ -81,8 +81,8 @@ index f019f1330f9f1e6aa98ef3f914833769cbadea16..638432a2e6506d3db6a25c068a33eeaf this.sendDirtyEntityData(); } -- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { -+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker +- if (this.tickCount % this.updateInterval == 0 || this.entity.needsSync || this.entity.getEntityData().isDirty()) { ++ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.needsSync || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker byte b = Mth.packDegrees(this.entity.getYRot()); byte b1 = Mth.packDegrees(this.entity.getXRot()); boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1; @@ -98,7 +98,7 @@ index f019f1330f9f1e6aa98ef3f914833769cbadea16..638432a2e6506d3db6a25c068a33eeaf @@ -233,6 +240,7 @@ public class ServerEntity { } - this.entity.hasImpulse = false; + this.entity.needsSync = false; + this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker } diff --git a/paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch b/paper-server/patches/features/0014-Eigencraft-redstone-implementation.patch similarity index 99% rename from paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch rename to paper-server/patches/features/0014-Eigencraft-redstone-implementation.patch index ba8898d4fb4e..ef84f13c5404 100644 --- a/paper-server/patches/features/0015-Eigencraft-redstone-implementation.patch +++ b/paper-server/patches/features/0014-Eigencraft-redstone-implementation.patch @@ -978,10 +978,10 @@ index 0000000000000000000000000000000000000000..ff747a1ecdf3c888bca0d69de4f85dcd + } +} diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a3c27d5c6 100644 +index 417e12d3dfabdfce40d6a53d217b86a39defc553..d7ff98f4ecadd37f22d0a38d94a5975db60d6285 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -265,6 +265,60 @@ public class RedStoneWireBlock extends Block { +@@ -264,6 +264,60 @@ public class RedStoneWireBlock extends Block { return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER); } @@ -1042,7 +1042,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a private void updatePowerStrength(Level level, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean updateShape) { if (useExperimentalEvaluator(level)) { new ExperimentalRedstoneWireEvaluator(this).updatePowerStrength(level, pos, state, orientation, updateShape); -@@ -293,7 +347,7 @@ public class RedStoneWireBlock extends Block { +@@ -292,7 +346,7 @@ public class RedStoneWireBlock extends Block { @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { if (!oldState.is(state.getBlock()) && !level.isClientSide()) { @@ -1051,7 +1051,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a for (Direction direction : Direction.Plane.VERTICAL) { level.updateNeighborsAt(pos.relative(direction), this); -@@ -310,7 +364,7 @@ public class RedStoneWireBlock extends Block { +@@ -309,7 +363,7 @@ public class RedStoneWireBlock extends Block { level.updateNeighborsAt(pos.relative(direction), this); } @@ -1060,7 +1060,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a this.updateNeighborsOfNeighboringWires(level, pos); } } -@@ -335,7 +389,7 @@ public class RedStoneWireBlock extends Block { +@@ -334,7 +388,7 @@ public class RedStoneWireBlock extends Block { if (!level.isClientSide()) { if (neighborBlock != this || !useExperimentalEvaluator(level)) { if (state.canSurvive(level, pos)) { @@ -1070,7 +1070,7 @@ index bd8d8431766fd3fa98e51f4122259ba03fc39272..07d2b9b7ebea9827ef7a535c090b311a 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 8c4d7047ae5b74262d4fb6c46975822953c23938..4edf6e96cd47ab75aedd4baefcf49cd3fae00d7a 100644 +index 82a45a598cd3d7520b15bac9b47117ef7b1f98ba..53b8df8e6dd379126af3e1feb2220e222430ce94 100644 --- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java @@ -45,7 +45,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/0015-Add-Alternate-Current-redstone-implementation.patch similarity index 98% rename from paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch rename to paper-server/patches/features/0015-Add-Alternate-Current-redstone-implementation.patch index eca4cb8bd5c2..7ddb020d9b5e 100644 --- a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0015-Add-Alternate-Current-redstone-implementation.patch @@ -2326,10 +2326,10 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index ce6f83c83b0235d59b4cadd248ff218985978ab5..71de8d8920eb33d15a18653dcef370c8e1a43712 100644 +index d7238270a6df8d1182874b46b588b971ca6f7a0e..db2054e84f5717a37683d57890dcd585769effbc 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -221,6 +221,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -227,6 +227,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final net.minecraft.server.level.progress.LevelLoadListener levelLoadListener; public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent @@ -2337,7 +2337,7 @@ index ce6f83c83b0235d59b4cadd248ff218985978ab5..71de8d8920eb33d15a18653dcef370c8 @Override public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { -@@ -2660,6 +2661,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2696,6 +2697,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return this.debugSynchronizers; } @@ -2348,14 +2348,14 @@ index ce6f83c83b0235d59b4cadd248ff218985978ab5..71de8d8920eb33d15a18653dcef370c8 + } + // Paper end - optimize redstone (Alternate Current) + - final class EntityCallbacks implements LevelCallback { - @Override - public void onCreated(Entity entity) { + public boolean isAllowedToEnterPortal(Level level) { + return level.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 439abba4f371343dfd8e5ede7c20050ca049fcd2..96fa7390a4bcfa7bdf2cf5346f2de895ac085203 100644 +index fd8b41b3f1ee64ec30895d787c282eaf108ea402..bc0824b42e2fde246f052afe1e1393de632ccfb7 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -2078,6 +2078,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -2040,6 +2040,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return this.palettedContainerFactory; } @@ -2374,10 +2374,10 @@ index 439abba4f371343dfd8e5ede7c20050ca049fcd2..96fa7390a4bcfa7bdf2cf5346f2de895 NONE("none"), BLOCK("block"), diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623b244ad3e 100644 +index d7ff98f4ecadd37f22d0a38d94a5975db60d6285..6d98bc37d88459d1e0a171b52bbff5810d775c38 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -265,7 +265,7 @@ public class RedStoneWireBlock extends Block { +@@ -264,7 +264,7 @@ public class RedStoneWireBlock extends Block { return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER); } @@ -2386,7 +2386,7 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 // The bulk of the new functionality is found in RedstoneWireTurbo.java io.papermc.paper.redstone.RedstoneWireTurbo turbo = new io.papermc.paper.redstone.RedstoneWireTurbo(this); -@@ -347,7 +347,13 @@ public class RedStoneWireBlock extends Block { +@@ -346,7 +346,13 @@ public class RedStoneWireBlock extends Block { @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { if (!oldState.is(state.getBlock()) && !level.isClientSide()) { @@ -2401,7 +2401,7 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 for (Direction direction : Direction.Plane.VERTICAL) { level.updateNeighborsAt(pos.relative(direction), this); -@@ -364,7 +370,13 @@ public class RedStoneWireBlock extends Block { +@@ -363,7 +369,13 @@ public class RedStoneWireBlock extends Block { level.updateNeighborsAt(pos.relative(direction), this); } @@ -2416,7 +2416,7 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 this.updateNeighborsOfNeighboringWires(level, pos); } } -@@ -387,9 +399,15 @@ public class RedStoneWireBlock extends Block { +@@ -386,9 +398,15 @@ public class RedStoneWireBlock extends Block { @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { if (!level.isClientSide()) { @@ -2434,10 +2434,10 @@ index 07d2b9b7ebea9827ef7a535c090b311a3c27d5c6..a07d9237d227fe6d419d8a9bc44fc623 dropResources(state, level, pos); level.removeBlock(pos, false); diff --git a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java -index 83f5da3e24834882193b9d7e3a788517e4b12b55..0c50a0bbbef1229230712b7c04364fea06859674 100644 +index 413d6b66a7e368ebb590064b0d0dd47b64c68659..05e99653bb1f3b392be86f9fa9814b87ca301bca 100644 --- a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java +++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java -@@ -17,6 +17,11 @@ public class ExperimentalRedstoneUtils { +@@ -16,6 +16,11 @@ public class ExperimentalRedstoneUtils { if (front != null) { orientation = orientation.withFront(front); } diff --git a/paper-server/patches/features/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features/0016-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch similarity index 92% rename from paper-server/patches/features/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch rename to paper-server/patches/features/0016-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch index 9a25ae0dcb90..d0845664ca6b 100644 --- a/paper-server/patches/features/0018-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch +++ b/paper-server/patches/features/0016-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 984db72272d552c7210bd6f437ea88694ddd2828..dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc 100644 +index 944a01c34d19225d8366f6f97cbc3cacbb5d5498..f2ef716788c1ed1933139c1f53a6d73769362809 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; @@ -19,7 +19,7 @@ index 984db72272d552c7210bd6f437ea88694ddd2828..dea2823a9d1d69dcb0a4759d8ea9b301 private static final int SECTOR_BYTES = 4096; @VisibleForTesting protected static final int SECTOR_INTS = 1024; -@@ -455,6 +456,24 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -452,6 +453,24 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche this.pos = pos; } @@ -45,11 +45,11 @@ index 984db72272d552c7210bd6f437ea88694ddd2828..dea2823a9d1d69dcb0a4759d8ea9b301 public void close() throws IOException { ByteBuffer byteBuffer = 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 283f73e633e32585530458545bf54fc6a644c830..5133590b1a8c7035a949b85ceefa904b583e4e7f 100644 +index 98b3f20c720d70293c6fcf77fdc081b44c71dd6b..3ca75289ac9eb05eadb74c87c0c94cbc026fd08f 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.util.ExceptionCollector; - import net.minecraft.world.level.ChunkPos; +@@ -16,6 +16,7 @@ import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.io.ChunkSystemRegionFileStorage { // Paper - rewrite chunk system + private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper @@ -81,7 +81,7 @@ index 283f73e633e32585530458545bf54fc6a644c830..5133590b1a8c7035a949b85ceefa904b return writeData; } -@@ -328,9 +342,17 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -327,9 +341,17 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise if (chunkData == null) { regionFile.clear(chunkPos); } else { @@ -100,7 +100,7 @@ index 283f73e633e32585530458545bf54fc6a644c830..5133590b1a8c7035a949b85ceefa904b } } } -@@ -373,4 +395,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -372,4 +394,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public RegionStorageInfo info() { return this.info; } diff --git a/paper-server/patches/features/0019-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features/0017-Entity-load-save-limit-per-chunk.patch similarity index 93% rename from paper-server/patches/features/0019-Entity-load-save-limit-per-chunk.patch rename to paper-server/patches/features/0017-Entity-load-save-limit-per-chunk.patch index 6ca36525f987..74c39921a062 100644 --- a/paper-server/patches/features/0019-Entity-load-save-limit-per-chunk.patch +++ b/paper-server/patches/features/0017-Entity-load-save-limit-per-chunk.patch @@ -9,7 +9,7 @@ defaults are only included for certain entites, this allows setting limits for any entity type. diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -index c380487a97f626163e1f13d87231d64ce2ea4b24..b2bcfb3557a0326fd7ec1059f95d6da4568dfd80 100644 +index c2363cfa5e93942fe837efd9f39478698f6d1a98..2dfd412344a0e57f25a08d9c65656a13113baa4e 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java @@ -116,8 +116,19 @@ public final class ChunkEntitySlices { @@ -33,10 +33,10 @@ index c380487a97f626163e1f13d87231d64ce2ea4b24..b2bcfb3557a0326fd7ec1059f95d6da4 scopedCollector.forChild(entity.problemPath()), entity.registryAccess() ); diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java -index 6515f0eeb8f05985cd483d7b6264a6eac073d364..4706a41ecaccd20fc623ce64858b160204f60f9e 100644 +index 3cf2378a2ccf117fab9fc6fc60fcb0ecdf638d45..abccad13c2bb3a33e98ad8eb6d7f08c0ef021811 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1598,7 +1598,18 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -1615,7 +1615,18 @@ public class EntityType implements FeatureElement, EntityTypeT } public static Stream loadEntitiesRecursive(ValueInput.ValueInputList input, Level level, EntitySpawnReason spawnReason) { @@ -56,7 +56,7 @@ index 6515f0eeb8f05985cd483d7b6264a6eac073d364..4706a41ecaccd20fc623ce64858b1602 return entity; })); diff --git a/net/minecraft/world/level/chunk/storage/EntityStorage.java b/net/minecraft/world/level/chunk/storage/EntityStorage.java -index bf45cce4db77966d44d7a8d97673bb6631a6adaf..f1f8575a4b37114ced3cdb1d2ea33a36a2db44fd 100644 +index bfba76d8f442905e4d3a62b65edabbca12fdb10e..2ce9caafffc86fee82abf0a33423a172a8158e37 100644 --- a/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java @@ -95,7 +95,18 @@ public class EntityStorage implements EntityPersistentStorage { diff --git a/paper-server/patches/features/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features/0018-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 97% rename from paper-server/patches/features/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to paper-server/patches/features/0018-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 6aed043970d1..0865b24e7776 100644 --- a/paper-server/patches/features/0020-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/paper-server/patches/features/0018-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -55,7 +55,7 @@ index 64a718c98f799c62a5bb28e1e8e5f66cc96c915d..666f2e967c99f78422c83fb20e1a3bf3 this.used.set(sectorOffset, sectorOffset + sectorCount); } diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79017e3987 100644 +index f2ef716788c1ed1933139c1f53a6d73769362809..c6adcb44bc96eaeba74bfc228a6a61765b1628e7 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 @@ -72,7 +72,7 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79 + + private static final net.minecraft.nbt.CompoundTag OVERSIZED_COMPOUND = new net.minecraft.nbt.CompoundTag(); + -+ private @Nullable net.minecraft.nbt.CompoundTag attemptRead(long sector, int chunkDataLength, long fileLength) throws IOException { ++ private net.minecraft.nbt.@Nullable CompoundTag attemptRead(long sector, int chunkDataLength, long fileLength) throws IOException { + try { + if (chunkDataLength < 0) { + return null; @@ -548,10 +548,10 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79 + } + // Paper end + - @Nullable - public synchronized DataInputStream getChunkDataInputStream(ChunkPos chunkPos) throws IOException { + public synchronized @Nullable DataInputStream getChunkDataInputStream(ChunkPos chunkPos) throws IOException { int offset = this.getOffset(chunkPos); -@@ -155,30 +584,67 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + if (offset == 0) { +@@ -154,30 +583,67 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche byteBuffer.flip(); if (byteBuffer.remaining() < 5) { LOGGER.error("Chunk {} header is truncated: expected {} but read {}", chunkPos, i, byteBuffer.remaining()); @@ -621,7 +621,7 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79 } } } -@@ -361,9 +827,14 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -358,9 +824,14 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche } private ByteBuffer createExternalStub() { @@ -638,7 +638,7 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..22f3aa1674664906e8ec45372d758d79 return byteBuffer; } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 5133590b1a8c7035a949b85ceefa904b583e4e7f..8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7 100644 +index 3ca75289ac9eb05eadb74c87c0c94cbc026fd08f..1e9e061ec694ad64fc2724b83a66dfec7e069a43 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -24,6 +24,36 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -744,7 +744,7 @@ index 5133590b1a8c7035a949b85ceefa904b583e4e7f..8ea830f561f5b7d6ff6ca3c38adc7fe8 } @org.jetbrains.annotations.Contract("_, false -> !null") @Nullable private RegionFile getRegionFile(ChunkPos chunkPos, boolean existingOnly) throws IOException { // CraftBukkit -@@ -310,6 +366,19 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -309,6 +365,19 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise } var4 = NbtIo.read(chunkDataInputStream); @@ -765,7 +765,7 @@ index 5133590b1a8c7035a949b85ceefa904b583e4e7f..8ea830f561f5b7d6ff6ca3c38adc7fe8 return var4; diff --git a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -index 1649119f45d970a9bf1683d676c47ecfc18ad047..cc544f3199cd6af29e50362923d0651705877f16 100644 +index d857a69ad3a0c4eeec52585e8d92f0f8673684f3..e813dedf8d70ae58d595bcd7bc92a1de845fe4a9 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java @@ -21,7 +21,7 @@ import org.slf4j.Logger; @@ -778,7 +778,7 @@ index 1649119f45d970a9bf1683d676c47ecfc18ad047..cc544f3199cd6af29e50362923d06517 public static final RegionFileVersion VERSION_GZIP = register( new RegionFileVersion( diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 0994145addaa06c0094cfd6601d1cc19794343b1..1652513d8a7e6036c82162517948dd22ca98d109 100644 +index b2363fa364be15d0a28f5966615131282b7aaa8f..68874c0b6f6f7c5d8e3a79c9a7b391b9624ab748 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( @@ -788,7 +788,7 @@ index 0994145addaa06c0094cfd6601d1cc19794343b1..1652513d8a7e6036c82162517948dd22 + // Paper start - Attempt to recalculate regionfile header if it is corrupt + // TODO: Check on update + public static long getLastWorldSaveTime(final CompoundTag chunkData) { -+ final int dataVersion = ChunkStorage.getVersion(chunkData); ++ final int dataVersion = NbtUtils.getDataVersion(chunkData); + if (dataVersion < 2842) { // Level tag is removed after this version + final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); + return levelData.getLongOr("LastUpdate", 0L); @@ -800,7 +800,7 @@ index 0994145addaa06c0094cfd6601d1cc19794343b1..1652513d8a7e6036c82162517948dd22 // 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(); -@@ -548,7 +560,7 @@ public record SerializableChunkData( +@@ -552,7 +564,7 @@ public record SerializableChunkData( compoundTag.putInt("xPos", this.chunkPos.x); compoundTag.putInt("yPos", this.minSectionY); compoundTag.putInt("zPos", this.chunkPos.z); diff --git a/paper-server/patches/features/0021-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0019-Incremental-chunk-and-player-saving.patch similarity index 89% rename from paper-server/patches/features/0021-Incremental-chunk-and-player-saving.patch rename to paper-server/patches/features/0019-Incremental-chunk-and-player-saving.patch index 4e2a72531e39..e1e46a54f4de 100644 --- a/paper-server/patches/features/0021-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0019-Incremental-chunk-and-player-saving.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 3228e6c886b62325c3c47a860fcf3d04ea53f764..ff6fc300e9e7d1dbf4b0fa1e59bffe94e1f51259 100644 +index bdaca3647425711ee8b10eb0593a9c3cb4037ede..e7df5f105c721f2e1be1a13694275c0f03b7932b 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -971,7 +971,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> type = poiManager.getType(target); diff --git a/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index f67fbc8b6f5f0374f41180ec36de355c7a538aca..179e6d26f85ca7c4812e855dd671d8e92067292b 100644 +index e2b05800736d29f6061a9f2117e51c8a0d5bfeb6..95fa0d9487542ba5308c60d29095efa6c90e86d6 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiManager.java -@@ -257,36 +257,47 @@ public class PoiManager extends SectionStorage im +@@ -256,36 +256,47 @@ public class PoiManager extends SectionStorage im public Optional find( Predicate> typePredicate, Predicate posPredicate, BlockPos pos, int distance, PoiManager.Occupancy status ) { @@ -955,7 +955,7 @@ index f67fbc8b6f5f0374f41180ec36de355c7a538aca..179e6d26f85ca7c4812e855dd671d8e9 .map(poiRecord -> { poiRecord.acquireTicket(); return poiRecord.getPos(); -@@ -301,8 +312,21 @@ public class PoiManager extends SectionStorage im +@@ -300,8 +311,21 @@ public class PoiManager extends SectionStorage im int distance, RandomSource random ) { @@ -980,7 +980,7 @@ index f67fbc8b6f5f0374f41180ec36de355c7a538aca..179e6d26f85ca7c4812e855dd671d8e9 public boolean release(BlockPos pos) { diff --git a/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index bba84a390e46a1288cc3cb36ba01941e47a1fec2..df5799fd48b509dc3ba02a21ad39a5add9b114e2 100644 +index f209696e0158df5cd32e9949b3054452d6a3e5cd..49cbdd80057250c37464ca5f5dd39a20dbaa9f2c 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiSection.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiSection.java @@ -28,7 +28,7 @@ import org.slf4j.Logger; @@ -993,15 +993,16 @@ index bba84a390e46a1288cc3cb36ba01941e47a1fec2..df5799fd48b509dc3ba02a21ad39a5ad private boolean isValid; diff --git a/net/minecraft/world/level/chunk/storage/SectionStorage.java b/net/minecraft/world/level/chunk/storage/SectionStorage.java -index afac559b3c38c4a175070ed823dc8f2c34f4a004..1fc7d8518f7c8d69c2520dbc044a3c202d008756 100644 +index 42699c82321233eaa3647ca0ac4d1f24b6a6227f..a70329731f7d048b52b73f0d12d7436361cfaa96 100644 --- a/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SectionStorage.java -@@ -131,11 +131,11 @@ public class SectionStorage implements AutoCloseable, ca.spottedleaf.moonr +@@ -130,11 +130,12 @@ public class SectionStorage implements AutoCloseable, ca.spottedleaf.moonr + return !this.dirtyChunks.isEmpty(); } - @Nullable -- protected Optional get(long sectionKey) { -+ public Optional get(long sectionKey) { // Paper - public +- protected @Nullable Optional get(long sectionKey) { ++ ++ public @Nullable Optional get(long sectionKey) { // Paper - public return this.storage.get(sectionKey); } @@ -1011,7 +1012,7 @@ index afac559b3c38c4a175070ed823dc8f2c34f4a004..1fc7d8518f7c8d69c2520dbc044a3c20 return Optional.empty(); } else { diff --git a/net/minecraft/world/level/portal/PortalForcer.java b/net/minecraft/world/level/portal/PortalForcer.java -index 0556076d42cff262e8148078410fe6cfa4d8b14b..39418746d5818ce136e79aa1b57b1e6e44e17c37 100644 +index 491affe4343b3843bcdcbae0cca670d120ea24d0..9c552437faa20d10bb5bf67a15282b1e8dec94c5 100644 --- a/net/minecraft/world/level/portal/PortalForcer.java +++ b/net/minecraft/world/level/portal/PortalForcer.java @@ -49,13 +49,38 @@ public class PortalForcer { diff --git a/paper-server/patches/features/0023-Flush-regionfiles-on-save-configuration-option.patch b/paper-server/patches/features/0021-Flush-regionfiles-on-save-configuration-option.patch similarity index 100% rename from paper-server/patches/features/0023-Flush-regionfiles-on-save-configuration-option.patch rename to paper-server/patches/features/0021-Flush-regionfiles-on-save-configuration-option.patch diff --git a/paper-server/patches/features/0024-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch similarity index 94% rename from paper-server/patches/features/0024-Optimise-collision-checking-in-player-move-packet-ha.patch rename to paper-server/patches/features/0022-Optimise-collision-checking-in-player-move-packet-ha.patch index 936897f94dde..72c2c9c5484e 100644 --- a/paper-server/patches/features/0024-Optimise-collision-checking-in-player-move-packet-ha.patch +++ b/paper-server/patches/features/0022-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 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c414fe40d 100644 +index 1c5750c258bfb4b551048670a5e73a19a813ec47..ad4d20dda67ffb37e15a1623104a6e23417cc68e 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -613,6 +613,7 @@ public class ServerGamePacketListenerImpl +@@ -623,6 +623,7 @@ public class ServerGamePacketListenerImpl } rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); @@ -17,7 +17,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c double verticalDelta = d4; d3 = d - rootVehicle.getX(); d4 = d1 - rootVehicle.getY(); -@@ -624,12 +625,21 @@ public class ServerGamePacketListenerImpl +@@ -634,12 +635,21 @@ public class ServerGamePacketListenerImpl d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot @@ -42,7 +42,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c rootVehicle.absSnapTo(x, y, z, f, f1); this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle)); rootVehicle.removeLatestMovementRecording(); -@@ -708,9 +718,32 @@ public class ServerGamePacketListenerImpl +@@ -718,9 +728,32 @@ public class ServerGamePacketListenerImpl } private boolean noBlocksAround(Entity entity) { @@ -78,7 +78,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c } @Override -@@ -1485,7 +1518,7 @@ public class ServerGamePacketListenerImpl +@@ -1509,7 +1542,7 @@ public class ServerGamePacketListenerImpl } } @@ -87,7 +87,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above -@@ -1524,6 +1557,7 @@ public class ServerGamePacketListenerImpl +@@ -1548,6 +1581,7 @@ public class ServerGamePacketListenerImpl boolean flag1 = this.player.verticalCollisionBelow; this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move @@ -95,7 +95,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c // Paper start - prevent position desync if (this.awaitingPositionFromClient != null) { return; // ... thanks Mojang for letting move calls teleport across dimensions. -@@ -1556,7 +1590,17 @@ public class ServerGamePacketListenerImpl +@@ -1581,7 +1615,17 @@ public class ServerGamePacketListenerImpl } // Paper start - Add fail move event @@ -114,7 +114,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c if (!allowMovement) { io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, toX, toY, toZ, toYaw, toPitch, false); -@@ -1692,7 +1736,7 @@ public class ServerGamePacketListenerImpl +@@ -1716,7 +1760,7 @@ public class ServerGamePacketListenerImpl private boolean updateAwaitingTeleport() { if (this.awaitingPositionFromClient != null) { @@ -123,7 +123,7 @@ index 2c844354f2598ab786e3696897154b5d3a18703c..ef7d44ea1c1582bbf1d544819825778c this.awaitingTeleportTime = this.tickCount; this.teleport( this.awaitingPositionFromClient.x, -@@ -1711,6 +1755,34 @@ public class ServerGamePacketListenerImpl +@@ -1735,6 +1779,34 @@ public class ServerGamePacketListenerImpl } } diff --git a/paper-server/patches/features/0025-Improve-keepalive-ping-system.patch b/paper-server/patches/features/0023-Improve-keepalive-ping-system.patch similarity index 99% rename from paper-server/patches/features/0025-Improve-keepalive-ping-system.patch rename to paper-server/patches/features/0023-Improve-keepalive-ping-system.patch index 3f4fcd3ca57f..f046496ff6a4 100644 --- a/paper-server/patches/features/0025-Improve-keepalive-ping-system.patch +++ b/paper-server/patches/features/0023-Improve-keepalive-ping-system.patch @@ -100,7 +100,7 @@ index 21d50675bfe90c2276890779eb23de58ac915b9a..7be34e37562875313b8e43357921b5fe } } diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 39fe30969687d4675fec40e7df9c1f85971683f6..c6db2c96db96453daaf49779f588f75f7c3d3d60 100644 +index 079ab378920c0e52ef4e42ef20b37bd389f40870..b8a4b4cc02a2fc6b70f4b840796eed501aad6239 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -39,12 +39,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack diff --git a/paper-server/patches/features/0026-Optimise-EntityScheduler-ticking.patch b/paper-server/patches/features/0024-Optimise-EntityScheduler-ticking.patch similarity index 91% rename from paper-server/patches/features/0026-Optimise-EntityScheduler-ticking.patch rename to paper-server/patches/features/0024-Optimise-EntityScheduler-ticking.patch index 62505d9e534a..85beda79758c 100644 --- a/paper-server/patches/features/0026-Optimise-EntityScheduler-ticking.patch +++ b/paper-server/patches/features/0024-Optimise-EntityScheduler-ticking.patch @@ -8,7 +8,7 @@ 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 a2fbc13105673e926cbaed69221826ebd392140f..a42938e1abd371dba6806e65552fde71b178a096 100644 +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 { @@ -20,10 +20,10 @@ index a2fbc13105673e926cbaed69221826ebd392140f..a42938e1abd371dba6806e65552fde71 @Override diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index ff6fc300e9e7d1dbf4b0fa1e59bffe94e1f51259..d58ee455467b2c8307ea20f8a9d88f0f18053fc1 100644 +index e7df5f105c721f2e1be1a13694275c0f03b7932b..0f56d83701ac770799970fceeb73eab57adf5c38 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1736,33 +1736,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entities, NaturalSpawner.ChunkGetter chunkGetter, LocalMobCapCalculator calculator ) { @@ -111,7 +110,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 PotentialCalculator potentialCalculator = new PotentialCalculator(); Object2IntOpenHashMap map = new Object2IntOpenHashMap<>(); -@@ -89,11 +97,16 @@ public final class NaturalSpawner { +@@ -90,11 +98,16 @@ public final class NaturalSpawner { potentialCalculator.addCharge(entity.blockPosition(), mobSpawnCost.charge()); } @@ -129,7 +128,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 }); } } -@@ -131,7 +144,7 @@ public final class NaturalSpawner { +@@ -132,7 +145,7 @@ public final class NaturalSpawner { if ((spawnFriendlies || !mobCategory.isFriendly()) && (spawnEnemies || mobCategory.isFriendly()) && (spawnPassives || !mobCategory.isPersistent()) @@ -138,7 +137,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 list.add(mobCategory); // CraftBukkit end } -@@ -145,8 +158,37 @@ public final class NaturalSpawner { +@@ -146,8 +159,37 @@ public final class NaturalSpawner { profilerFiller.push("spawner"); for (MobCategory mobCategory : categories) { @@ -178,7 +177,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 } } -@@ -166,9 +208,16 @@ public final class NaturalSpawner { +@@ -167,9 +209,16 @@ public final class NaturalSpawner { public static void spawnCategoryForChunk( MobCategory category, ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { @@ -196,7 +195,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 } } -@@ -185,6 +234,12 @@ public final class NaturalSpawner { +@@ -186,6 +235,12 @@ public final class NaturalSpawner { NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { @@ -209,7 +208,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int y = pos.getY(); -@@ -249,9 +304,14 @@ public final class NaturalSpawner { +@@ -250,9 +305,14 @@ public final class NaturalSpawner { ++i; ++i3; callback.run(mobForSpawn, chunk); @@ -225,7 +224,7 @@ index f95206f001f561755ba2423e22bc55632b26f36d..47384eedbb67f2ea50a3846f8499f6a8 return; } -@@ -566,7 +626,7 @@ public final class NaturalSpawner { +@@ -564,7 +624,7 @@ public final class NaturalSpawner { this.spawnPotential.addCharge(blockPos, d); MobCategory category = type.getCategory(); this.mobCategoryCounts.addTo(category, 1); diff --git a/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch similarity index 87% rename from paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch rename to paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch index 7b5342a2fb32..07ab47f034e4 100644 --- a/paper-server/patches/features/0028-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch +++ b/paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch @@ -6,10 +6,10 @@ 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 2aad9f90a7c1815ec4855d338848657dc0d9a3c7..ce53eb1e966e07b04e6a13785a858a3318b2c573 100644 +index 0bf14bf6ece5136f9c9972439076c33a7036be5c..6f32fb08788605ebf00839d412a7f4d78137aadf 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -260,8 +260,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -266,8 +266,25 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } } @@ -33,14 +33,14 @@ index 2aad9f90a7c1815ec4855d338848657dc0d9a3c7..ce53eb1e966e07b04e6a13785a858a33 public int getMobCountNear(final ServerPlayer player, final net.minecraft.world.entity.MobCategory mobCategory) { - return player.mobCounts[mobCategory.ordinal()]; + return player.mobCounts[mobCategory.ordinal()] + player.mobBackoffCounts[mobCategory.ordinal()]; // Paper - per player mob count backoff - } + } // Paper end - Optional per player mob spawns diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index f31b7ddddf80e58c2323d85ff48a98c3e92e33e0..488fc6088d69148f60a913b42ffb964c48eb0324 100644 +index 9b8222bda0f119f272d90f980c9f9540211af84a..af67b07722bb0125acd081dab767d7e7b360623b 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -541,7 +541,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -535,7 +535,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled // re-set mob counts for (ServerPlayer player : this.level.players) { @@ -60,10 +60,10 @@ index f31b7ddddf80e58c2323d85ff48a98c3e92e33e0..488fc6088d69148f60a913b42ffb964c spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, 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 ebca471ba92f49b00707a3d193cd424a94b956e4..e2fdaf72b9714d919938b3e82328971c887c7ab1 100644 +index b3d9c359d091637e6911b17483cf594099aa61f4..791296eb42c961287db7ce8e56959910cc3b04e1 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -423,6 +423,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -413,6 +413,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 ebca471ba92f49b00707a3d193cd424a94b956e4..e2fdaf72b9714d919938b3e82328971c 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 47384eedbb67f2ea50a3846f8499f6a81fd38b82..911c5099a2bbb3e955c9314219114873642c7355 100644 +index 253268a70179139daa9ad587f9e0e2f48d61beb9..4e5078495037078922ab6350a500acdabe177ca5 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -281,6 +281,11 @@ public final class NaturalSpawner { +@@ -282,6 +282,11 @@ public final class NaturalSpawner { // Paper start - PreCreatureSpawnEvent PreSpawnStatus doSpawning = isValidSpawnPostitionForType(level, category, structureManager, generator, spawnerData, mutableBlockPos, d2); diff --git a/paper-server/patches/features/0029-Optimize-Hoppers.patch b/paper-server/patches/features/0027-Optimize-Hoppers.patch similarity index 95% rename from paper-server/patches/features/0029-Optimize-Hoppers.patch rename to paper-server/patches/features/0027-Optimize-Hoppers.patch index 1f428c03f88e..a8091d50ecbb 100644 --- a/paper-server/patches/features/0029-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0027-Optimize-Hoppers.patch @@ -48,22 +48,22 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf + } +} diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index d58ee455467b2c8307ea20f8a9d88f0f18053fc1..f63a5567a2e845de904c2dacfbb875049e3e0c65 100644 +index 0f56d83701ac770799970fceeb73eab57adf5c38..ba4a3f33e10111d6b278d27938907c76ff28c88b 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1791,6 +1791,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent serverLevel.updateLagCompensationTick(); // Paper - lag compensation + net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = serverLevel.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers - profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location()); + profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().identifier()); /* Drop global time updates if (this.tickCount % 20 == 0) { diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index fc6f17db0bf4b4ea9f913bbf5d4c1d5cbb10dc03..47862c00e9e01c7cdd5fcd808cc1b76740b85a57 100644 +index c91797613b68cd9c624779a2c7cd3e76edf9423e..b00ad17852e9890f848fc2124e2287885c2b9c5d 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -808,10 +808,16 @@ public final class ItemStack implements DataComponentHolder { +@@ -813,10 +813,16 @@ public final class ItemStack implements DataComponentHolder { } public ItemStack copy() { @@ -83,10 +83,10 @@ index fc6f17db0bf4b4ea9f913bbf5d4c1d5cbb10dc03..47862c00e9e01c7cdd5fcd808cc1b767 return itemStack; } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index bdbc6df5787cd1ca77541bc0602ec563e8799fbc..bd038bdaa00fb1e09b098b4d2809d17e2382288b 100644 +index 647ef4c1715e151711e3de70dfcbbc5037ac12ab..fb22ebe9758014ebf2aebcda21155f1c4c83fafe 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -37,6 +37,7 @@ import net.minecraft.world.level.storage.ValueOutput; +@@ -37,6 +37,7 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; public abstract class BlockEntity implements DebugValueSource { @@ -94,7 +94,7 @@ index bdbc6df5787cd1ca77541bc0602ec563e8799fbc..bd038bdaa00fb1e09b098b4d2809d17e // CraftBukkit start - data containers private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; -@@ -229,6 +230,7 @@ public abstract class BlockEntity implements DebugValueSource { +@@ -226,6 +227,7 @@ public abstract class BlockEntity implements DebugValueSource { public void setChanged() { if (this.level != null) { @@ -103,7 +103,7 @@ index bdbc6df5787cd1ca77541bc0602ec563e8799fbc..bd038bdaa00fb1e09b098b4d2809d17e } } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a956f79726 100644 +index dbd03aa40f69522bc197ecaab88f53fd8bb6d7a9..ba554c02890d66a872f1c19723eb55b23ab7add2 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -144,18 +144,56 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -628,21 +628,21 @@ index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a9 stack = leftover; // Paper - Make hoppers respect inventory max stack size flag = true; } else if (canMergeItems(item, stack)) { -@@ -526,13 +775,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -522,12 +771,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + } - @Nullable - public static Container getContainerAt(Level level, BlockPos pos) { + public static @Nullable Container getContainerAt(Level level, BlockPos pos) { - return getContainerAt(level, pos, level.getBlockState(pos), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + return getContainerAt(level, pos, level.getBlockState(pos), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, true); // Paper - Optimize hoppers } - @Nullable - private static Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) { +- private static @Nullable Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) { ++ @Nullable ++ private static Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) { + // Paper start - Perf: Optimize Hoppers + return HopperBlockEntity.getContainerAt(level, pos, state, x, y, z, false); + } -+ @Nullable -+ private static Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z, final boolean optimizeEntities) { ++ private static @Nullable Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z, final boolean optimizeEntities) { + // Paper end - Perf: Optimize Hoppers Container blockContainer = getBlockContainer(level, pos, state); - if (blockContainer == null) { @@ -650,10 +650,10 @@ index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a9 blockContainer = getEntityContainer(level, x, y, z); } -@@ -558,14 +813,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -551,14 +806,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + } - @Nullable - private static Container getEntityContainer(Level level, double x, double y, double z) { + private static @Nullable Container getEntityContainer(Level level, double x, double y, double z) { - List entities = level.getEntities( - (Entity)null, new AABB(x - 0.5, y - 0.5, z - 0.5, x + 0.5, y + 0.5, z + 0.5), EntitySelector.CONTAINER_ENTITY_SELECTOR + List entities = level.getEntitiesOfClass( @@ -669,10 +669,10 @@ index 96414f8bce0a89f11c64bf26924fc7bb4588e9be..28348e3881c3c8591053a01b193fb2a9 @Override diff --git a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index d2cd30ed072a3d75c32b49a72920a9c26ce29922..dc59465d63e36bd50a48a8ea4197424556736552 100644 +index 54c2c171c4bdc2d4d0ad048609dbdd0be8691017..4bf59f040ca2d6f35ef3c74cd8195c326234190a 100644 --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -54,7 +54,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc +@@ -52,7 +52,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc @Override public ItemStack getItem(int index) { diff --git a/paper-server/patches/features/0030-Anti-Xray.patch b/paper-server/patches/features/0028-Anti-Xray.patch similarity index 93% rename from paper-server/patches/features/0030-Anti-Xray.patch rename to paper-server/patches/features/0028-Anti-Xray.patch index 235b571e6956..bc5f16e6da9e 100644 --- a/paper-server/patches/features/0030-Anti-Xray.patch +++ b/paper-server/patches/features/0028-Anti-Xray.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 045778402404d46610165d15d8d430d6ae968688..695b8b708ffda1a927d865ba9891bb85303d75af 100644 +index 485413cb6b20c4bd20fbc29a0db43c051993fe79..22f37a0779996c9e3a9416a2a1ba2bee74e3f568 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -48,20 +48,25 @@ public final class FeatureHooks { @@ -55,7 +55,7 @@ index c9086bca5cbb780fd586f667e31a8fe1400ae58a..f828d07018d9a17aaa0142aac67ebed5 if (buffer.writerIndex() != buffer.capacity()) { diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index bd9b29da33670afd6ad0ea86927dad8c4a69faca..33ca4c2110673dee34b66c8d05ee83c4df828f2e 100644 +index 919eaac837298c1936ec7aa06375c72a7acd2daa..19547e22620f16d01f05bbd13a4dcb9c0df636df 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -41,13 +41,23 @@ public class ClientboundLevelChunkPacketData { @@ -103,7 +103,7 @@ index bd9b29da33670afd6ad0ea86927dad8c4a69faca..33ca4c2110673dee34b66c8d05ee83c4 if (buffer.writerIndex() != buffer.capacity()) { diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java -index fdd164cd45a26c7ef25f1153ab8985ba50c01b14..8578d1f78ddd1bb75f3230f04bfaa35af9f5f822 100644 +index 3c0f0a612cc57c9f03abfb0ccb1f891305d03d45..9f43cfbdd49df61de869fd65fb2cbea39a563260 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java @@ -18,18 +18,31 @@ public class ClientboundLevelChunkWithLightPacket implements Packet server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs -+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs & Async-Anti-Xray: Pass executor +- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.identifier(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs ++ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.identifier(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs & Async-Anti-Xray: Pass executor this.levelStorageAccess = levelStorageAccess; this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); this.levelLoadListener = new net.minecraft.server.level.progress.LoggingLevelLoadListener(false, this); diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index c7407319dc4f6c6c34428f7038cca407a0e43c61..7166889bce8065508030ecd5b1400ee9be031bf3 100644 +index e22368b036c35d32dca79b0e840f1008dce830a4..6771cbbae863fa181e19c5fb74d2018d3559ef4e 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -316,6 +316,7 @@ public class ServerPlayerGameMode { +@@ -313,6 +313,7 @@ public class ServerPlayerGameMode { org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelectedItem()); // CraftBukkit } } @@ -184,10 +184,10 @@ index c65b274b965b95eae33690e63c5da2d5a9f2981a..644948d64791d0ffa4166375d0f4419f if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), packetListener.getPlayer().getBukkitEntity()).callEvent(); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 410be367549a345677c94e9f8d7db0b7fffbf073..015ffd8298989bdb597b18d79adc3debcffc0977 100644 +index a17d021269c65d98a2ba847c0059a421ea051863..9f86d1fc4ea4c6987fa207644573565aea7edead 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -323,7 +323,7 @@ public abstract class PlayerList { +@@ -329,7 +329,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(serverLevel, player.chunkPosition(), plains), @@ -197,7 +197,7 @@ index 410be367549a345677c94e9f8d7db0b7fffbf073..015ffd8298989bdb597b18d79adc3deb } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a86d023a0 100644 +index bc0824b42e2fde246f052afe1e1393de632ccfb7..7bfaec43c12fb61b3fd7bac2c01903b81404280f 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -139,6 +139,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -207,9 +207,9 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a + public final io.papermc.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray private final CraftWorld world; public net.kyori.adventure.util.TriState pvpMode = net.kyori.adventure.util.TriState.NOT_SET; - public @Nullable org.bukkit.generator.ChunkGenerator generator; + public org.bukkit.generator.@Nullable ChunkGenerator generator; @@ -831,7 +832,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - @Nullable org.bukkit.generator.BiomeProvider biomeProvider, // Paper + org.bukkit.generator.@Nullable BiomeProvider biomeProvider, // Paper org.bukkit.World.Environment environment, // Paper java.util.function.Function paperWorldConfigCreator // Paper - create paper world config @@ -218,7 +218,7 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a ) { // Paper start - getblock optimisations - cache world height/sections final DimensionType dimType = dimensionTypeRegistration.value(); -@@ -866,6 +868,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -865,6 +867,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 @@ -226,7 +226,7 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a } // Paper start - Cancel hit for vanished players -@@ -1071,6 +1074,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1068,6 +1071,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl snapshot.setFlags(flags); // Paper - always set the flag of the most recent call to mitigate issues with multiple update at the same pos with different flags } BlockState blockState = chunkAt.setBlockState(pos, state, flags); @@ -235,10 +235,10 @@ index 96fa7390a4bcfa7bdf2cf5346f2de895ac085203..d225267b1b07854b76c88ce461d7817a if (blockState == null) { // CraftBukkit start - remove blockstate if failed (or the same) diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index 71aa0220309e418fbbda66c2fa14fec498bf443d..22bc09e99b6755db403fad2e1136175737abed7c 100644 +index a49a06662de4062a77112e358f536d45d65bf91f..54ddcf92e72b9cbd0eb442e5d0faa83c0cf3b33b 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -164,7 +164,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -161,7 +161,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh } } @@ -247,7 +247,7 @@ index 71aa0220309e418fbbda66c2fa14fec498bf443d..22bc09e99b6755db403fad2e11361757 // Paper start - rewrite chunk system if (!((Object)this instanceof ImposterProtoChunk)) { this.starlight$setBlockNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(levelHeightAccessor)); -@@ -177,10 +177,10 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -174,10 +174,10 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh // Paper end - get block chunk optimisation } @@ -261,11 +261,11 @@ index 71aa0220309e418fbbda66c2fa14fec498bf443d..22bc09e99b6755db403fad2e11361757 } } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 4be0c11b3066bc56ac2b8658e064958038da44bf..de59760d27280555a334bda4f436164568cffbd6 100644 +index 356a89ef2396f245e438d59d65edd0445693cb8b..7f2fa1978c2ca5620f0f3c1f26570d924d7fb3e5 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -152,7 +152,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot - @Nullable LevelChunk.PostLoadProcessor postLoad, +@@ -151,7 +151,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot + LevelChunk.@Nullable PostLoadProcessor postLoad, @Nullable BlendingData blendingData ) { - super(pos, data, level, level.palettedContainerFactory(), inhabitedTime, sections, blendingData); @@ -314,7 +314,7 @@ index 5a76746a27d04cc095585655f2ef19ac10528071..201ba8b6ea45f526fbd5292164bb4cb6 public int getSerializedSize() { diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7..54d71bd666a946bdf6eece520e080c3f96003452 100644 +index 0740775f2fa49c4313c1de6dd00f0a39fe2e0463..7c8f8772a6fba04dbafdb5dbf8098b6ebce6d6f2 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 @@ -457,7 +457,7 @@ index 49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7..54d71bd666a946bdf6eece520e080c3f + } @Override - public synchronized void write(FriendlyByteBuf buffer) { // Paper - synchronize -+ public synchronized void write(FriendlyByteBuf buffer, @Nullable io.papermc.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { // Paper - synchronize ++ public synchronized void write(FriendlyByteBuf buffer, io.papermc.paper.antixray.@Nullable ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { // Paper - synchronize this.acquire(); try { @@ -508,7 +508,7 @@ index 49c00586c1ae55e5e85787fa7cd4b84e8d5c83c7..54d71bd666a946bdf6eece520e080c3f - public void write(FriendlyByteBuf buffer, IdMap map) { + // Paper start - Anti-Xray - Add chunk packet info -+ public void write(FriendlyByteBuf buffer, IdMap map, @Nullable io.papermc.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { ++ public void write(FriendlyByteBuf buffer, IdMap map, io.papermc.paper.antixray.@Nullable ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { buffer.writeByte(this.storage.getBits()); this.palette.write(buffer, map); + if (chunkPacketInfo != null) { @@ -590,18 +590,18 @@ index bcf7d5cca1f6e70222fccbeb259b6e323aa4c21a..787f5173425f617a89033e5b76256688 private static final Palette.Factory HASHMAP_PALETTE_FACTORY = HashMapPalette::create; 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 1652513d8a7e6036c82162517948dd22ca98d109..2e8a1898c9ef8bbfd58ea1e9fbd7f6a633822fb9 100644 +index 68874c0b6f6f7c5d8e3a79c9a7b391b9624ab748..95c8d65a4b6db8d0721460ae55cb8fb8143ea9a2 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -140,6 +140,7 @@ public record SerializableChunkData( +@@ -139,6 +139,7 @@ public record SerializableChunkData( + // Paper end - Do not let the server load chunks from newer versions - @Nullable public static SerializableChunkData parse(LevelHeightAccessor level, PalettedContainerFactory containerFactory, CompoundTag tag) { + net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) level; // Paper - Anti-Xray This is is seemingly only called from ChunkMap, where, we have a server level. We'll fight this later if needed. if (tag.getString("Status").isEmpty()) { return null; } else { -@@ -198,9 +199,11 @@ public record SerializableChunkData( +@@ -199,9 +200,11 @@ public record SerializableChunkData( int byteOr = compoundTag.getByteOr("Y", (byte)0); LevelChunkSection levelChunkSection; if (byteOr >= level.getMinSectionY() && byteOr <= level.getMaxSectionY()) { diff --git a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch index fb16e7594569..803bcf504342 100644 --- a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch +++ b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/PaperHooks.java.patch @@ -17,7 +17,7 @@ +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.boss.EnderDragonPart; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; diff --git a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch index b699e0d32d5a..fa336bf0640a 100644 --- a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch +++ b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch @@ -1,8 +1,8 @@ --- a/com/mojang/math/OctahedralGroup.java +++ b/com/mojang/math/OctahedralGroup.java -@@ -123,6 +_,12 @@ - } - ); +@@ -105,6 +_,12 @@ + .map(group -> Arrays.stream(values()).filter(octahedralGroup -> group.compose(octahedralGroup) == IDENTITY).findAny().get()) + .toArray(OctahedralGroup[]::new); + static { + for (OctahedralGroup octahedralGroup : values()) { @@ -13,7 +13,7 @@ private OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { this.name = name; this.invertX = invertX; -@@ -160,7 +_,7 @@ +@@ -145,7 +_,7 @@ return this.name; } @@ -22,7 +22,7 @@ if (this.rotatedDirections == null) { this.rotatedDirections = Util.makeEnumMap(Direction.class, direction1 -> { Direction.Axis axis = direction1.getAxis(); -@@ -171,6 +_,11 @@ +@@ -156,6 +_,11 @@ }); } diff --git a/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch b/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch index 98fe6924975c..5af9881635a4 100644 --- a/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch +++ b/paper-server/patches/sources/com/mojang/serialization/Dynamic.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/serialization/Dynamic.java +++ b/com/mojang/serialization/Dynamic.java -@@ -19,6 +_,7 @@ +@@ -20,6 +_,7 @@ @SuppressWarnings("unused") public class Dynamic extends DynamicLike { @@ -8,7 +8,7 @@ private final T value; public Dynamic(final DynamicOps ops) { -@@ -120,7 +_,7 @@ +@@ -121,7 +_,7 @@ return new OptionalDynamic<>(ops, ops.getMap(value).flatMap(m -> { final T value = m.get(key); if (value == null) { 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 b0f903228bdb..dd764f0757aa 100644 --- a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch +++ b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch @@ -17,7 +17,7 @@ +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.monster.Spider; ++import net.minecraft.world.entity.monster.spider.Spider; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; @@ -228,7 +228,7 @@ + } + + public static java.util.concurrent.Executor getWorldgenExecutor() { -+ return net.minecraft.Util.backgroundExecutor(); ++ return net.minecraft.util.Util.backgroundExecutor(); + } + + public static void setViewDistance(ServerPlayer player, int distance) { diff --git a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch b/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch index a2a9d43baa0f..eb3d87a70583 100644 --- a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch +++ b/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/ChatFormatting.java +++ b/net/minecraft/ChatFormatting.java -@@ -118,6 +_,19 @@ +@@ -114,6 +_,19 @@ return friendlyName == null ? null : FORMATTING_BY_NAME.get(cleanName(friendlyName)); } @@ -17,6 +17,6 @@ + } + // Paper end - add method to get by hex value + - @Nullable - public static ChatFormatting getById(int index) { + public static @Nullable ChatFormatting getById(int index) { if (index < 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 d9c00ba98178..9166f45ad73a 100644 --- a/paper-server/patches/sources/net/minecraft/CrashReport.java.patch +++ b/paper-server/patches/sources/net/minecraft/CrashReport.java.patch @@ -11,7 +11,7 @@ } public String getTitle() { -@@ -218,7 +_,7 @@ +@@ -217,7 +_,7 @@ } public static void preload() { diff --git a/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch b/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch index aeb440896784..6c17a3351155 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementTree.java +++ b/net/minecraft/advancements/AdvancementTree.java -@@ -26,7 +_,7 @@ +@@ -25,7 +_,7 @@ this.remove(advancementNode); } @@ -9,7 +9,7 @@ this.nodes.remove(node.holder().id()); if (node.parent() == null) { this.roots.remove(node); -@@ -62,7 +_,7 @@ +@@ -61,7 +_,7 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch b/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch index e43dabe61746..d559a186341d 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/criterion/LocationPredicate.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/advancements/critereon/LocationPredicate.java -+++ b/net/minecraft/advancements/critereon/LocationPredicate.java +--- a/net/minecraft/advancements/criterion/LocationPredicate.java ++++ b/net/minecraft/advancements/criterion/LocationPredicate.java @@ -44,7 +_,7 @@ public boolean matches(ServerLevel level, double x, double y, double z) { if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { diff --git a/paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch b/paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch index c4d763988944..8764e1c98d7a 100644 --- a/paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -+++ b/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +--- a/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java ++++ b/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java @@ -15,41 +_,41 @@ import net.minecraft.world.level.storage.loot.LootContext; diff --git a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch index 8f350ebabe4a..4266c14e397a 100644 --- a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -47,7 +_,7 @@ - import net.minecraft.world.phys.Vec2; +@@ -48,7 +_,7 @@ import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; --public class CommandSourceStack implements ExecutionCommandSource, PermissionSource, SharedSuggestionProvider { -+public class CommandSourceStack implements ExecutionCommandSource, PermissionSource, SharedSuggestionProvider, io.papermc.paper.command.brigadier.PaperCommandSourceStack { // Paper - Brigadier API +-public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider { ++public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider, io.papermc.paper.command.brigadier.PaperCommandSourceStack { // Paper - Brigadier API public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity")); public final CommandSource source; @@ -31,7 +31,7 @@ + new Vec3(location.x(), location.y(), location.z()), + new Vec2(location.getPitch(), location.getYaw()), + ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(), -+ this.permissionLevel, ++ this.permissions, + this.textName, + this.displayName, + this.server, @@ -48,8 +48,8 @@ public CommandSourceStack withRotation(Vec2 rotation) { return this.rotation.equals(rotation) ? this -@@ -396,6 +_,32 @@ - return this.permissionLevel >= level; +@@ -379,6 +_,32 @@ + return this.permissions; } + // Paper start - Fix permission levels for command blocks @@ -59,14 +59,14 @@ + // Paper end - Fix permission levels for command blocks + + // CraftBukkit start -+ public boolean hasPermission(int i, String bukkitPermission) { ++ public boolean hasPermission(net.minecraft.server.permissions.Permission permission, String bukkitPermission) { + // Paper start - Fix permission levels for command blocks + final java.util.function.BooleanSupplier hasBukkitPerm = () -> this.source == CommandSource.NULL /*treat NULL as having all bukkit perms*/ || this.getBukkitSender().hasPermission(bukkitPermission); // lazily check bukkit perms to the benefit of custom permission setups + // if the server is null, we must check the vanilla perm level system + // if ignoreVanillaPermissions is true, we can skip vanilla perms and just run the bukkit perm check + //noinspection ConstantValue + if (this.getServer() == null || !this.getServer().server.ignoreVanillaPermissions) { // server & level are null for command function loading -+ final boolean hasPermLevel = this.permissionLevel >= i; ++ final boolean hasPermLevel = this.permissions.hasPermission(permission); + if (this.forceRespectPermissionLevel()) { // NULL CommandSource and command blocks (if setting is enabled) should always pass the vanilla perm check + return hasPermLevel && hasBukkitPerm.getAsBoolean(); + } else { // otherwise check vanilla perm first then bukkit perm, matching upstream behavior @@ -81,9 +81,9 @@ public Vec3 getPosition() { return this.worldPosition; } -@@ -500,20 +_,25 @@ - Component component = Component.translatable("chat.type.admin", this.getDisplayName(), message).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC); - if (this.server.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) { +@@ -482,20 +_,25 @@ + GameRules gameRules = this.level.getGameRules(); + if (gameRules.get(GameRules.SEND_COMMAND_FEEDBACK)) { for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { - if (serverPlayer.commandSource() != this.source && this.server.getPlayerList().isOp(serverPlayer.nameAndId())) { + if (serverPlayer.commandSource() != this.source && serverPlayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit @@ -92,8 +92,8 @@ } } -- if (this.source != this.server && this.server.getGameRules().getBoolean(GameRules.RULE_LOGADMINCOMMANDS)) { -+ if (this.source != this.server && this.server.getGameRules().getBoolean(GameRules.RULE_LOGADMINCOMMANDS) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot +- if (this.source != this.server && gameRules.get(GameRules.LOG_ADMIN_COMMANDS)) { ++ if (this.source != this.server && gameRules.get(GameRules.LOG_ADMIN_COMMANDS) && !org.spigotmc.SpigotConfig.silentCommandBlocks) { // Spigot this.server.sendSystemMessage(component); } } @@ -110,7 +110,7 @@ } } -@@ -524,7 +_,7 @@ +@@ -506,7 +_,7 @@ @Override public Collection getOnlinePlayerNames() { @@ -119,7 +119,7 @@ } @Override -@@ -604,4 +_,16 @@ +@@ -586,4 +_,16 @@ public boolean isSilent() { return this.silent; } 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 bd775ab10d66..dfe4e32943b8 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -1,13 +1,22 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -172,12 +_,18 @@ +@@ -155,6 +_,7 @@ + import org.slf4j.Logger; + + public class Commands { ++ public interface RestrictedMarker { } // Paper - restricted api + public static final String COMMAND_PREFIX = "/"; + private static final ThreadLocal<@Nullable ExecutionContext> CURRENT_EXECUTION_CONTEXT = new ThreadLocal<>(); + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -179,6 +_,7 @@ @Override public boolean isRestricted(CommandNode node) { -+ if (node.getRequirement() instanceof PermissionSource.RestrictedMarker) return true; // Paper - restricted api - return node.getRequirement() instanceof PermissionCheck permissionCheck && permissionCheck.requiredLevel() > 0; ++ if (node.getRequirement() instanceof RestrictedMarker) return true; // Paper - restricted api + Predicate requirement = node.getRequirement(); + return !requirement.test(this.noPermissionSource); } - }; +@@ -186,6 +_,11 @@ private final CommandDispatcher dispatcher = new CommandDispatcher<>(); public Commands(Commands.CommandSelection selection, CommandBuildContext context) { @@ -19,7 +28,7 @@ AdvancementCommands.register(this.dispatcher); AttributeCommand.register(this.dispatcher, context); ExecuteCommand.register(this.dispatcher, context); -@@ -287,6 +_,42 @@ +@@ -296,6 +_,42 @@ PublishCommand.register(this.dispatcher); } @@ -27,7 +36,7 @@ + for (final CommandNode node : this.dispatcher.getRoot().getChildren()) { + if (node.getRequirement() == com.mojang.brigadier.builder.ArgumentBuilder.defaultRequirement()) { + node.requirement = stack -> stack.source == CommandSource.NULL || stack.getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(node)); -+ } else if (node.getRequirement() instanceof net.minecraft.commands.PermissionSource.Check check) { ++ } else if (node.getRequirement() instanceof PermissionProviderCheck check) { + check.vanillaNode().set(node); + } + } @@ -62,7 +71,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -306,6 +_,13 @@ +@@ -315,6 +_,13 @@ } public void performCommand(ParseResults parseResults, String command) { @@ -76,7 +85,7 @@ CommandSourceStack commandSourceStack = parseResults.getContext().getSource(); Profiler.get().push(() -> "/" + command); ContextChain contextChain = finishParsing(parseResults, command, commandSourceStack); -@@ -319,10 +_,13 @@ +@@ -328,10 +_,13 @@ ) ); } @@ -93,14 +102,7 @@ StackTraceElement[] stackTrace = var12.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -348,13 +_,17 @@ - } - - @Nullable -- private static ContextChain finishParsing(ParseResults parseResults, String command, CommandSourceStack source) { -+ private ContextChain finishParsing(ParseResults parseResults, String command, CommandSourceStack source) { - try { - validateParseResults(parseResults); +@@ -364,7 +_,11 @@ return ContextChain.tryFlatten(parseResults.getContext().build(command)) .orElseThrow(() -> CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(parseResults.getReader())); } catch (CommandSyntaxException var7) { @@ -113,7 +115,7 @@ if (var7.getInput() != null && var7.getCursor() >= 0) { int min = Math.min(var7.getInput().length(), var7.getCursor()); MutableComponent mutableComponent = Component.empty() -@@ -371,7 +_,17 @@ +@@ -381,7 +_,17 @@ } mutableComponent.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); @@ -132,7 +134,7 @@ } return null; -@@ -399,17 +_,110 @@ +@@ -409,17 +_,110 @@ } public void sendCommands(ServerPlayer player) { @@ -246,7 +248,7 @@ if (argumentBuilder.getRedirect() != null) { argumentBuilder.redirect(output.get(argumentBuilder.getRedirect())); } -@@ -418,7 +_,7 @@ +@@ -428,7 +_,7 @@ output.put(commandNode, commandNode1); current.addChild(commandNode1); if (!commandNode.getChildren().isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/commands/PermissionSource.java.patch b/paper-server/patches/sources/net/minecraft/commands/PermissionSource.java.patch deleted file mode 100644 index 0d8a8570bb81..000000000000 --- a/paper-server/patches/sources/net/minecraft/commands/PermissionSource.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/commands/PermissionSource.java -+++ b/net/minecraft/commands/PermissionSource.java -@@ -9,9 +_,22 @@ - return this.hasPermission(2); - } - -- public record Check(@Override int requiredLevel) implements PermissionCheck { -+ // Paper start - Vanilla Command permission checking & expose restricted API -+ interface RestrictedMarker { } -+ -+ public record Check(@Override int requiredLevel, java.util.concurrent.atomic.AtomicReference> vanillaNode) implements PermissionCheck { -+ public Check(int requiredLevel) { -+ this(requiredLevel, new java.util.concurrent.atomic.AtomicReference<>()); -+ } -+ // Paper end - Vanilla Command permission checking & expose restricted API - @Override - public boolean test(T source) { -+ // Paper start - Vanilla Command permission checking -+ com.mojang.brigadier.tree.CommandNode currentCommand = vanillaNode.get(); -+ if (currentCommand != null && source instanceof CommandSourceStack commandSourceStack) { -+ return commandSourceStack.hasPermission(this.requiredLevel, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand)); -+ } -+ // Paper end - Vanilla Command permission checking - return source.hasPermission(this.requiredLevel); - } - } diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch index 4a154e157e21..a1eea4fbe882 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/EntityArgument.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/EntityArgument.java +++ b/net/minecraft/commands/arguments/EntityArgument.java -@@ -105,9 +_,14 @@ +@@ -106,9 +_,14 @@ } private EntitySelector parse(StringReader reader, boolean allowSelectors) throws CommandSyntaxException { @@ -16,17 +16,19 @@ if (entitySelector.getMaxResults() > 1 && this.single) { if (this.playersOnly) { reader.setCursor(0); -@@ -129,7 +_,13 @@ +@@ -130,9 +_,15 @@ if (context.getSource() instanceof SharedSuggestionProvider sharedSuggestionProvider) { StringReader stringReader = new StringReader(builder.getInput()); stringReader.setCursor(builder.getStart()); -- EntitySelectorParser entitySelectorParser = new EntitySelectorParser(stringReader, EntitySelectorParser.allowSelectors(sharedSuggestionProvider)); + // Paper start - Fix EntityArgument permissions + final boolean permission = sharedSuggestionProvider instanceof CommandSourceStack stack -+ ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector") ++ ? stack.bypassSelectorPermissions || stack.hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS, "minecraft.command.selector") + // Only CommandSourceStack implements SharedSuggestionProvider. If *somehow* anything else ends up here, try to query its permission level, otherwise yield false. -+ : (sharedSuggestionProvider instanceof final net.minecraft.commands.PermissionSource permissionSource && permissionSource.hasPermission(2)); -+ EntitySelectorParser entitySelectorParser = new EntitySelectorParser(stringReader, permission); ++ : sharedSuggestionProvider.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS); + EntitySelectorParser entitySelectorParser = new EntitySelectorParser( +- stringReader, sharedSuggestionProvider.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS) ++ stringReader, permission + ); + // Paper end - Fix EntityArgument permissions try { diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch index c2bfa9606584..9ec0535601f1 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/MessageArgument.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/MessageArgument.java +++ b/net/minecraft/commands/arguments/MessageArgument.java -@@ -40,6 +_,11 @@ +@@ -41,6 +_,11 @@ public static void resolveChatMessage(CommandContext context, String key, Consumer callback) throws CommandSyntaxException { MessageArgument.Message message = context.getArgument(key, MessageArgument.Message.class); @@ -12,7 +12,7 @@ CommandSourceStack commandSourceStack = context.getSource(); Component component = message.resolveComponent(commandSourceStack); CommandSigningContext signingContext = commandSourceStack.getSigningContext(); -@@ -54,17 +_,21 @@ +@@ -55,17 +_,21 @@ private static void resolveSignedMessage(Consumer callback, CommandSourceStack source, PlayerChatMessage message) { MinecraftServer server = source.getServer(); CompletableFuture completableFuture = filterPlainText(source, message); diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch index 5d7a0a0c8b7a..4a39a4919f11 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/blocks/BlockStateParser.java.patch @@ -7,5 +7,5 @@ - private final Map, Comparable> properties = Maps.newHashMap(); + private final Map, Comparable> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable private final Map vagueProperties = Maps.newHashMap(); - private ResourceLocation id = ResourceLocation.withDefaultNamespace(""); - @Nullable + private Identifier id = Identifier.withDefaultNamespace(""); + private @Nullable StateDefinition definition; diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch index b95523bc7703..936c7f5ec845 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -106,7 +_,7 @@ +@@ -103,7 +_,7 @@ } private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException { -- if (this.usesSelector && !source.allowsSelectors()) { -+ if (!source.bypassSelectorPermissions && (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms +- if (this.usesSelector && !source.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS)) { ++ if (!source.bypassSelectorPermissions && this.usesSelector && !source.hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS, "minecraft.command.selector")) { // CraftBukkit // Paper - add bypass for selector perms throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create(); } } diff --git a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index 8507af1706cd..f7a84f01766c 100644 --- a/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java -@@ -125,6 +_,11 @@ +@@ -113,6 +_,11 @@ } public static boolean allowSelectors(S suggestionProvider) { + // Paper start - Fix EntityArgument permissions + if (suggestionProvider instanceof net.minecraft.commands.CommandSourceStack stack) { -+ return stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector"); ++ return stack.bypassSelectorPermissions || stack.hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS, "minecraft.command.selector"); + } + // Paper end - Fix EntityArgument permissions - return suggestionProvider instanceof PermissionSource permissionSource && permissionSource.allowsSelectors(); + return suggestionProvider instanceof PermissionSetSupplier permissionSetSupplier + && permissionSetSupplier.permissions().hasPermission(Permissions.COMMANDS_ENTITY_SELECTORS); } - -@@ -201,8 +_,10 @@ +@@ -195,8 +_,10 @@ }; } @@ -25,7 +25,7 @@ this.suggestions = this::suggestSelector; if (!this.reader.canRead()) { throw ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); -@@ -474,6 +_,12 @@ +@@ -458,6 +_,12 @@ } public EntitySelector parse() throws CommandSyntaxException { @@ -38,7 +38,7 @@ this.startPosition = this.reader.getCursor(); this.suggestions = this::suggestNameOrSelector; if (this.reader.canRead() && this.reader.peek() == '@') { -@@ -482,7 +_,7 @@ +@@ -466,7 +_,7 @@ } this.reader.skip(); 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 d8a0bc922e48..0738cd2b3dc0 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 -@@ -159,67 +_,84 @@ +@@ -156,67 +_,84 @@ @Override public BlockPos above() { @@ -98,7 +98,7 @@ } @Override -@@ -659,9 +_,9 @@ +@@ -651,9 +_,9 @@ } public BlockPos.MutableBlockPos set(int x, int y, int z) { @@ -111,7 +111,7 @@ return this; } -@@ -724,19 +_,19 @@ +@@ -711,19 +_,19 @@ @Override public BlockPos.MutableBlockPos setX(int x) { diff --git a/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch b/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch index 9c9c783ebd0c..9567a6a67952 100644 --- a/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/ClientAsset.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/core/ClientAsset.java +++ b/net/minecraft/core/ClientAsset.java -@@ -24,7 +_,7 @@ +@@ -23,7 +_,7 @@ .map(ClientAsset.ResourceTexture::new, ClientAsset.ResourceTexture::id); - public ResourceTexture(ResourceLocation id) { + public ResourceTexture(Identifier id) { - this(id, id.withPath(path -> "textures/" + path + ".png")); + this(id, id.withPath(path -> "textures/" + path + ".png")); // Paper - diff on change - io.papermc.paper.registry.data.client.ClientAssetImpl#pathFromIdentifier } diff --git a/paper-server/patches/sources/net/minecraft/core/Holder.java.patch b/paper-server/patches/sources/net/minecraft/core/Holder.java.patch index c1d6d57ceb0c..34c31f6e8258 100644 --- a/paper-server/patches/sources/net/minecraft/core/Holder.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Holder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Holder.java +++ b/net/minecraft/core/Holder.java -@@ -230,7 +_,7 @@ +@@ -227,7 +_,7 @@ } void bindTags(Collection> tags) { diff --git a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch index 941381d50bd2..1c658944e836 100644 --- a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -32,17 +_,25 @@ +@@ -32,16 +_,24 @@ public class MappedRegistry implements WritableRegistry { private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); - private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(), map -> map.defaultReturnValue(-1)); -- private final Map> byLocation = new HashMap<>(); +- private final Map> byLocation = new HashMap<>(); - private final Map, Holder.Reference> byKey = new HashMap<>(); - private final Map> byValue = new IdentityHashMap<>(); - private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(); + private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(2048), map -> map.defaultReturnValue(-1)); // Paper - Perf: Use bigger expected size to reduce collisions -+ private final Map> byLocation = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions ++ private final Map> byLocation = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map, Holder.Reference> byKey = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions @@ -18,36 +18,35 @@ private final Map, HolderSet.Named> frozenTags = new IdentityHashMap<>(); MappedRegistry.TagSet allTags = MappedRegistry.TagSet.unbound(); private boolean frozen; - @Nullable - private Map> unregisteredIntrusiveHolders; + private @Nullable Map> unregisteredIntrusiveHolders; + // Paper start - support pre-filling in registry mod API -+ private final Map temporaryUnfrozenMap = new HashMap<>(); ++ private final Map temporaryUnfrozenMap = new HashMap<>(); + + @Override + public Optional getValueForCopying(final ResourceKey resourceKey) { -+ return this.frozen ? this.getOptional(resourceKey) : Optional.ofNullable(this.temporaryUnfrozenMap.get(resourceKey.location())); ++ return this.frozen ? this.getOptional(resourceKey) : Optional.ofNullable(this.temporaryUnfrozenMap.get(resourceKey.identifier())); + } + // Paper end - support pre-filling in registry mod API @Override public Stream> listTags() { -@@ -113,6 +_,7 @@ +@@ -112,6 +_,7 @@ this.toId.put(value, size); this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); -+ this.temporaryUnfrozenMap.put(key.location(), value); // Paper - support pre-filling in registry mod API ++ this.temporaryUnfrozenMap.put(key.identifier(), value); // Paper - support pre-filling in registry mod API return reference; } } -@@ -274,6 +_,7 @@ +@@ -268,6 +_,7 @@ return this; } else { this.frozen = true; + this.temporaryUnfrozenMap.clear(); // Paper - support pre-filling in registry mod API this.byValue.forEach((object, reference) -> reference.bindValue((T)object)); - List list = this.byKey + List list = this.byKey .entrySet() -@@ -508,4 +_,13 @@ +@@ -502,4 +_,13 @@ Stream> getTags(); } diff --git a/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch b/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch index 49e43c6489f0..9b131d3e85a4 100644 --- a/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Vec3i.java +++ b/net/minecraft/core/Vec3i.java -@@ -22,9 +_,9 @@ +@@ -23,9 +_,9 @@ ByteBufCodecs.VAR_INT, Vec3i::getX, ByteBufCodecs.VAR_INT, Vec3i::getY, ByteBufCodecs.VAR_INT, Vec3i::getZ, Vec3i::new ); public static final Vec3i ZERO = new Vec3i(0, 0, 0); @@ -13,7 +13,7 @@ public static Codec offsetCodec(int maxOffset) { return CODEC.validate( -@@ -41,12 +_,12 @@ +@@ -42,12 +_,12 @@ } @Override @@ -28,7 +28,7 @@ return (this.getY() + this.getZ() * 31) * 31 + this.getX(); } -@@ -59,15 +_,15 @@ +@@ -60,15 +_,15 @@ } } @@ -47,7 +47,7 @@ return this.z; } -@@ -241,4 +_,11 @@ +@@ -250,4 +_,11 @@ public String toShortString() { return this.getX() + ", " + this.getY() + ", " + this.getZ(); } diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch index 855a46776605..52040ac041fe 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch @@ -44,7 +44,7 @@ } }; } -@@ -249,6 +_,42 @@ +@@ -248,6 +_,42 @@ Builder() { } 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 751de4f933df..738c56efba60 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 -@@ -206,10 +_,10 @@ +@@ -236,10 +_,10 @@ "map_post_processing", builder -> builder.networkSynchronized(MapPostProcessing.STREAM_CODEC) ); public static final DataComponentType CHARGED_PROJECTILES = register( @@ -13,7 +13,7 @@ ); public static final DataComponentType POTION_CONTENTS = register( "potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding() -@@ -292,7 +_,7 @@ +@@ -322,7 +_,7 @@ "pot_decorations", builder -> builder.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/DispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index b104f6654b05..ba660f85657e 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,10 +_,38 @@ +@@ -88,10 +_,38 @@ if (type == null) { return item; } else { @@ -40,7 +40,7 @@ null, blockSource.pos().relative(direction), EntitySpawnReason.DISPENSER, -@@ -102,7 +_,8 @@ +@@ -103,7 +_,8 @@ return ItemStack.EMPTY; } @@ -50,7 +50,7 @@ blockSource.level().gameEvent(null, GameEvent.ENTITY_PLACE, blockSource.pos()); return item; } -@@ -121,12 +_,38 @@ +@@ -122,12 +_,38 @@ Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); ServerLevel serverLevel = blockSource.level(); @@ -91,45 +91,45 @@ } return item; -@@ -146,8 +_,35 @@ - new AABB(blockPos), - abstractChestedHorse1 -> abstractChestedHorse1.isAlive() && !abstractChestedHorse1.hasChest() +@@ -149,8 +_,35 @@ )) { -- if (abstractChestedHorse.isTamed() && abstractChestedHorse.getSlot(499).set(item)) { -- item.shrink(1); -+ if (abstractChestedHorse.isTamed()/* && abstractChestedHorse.getSlot(499).set(item)*/) { + if (abstractChestedHorse.isTamed()) { + SlotAccess slot = abstractChestedHorse.getSlot(499); +- if (slot != null && slot.set(item)) { +- item.shrink(1); + // CraftBukkit start -+ ItemStack singleCopy = item.copyWithCount(1); -+ ServerLevel world = blockSource.level(); -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleCopy); -+ org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), abstractChestedHorse.getBukkitLivingEntity()); -+ world.getCraftServer().getPluginManager().callEvent(event); ++ if (slot != null/* && slot.set(item)*/) { ++ ItemStack singleCopy = item.copyWithCount(1); ++ ServerLevel world = blockSource.level(); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockSource.pos()); ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleCopy); ++ org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), abstractChestedHorse.getBukkitLivingEntity()); ++ world.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ this.setSuccess(false); -+ return item; -+ } -+ -+ 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(blockSource, eventStack); -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); ++ if (event.isCancelled()) { ++ this.setSuccess(false); + return item; + } -+ } -+ abstractChestedHorse.getSlot(499).set(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); -+ // CraftBukkit end + -+ if (shrink) item.shrink(1); // Paper - actually handle here - this.setSuccess(true); - return item; - } -@@ -185,8 +_,45 @@ ++ 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(blockSource, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { ++ dispenseBehavior.dispense(blockSource, eventStack); ++ return item; ++ } ++ } ++ slot.set(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); ++ // CraftBukkit end ++ ++ if (shrink) item.shrink(1); // Paper - actually handle here + this.setSuccess(true); + return item; + } +@@ -189,8 +_,45 @@ DispensibleContainerItem dispensibleContainerItem = (DispensibleContainerItem)item.getItem(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); Level level = blockSource.level(); @@ -176,7 +176,7 @@ return this.consumeWithRemainder(blockSource, item, new ItemStack(Items.BUCKET)); } else { return this.defaultDispenseItemBehavior.dispense(blockSource, item); -@@ -209,12 +_,19 @@ +@@ -213,12 +_,19 @@ BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = levelAccessor.getBlockState(blockPos); if (blockState.getBlock() instanceof BucketPickup bucketPickup) { @@ -197,7 +197,7 @@ return this.consumeWithRemainder(blockSource, item, new ItemStack(item1)); } } else { -@@ -229,15 +_,26 @@ +@@ -233,15 +_,26 @@ this.setSuccess(true); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); @@ -227,7 +227,7 @@ serverLevel.removeBlock(blockPos, false); } else { this.setSuccess(false); -@@ -259,11 +_,46 @@ +@@ -263,11 +_,46 @@ this.setSuccess(true); Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); @@ -274,7 +274,7 @@ return item; } -@@ -277,11 +_,36 @@ +@@ -281,11 +_,36 @@ return item; } else { BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); @@ -314,7 +314,7 @@ this.setSuccess(true); return item; } -@@ -295,6 +_,13 @@ +@@ -299,6 +_,13 @@ Level level = blockSource.level(); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); @@ -328,7 +328,7 @@ if (level.isEmptyBlock(blockPos) && WitherSkullBlock.canSpawnMob(level, blockPos, item)) { level.setBlock( blockPos, -@@ -310,7 +_,7 @@ +@@ -314,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -337,7 +337,7 @@ } return item; -@@ -323,6 +_,13 @@ +@@ -327,6 +_,13 @@ Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); CarvedPumpkinBlock carvedPumpkinBlock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; @@ -351,7 +351,7 @@ if (level.isEmptyBlock(blockPos) && carvedPumpkinBlock.canSpawnGolem(level, blockPos)) { if (!level.isClientSide()) { level.setBlock(blockPos, carvedPumpkinBlock.defaultBlockState(), Block.UPDATE_ALL); -@@ -332,7 +_,7 @@ +@@ -336,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -360,7 +360,7 @@ } return item; -@@ -358,6 +_,12 @@ +@@ -362,6 +_,12 @@ ServerLevel serverLevel = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = serverLevel.getBlockState(blockPos); @@ -373,7 +373,7 @@ if (blockState.is( BlockTags.BEEHIVES, blockStateBase -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL) && blockStateBase.getBlock() instanceof BeehiveBlock -@@ -386,6 +_,13 @@ +@@ -390,6 +_,13 @@ this.setSuccess(true); if (blockState.is(Blocks.RESPAWN_ANCHOR)) { if (blockState.getValue(RespawnAnchorBlock.CHARGE) != 4) { @@ -387,7 +387,7 @@ RespawnAnchorBlock.charge(null, level, blockPos, blockState); item.shrink(1); } else { -@@ -409,6 +_,28 @@ +@@ -413,6 +_,28 @@ this.setSuccess(false); return item; } else { @@ -416,7 +416,7 @@ for (Armadillo armadillo : entitiesOfClass) { if (armadillo.brushOffScute(null, item)) { item.hurtAndBreak(16, serverLevel, null, item1 -> {}); -@@ -429,6 +_,13 @@ +@@ -433,6 +_,13 @@ BlockState blockState = level.getBlockState(blockPos); Optional waxed = HoneycombItem.getWaxed(blockState); if (waxed.isPresent()) { @@ -430,7 +430,7 @@ level.setBlockAndUpdate(blockPos, waxed.get()); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_WAX_ON, blockPos, 0); item.shrink(1); -@@ -456,6 +_,12 @@ +@@ -460,6 +_,12 @@ if (!serverLevel.getBlockState(blockPos1).is(BlockTags.CONVERTABLE_TO_MUD)) { return this.defaultDispenseItemBehavior.dispense(blockSource, item); } else { 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 1f38f500e383..83c57bdfd6a3 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,7 +1,7 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -336,6 +_,11 @@ - public static final Registry> DIALOG_BODY_TYPE = registerSimple(Registries.DIALOG_BODY_TYPE, DialogBodyTypes::bootstrap); +@@ -356,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; + // Paper start - add built-in registry conversions @@ -12,15 +12,15 @@ private static Registry registerSimple(ResourceKey> registryKey, BuiltInRegistries.RegistryBootstrap bootstrap) { return internalRegister(registryKey, new MappedRegistry<>(registryKey, Lifecycle.stable(), false), bootstrap); -@@ -363,6 +_,7 @@ +@@ -383,6 +_,7 @@ ResourceKey> registryKey, R registry, BuiltInRegistries.RegistryBootstrap bootstrap ) { - Bootstrap.checkBootstrapCalled(() -> "registry " + registryKey.location()); + Bootstrap.checkBootstrapCalled(() -> "registry " + registryKey.identifier()); + io.papermc.paper.registry.PaperRegistryAccess.instance().registerRegistry(registry); // Paper - initialize API registry - ResourceLocation resourceLocation = registryKey.location(); - LOADERS.put(resourceLocation, () -> bootstrap.run(registry)); + Identifier identifier = registryKey.identifier(); + LOADERS.put(identifier, () -> bootstrap.run(registry)); WRITABLE_REGISTRY.register((ResourceKey)registryKey, registry, RegistrationInfo.BUILT_IN); -@@ -370,16 +_,34 @@ +@@ -390,16 +_,34 @@ } public static void bootStrap() { @@ -47,15 +47,15 @@ + throw new RuntimeException(ex); + } + // Paper end - class-load org.bukkit.Registry - LOADERS.forEach((resourceLocation, supplier) -> { + LOADERS.forEach((identifier, supplier) -> { if (supplier.get() == null) { - LOGGER.error("Unable to bootstrap registry '{}'", resourceLocation); + LOGGER.error("Unable to bootstrap registry '{}'", identifier); } -+ io.papermc.paper.registry.PaperRegistryAccess.instance().lockReferenceHolders(ResourceKey.createRegistryKey(resourceLocation)); // Paper - lock reference holder creation ++ io.papermc.paper.registry.PaperRegistryAccess.instance().lockReferenceHolders(ResourceKey.createRegistryKey(identifier)); // Paper - lock reference holder creation }); } -@@ -388,6 +_,7 @@ +@@ -408,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 e846768ab6ef..289351cfa27d 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 -@@ -1002,7 +_,6 @@ +@@ -1046,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/GameTestInfo.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch index 405db6d114b8..b41f4ca1b28a 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestInfo.java +++ b/net/minecraft/gametest/framework/GameTestInfo.java -@@ -247,7 +_,7 @@ +@@ -244,7 +_,7 @@ AABB structureBounds = this.getStructureBounds(); List entitiesOfClass = this.getLevel() .getEntitiesOfClass(Entity.class, structureBounds.inflate(1.0), entity -> !(entity instanceof Player)); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch index 9026c81bf78b..c7d9012b3e1e 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestMainUtil.java +++ b/net/minecraft/gametest/framework/GameTestMainUtil.java -@@ -77,7 +_,7 @@ +@@ -75,7 +_,7 @@ copyPacks(string, string1); } 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 40b256941af9..1ab2a5ca3a50 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 -@@ -143,6 +_,8 @@ +@@ -146,6 +_,8 @@ boolean verify ) { super( @@ -9,12 +9,11 @@ serverThread, storageSource, packRepository, -@@ -158,8 +_,16 @@ +@@ -161,9 +_,17 @@ @Override public boolean initServer() { - this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) {}); -- this.loadLevel(); + // Paper start + this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, new EmptyNotificationService()) { + @Override @@ -22,13 +21,15 @@ + throw new UnsupportedOperationException("Should not be called in a GameTestServer"); + } + }); -+ this.loadLevel("blah"); + this.initPostWorld(); + Gizmos.withCollector(GizmoCollector.NOOP); +- this.loadLevel(); ++ this.loadLevel("blah"); + // Paper end ServerLevel serverLevel = this.overworld(); this.testBatches = this.evaluateTestsToRun(serverLevel); LOGGER.info("Started game test server"); -@@ -354,6 +_,13 @@ +@@ -348,6 +_,13 @@ return false; } @@ -42,7 +43,7 @@ @Override public boolean isSingleplayerOwner(NameAndId nameAndId) { return false; -@@ -401,5 +_,16 @@ +@@ -395,5 +_,16 @@ @Override public void save() { } 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 142439d7e687..f705c709f77c 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,30 +1,20 @@ --- a/net/minecraft/gametest/framework/TestEnvironmentDefinition.java +++ b/net/minecraft/gametest/framework/TestEnvironmentDefinition.java -@@ -132,11 +_,11 @@ +@@ -124,7 +_,7 @@ + public void setup(ServerLevel level) { + GameRules gameRules = level.getGameRules(); MinecraftServer server = level.getServer(); - - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { -- gameRules.getRule(entry.key()).set(entry.value(), server); -+ gameRules.getRule(entry.key()).set(entry.value(), level); // Paper - per-world - } - - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.intRules) { -- gameRules.getRule(entry.key()).set(entry.value(), server); -+ gameRules.getRule(entry.key()).set(entry.value(), level); // Paper - per-world - } +- gameRules.setAll(this.gameRulesMap, server); ++ gameRules.setAll(this.gameRulesMap, level); // Paper - per-world game rules } -@@ -146,11 +_,11 @@ - MinecraftServer server = level.getServer(); - - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { -- gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), server); -+ gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), level); // Paper - per-world - } + @Override +@@ -133,7 +_,7 @@ + } - for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.intRules) { -- gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), server); -+ gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), level); // Paper - per-world - } + private void resetRule(ServerLevel level, GameRule rule) { +- level.getGameRules().set(rule, rule.defaultValue(), level.getServer()); ++ level.getGameRules().set(rule, rule.defaultValue(), level); // Paper - per-world game rules } + @Override diff --git a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch index 644f58a4e09e..c07e64d19e6c 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch @@ -18,7 +18,7 @@ } @Override -@@ -402,9 +_,16 @@ +@@ -400,9 +_,16 @@ @Override public CompoundTag copy() { @@ -38,7 +38,7 @@ } @Override -@@ -525,22 +_,47 @@ +@@ -523,22 +_,47 @@ this.merge((CompoundTag)mapCodec.encoder().encodeStart(ops, data).getOrThrow()); } 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 926de43667ff..5cd314e969fc 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java -@@ -119,6 +_,11 @@ +@@ -118,6 +_,11 @@ } public static CompoundTag read(DataInput input, NbtAccounter accounter) throws IOException { diff --git a/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch b/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch index 6bf901555d4e..f32f5b684f24 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/SnbtGrammar.java +++ b/net/minecraft/nbt/SnbtGrammar.java -@@ -591,7 +_,7 @@ +@@ -587,7 +_,7 @@ Atom>> atom30 = Atom.of("map_entries"); dictionary.put(atom30, Term.repeatedWithTrailingSeparator(namedRule3, atom30, StringReaderTerms.character(',')), scope -> scope.getOrThrow(atom30)); Atom atom31 = Atom.of("map_literal"); @@ -9,7 +9,7 @@ List> list = scope.getOrThrow(atom30); if (list.isEmpty()) { return object2; -@@ -626,7 +_,9 @@ +@@ -622,7 +_,9 @@ atom35, Term.sequence( StringReaderTerms.character('['), 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 541952750e5b..9e277b37beeb 100644 --- a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch @@ -1,23 +1,6 @@ --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -73,13 +_,13 @@ - public static final Marker PACKET_RECEIVED_MARKER = Util.make(MarkerFactory.getMarker("PACKET_RECEIVED"), marker -> marker.add(PACKET_MARKER)); - public static final Marker PACKET_SENT_MARKER = Util.make(MarkerFactory.getMarker("PACKET_SENT"), marker -> marker.add(PACKET_MARKER)); - public static final Supplier NETWORK_WORKER_GROUP = Suppliers.memoize( -- () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Client IO #%d").setDaemon(true).build()) -+ () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - public static final Supplier NETWORK_EPOLL_WORKER_GROUP = Suppliers.memoize( -- () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build()) -+ () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - public static final Supplier LOCAL_WORKER_GROUP = Suppliers.memoize( -- () -> new DefaultEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Local Client IO #%d").setDaemon(true).build()) -+ () -> new DefaultEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Local Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - private static final ProtocolInfo INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND; - private final PacketFlow receiving; -@@ -87,6 +_,11 @@ +@@ -68,6 +_,11 @@ private final Queue> pendingActions = Queues.newConcurrentLinkedQueue(); public Channel channel; public SocketAddress address; @@ -26,13 +9,13 @@ + public com.mojang.authlib.properties.Property[] spoofedProfile; + public boolean preparing = true; + // Spigot end - @Nullable - private volatile PacketListener disconnectListener; - @Nullable -@@ -105,6 +_,43 @@ - private volatile DisconnectionDetails delayedDisconnect; - @Nullable - BandwidthDebugMonitor bandwidthDebugMonitor; + private volatile @Nullable PacketListener disconnectListener; + private volatile @Nullable PacketListener packetListener; + private @Nullable DisconnectionDetails disconnectionDetails; +@@ -81,6 +_,43 @@ + private boolean handlingFault; + private volatile @Nullable DisconnectionDetails delayedDisconnect; + @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; + public String hostname = ""; // CraftBukkit - add field + // Paper start - NetworkClient implementation + public int protocolVersion; @@ -51,7 +34,7 @@ + // Paper end - add utility methods + // Paper start - packet limiter + protected final Object PACKET_LIMIT_LOCK = new Object(); -+ protected final @Nullable io.papermc.paper.util.IntervalledCounter allPacketCounts = io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.isEnabled() ? new io.papermc.paper.util.IntervalledCounter( ++ protected final io.papermc.paper.util.@Nullable IntervalledCounter allPacketCounts = io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.isEnabled() ? new io.papermc.paper.util.IntervalledCounter( + (long)(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.interval() * 1.0e9) + ) : null; + protected final java.util.Map>, io.papermc.paper.util.IntervalledCounter> packetSpecificLimits = new java.util.HashMap<>(); @@ -66,14 +49,14 @@ + } + // Paper end - packet limiter + @Nullable public SocketAddress haProxyAddress; // Paper - Add API to get player's proxy address -+ public @Nullable java.util.Optional legacySavedLoginEventResultOverride; // Paper - playerloginevent ++ public java.util.@Nullable Optional legacySavedLoginEventResultOverride; // Paper - playerloginevent + public boolean handledLegacyLoginEvent; // Paper - playerloginevent -+ public @Nullable net.minecraft.server.level.ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent -+ public @Nullable org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper ++ public net.minecraft.server.level.@Nullable ServerPlayer savedPlayerForLegacyEvents; // Paper - playerloginevent & PlayerSpawnLocationEvent ++ public org.bukkit.event.player.PlayerResourcePackStatusEvent.@Nullable Status resourcePackStatus; // Paper public Connection(PacketFlow receiving) { this.receiving = receiving; -@@ -115,6 +_,7 @@ +@@ -91,6 +_,7 @@ super.channelActive(ctx); this.channel = ctx.channel(); this.address = this.channel.remoteAddress(); @@ -81,7 +64,7 @@ if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } -@@ -127,14 +_,31 @@ +@@ -103,14 +_,31 @@ @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable exception) { @@ -113,7 +96,7 @@ this.disconnect(Component.translatable("disconnect.timeout")); } else { Component component = Component.translatable("disconnect.genericReason", "Internal Exception: " + exception); -@@ -146,9 +_,11 @@ +@@ -122,9 +_,11 @@ disconnectionDetails = new DisconnectionDetails(component); } @@ -126,7 +109,7 @@ Packet packet = (Packet)(this.sendLoginDisconnect ? new ClientboundLoginDisconnectPacket(component) : new ClientboundDisconnectPacket(component)); -@@ -165,6 +_,7 @@ +@@ -141,6 +_,7 @@ } } } @@ -134,7 +117,7 @@ } @Override -@@ -174,10 +_,60 @@ +@@ -150,10 +_,60 @@ if (packetListener == null) { throw new IllegalStateException("Received a packet before the packet listener was initialized"); } else { @@ -195,7 +178,7 @@ } catch (RejectedExecutionException var6) { this.disconnect(Component.translatable("multiplayer.disconnect.server_shutdown")); } catch (ClassCastException var7) { -@@ -370,10 +_,30 @@ +@@ -346,10 +_,30 @@ } } @@ -226,7 +209,7 @@ } if (!this.isConnected() && !this.disconnectionHandled) { -@@ -381,7 +_,7 @@ +@@ -357,7 +_,7 @@ } if (this.channel != null) { @@ -235,7 +218,7 @@ } if (this.tickCount++ % 20 == 0) { -@@ -417,12 +_,13 @@ +@@ -393,12 +_,13 @@ } public void disconnect(DisconnectionDetails disconnectionDetails) { @@ -250,7 +233,7 @@ this.disconnectionDetails = disconnectionDetails; } } -@@ -569,6 +_,13 @@ +@@ -533,6 +_,13 @@ } } @@ -264,7 +247,7 @@ public void setupCompression(int threshold, boolean validateDecompressed) { if (threshold >= 0) { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder compressionDecoder) { -@@ -582,6 +_,7 @@ +@@ -546,6 +_,7 @@ } else { this.channel.pipeline().addAfter("prepender", "compress", new CompressionEncoder(threshold)); } @@ -272,7 +255,7 @@ } else { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { this.channel.pipeline().remove("decompress"); -@@ -590,6 +_,7 @@ +@@ -554,6 +_,7 @@ if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) { this.channel.pipeline().remove("compress"); } @@ -280,7 +263,7 @@ } } -@@ -607,6 +_,26 @@ +@@ -571,6 +_,26 @@ ); packetListener1.onDisconnect(disconnectionDetails); } diff --git a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch index 74c11d5f854c..c4e2ef021142 100644 --- a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java @@ -70,14 +_,20 @@ + public class FriendlyByteBuf extends ByteBuf { - public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; -+ @Nullable public final java.util.Locale adventure$locale; // Paper - track player's locale for server-side translations ++ public final java.util.@Nullable Locale adventure$locale; // Paper - track player's locale for server-side translations public static final short MAX_STRING_LENGTH = 32767; public static final int MAX_COMPONENT_STRING_LENGTH = 262144; private static final int PUBLIC_KEY_SIZE = 256; @@ -36,7 +36,7 @@ } public static IntFunction limitValue(IntFunction function, int limit) { -@@ -554,7 +_,7 @@ +@@ -552,7 +_,7 @@ try { NbtIo.writeAnyTag(tag, new ByteBufOutputStream(buffer)); diff --git a/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch b/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch index d0035abf78e1..46628723821a 100644 --- a/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/Varint21FrameDecoder.java +++ b/net/minecraft/network/Varint21FrameDecoder.java -@@ -41,6 +_,12 @@ +@@ -40,6 +_,12 @@ @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch index f0ee199b6887..b340bb0c3041 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch @@ -13,7 +13,7 @@ + java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer player, Component message); // Paper - adventure; support async chat decoration events + + // Paper start - adventure; support async chat decoration events -+ default java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer sender, @Nullable net.minecraft.commands.CommandSourceStack commandSourceStack, Component message) { ++ default java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer sender, net.minecraft.commands.@Nullable CommandSourceStack commandSourceStack, Component message) { + throw new UnsupportedOperationException("Must override this implementation"); + } + // Paper end - adventure; support async chat decoration events diff --git a/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch index d9578e5969d4..6159dbd6c797 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/Component.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/network/chat/Component.java +++ b/net/minecraft/network/chat/Component.java @@ -25,7 +_,19 @@ - import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; -public interface Component extends Message, FormattedText { +public interface Component extends Message, FormattedText, Iterable { // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch index 32a7711c1546..1f1547c9d69d 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch @@ -5,7 +5,7 @@ public class ComponentSerialization { public static final Codec CODEC = Codec.recursive("Component", ComponentSerialization::createCodec); - public static final StreamCodec STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(CODEC); -+ public static final StreamCodec STREAM_CODEC = createTranslationAware(() -> net.minecraft.nbt.NbtAccounter.create(net.minecraft.network.FriendlyByteBuf.DEFAULT_NBT_QUOTA)); // Paper - adventure ++ public static final StreamCodec STREAM_CODEC = createTranslationAware(() -> net.minecraft.nbt.NbtAccounter.create(net.minecraft.nbt.NbtAccounter.DEFAULT_NBT_QUOTA)); // Paper - adventure public static final StreamCodec> OPTIONAL_STREAM_CODEC = STREAM_CODEC.apply(ByteBufCodecs::optional); - public static final StreamCodec TRUSTED_STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistriesTrusted(CODEC); + // Paper start - adventure; use locale from bytebuf for translation 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 082b3e84e871..525b0643e6f4 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/ComponentUtils.java +++ b/net/minecraft/network/chat/ComponentUtils.java -@@ -33,16 +_,45 @@ +@@ -49,16 +_,45 @@ } } 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 af25ad25c9bd..18e60d87993d 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 @@ -1,7 +1,7 @@ --- a/net/minecraft/network/chat/MessageSignature.java +++ b/net/minecraft/network/chat/MessageSignature.java @@ -13,6 +_,7 @@ - import net.minecraft.util.SignatureValidator; + 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 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 99e4fad8ac77..677316ab3cbe 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 -@@ -94,6 +_,11 @@ +@@ -97,6 +_,11 @@ @Override public boolean equals(Object other) { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch index 8b60666cfb41..f6d43730715a 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch @@ -21,7 +21,7 @@ + return PlayerChatMessage.this.signature == null ? null : PlayerChatMessage.this.signature.adventure(); + } + @Override -+ public @Nullable net.kyori.adventure.text.Component unsignedContent() { ++ public net.kyori.adventure.text.@Nullable Component unsignedContent() { + return PlayerChatMessage.this.unsignedContent() == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(PlayerChatMessage.this.unsignedContent()); + } + @Override diff --git a/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch index 440e3748c579..72366c94cd99 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/SignedMessageChain.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/SignedMessageChain.java +++ b/net/minecraft/network/chat/SignedMessageChain.java -@@ -40,14 +_,14 @@ +@@ -39,14 +_,14 @@ if (signature == null) { throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.MISSING_PROFILE_KEY); } else if (publicKey.data().hasExpired()) { @@ -17,7 +17,7 @@ } else { SignedMessageChain.this.lastTimeStamp = body.timeStamp(); PlayerChatMessage playerChatMessage = new PlayerChatMessage(signedMessageLink, signature, body, null, FilterMask.PASS_THROUGH); -@@ -80,8 +_,15 @@ +@@ -79,8 +_,15 @@ static final Component INVALID_SIGNATURE = Component.translatable("chat.disabled.invalid_signature"); static final Component OUT_OF_ORDER_CHAT = Component.translatable("chat.disabled.out_of_order_chat"); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch index b9e08a06cfbc..40288d32b2e2 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/TextColor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/TextColor.java +++ b/net/minecraft/network/chat/TextColor.java -@@ -17,23 +_,29 @@ +@@ -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) @@ -10,8 +10,7 @@ .stream() .collect(ImmutableMap.toImmutableMap(textColor -> textColor.name, Function.identity())); private final int value; - @Nullable - public final String name; + public final @Nullable String name; + // CraftBukkit start + @Nullable + public final ChatFormatting format; diff --git a/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch index 90795a01c010..ca177c9cdd7f 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/contents/NbtContents.java +++ b/net/minecraft/network/chat/contents/NbtContents.java -@@ -120,7 +_,7 @@ +@@ -118,7 +_,7 @@ if (this.interpreting) { RegistryOps registryOps = source.registryAccess().createSerializationContext(NbtOps.INSTANCE); Component component = DataFixUtils.orElse( @@ -9,7 +9,7 @@ ); return stream.flatMap(tag -> { try { -@@ -133,7 +_,7 @@ +@@ -131,7 +_,7 @@ }).reduce((mutableComponent, component1) -> mutableComponent.append(component).append(component1)).orElseGet(Component::empty); } else { Stream stream1 = stream.map(NbtContents::asString); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch index 607754e3e550..bdbfe1fcb029 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/contents/TranslatableContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/contents/TranslatableContents.java +++ b/net/minecraft/network/chat/contents/TranslatableContents.java -@@ -180,6 +_,16 @@ +@@ -178,6 +_,16 @@ @Override public Optional visit(FormattedText.ContentConsumer contentConsumer) { @@ -17,7 +17,7 @@ this.decompose(); for (FormattedText formattedText : this.decomposedParts) { -@@ -191,6 +_,27 @@ +@@ -189,6 +_,27 @@ return Optional.empty(); } 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 3492b4b64b0d..6d8633da13b2 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/network/codec/ByteBufCodecs.java +++ b/net/minecraft/network/codec/ByteBufCodecs.java -@@ -423,6 +_,48 @@ +@@ -418,6 +_,48 @@ }; } diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch index d0e27d1590aa..59f5e69f5568 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch @@ -2,11 +2,11 @@ +++ b/net/minecraft/network/protocol/common/custom/DiscardedPayload.java @@ -4,13 +_,19 @@ import net.minecraft.network.codec.StreamCodec; - import net.minecraft.resources.ResourceLocation; + import net.minecraft.resources.Identifier; --public record DiscardedPayload(ResourceLocation id) implements CustomPacketPayload { -+public record DiscardedPayload(ResourceLocation id, byte[] data) implements CustomPacketPayload { // Paper - store data - public static StreamCodec codec(ResourceLocation id, int maxSize) { +-public record DiscardedPayload(Identifier id) implements CustomPacketPayload { ++public record DiscardedPayload(Identifier id, byte[] data) implements CustomPacketPayload { // Paper - store data + public static StreamCodec codec(Identifier id, int maxSize) { - return CustomPacketPayload.codec((value, output) -> {}, buffer -> { + return CustomPacketPayload.codec((value, output) -> { + // Paper start diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch index ef54b04ade6a..03d18f0dc288 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch @@ -9,7 +9,7 @@ throw new RuntimeException("Chunk Packet trying to allocate too much memory on read."); } else { this.buffer = new byte[varInt]; -@@ -155,6 +_,7 @@ +@@ -154,6 +_,7 @@ CompoundTag updateTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess()); BlockPos blockPos = blockEntity.getBlockPos(); int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch index a04c1424dd9e..bed45c045c4a 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch @@ -83,7 +83,7 @@ UPDATE_GAME_MODE( (entryBuilder, buffer) -> entryBuilder.gameMode = GameType.byId(buffer.readVarInt()), @@ -161,10 +_,15 @@ - @Nullable RemoteChatSession.Data chatSession + RemoteChatSession.@Nullable Data chatSession ) { Entry(ServerPlayer player) { + // Paper start - Add Listing API for Player 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 cfe10e0294d2..8623dbc40ee0 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 @@ -12,7 +12,7 @@ private ClientboundSetPlayerTeamPacket(String name, int method, Optional parameters, Collection players) { this.name = name; this.method = method; -@@ -199,7 +_,7 @@ +@@ -197,7 +_,7 @@ ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.displayName); buffer.writeByte(this.options); Team.Visibility.STREAM_CODEC.encode(buffer, this.nametagVisibility); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch index d7bf58f0ce54..8d441064cbc2 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundInteractPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ServerboundInteractPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundInteractPacket.java -@@ -145,6 +_,15 @@ +@@ -152,6 +_,15 @@ buffer.writeEnum(this.hand); } } diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch index e1eb0709fe12..d8ce01b3e11d 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch @@ -6,7 +6,7 @@ } + + // Paper start - MC Utils - default query payloads -+ public static record PlayerInfoChannelPayload(ResourceLocation id, FriendlyByteBuf buffer) implements CustomQueryPayload { ++ public static record PlayerInfoChannelPayload(Identifier id, FriendlyByteBuf buffer) implements CustomQueryPayload { + @Override + public void write(final FriendlyByteBuf buf) { + buf.writeBytes(this.buffer.copy()); diff --git a/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch index aa852751be21..24afdbddedb8 100644 --- a/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/syncher/EntityDataSerializers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/syncher/EntityDataSerializers.java +++ b/net/minecraft/network/syncher/EntityDataSerializers.java -@@ -53,10 +_,27 @@ +@@ -55,10 +_,27 @@ public static final EntityDataSerializer> OPTIONAL_COMPONENT = EntityDataSerializer.forValueType( ComponentSerialization.TRUSTED_OPTIONAL_STREAM_CODEC ); diff --git a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch index 9a5fc7c227a3..d94f74eb7226 100644 --- a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -14,7 +14,7 @@ public boolean isDirty() { return this.isDirty; } -@@ -169,6 +_,19 @@ +@@ -167,6 +_,19 @@ return new SynchedEntityData(this.entity, this.itemsById); } } diff --git a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch similarity index 50% rename from paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch rename to paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch index 8aeb195136e7..23ea05ccf452 100644 --- a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/Identifier.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/resources/ResourceLocation.java -+++ b/net/minecraft/resources/ResourceLocation.java -@@ -23,6 +_,7 @@ +--- a/net/minecraft/resources/Identifier.java ++++ b/net/minecraft/resources/Identifier.java +@@ -20,6 +_,7 @@ public static final char NAMESPACE_SEPARATOR = ':'; public static final String DEFAULT_NAMESPACE = "minecraft"; public static final String REALMS_NAMESPACE = "realms"; @@ -8,35 +8,35 @@ private final String namespace; private final String path; -@@ -31,6 +_,13 @@ +@@ -28,6 +_,13 @@ assert isValidPath(path); -+ // Paper start - Validate ResourceLocation ++ // Paper start - Validate Identifier + // Check for the max network string length (capped at Short.MAX_VALUE) as well as the max bytes of a StringTag (length written as an unsigned short) + final String resourceLocation = namespace + ":" + path; + if (resourceLocation.length() > Short.MAX_VALUE || io.netty.buffer.ByteBufUtil.utf8MaxBytes(resourceLocation) > 2 * Short.MAX_VALUE + 1) { -+ throw new ResourceLocationException("Resource location too long: " + resourceLocation); ++ throw new IdentifierException("Resource location too long: " + resourceLocation); + } -+ // Paper end - Validate ResourceLocation ++ // Paper end - Validate Identifier this.namespace = namespace; this.path = path; } -@@ -243,7 +_,7 @@ +@@ -238,7 +_,7 @@ private static String assertValidNamespace(String namespace, String path) { if (!isValidNamespace(namespace)) { -- throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + namespace + ":" + path); -+ throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + org.apache.commons.lang3.StringUtils.normalizeSpace(namespace) + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize ResourceLocation error logging +- throw new IdentifierException("Non [a-z0-9_.-] character in namespace of location: " + namespace + ":" + path); ++ throw new IdentifierException("Non [a-z0-9_.-] character in namespace of location: " + org.apache.commons.lang3.StringUtils.normalizeSpace(namespace) + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize Identifier error logging } else { return namespace; } -@@ -268,7 +_,7 @@ +@@ -263,7 +_,7 @@ private static String assertValidPath(String namespace, String path) { if (!isValidPath(path)) { -- throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + path); -+ throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize ResourceLocation error logging +- throw new IdentifierException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + path); ++ throw new IdentifierException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize Identifier error logging } else { return 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 3f52e9a7fc62..5776d719e9a2 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 -@@ -206,11 +_,21 @@ +@@ -212,11 +_,21 @@ final Map>, RegistryOps.RegistryInfo> map = new HashMap<>(); registryLookups.forEach(registryLookup -> map.put(registryLookup.key(), createInfoForContextRegistry((HolderLookup.RegistryLookup)registryLookup))); loaders.forEach(loader -> map.put(loader.registry.key(), createInfoForNewRegistry(loader.registry))); @@ -22,7 +22,7 @@ }; } -@@ -274,13 +_,14 @@ +@@ -280,13 +_,14 @@ RegistryOps ops, ResourceKey resourceKey, Resource resource, @@ -39,15 +39,15 @@ } } -@@ -294,6 +_,7 @@ +@@ -300,6 +_,7 @@ FileToIdConverter fileToIdConverter = FileToIdConverter.registry(registry.key()); RegistryOps registryOps = RegistryOps.create(JsonOps.INSTANCE, registryInfoLookup); + final io.papermc.paper.registry.data.util.Conversions conversions = new io.papermc.paper.registry.data.util.Conversions(registryInfoLookup); // Paper - create conversions - for (Entry entry : fileToIdConverter.listMatchingResources(resourceManager).entrySet()) { - ResourceLocation resourceLocation = entry.getKey(); - ResourceKey resourceKey = ResourceKey.create(registry.key(), fileToIdConverter.fileToId(resourceLocation)); -@@ -301,7 +_,7 @@ + for (Entry entry : fileToIdConverter.listMatchingResources(resourceManager).entrySet()) { + Identifier identifier = entry.getKey(); + ResourceKey resourceKey = ResourceKey.create(registry.key(), fileToIdConverter.fileToId(identifier)); +@@ -307,7 +_,7 @@ RegistrationInfo registrationInfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo()); try { @@ -56,7 +56,7 @@ } catch (Exception var14) { loadingErrors.put( resourceKey, -@@ -310,7 +_,9 @@ +@@ -316,7 +_,9 @@ } } @@ -67,7 +67,7 @@ } static void loadContentsFromNetwork( -@@ -327,6 +_,7 @@ +@@ -333,6 +_,7 @@ RegistryOps registryOps1 = RegistryOps.create(JsonOps.INSTANCE, registryInfoLookup); FileToIdConverter fileToIdConverter = FileToIdConverter.registry(registry.key()); @@ -75,16 +75,16 @@ for (RegistrySynchronization.PackedRegistryEntry packedRegistryEntry : networkedRegistryData.elements) { ResourceKey resourceKey = ResourceKey.create(registry.key(), packedRegistryEntry.id()); Optional optional = packedRegistryEntry.data(); -@@ -345,7 +_,7 @@ +@@ -351,7 +_,7 @@ try { - Resource resourceOrThrow = resourceProvider.getResourceOrThrow(resourceLocation); + Resource resourceOrThrow = resourceProvider.getResourceOrThrow(identifier); - loadElementFromResource(registry, codec, registryOps1, resourceKey, resourceOrThrow, NETWORK_REGISTRATION_INFO); + loadElementFromResource(registry, codec, registryOps1, resourceKey, resourceOrThrow, NETWORK_REGISTRATION_INFO, conversions); // Paper - pass conversions } catch (Exception var17) { loadingErrors.put(resourceKey, new IllegalStateException("Failed to parse local data", var17)); } -@@ -387,6 +_,7 @@ +@@ -393,6 +_,7 @@ RegistryDataLoader.Loader create(Lifecycle registryLifecycle, Map, Exception> loadingErrors) { WritableRegistry writableRegistry = new MappedRegistry<>(this.key, registryLifecycle); 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 667cc9190f97..bcb9b55ffc1f 100644 --- a/paper-server/patches/sources/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Main.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -66,8 +_,10 @@ - reason = "System.out needed before bootstrap" - ) +@@ -64,8 +_,10 @@ + + @SuppressForbidden(reason = "System.out needed before bootstrap") @DontObfuscate - public static void main(String[] args) { + public static void main(final OptionSet optionSet) { // CraftBukkit - replaces main(String[] args) @@ -12,7 +12,7 @@ OptionParser optionParser = new OptionParser(); OptionSpec optionSpec = optionParser.accepts("nogui"); OptionSpec optionSpec1 = optionParser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -92,41 +_,94 @@ +@@ -90,41 +_,94 @@ optionParser.printHelpOn(System.err); return; } @@ -116,7 +116,7 @@ Dynamic dataTag; if (levelStorageAccess.hasWorldData()) { LevelSummary summary; -@@ -168,12 +_,36 @@ +@@ -166,12 +_,36 @@ } Dynamic dynamic = dataTag; @@ -154,7 +154,7 @@ WorldStem worldStem; try { -@@ -182,6 +_,7 @@ +@@ -180,6 +_,7 @@ executor -> WorldLoader.load( initConfig, context -> { @@ -162,7 +162,7 @@ Registry registry = context.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM); if (dynamic != null) { LevelDataAndDimensions levelDataAndDimensions = LevelStorageSource.getLevelDataAndDimensions( -@@ -193,7 +_,7 @@ +@@ -191,7 +_,7 @@ } else { LOGGER.info("No existing world data, creating new world"); return createNewWorldData( @@ -171,7 +171,7 @@ ); } }, -@@ -211,6 +_,7 @@ +@@ -209,6 +_,7 @@ return; } @@ -179,7 +179,7 @@ RegistryAccess.Frozen frozen = worldStem.registries().compositeAccess(); WorldData worldData = worldStem.worldData(); boolean hasOptionSpec1 = optionSet.has(optionSpec6); -@@ -219,22 +_,50 @@ +@@ -217,22 +_,50 @@ } levelStorageAccess.saveDataTag(frozen, worldData); @@ -233,13 +233,13 @@ Thread thread = new Thread("Server Shutdown Thread") { @Override public void run() { -@@ -243,12 +_,13 @@ +@@ -241,12 +_,13 @@ }; thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); Runtime.getRuntime().addShutdownHook(thread); + */ // CraftBukkit end - } catch (Exception var42) { - LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable)var42); + } catch (Throwable var42) { + LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", var42); } } @@ -248,7 +248,7 @@ DedicatedServerSettings settings, WorldLoader.DataLoadContext context, Registry stemRegistry, boolean demo, boolean generateBonusChest ) { LevelSettings levelSettings; -@@ -316,7 +_,7 @@ +@@ -314,7 +_,7 @@ RegistryAccess registryAccess, boolean recreateRegionFiles ) { 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 28c737fe0b38..9accb9289b3b 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 -@@ -178,11 +_,13 @@ +@@ -186,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, ChunkIOErrorReporter { @@ -15,16 +15,16 @@ 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; -@@ -209,7 +_,7 @@ - private MinecraftServer.TimeProfiler debugCommandProfiler; +@@ -217,7 +_,7 @@ + private MinecraftServer.@Nullable TimeProfiler debugCommandProfiler; private boolean debugCommandProfilerDelayStart; private ServerConnectionListener connection; - private final LevelLoadListener levelLoadListener; + // Paper - per world load listener - moved LevelLoadListener to ServerLevel - @Nullable - private ServerStatus status; - @Nullable -@@ -222,14 +_,14 @@ + private @Nullable ServerStatus status; + private ServerStatus.@Nullable Favicon statusIcon; + private final RandomSource random = RandomSource.create(); +@@ -228,13 +_,14 @@ private Map, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -35,13 +35,12 @@ protected final Proxy proxy; private boolean onlineMode; private boolean preventProxyConnections; -- @Nullable -- private String motd; +- private @Nullable String motd; + private net.kyori.adventure.text.Component motd; // Paper - Adventure private int playerIdleTimeout; private final long[] tickTimesNanos = new long[100]; private long aggregatedTickTimesNanos = 0L; -@@ -278,10 +_,109 @@ +@@ -281,10 +_,109 @@ private final DiscontinuousFrame tickFrame; private final PacketProcessor packetProcessor; @@ -84,7 +83,7 @@ + private long taskExecutionTime; + private final Object statsLock = new Object(); + private @Nullable double[] tps; -+ private @Nullable ca.spottedleaf.moonrise.common.time.TickData.MSPTData msptData5s; ++ private ca.spottedleaf.moonrise.common.time.TickData.@Nullable MSPTData msptData5s; + + private void addTickTime(final ca.spottedleaf.moonrise.common.time.TickTime time) { + synchronized (this.statsLock) { @@ -124,7 +123,7 @@ + } + } + -+ public @Nullable ca.spottedleaf.moonrise.common.time.TickData.MSPTData getMSPTData5s() { ++ public ca.spottedleaf.moonrise.common.time.TickData.@Nullable MSPTData getMSPTData5s() { + synchronized (this.statsLock) { + if (this.msptData5s == null) { + this.msptData5s = this.tickTimes5s.getMSPTData(null, this.tickRateManager().nanosecondsPerTick()); @@ -152,7 +151,7 @@ if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } -@@ -293,6 +_,10 @@ +@@ -296,6 +_,10 @@ } public MinecraftServer( @@ -163,7 +162,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -303,18 +_,19 @@ +@@ -306,18 +_,19 @@ LevelLoadListener levelLoadListener ) { super("Server"); @@ -186,8 +185,8 @@ this.storageSource = storageSource; this.playerDataStorage = storageSource.createPlayerStorage(); this.fixerUpper = fixerUpper; -@@ -333,6 +_,38 @@ - this.notificationManager = new NotificationManager(); +@@ -337,6 +_,38 @@ + this.serverActivityMonitor = new ServerActivityMonitor(this.notificationManager, 30); this.packetProcessor = new PacketProcessor(serverThread); } + // CraftBukkit start @@ -224,8 +223,8 @@ + this.paperConfigurations = services.paper().configurations(); // Paper - add paper configuration files } - private void readScoreboard(DimensionDataStorage dataStorage) { -@@ -371,15 +_,15 @@ + protected abstract boolean initServer() throws IOException; +@@ -369,15 +_,15 @@ }; } @@ -246,7 +245,7 @@ if (profiledDuration != null) { profiledDuration.finish(true); } -@@ -393,30 +_,126 @@ +@@ -391,31 +_,127 @@ } } @@ -316,7 +315,7 @@ + if (biomeProvider == null && chunkGenerator != null) { + biomeProvider = chunkGenerator.getDefaultBiomeProvider(worldInfo); + } -+ final ResourceKey dimensionKey = ResourceKey.create(Registries.DIMENSION, loadingInfo.stemKey().location()); ++ final ResourceKey dimensionKey = ResourceKey.create(Registries.DIMENSION, loadingInfo.stemKey().identifier()); + ServerLevel serverLevel; + if (loadingInfo.stemKey() == LevelStem.OVERWORLD) { + serverLevel = new ServerLevel( @@ -338,8 +337,9 @@ + this.worldData = serverLevelData; + this.worldData.setGameType(((net.minecraft.server.dedicated.DedicatedServer) this).getProperties().gameMode.get()); // From DedicatedServer.init DimensionDataStorage dataStorage = serverLevel.getDataStorage(); - this.readScoreboard(dataStorage); + this.scoreboard.load(dataStorage.computeIfAbsent(ScoreboardSaveData.TYPE).getData()); this.commandStorage = new CommandStorage(dataStorage); + this.stopwatches = dataStorage.computeIfAbsent(Stopwatches.TYPE); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, serverLevel.getScoreboard()); + } else { + final List spawners; @@ -383,7 +383,7 @@ serverLevelData.setInitialized(true); if (isDebugWorld) { this.setupDebugLevel(this.worldData); -@@ -436,38 +_,16 @@ +@@ -435,38 +_,16 @@ } GlobalPos globalPos = this.selectLevelLoadFocusPos(); @@ -402,7 +402,7 @@ - ResourceKey resourceKey = entry.getKey(); - ServerLevel serverLevel1; - if (resourceKey != LevelStem.OVERWORLD) { -- ResourceKey resourceKey1 = ResourceKey.create(Registries.DIMENSION, resourceKey.location()); +- ResourceKey resourceKey1 = ResourceKey.create(Registries.DIMENSION, resourceKey.identifier()); - DerivedLevelData derivedLevelData = new DerivedLevelData(this.worldData, serverLevelData); - serverLevel1 = new ServerLevel( - this, @@ -430,8 +430,8 @@ Optional legacyWorldBorderSettings = serverLevelData.getLegacyWorldBorderSettings(); if (legacyWorldBorderSettings.isPresent()) { WorldBorder.Settings settings = legacyWorldBorderSettings.get(); -@@ -488,16 +_,14 @@ - dataStorage1.set(WorldBorder.TYPE, settings1.toWorldBorder()); +@@ -489,16 +_,14 @@ + dataStorage1.set(WorldBorder.TYPE, worldBorder); } - flag = true; @@ -453,7 +453,7 @@ } private static void setInitialSpawn( -@@ -509,6 +_,30 @@ +@@ -510,6 +_,30 @@ levelData.setSpawn(LevelData.RespawnData.of(level.dimension(), BlockPos.ZERO.above(80), 0.0F, 0.0F)); } else { ServerChunkCache chunkSource = level.getChunkSource(); @@ -484,7 +484,7 @@ ChunkPos chunkPos = new ChunkPos(chunkSource.randomState().sampler().findSpawnPosition()); levelLoadListener.start(LevelLoadListener.Stage.PREPARE_GLOBAL_SPAWN, 0); levelLoadListener.updateFocus(level.dimension(), chunkPos); -@@ -565,10 +_,13 @@ +@@ -566,10 +_,13 @@ serverLevelData.setGameType(GameType.SPECTATOR); } @@ -500,7 +500,7 @@ chunkLoadCounter.track(serverLevel, () -> { TicketStorage ticketStorage = serverLevel.getDataStorage().get(TicketStorage.TYPE); if (ticketStorage != null) { -@@ -577,17 +_,19 @@ +@@ -578,17 +_,19 @@ }); } @@ -518,7 +518,7 @@ - this.levelLoadListener.finish(LevelLoadListener.Stage.LOAD_INITIAL_CHUNKS); - this.updateMobSpawningFlags(); + serverLevel.levelLoadListener.finish(LevelLoadListener.Stage.LOAD_INITIAL_CHUNKS); // Paper - per world load listener -+ serverLevel.setSpawnSettings(serverLevel.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && serverLevel.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean)) ++ serverLevel.setSpawnSettings(serverLevel.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && serverLevel.getGameRules().get(GameRules.SPAWN_MONSTERS)); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean)) this.updateEffectiveRespawnData(); + this.forceTicks = false; // CraftBukkit + serverLevel.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API @@ -526,7 +526,7 @@ } protected GlobalPos selectLevelLoadFocusPos() { -@@ -620,8 +_,10 @@ +@@ -622,8 +_,10 @@ flag = true; } @@ -539,7 +539,7 @@ if (flush) { for (ServerLevel serverLevel : this.getAllLevels()) { LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName()); -@@ -651,19 +_,49 @@ +@@ -653,19 +_,49 @@ this.stopServer(); } @@ -590,7 +590,7 @@ } LOGGER.info("Saving worlds"); -@@ -705,6 +_,25 @@ +@@ -707,6 +_,25 @@ } catch (IOException var4) { LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); } @@ -616,7 +616,7 @@ } public String getLocalIp() { -@@ -720,6 +_,14 @@ +@@ -722,6 +_,14 @@ } public void halt(boolean waitForShutdown) { @@ -631,7 +631,7 @@ this.running = false; if (waitForShutdown) { try { -@@ -730,6 +_,118 @@ +@@ -732,6 +_,118 @@ } } @@ -750,7 +750,7 @@ protected void runServer() { try { if (!this.initServer()) { -@@ -737,26 +_,68 @@ +@@ -739,26 +_,68 @@ } this.nextTickTimeNanos = Util.getNanos(); @@ -829,7 +829,7 @@ boolean flag = l == 0L; if (this.debugCommandProfilerDelayStart) { -@@ -764,7 +_,7 @@ +@@ -766,7 +_,7 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); } @@ -837,16 +837,8 @@ + // Paper - improve tick loop - done above try (Profiler.Scope scope = Profiler.use(this.createProfiler())) { - ProfilerFiller profilerFiller = Profiler.get(); -@@ -773,13 +_,15 @@ - profilerFiller.push("scheduledPacketProcessing"); - this.packetProcessor.processQueuedPackets(); - profilerFiller.pop(); -+ this.runAllTasksAtTickStart(); // Paper - improve tick loop - this.tickServer(flag ? () -> false : this::haveTime); - this.tickFrame.end(); -+ this.recordEndOfTick(); // Paper - improve tick loop - profilerFiller.popPush("nextTickWait"); + this.processPacketsAndTick(flag); +@@ -775,7 +_,7 @@ this.mayHaveDelayedTasks = true; this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos); this.startMeasuringTaskExecutionTime(); @@ -855,7 +847,7 @@ this.finishMeasuringTaskExecutionTime(); if (flag) { this.tickRateManager.endTickWork(); -@@ -813,7 +_,7 @@ +@@ -809,7 +_,7 @@ } catch (Throwable var64) { LOGGER.error("Exception stopping the server", var64); } finally { @@ -864,7 +856,7 @@ } } } -@@ -865,7 +_,14 @@ +@@ -861,7 +_,14 @@ } private boolean haveTime() { @@ -880,13 +872,10 @@ } public static boolean throwIfFatalException() { -@@ -892,14 +_,11 @@ +@@ -887,11 +_,11 @@ + } protected void waitUntilNextTick() { - ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("scheduledPacketProcessing"); -- this.packetProcessor.processQueuedPackets(); -- profilerFiller.pop(); - this.runAllTasks(); + // Paper - improve tick loop - moved to start of tick this.waitingForNextTick = true; @@ -897,7 +886,7 @@ } finally { this.waitingForNextTick = false; } -@@ -918,17 +_,23 @@ +@@ -910,17 +_,23 @@ @Override public TickTask wrapRunnable(Runnable runnable) { @@ -923,7 +912,7 @@ this.mayHaveDelayedTasks = flag; return flag; } -@@ -937,15 +_,16 @@ +@@ -929,15 +_,16 @@ if (super.pollTask()) { return true; } else { @@ -942,7 +931,7 @@ } } -@@ -993,26 +_,44 @@ +@@ -990,26 +_,44 @@ } public void tickServer(BooleanSupplier hasTimeLeft) { @@ -988,7 +977,7 @@ this.tickCount++; this.tickRateManager.tick(); this.tickChildren(hasTimeLeft); -@@ -1022,11 +_,18 @@ +@@ -1019,11 +_,18 @@ } this.ticksUntilAutosave--; @@ -1008,7 +997,19 @@ profilerFiller.push("tallying"); long l = Util.getNanos() - nanos; int i1 = this.tickCount % 100; -@@ -1039,7 +_,7 @@ +@@ -1039,16 +_,16 @@ + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("tick"); + this.tickFrame.start(); +- profilerFiller.push("scheduledPacketProcessing"); +- this.packetProcessor.processQueuedPackets(); +- profilerFiller.pop(); ++ // Paper - improve tick loop - moved into runAllTasksAtTickStart ++ this.runAllTasksAtTickStart(); // Paper - improve tick loop + this.tickServer(sprinting ? () -> false : this::haveTime); + this.tickFrame.end(); ++ this.recordEndOfTick(); // Paper - improve tick loop + profilerFiller.pop(); } private void autoSave() { @@ -1017,7 +1018,7 @@ LOGGER.debug("Autosave started"); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("save"); -@@ -1081,7 +_,7 @@ +@@ -1090,7 +_,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players players = this.buildPlayerStatus(); return new ServerStatus( @@ -1026,7 +1027,7 @@ Optional.of(players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), -@@ -1095,7 +_,7 @@ +@@ -1104,7 +_,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(maxPlayers, players.size(), List.of()); } else { @@ -1035,7 +1036,7 @@ ObjectArrayList list = new ObjectArrayList<>(min); int randomInt = Mth.nextInt(this.random, 0, players.size() - min); -@@ -1112,18 +_,77 @@ +@@ -1121,18 +_,77 @@ protected void tickChildren(BooleanSupplier hasTimeLeft) { ProfilerFiller profilerFiller = Profiler.get(); this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing()); @@ -1079,7 +1080,7 @@ + // Send time updates to everyone, it will get the right time from the world the player is in. + // Paper start - Perf: Optimize time updates + for (final ServerLevel level : this.getAllLevels()) { -+ final boolean doDaylight = level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT); ++ final boolean doDaylight = level.getGameRules().get(GameRules.ADVANCE_TIME); + final long dayTime = level.getDayTime(); + long worldTime = level.getGameTime(); + final ClientboundSetTimePacket worldPacket = new ClientboundSetTimePacket(worldTime, dayTime, doDaylight); @@ -1102,7 +1103,7 @@ + serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent + serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent + serverLevel.updateLagCompensationTick(); // Paper - lag compensation - profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location()); + profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().identifier()); + /* Drop global time updates if (this.tickCount % 20 == 0) { profilerFiller.push("timeSync"); @@ -1113,7 +1114,7 @@ profilerFiller.push("tick"); -@@ -1137,7 +_,9 @@ +@@ -1146,7 +_,9 @@ profilerFiller.pop(); profilerFiller.pop(); @@ -1123,8 +1124,8 @@ profilerFiller.popPush("connection"); this.tickConnection(); -@@ -1166,9 +_,12 @@ - profilerFiller.pop(); +@@ -1176,9 +_,12 @@ + this.serverActivityMonitor.tick(); } - private void updateEffectiveRespawnData() { @@ -1138,7 +1139,7 @@ this.effectiveRespawnData = serverLevel.getWorldBorderAdjustedRespawnData(respawnData); } -@@ -1224,6 +_,22 @@ +@@ -1228,6 +_,22 @@ return this.levels.get(dimension); } @@ -1161,7 +1162,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1248,7 +_,7 @@ +@@ -1252,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -1170,7 +1171,7 @@ } public SystemReport fillSystemReport(SystemReport systemReport) { -@@ -1283,7 +_,7 @@ +@@ -1287,7 +_,7 @@ @Override public void sendSystemMessage(Component message) { @@ -1179,7 +1180,7 @@ } public KeyPair getKeyPair() { -@@ -1321,11 +_,17 @@ +@@ -1324,11 +_,17 @@ } } @@ -1196,21 +1197,13 @@ + level.getWorld(), source, org.bukkit.craftbukkit.util.CraftDifficulty.toBukkit(difficulty) + ).callEvent(); + worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : difficulty); -+ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && level.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); ++ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && level.getGameRules().get(GameRules.SPAWN_MONSTERS)); + // this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); + // Paper end - per level difficulty } } -@@ -1397,6 +_,7 @@ - - public abstract boolean isEpollEnabled(); - -+ @io.papermc.paper.annotation.DoNotUse @Deprecated(forRemoval = true) // Paper - use CraftWorld#getPVP - public boolean isPvpAllowed() { - return this.getGameRules().getBoolean(GameRules.RULE_PVP); - } -@@ -1415,10 +_,20 @@ +@@ -1400,10 +_,20 @@ @Override public String getMotd() { @@ -1232,7 +1225,7 @@ this.motd = motd; } -@@ -1447,9 +_,13 @@ +@@ -1432,9 +_,13 @@ int i = 0; for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { @@ -1248,7 +1241,7 @@ } return i; -@@ -1457,7 +_,7 @@ +@@ -1442,7 +_,7 @@ } public ServerConnectionListener getConnection() { @@ -1257,7 +1250,7 @@ } public boolean isReady() { -@@ -1525,7 +_,7 @@ +@@ -1505,7 +_,7 @@ @Override public void executeIfPossible(Runnable task) { if (this.isStopped()) { @@ -1266,7 +1259,7 @@ } else { super.executeIfPossible(task); } -@@ -1560,7 +_,14 @@ +@@ -1540,7 +_,14 @@ return this.functionManager; } @@ -1281,7 +1274,7 @@ CompletableFuture completableFuture = CompletableFuture.supplyAsync( () -> selectedIds.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()), this -@@ -1568,7 +_,7 @@ +@@ -1548,7 +_,7 @@ .thenCompose( list -> { CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, list); @@ -1290,7 +1283,7 @@ return ReloadableServerResources.loadResources( closeableResourceManager, this.registries, -@@ -1589,20 +_,39 @@ +@@ -1569,20 +_,39 @@ ) .thenAcceptAsync( reloadableResources -> { @@ -1332,7 +1325,7 @@ }, this ); -@@ -1619,7 +_,7 @@ +@@ -1599,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet featureFlagSet = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet featureFlagSet1 = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1341,7 +1334,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), featureFlagSet, false); } else { -@@ -1674,7 +_,7 @@ +@@ -1654,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( PackRepository packRepository, Collection selectedPacks, FeatureFlagSet enabledFeatures, boolean safeMode ) { @@ -1350,7 +1343,7 @@ enableForcedFeaturePacks(packRepository, enabledFeatures); DataPackConfig selectedPacks1 = getSelectedPacks(packRepository, safeMode); FeatureFlagSet featureFlagSet = packRepository.getRequestedFeatureFlags().join(enabledFeatures); -@@ -1706,7 +_,7 @@ +@@ -1686,7 +_,7 @@ } } @@ -1359,7 +1352,7 @@ } } -@@ -1723,8 +_,8 @@ +@@ -1703,8 +_,8 @@ UserWhiteList whiteList = playerList.getWhiteList(); for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) { @@ -1370,7 +1363,7 @@ } } } -@@ -1754,12 +_,12 @@ +@@ -1734,12 +_,12 @@ } public ServerLevel findRespawnDimension() { @@ -1385,7 +1378,7 @@ public void setRespawnData(LevelData.RespawnData respawnData) { ServerLevelData serverLevelData = this.worldData.overworldData(); LevelData.RespawnData respawnData1 = serverLevelData.getRespawnData(); -@@ -1957,6 +_,17 @@ +@@ -1941,6 +_,17 @@ } } @@ -1403,7 +1396,7 @@ private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -2078,16 +_,22 @@ +@@ -2061,16 +_,22 @@ } public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { @@ -1430,7 +1423,7 @@ } public boolean logIPs() { -@@ -2098,8 +_,9 @@ +@@ -2081,8 +_,9 @@ LOGGER.debug("Received custom click action {} with payload {}", id, payload.orElse(null)); } @@ -1441,18 +1434,48 @@ } public boolean setAutoSave(boolean autoSave) { -@@ -2125,8 +_,9 @@ +@@ -2108,12 +_,14 @@ return false; } -+ @io.papermc.paper.annotation.DoNotUse @Deprecated(forRemoval = true) // Paper - per level gamerules - replace all calls - public void onGameRuleChanged(String key, GameRules.Value value) { -- this.notificationManager().onGameRuleChanged(key, value); -+ throw new UnsupportedOperationException(); // Paper - per level gamerules - replace callers +- public void onGameRuleChanged(GameRule rule, T value) { +- this.notificationManager().onGameRuleChanged(rule, value); ++ // Paper start - per-world game rules ++ public void onGameRuleChanged(ServerLevel serverLevel, GameRule rule, T value) { ++ this.notificationManager().onGameRuleChanged(serverLevel, rule, value); ++ // Paper end - per-world game rules + if (rule == GameRules.REDUCED_DEBUG_INFO) { + byte b = (byte)((Boolean)value ? 22 : 23); + +- for (ServerPlayer serverPlayer : this.getPlayerList().getPlayers()) { ++ for (ServerPlayer serverPlayer : serverLevel.players()) { // Paper - per-world game rules + serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); + } + } else if (rule == GameRules.LIMITED_CRAFTING || rule == GameRules.IMMEDIATE_RESPAWN) { +@@ -2121,18 +_,18 @@ + ? ClientboundGameEventPacket.LIMITED_CRAFTING + : ClientboundGameEventPacket.IMMEDIATE_RESPAWN; + ClientboundGameEventPacket clientboundGameEventPacket = new ClientboundGameEventPacket(type, (Boolean)value ? 1.0F : 0.0F); +- this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.send(clientboundGameEventPacket)); ++ serverLevel.players().forEach(serverPlayer1 -> serverPlayer1.connection.send(clientboundGameEventPacket)); // Paper - per-world game rules + } else if (rule == GameRules.LOCATOR_BAR) { +- this.getAllLevels().forEach(serverLevel -> { ++ // this.getAllLevels().forEach(serverLevel -> { // Paper - per-world game rules + ServerWaypointManager waypointManager = serverLevel.getWaypointManager(); + if ((Boolean)value) { + serverLevel.players().forEach(waypointManager::updatePlayer); + } else { + waypointManager.breakAllConnections(); + } +- }); ++ // }); // Paper - per-world game rules + } else if (rule == GameRules.SPAWN_MONSTERS) { +- this.updateMobSpawningFlags(); ++ serverLevel.setSpawnSettings(serverLevel.serverLevelData.getDifficulty() != net.minecraft.world.Difficulty.PEACEFUL && serverLevel.getGameRules().get(GameRules.SPAWN_MONSTERS)); // Paper - per-world game rules + } } - public boolean acceptsTransfers() { -@@ -2260,4 +_,53 @@ +@@ -2267,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 42f13731adeb..91cc5562a305 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,15 @@ private final PlayerList playerList; private final Path playerSavePath; private AdvancementTree tree; -@@ -60,6 +_,7 @@ - private AdvancementHolder lastSelectedTab; +@@ -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 final Map, Set>> criterionData = new java.util.IdentityHashMap<>(); // Paper - fix advancement data player leakage public PlayerAdvancements(DataFixer dataFixer, PlayerList playerList, ServerAdvancementManager manager, Path playerSavePath, ServerPlayer player) { this.playerList = playerList; -@@ -127,6 +_,7 @@ +@@ -126,6 +_,7 @@ } public void save() { @@ -25,15 +25,15 @@ JsonElement jsonElement = this.codec.encodeStart(JsonOps.INSTANCE, this.asData()).getOrThrow(); try { -@@ -144,6 +_,7 @@ +@@ -143,6 +_,7 @@ data.forEach((path, progress) -> { AdvancementHolder advancementHolder = advancementManager.get(path); if (advancementHolder == null) { -+ if (!path.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) return; // CraftBukkit ++ if (!path.getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) return; // CraftBukkit LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", path, this.playerSavePath); } else { this.startProgress(advancementHolder, progress); -@@ -168,14 +_,31 @@ +@@ -167,14 +_,31 @@ AdvancementProgress orStartProgress = this.getOrStartProgress(advancement); boolean isDone = orStartProgress.isDone(); if (orStartProgress.grantProgress(criterionKey)) { @@ -58,21 +58,21 @@ + // Paper end advancement.value().rewards().grant(this.player); advancement.value().display().ifPresent(displayInfo -> { -- if (displayInfo.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { +- if (displayInfo.shouldAnnounceChat() && this.player.level().getGameRules().get(GameRules.SHOW_ADVANCEMENT_MESSAGES)) { - this.playerList.broadcastSystemMessage(displayInfo.getType().createAnnouncement(advancement, this.player), false); + // Paper start - Add Adventure message to PlayerAdvancementDoneEvent -+ if (event.message() != null && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { ++ if (event.message() != null && this.player.level().getGameRules().get(GameRules.SHOW_ADVANCEMENT_MESSAGES)) { + this.playerList.broadcastSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.message()), false); + // Paper end } }); } -@@ -246,7 +_,7 @@ +@@ -245,7 +_,7 @@ public void flushDirty(ServerPlayer player, boolean showAdvancements) { if (this.isFirstPacket || !this.rootsToUpdate.isEmpty() || !this.progressChanged.isEmpty()) { - Map map = new HashMap<>(); + Map map = new HashMap<>(); - Set set = new HashSet<>(); + Set set = new java.util.TreeSet<>(java.util.Comparator.comparing(adv -> adv.id().toString())); // Paper - Changed from HashSet to TreeSet ordered alphabetically. - Set set1 = new HashSet<>(); + Set set1 = new HashSet<>(); for (AdvancementNode advancementNode : this.rootsToUpdate) { diff --git a/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch b/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch index 138e996818e6..17d2976357a1 100644 --- a/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ReloadableServerRegistries.java.patch @@ -22,13 +22,13 @@ () -> { WritableRegistry writableRegistry = new MappedRegistry<>(lootDataType.registryKey(), Lifecycle.experimental()); + io.papermc.paper.registry.PaperRegistryAccess.instance().registerReloadableRegistry(writableRegistry); // Paper - register reloadable registry - Map map = new HashMap<>(); + Map map = new HashMap<>(); SimpleJsonResourceReloadListener.scanDirectory(resourceManager, lootDataType.registryKey(), ops, lootDataType.codec(), map); map.forEach( -- (resourceLocation, object) -> writableRegistry.register( -- ResourceKey.create(lootDataType.registryKey(), resourceLocation), (T)object, DEFAULT_REGISTRATION_INFO -+ (resourceLocation, object) -> io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerWithListeners(writableRegistry, // Paper - register with listeners -+ ResourceKey.create(lootDataType.registryKey(), resourceLocation), (T)object, DEFAULT_REGISTRATION_INFO, conversions // Paper - register with listeners +- (identifier, object) -> writableRegistry.register( +- ResourceKey.create(lootDataType.registryKey(), identifier), (T)object, DEFAULT_REGISTRATION_INFO ++ (identifier, object) -> io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerWithListeners(writableRegistry, // Paper - register with listeners ++ ResourceKey.create(lootDataType.registryKey(), identifier), (T)object, DEFAULT_REGISTRATION_INFO, conversions // Paper - register with listeners ) ); - TagLoader.loadTagsForRegistry(resourceManager, writableRegistry); diff --git a/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch b/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch index 164b4a459341..37f4eb620c5e 100644 --- a/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -38,7 +_,9 @@ +@@ -39,7 +_,9 @@ this.fullRegistryHolder = new ReloadableServerRegistries.Holder(registryAccess.compositeAccess()); this.postponedTags = postponedTags; this.recipes = new RecipeManager(registries); @@ -9,11 +9,11 @@ + io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setDispatcher(this.commands, CommandBuildContext.simple(registries, enabledFeatures)); // Paper - Brigadier Command API + io.papermc.paper.command.PaperCommands.registerCommands(); // Paper this.advancements = new ServerAdvancementManager(registries); - this.functionLibrary = new ServerFunctionLibrary(functionCompilationLevel, this.commands.getDispatcher()); + this.functionLibrary = new ServerFunctionLibrary(permissions, this.commands.getDispatcher()); } -@@ -83,6 +_,14 @@ +@@ -84,6 +_,14 @@ ReloadableServerResources reloadableServerResources = new ReloadableServerResources( - loadResult.layers(), loadResult.lookupWithUpdatedTags(), enabledFeatures, commandSelection, postponedTags, functionCompilationLevel + loadResult.layers(), loadResult.lookupWithUpdatedTags(), enabledFeatures, commandSelection, postponedTags, permissions ); + // Paper start - call commands event for bootstraps + //noinspection ConstantValue 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 3be388af5518..3f0820b171c8 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerAdvancementManager.java.patch @@ -4,22 +4,22 @@ 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 +- 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(Map object, ResourceManager resourceManager, ProfilerFiller profiler) { - Builder builder = ImmutableMap.builder(); - object.forEach((resourceLocation, advancement) -> { + protected void apply(Map object, ResourceManager resourceManager, ProfilerFiller profiler) { + Builder builder = ImmutableMap.builder(); + object.forEach((identifier, advancement) -> { + // Spigot start -+ if (org.spigotmc.SpigotConfig.disabledAdvancements != null && (org.spigotmc.SpigotConfig.disabledAdvancements.contains("*") || org.spigotmc.SpigotConfig.disabledAdvancements.contains(resourceLocation.toString()) || org.spigotmc.SpigotConfig.disabledAdvancements.contains(resourceLocation.getNamespace()))) { ++ if (org.spigotmc.SpigotConfig.disabledAdvancements != null && (org.spigotmc.SpigotConfig.disabledAdvancements.contains("*") || org.spigotmc.SpigotConfig.disabledAdvancements.contains(identifier.toString()) || org.spigotmc.SpigotConfig.disabledAdvancements.contains(identifier.getNamespace()))) { + return; + } + // Spigot end - this.validate(resourceLocation, advancement); - builder.put(resourceLocation, new AdvancementHolder(resourceLocation, advancement)); + this.validate(identifier, advancement); + builder.put(identifier, new AdvancementHolder(identifier, advancement)); }); - this.advancements = builder.buildOrThrow(); + this.advancements = new java.util.HashMap<>(builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable diff --git a/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch index 399fc05dbb60..5b4c62b4b947 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerFunctionLibrary.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/ServerFunctionLibrary.java +++ b/net/minecraft/server/ServerFunctionLibrary.java -@@ -114,7 +_,7 @@ +@@ -108,7 +_,7 @@ return null; }).join()); this.functions = builder.build(); -- this.tags = this.tagsLoader.build((Map>)pair.getFirst()); -+ this.tags = this.tagsLoader.build((Map>)pair.getFirst(), null); // Paper - command function tags are not implemented yet +- this.tags = this.tagsLoader.build((Map>)pair.getFirst()); ++ this.tags = this.tagsLoader.build((Map>)pair.getFirst(), null); // Paper - command function tags are not implemented yet }, gameExecutor ); 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 d7a0e5305ef7..bde4eb4ab7c6 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ServerScoreboard.java +++ b/net/minecraft/server/ServerScoreboard.java -@@ -45,9 +_,7 @@ +@@ -51,9 +_,7 @@ protected void onScoreChanged(ScoreHolder scoreHolder, Objective objective, Score score) { super.onScoreChanged(scoreHolder, objective, score); if (this.trackedObjectives.contains(objective)) { @@ -11,7 +11,7 @@ new ClientboundSetScorePacket( scoreHolder.getScoreboardName(), objective.getName(), -@@ -70,7 +_,7 @@ +@@ -76,7 +_,7 @@ @Override public void onPlayerRemoved(ScoreHolder scoreHolder) { super.onPlayerRemoved(scoreHolder); @@ -20,7 +20,7 @@ this.setDirty(); } -@@ -78,7 +_,7 @@ +@@ -84,7 +_,7 @@ public void onPlayerScoreRemoved(ScoreHolder scoreHolder, Objective objective) { super.onPlayerScoreRemoved(scoreHolder, objective); if (this.trackedObjectives.contains(objective)) { @@ -29,7 +29,7 @@ } this.setDirty(); -@@ -90,7 +_,7 @@ +@@ -96,7 +_,7 @@ super.setDisplayObjective(slot, objective); if (displayObjective != objective && displayObjective != null) { if (this.getObjectiveDisplaySlotCount(displayObjective) > 0) { @@ -38,7 +38,7 @@ } else { this.stopTrackingObjective(displayObjective); } -@@ -98,7 +_,7 @@ +@@ -104,7 +_,7 @@ if (objective != null) { if (this.trackedObjectives.contains(objective)) { @@ -47,7 +47,7 @@ } else { this.startTrackingObjective(objective); } -@@ -110,9 +_,7 @@ +@@ -116,9 +_,7 @@ @Override public boolean addPlayerToTeam(String playerName, PlayerTeam team) { if (super.addPlayerToTeam(playerName, team)) { @@ -58,7 +58,7 @@ this.updatePlayerWaypoint(playerName); this.setDirty(); return true; -@@ -121,16 +_,44 @@ +@@ -127,16 +_,44 @@ } } @@ -106,7 +106,7 @@ @Override public void onObjectiveAdded(Objective objective) { super.onObjectiveAdded(objective); -@@ -141,7 +_,7 @@ +@@ -147,7 +_,7 @@ public void onObjectiveChanged(Objective objective) { super.onObjectiveChanged(objective); if (this.trackedObjectives.contains(objective)) { @@ -115,7 +115,7 @@ } this.setDirty(); -@@ -160,14 +_,14 @@ +@@ -166,14 +_,14 @@ @Override public void onTeamAdded(PlayerTeam team) { super.onTeamAdded(team); @@ -132,7 +132,7 @@ this.updateTeamWaypoints(team); this.setDirty(); } -@@ -175,7 +_,7 @@ +@@ -181,7 +_,7 @@ @Override public void onTeamRemoved(PlayerTeam team) { super.onTeamRemoved(team); @@ -141,7 +141,7 @@ this.updateTeamWaypoints(team); this.setDirty(); } -@@ -219,6 +_,7 @@ +@@ -226,6 +_,7 @@ List> startTrackingPackets = this.getStartTrackingPackets(objective); for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { @@ -149,7 +149,7 @@ for (Packet packet : startTrackingPackets) { serverPlayer.connection.send(packet); } -@@ -244,6 +_,7 @@ +@@ -251,6 +_,7 @@ List> stopTrackingPackets = this.getStopTrackingPackets(objective); for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { @@ -157,7 +157,7 @@ for (Packet packet : stopTrackingPackets) { serverPlayer.connection.send(packet); } -@@ -295,4 +_,13 @@ +@@ -287,4 +_,13 @@ .forEach(serverPlayer -> serverLevel.getWaypointManager().remakeConnections(serverPlayer)); } } diff --git a/paper-server/patches/sources/net/minecraft/server/Services.java.patch b/paper-server/patches/sources/net/minecraft/server/Services.java.patch index a4cc21df362d..7c8740bb9afa 100644 --- a/paper-server/patches/sources/net/minecraft/server/Services.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Services.java.patch @@ -45,4 +45,4 @@ + // Paper end - load paper config files from cli options } - @Nullable + public @Nullable SignatureValidator profileKeySignatureValidator() { diff --git a/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch b/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch index a2c0814152b9..58978e5e9ff9 100644 --- a/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/WorldLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldLoader.java +++ b/net/minecraft/server/WorldLoader.java -@@ -37,7 +_,7 @@ +@@ -38,7 +_,7 @@ CloseableResourceManager closeableResourceManager = pair.getSecond(); LayeredRegistryAccess layeredRegistryAccess = RegistryLayer.createRegistryAccess(); List> list = TagLoader.loadTagsForExistingRegistries( diff --git a/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch b/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch index 3338d7d8be9e..511f66f064a7 100644 --- a/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/bossevents/CustomBossEvent.java.patch @@ -15,5 +15,5 @@ + } + // CraftBukkit end - public CustomBossEvent(ResourceLocation id, Component name) { + public CustomBossEvent(Identifier id, Component name) { super(name, BossEvent.BossBarColor.WHITE, BossEvent.BossBarOverlay.PROGRESS); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch index 9d1cc61c466b..8a3de200eb96 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/DebugCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/DebugCommand.java +++ b/net/minecraft/server/commands/DebugCommand.java -@@ -262,6 +_,13 @@ +@@ -263,6 +_,13 @@ return true; } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch index af9b8546b7b6..c308208079fb 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/GameRuleCommand.java.patch @@ -1,22 +1,12 @@ --- a/net/minecraft/server/commands/GameRuleCommand.java +++ b/net/minecraft/server/commands/GameRuleCommand.java -@@ -30,15 +_,15 @@ +@@ -37,8 +_,7 @@ - static > int setRule(CommandContext context, GameRules.Key gameRule) { + private static int setRule(CommandContext context, GameRule rule) { CommandSourceStack commandSourceStack = context.getSource(); -- T rule = commandSourceStack.getServer().getGameRules().getRule(gameRule); -- rule.setFromArgument(context, "value"); -- commandSourceStack.getServer().onGameRuleChanged(gameRule.getId(), rule); -+ T rule = commandSourceStack.getLevel().getGameRules().getRule(gameRule); // CraftBukkit -+ rule.setFromArgument(context, "value", gameRule); // Paper - Add WorldGameRuleChangeEvent -+ commandSourceStack.getServer().notificationManager().onGameRuleChanged(commandSourceStack.getLevel(), gameRule.getId(), rule); // Paper - per-world game rules - commandSourceStack.sendSuccess(() -> Component.translatable("commands.gamerule.set", gameRule.getId(), rule.toString()), true); - return rule.getCommandResult(); - } - - static > int queryRule(CommandSourceStack source, GameRules.Key gameRule) { -- T rule = source.getServer().getGameRules().getRule(gameRule); -+ T rule = source.getLevel().getGameRules().getRule(gameRule); // CraftBukkit - source.sendSuccess(() -> Component.translatable("commands.gamerule.query", gameRule.getId(), rule.toString()), false); - return rule.getCommandResult(); +- T argument = context.getArgument("value", rule.valueClass()); +- commandSourceStack.getLevel().getGameRules().set(rule, argument, context.getSource().getServer()); ++ T argument = org.bukkit.craftbukkit.event.CraftEventFactory.handleGameRuleSet(rule, context.getArgument("value", rule.valueClass()), commandSourceStack.getLevel(), context.getSource().getBukkitSender()).value(); // Paper - per-world game rules and event + commandSourceStack.sendSuccess(() -> Component.translatable("commands.gamerule.set", rule.id(), rule.serialize(argument)), true); + return rule.getCommandResult(argument); } diff --git a/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch index da6d6d1877d7..a96e3087c595 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/ReloadCommand.java.patch @@ -34,4 +34,4 @@ + // CraftBukkit end public static void register(CommandDispatcher dispatcher) { - dispatcher.register(Commands.literal("reload").requires(Commands.hasPermission(2)).executes(commandContext -> { + dispatcher.register(Commands.literal("reload").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)).executes(commandContext -> { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch index bd614fe2f377..1e8073d25ded 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/ScheduleCommand.java.patch @@ -12,13 +12,13 @@ @@ -101,7 +_,7 @@ } else { long l = source.getLevel().getGameTime() + time; - ResourceLocation resourceLocation = function.getFirst(); + Identifier identifier = function.getFirst(); - TimerQueue scheduledEvents = source.getServer().getWorldData().overworldData().getScheduledEvents(); + TimerQueue scheduledEvents = source.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer Optional> optional = function.getSecond().left(); if (optional.isPresent()) { if (optional.get() instanceof MacroFunction) { -@@ -132,7 +_,7 @@ +@@ -130,7 +_,7 @@ } private static int remove(CommandSourceStack source, String function) throws CommandSyntaxException { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch index 5c5602ee100f..de35da33ce39 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/commands/SetSpawnCommand.java +++ b/net/minecraft/server/commands/SetSpawnCommand.java -@@ -73,24 +_,34 @@ - float f = rotation.y; - float f1 = rotation.x; +@@ -74,24 +_,34 @@ + float f = Mth.wrapDegrees(rotation.y); + float f1 = Mth.clamp(rotation.x, -90.0F, 90.0F); + final Collection actualTargets = new java.util.ArrayList<>(); // Paper - Add PlayerSetSpawnEvent for (ServerPlayer serverPlayer : targets) { @@ -20,7 +20,7 @@ + } + // Paper end - Add PlayerSetSpawnEvent - String string = resourceKey.location().toString(); + String string = resourceKey.identifier().toString(); - if (targets.size() == 1) { + if (actualTargets.size() == 1) { // Paper - Add PlayerSetSpawnEvent source.sendSuccess( 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 c5eb7abe8e42..17c29d6a3d34 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 -@@ -165,7 +_,7 @@ +@@ -166,7 +_,7 @@ } private static void mutateIcon(CommandSourceStack source, WaypointTransmitter waypoint, Consumer mutator) { 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 57bff330f478..c8cd84714454 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,19 +1,18 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -78,10 +_,10 @@ +@@ -80,9 +_,9 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final int CONVERSION_RETRY_DELAY_MS = 5000; private static final int CONVERSION_RETRIES = 2; - private final List consoleInput = Collections.synchronizedList(Lists.newArrayList()); + private final java.util.Queue serverCommandQueue = new java.util.concurrent.ConcurrentLinkedQueue<>(); // Paper - Perf: use a proper queue - @Nullable - private QueryThreadGs4 queryThreadGs4; + private @Nullable QueryThreadGs4 queryThreadGs4; - private final RconConsoleSource rconConsoleSource; + // private final RconConsoleSource rconConsoleSource; // CraftBukkit - remove field - @Nullable - private RconThread rconThread; + private @Nullable RconThread rconThread; public DedicatedServerSettings settings; -@@ -99,6 +_,7 @@ + private @Nullable MinecraftServerGui gui; +@@ -95,6 +_,7 @@ private long lastHeartbeat; public DedicatedServer( @@ -21,7 +20,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -107,9 +_,10 @@ +@@ -103,9 +_,10 @@ DataFixer fixerUpper, Services services ) { @@ -34,7 +33,7 @@ this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); this.serverLinks = createServerLinks(settings); if (settings.getProperties().codeOfConduct) { -@@ -194,6 +_,10 @@ +@@ -191,6 +_,10 @@ Thread thread = new Thread("Server console handler") { @Override public void run() { @@ -44,8 +43,8 @@ + /* BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); - String string3; -@@ -203,17 +_,41 @@ + String string4; +@@ -200,17 +_,41 @@ } } catch (IOException var4) { DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4); @@ -89,7 +88,7 @@ LOGGER.info("Loading properties"); DedicatedServerProperties properties = this.settings.getProperties(); if (this.isSingleplayer()) { -@@ -224,8 +_,46 @@ +@@ -221,8 +_,46 @@ this.setLocalIp(properties.serverIp); } @@ -137,7 +136,7 @@ InetAddress inetAddress = null; if (!this.getLocalIp().isEmpty()) { inetAddress = InetAddress.getByName(this.getLocalIp()); -@@ -234,46 +_,72 @@ +@@ -231,46 +_,72 @@ if (this.getPort() < 0) { this.setPort(properties.serverPort); } @@ -208,17 +207,17 @@ - this.loadLevel(); + this.loadLevel(this.storageSource.getLevelId()); // CraftBukkit long l = Util.getNanos() - nanos; - String string2 = String.format(Locale.ROOT, "%.3fs", l / 1.0E9); -- LOGGER.info("Done ({})! For help, type \"help\"", string2); -+ LOGGER.info("Done preparing level \"{}\" ({})", this.getLevelIdName(), string2); // Paper - Improve startup message, add total time + String string3 = String.format(Locale.ROOT, "%.3fs", l / 1.0E9); +- LOGGER.info("Done ({})! For help, type \"help\"", string3); ++ LOGGER.info("Done preparing level \"{}\" ({})", this.getLevelIdName(), string3); // Paper - Improve startup message, add total time + this.initPostWorld(); // Paper - don't include plugins in world preparation time if (properties.announcePlayerAchievements != null) { -- this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this); -+ this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(properties.announcePlayerAchievements, this.overworld()); // CraftBukkit - per-world +- this.worldData.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this); ++ this.worldData.getGameRules().set(GameRules.SHOW_ADVANCEMENT_MESSAGES, properties.announcePlayerAchievements, this.overworld()); // Paper - per-world game rules } if (properties.enableQuery) { -@@ -286,7 +_,7 @@ +@@ -283,7 +_,7 @@ this.rconThread = RconThread.create(this); } @@ -227,7 +226,7 @@ Thread thread1 = new Thread(new ServerWatchdog(this)); thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); thread1.setName("Server Watchdog"); -@@ -304,6 +_,12 @@ +@@ -301,6 +_,12 @@ } } @@ -240,7 +239,7 @@ @Override public boolean isEnforceWhitelist() { return this.settings.getProperties().enforceWhitelist.get(); -@@ -321,6 +_,7 @@ +@@ -318,6 +_,7 @@ @Override public void setUsingWhitelist(boolean usingWhitelist) { @@ -248,7 +247,7 @@ this.settings.update(dedicatedServerProperties -> dedicatedServerProperties.whiteList.update(this.registryAccess(), usingWhitelist)); } -@@ -371,7 +_,7 @@ +@@ -368,7 +_,7 @@ @Override public void forceDifficulty() { @@ -257,7 +256,7 @@ } public int viewDistance() { -@@ -427,11 +_,11 @@ +@@ -424,11 +_,11 @@ } if (this.rconThread != null) { @@ -271,7 +270,7 @@ } if (this.jsonRpcServer != null) { -@@ -441,6 +_,9 @@ +@@ -438,6 +_,9 @@ LOGGER.error("Interrupted while stopping the management server", (Throwable)var2); } } @@ -281,7 +280,7 @@ } @Override -@@ -450,12 +_,20 @@ +@@ -447,12 +_,20 @@ } public void handleConsoleInput(String msg, CommandSourceStack source) { @@ -305,7 +304,7 @@ this.getCommands().performPrefixedCommand(consoleInput.source, consoleInput.msg); } } -@@ -601,12 +_,15 @@ +@@ -592,12 +_,15 @@ @Override public String getMotd() { @@ -323,7 +322,7 @@ } @Override -@@ -632,7 +_,11 @@ +@@ -623,7 +_,11 @@ @Override public boolean enforceSecureProfile() { DedicatedServerProperties properties = this.getProperties(); @@ -336,7 +335,7 @@ } @Override -@@ -717,21 +_,60 @@ +@@ -708,21 +_,60 @@ @Override public String getPluginNames() { @@ -402,7 +401,7 @@ } @Override -@@ -863,4 +_,15 @@ +@@ -853,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 6a7a8d321b88..4525693454fd 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -48,6 +_,7 @@ +@@ -50,6 +_,7 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$"); private static final Splitter COMMA_SPLITTER = Splitter.on(',').trimResults(); @@ -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"; -@@ -97,7 +_,7 @@ +@@ -106,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", property -> Mth.clamp(property, 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); -@@ -114,13 +_,16 @@ +@@ -123,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 string = this.get("level-seed", ""); boolean flag = this.get("generate-structures", true); long l = WorldOptions.parseSeed(string).orElse(WorldOptions.randomSeed()); -@@ -141,15 +_,21 @@ +@@ -150,15 +_,21 @@ this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())) ); @@ -62,4 +62,4 @@ + // CraftBukkit end } - @Nullable + private static @Nullable Component parseResourcePackPrompt(String json) { diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch index 7c8135855ecc..f09c795ed4d6 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch @@ -83,19 +83,19 @@ this.properties.store(bufferedWriter, "Minecraft server properties"); } catch (IOException var7) { LOGGER.error("Failed to store properties to file: {}", filePath); -@@ -94,7 +_,7 @@ +@@ -93,7 +_,7 @@ + } - @Nullable - public String getStringRaw(String key) { + public @Nullable String getStringRaw(String key) { - return (String)this.properties.get(key); + return (String)this.getOverride(key, this.properties.getProperty(key)); // CraftBukkit } - @Nullable -@@ -109,6 +_,15 @@ + protected @Nullable V getLegacy(String key, Function serializer) { +@@ -107,6 +_,15 @@ } - protected V get(String key, Function serializer, Function deserializer, V defaultValue) { + protected V get(String key, Function serializer, Function deserializer, V defaultValue) { + // CraftBukkit start + try { + return this.get0(key, serializer, deserializer, defaultValue); @@ -103,12 +103,12 @@ + throw new RuntimeException("Could not load invalidly configured property '" + key + "'", ex); + } + } -+ private V get0(String key, Function serializer, Function deserializer, V defaultValue) { ++ private V get0(String key, Function serializer, Function deserializer, V defaultValue) { + // CraftBukkit end String stringRaw = this.getStringRaw(key); V object = MoreObjects.firstNonNull(stringRaw != null ? serializer.apply(stringRaw) : null, defaultValue); this.properties.put(key, deserializer.apply(object)); -@@ -185,7 +_,7 @@ +@@ -181,7 +_,7 @@ return map; } @@ -117,7 +117,7 @@ public class MutableValue implements Supplier { private final String key; -@@ -206,7 +_,7 @@ +@@ -202,7 +_,7 @@ public T update(RegistryAccess registryAccess, V newValue) { Properties map = Settings.this.cloneProperties(); map.put(this.key, this.serializer.apply(newValue)); 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 ab6d2d8cb54e..40640f3fda1f 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/gui/StatsComponent.java +++ b/net/minecraft/server/gui/StatsComponent.java -@@ -34,8 +_,17 @@ +@@ -32,8 +_,17 @@ private void tick() { long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); @@ -18,7 +18,7 @@ this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory()); this.repaint(); } -@@ -64,4 +_,10 @@ +@@ -62,4 +_,10 @@ public void close() { this.timer.stop(); } diff --git a/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch index 5acedfe81d4f..e8fa089602cf 100644 --- a/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java +++ b/net/minecraft/server/jsonrpc/JsonRpcNotificationService.java -@@ -96,7 +_,8 @@ +@@ -101,7 +_,8 @@ } @Override -- public void onGameRuleChanged(String key, GameRules.Value value) { -+ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value) { // Paper - per-world game rules (add level param) +- public void onGameRuleChanged(GameRule rule, T value) { ++ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value) { // Paper - per-world game rules (add level param) + if (level != level.getServer().overworld()) return; // Paper - per-world game rules - use overworld for vanilla protocol - this.broadcastNotification(OutgoingRpcMethods.GAMERULE_CHANGED, GameRulesService.getTypedRule(this.minecraftApi, key, value)); + this.broadcastNotification(OutgoingRpcMethods.GAMERULE_CHANGED, GameRulesService.getTypedRule(this.minecraftApi, rule, value)); } 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 6cda8047e978..92b7b4e23401 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,24 +1,11 @@ --- a/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java +++ b/net/minecraft/server/jsonrpc/internalapi/MinecraftGameRuleServiceImpl.java -@@ -24,18 +_,18 @@ - net.minecraft.world.level.GameRules.Value ruleValue = this.getRuleValue(rule.key()); - String string = ruleValue.serialize(); - if (ruleValue instanceof net.minecraft.world.level.GameRules.BooleanValue booleanValue) { -- booleanValue.set(Boolean.parseBoolean(rule.value()), this.server); -+ booleanValue.set(Boolean.parseBoolean(rule.value()), this.server.overworld()); // Paper - per-world game rules - use overworld for vanilla protocol - } else { - if (!(ruleValue instanceof net.minecraft.world.level.GameRules.IntegerValue integerValue)) { - throw new InvalidParameterJsonRpcException("Unknown rule type for key: " + rule.key()); - } - -- integerValue.set(Integer.parseInt(rule.value()), this.server); -+ integerValue.set(Integer.parseInt(rule.value()), this.server.overworld()); // Paper - per-world game rules - use overworld for vanilla protocol - } - - GameRulesService.TypedRule typedRule = this.getTypedRule(rule.key(), ruleValue); - this.jsonrpcLogger.log(client, "Game rule '{}' updated from '{}' to '{}'", typedRule.key(), string, typedRule.value()); -- this.server.onGameRuleChanged(rule.key(), ruleValue); -+ this.server.notificationManager().onGameRuleChanged(this.server.overworld(), rule.key(), ruleValue); // Paper - per-world game rules - use overworld for vanilla protocol - return typedRule; +@@ -24,7 +_,7 @@ + GameRule gameRule = update.gameRule(); + T object = this.gameRules.get(gameRule); + T object1 = update.value(); +- this.gameRules.set(gameRule, object1, this.server); ++ this.gameRules.set(gameRule, object1, this.server.overworld()); // Paper - per-world game rules - use overworld for vanilla protocol + this.jsonrpcLogger.log(client, "Game rule '{}' updated from '{}' to '{}'", gameRule.id(), gameRule.serialize(object), gameRule.serialize(object1)); + return update; } - diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch index b3f729b8b573..dbd31018891f 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkHolder.java.patch @@ -32,23 +32,23 @@ public CompletableFuture> getTickingChunkFuture() { return this.tickingChunkFuture; } -@@ -84,7 +_,7 @@ +@@ -83,7 +_,7 @@ + return this.fullChunkFuture; } - @Nullable -- public LevelChunk getTickingChunk() { -+ public final LevelChunk getTickingChunk() { // Paper - final for inline +- public @Nullable LevelChunk getTickingChunk() { ++ public final @Nullable LevelChunk getTickingChunk() { // Paper - final for inline return this.getTickingChunkFuture().getNow(UNLOADED_LEVEL_CHUNK).orElse(null); } -@@ -129,6 +_,7 @@ +@@ -127,6 +_,7 @@ } else { boolean flag = this.hasChangedSections; int sectionIndex = this.levelHeightAccessor.getSectionIndex(pos.getY()); + if (sectionIndex < 0 || sectionIndex >= this.changedBlocksPerSection.length) return false; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 - if (this.changedBlocksPerSection[sectionIndex] == null) { + ShortSet set = this.changedBlocksPerSection[sectionIndex]; + if (set == null) { this.hasChangedSections = true; - this.changedBlocksPerSection[sectionIndex] = new ShortOpenHashSet(); @@ -274,6 +_,38 @@ chunkMap.onFullChunkStatusChange(this.pos, fullChunkStatus); } 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 new file mode 100644 index 000000000000..a6ccc990f4f3 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkLevel.java.patch @@ -0,0 +1,11 @@ +--- 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 eb5307f183f4..9a82881e1e11 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -147,6 +_,33 @@ +@@ -152,6 +_,33 @@ public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -34,7 +34,7 @@ public ChunkMap( ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, -@@ -173,13 +_,19 @@ +@@ -180,13 +_,19 @@ this.level = level; RegistryAccess registryAccess = level.registryAccess(); long seed = level.getSeed(); @@ -56,7 +56,7 @@ this.mainThreadExecutor = mainThreadExecutor; ConsecutiveExecutor consecutiveExecutor = new ConsecutiveExecutor(dispatcher, "worldgen"); this.chunkStatusListener = chunkStatusListener; -@@ -209,6 +_,12 @@ +@@ -215,6 +_,12 @@ this.chunksToEagerlySave.add(chunkPos.toLong()); } @@ -69,7 +69,7 @@ protected ChunkGenerator generator() { return this.worldGenContext.generator(); } -@@ -354,9 +_,9 @@ +@@ -357,9 +_,9 @@ } ); stringBuilder.append("Updating:").append(System.lineSeparator()); @@ -81,7 +81,7 @@ CrashReport crashReport = CrashReport.forThrowable(exception, "Chunk loading"); CrashReportCategory crashReportCategory = crashReport.addCategory("Chunk loading"); crashReportCategory.setDetail("Details", details); -@@ -392,6 +_,7 @@ +@@ -394,6 +_,7 @@ holder.setTicketLevel(newLevel); } else { holder = new ChunkHolder(new ChunkPos(chunkPos), newLevel, this.level, this.lightEngine, this::onLevelChange, this); @@ -89,7 +89,7 @@ } this.updatingChunkMap.put(chunkPos, holder); -@@ -420,8 +_,8 @@ +@@ -422,8 +_,8 @@ protected void saveAllChunks(boolean flush) { if (flush) { @@ -100,7 +100,7 @@ .stream() .filter(ChunkHolder::wasAccessibleSinceLastSave) .peek(ChunkHolder::refreshAccessibility) -@@ -447,7 +_,7 @@ +@@ -449,7 +_,7 @@ this.nextChunkSaveTime.clear(); long millis = Util.getMillis(); @@ -109,7 +109,7 @@ this.saveChunkIfNeeded(chunkHolder, millis); } } -@@ -468,6 +_,7 @@ +@@ -470,6 +_,7 @@ public boolean hasWork() { return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() @@ -117,7 +117,7 @@ || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() -@@ -526,7 +_,11 @@ +@@ -528,7 +_,11 @@ this.scheduleUnload(chunkPos, chunkHolder); } else { ChunkAccess latestChunk = chunkHolder.getLatestChunk(); @@ -130,7 +130,7 @@ if (latestChunk instanceof LevelChunk levelChunk) { levelChunk.setLoaded(false); } -@@ -539,7 +_,9 @@ +@@ -541,7 +_,9 @@ this.lightEngine.updateChunkStatus(latestChunk.getPos()); this.lightEngine.tryScheduleUpdate(); this.nextChunkSaveTime.remove(latestChunk.getPos().toLong()); @@ -141,7 +141,7 @@ } }, this.unloadQueue::add).whenComplete((_void, error) -> { if (error != null) { -@@ -850,7 +_,7 @@ +@@ -848,7 +_,7 @@ } public int size() { @@ -150,7 +150,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -877,10 +_,10 @@ +@@ -875,10 +_,10 @@ .addColumn("fluid_ticks") .build(writer); @@ -164,24 +164,23 @@ Optional optional = Optional.ofNullable(chunkHolder.getLatestChunk()); Optional optional1 = optional.flatMap(chunk -> chunk instanceof LevelChunk ? Optional.of((LevelChunk)chunk) : Optional.empty()); csvOutput.writeRow( -@@ -920,11 +_,13 @@ +@@ -922,12 +_,12 @@ } - private CompletableFuture> readChunk(ChunkPos pos) { -- return this.read(pos).thenApplyAsync(optional -> optional.map(this::upgradeChunkTag), Util.backgroundExecutor().forName("upgradeChunk")); -+ return this.read(pos).thenApplyAsync(optional -> optional.map(tag -> upgradeChunkTag(tag, pos)), Util.backgroundExecutor().forName("upgradeChunk")); // CraftBukkit + private CompoundTag upgradeChunkTag(CompoundTag tag) { +- return this.upgradeChunkTag(tag, -1, getChunkDataFixContextTag(this.level.dimension(), this.generator().getTypeNameForDataFixer())); ++ return this.upgradeChunkTag(tag, -1, getChunkDataFixContextTag(this.level.getTypeKey(), this.generator().getTypeNameForDataFixer()), this.level); // CraftBukkit } -- private CompoundTag upgradeChunkTag(CompoundTag tag) { -- return this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, tag, this.generator().getTypeNameForDataFixer()); -+ // CraftBukkit start -+ private CompoundTag upgradeChunkTag(CompoundTag tag, ChunkPos pos) { -+ return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, tag, this.generator().getTypeNameForDataFixer(), pos, this.level); -+ // CraftBukkit end +- public static CompoundTag getChunkDataFixContextTag(ResourceKey dimension, Optional>> generator) { ++ public static CompoundTag getChunkDataFixContextTag(ResourceKey stemKey, Optional>> generator) { // CraftBukkit + CompoundTag compoundTag = new CompoundTag(); +- compoundTag.putString("dimension", dimension.identifier().toString()); ++ compoundTag.putString("dimension", stemKey.identifier().toString()); // CraftBukkit + generator.ifPresent(resourceKey -> compoundTag.putString("generator", resourceKey.identifier().toString())); + return compoundTag; } - - void collectSpawningChunks(List output) { -@@ -934,7 +_,7 @@ +@@ -939,7 +_,7 @@ ChunkHolder chunkHolder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); if (chunkHolder != null) { LevelChunk tickingChunk = chunkHolder.getTickingChunk(); @@ -190,7 +189,7 @@ output.add(tickingChunk); } } -@@ -954,13 +_,35 @@ +@@ -959,8 +_,14 @@ } public boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos) { @@ -205,6 +204,10 @@ + // Spigot end } + boolean anyPlayerCloseEnoughTo(BlockPos pos, int radius) { +@@ -976,8 +_,24 @@ + } + private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkPos) { + // Spigot start + return this.anyPlayerCloseEnoughForSpawningInternal(chunkPos, false); @@ -228,7 +231,7 @@ return true; } } -@@ -976,7 +_,7 @@ +@@ -993,7 +_,7 @@ Builder builder = ImmutableList.builder(); for (ServerPlayer serverPlayer : this.playerMap.getAllPlayers()) { @@ -237,7 +240,7 @@ builder.add(serverPlayer); } } -@@ -985,12 +_,12 @@ +@@ -1002,12 +_,12 @@ } } @@ -252,7 +255,7 @@ } } -@@ -1112,9 +_,19 @@ +@@ -1138,9 +_,19 @@ } public void addEntity(Entity entity) { @@ -272,7 +275,7 @@ if (i != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1138,6 +_,7 @@ +@@ -1164,6 +_,7 @@ } protected void removeEntity(Entity entity) { @@ -280,7 +283,7 @@ if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, false); -@@ -1299,10 +_,10 @@ +@@ -1323,10 +_,10 @@ final Entity entity; private final int range; SectionPos lastSectionPos; @@ -293,7 +296,7 @@ this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1349,6 +_,7 @@ +@@ -1373,6 +_,7 @@ } public void removePlayer(ServerPlayer player) { @@ -301,7 +304,7 @@ if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); if (this.seenBy.isEmpty()) { -@@ -1358,23 +_,45 @@ +@@ -1382,23 +_,45 @@ } public void updatePlayer(ServerPlayer player) { @@ -352,7 +355,7 @@ } } else { this.removePlayer(player); -@@ -1391,6 +_,7 @@ +@@ -1415,6 +_,7 @@ for (Entity entity : this.entity.getIndirectPassengers()) { int i1 = entity.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch index 8c9d908d0583..0ef527512714 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -74,6 +_,12 @@ +@@ -72,6 +_,12 @@ } if (!this.chunksToUpdateFutures.isEmpty()) { @@ -13,7 +13,7 @@ for (ChunkHolder chunkHolder : this.chunksToUpdateFutures) { chunkHolder.updateHighestAllowedStatus(chunkMap); } -@@ -123,8 +_,10 @@ +@@ -121,8 +_,10 @@ ChunkPos chunkPos = sectionPos.chunk(); long packedChunkPos = chunkPos.toLong(); ObjectSet set = this.playersPerChunk.get(packedChunkPos); 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 fe2eeb0f53b5..ba090aa9250e 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 @@ -6,6 +6,6 @@ public static CompletableFuture findSpawn(ServerLevel level, BlockPos pos) { - if (level.dimensionType().hasSkyLight() && level.getServer().getWorldData().getGameType() != GameType.ADVENTURE) { + if (level.dimensionType().hasSkyLight() && level.serverLevelData.getGameType() != GameType.ADVENTURE) { // CraftBukkit - int max = Math.max(0, level.getGameRules().getInt(GameRules.RULE_SPAWN_RADIUS)); + int max = Math.max(0, level.getGameRules().get(GameRules.RESPAWN_RADIUS)); int floor = Mth.floor(level.getWorldBorder().getDistanceToBorder(pos.getX(), pos.getZ())); if (floor < max) { 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 a1623773c6c5..90afddb38210 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 @@ -1,17 +1,17 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -68,6 +_,7 @@ +@@ -67,6 +_,7 @@ private final TicketStorage ticketStorage; private long lastInhabitedUpdate; public boolean spawnEnemies = true; + public boolean spawnFriendlies = true; // Paper - add back spawnFriendlies field private static final int CACHE_SIZE = 4; private final long[] lastChunkPos = new long[4]; - private final ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; -@@ -77,6 +_,13 @@ - @Nullable + private final @Nullable ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; +@@ -75,6 +_,13 @@ + private final Set chunkHoldersToBroadcast = new ReferenceOpenHashSet<>(); @VisibleForDebug - private NaturalSpawner.SpawnState lastSpawnState; + private NaturalSpawner.@Nullable SpawnState lastSpawnState; + // Paper start + public final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>(); + public int getFullChunksCount() { @@ -22,7 +22,7 @@ public ServerChunkCache( ServerLevel level, -@@ -125,6 +_,64 @@ +@@ -123,6 +_,64 @@ this.clearCache(); } @@ -87,7 +87,7 @@ @Override public ThreadedLevelLightEngine getLightEngine() { return this.lightEngine; -@@ -160,7 +_,7 @@ +@@ -156,7 +_,7 @@ for (int i = 0; i < 4; i++) { if (packedChunkPos == this.lastChunkPos[i] && chunkStatus == this.lastChunkStatus[i]) { ChunkAccess chunkAccess = this.lastChunk[i]; @@ -96,7 +96,7 @@ return chunkAccess; } } -@@ -169,6 +_,7 @@ +@@ -165,6 +_,7 @@ profilerFiller.incrementCounter("getChunkCacheMiss"); CompletableFuture> chunkFutureMainThread = this.getChunkFutureMainThread(x, z, chunkStatus, requireChunk); this.mainThreadProcessor.managedBlock(chunkFutureMainThread::isDone); @@ -104,7 +104,7 @@ ChunkResult chunkResult = chunkFutureMainThread.join(); ChunkAccess chunkAccess1 = chunkResult.orElse(null); if (chunkAccess1 == null && requireChunk) { -@@ -240,7 +_,15 @@ +@@ -235,7 +_,15 @@ long packedChunkPos = chunkPos.toLong(); int i = ChunkLevel.byStatus(chunkStatus); ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(packedChunkPos); @@ -121,7 +121,7 @@ this.addTicket(new Ticket(TicketType.UNKNOWN, i), chunkPos); if (this.chunkAbsent(visibleChunkIfPresent, i)) { ProfilerFiller profilerFiller = Profiler.get(); -@@ -260,7 +_,7 @@ +@@ -255,7 +_,7 @@ } private boolean chunkAbsent(@Nullable ChunkHolder chunkHolder, int status) { @@ -130,7 +130,7 @@ } @Override -@@ -315,17 +_,39 @@ +@@ -309,17 +_,39 @@ @Override public void close() throws IOException { @@ -172,18 +172,18 @@ this.ticketStorage.purgeStaleTickets(this.chunkMap); } -@@ -381,12 +_,20 @@ +@@ -375,12 +_,20 @@ naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap) ); this.lastSpawnState = spawnState; -- boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); -+ boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); +- boolean flag = this.level.getGameRules().get(GameRules.SPAWN_MOBS); ++ boolean flag = this.level.getGameRules().get(GameRules.SPAWN_MOBS) && !this.level.players().isEmpty(); // CraftBukkit + int i = this.level.getGameRules().get(GameRules.RANDOM_TICK_SPEED); List filteredSpawningCategories; -- if (_boolean) { -- boolean flag = this.level.getLevelData().getGameTime() % 400L == 0L; -- filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, true, this.spawnEnemies, flag); -+ if (_boolean && (this.spawnEnemies || this.spawnFriendlies)) { // Paper +- if (flag) { +- boolean flag1 = this.level.getGameTime() % 400L == 0L; +- filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, true, this.spawnEnemies, flag1); ++ if (flag && (this.spawnEnemies || this.spawnFriendlies)) { // Paper + // Paper start - PlayerNaturallySpawnCreaturesEvent + for (ServerPlayer entityPlayer : this.level.players()) { + int chunkRange = Math.min(level.spigotConfig.mobSpawnRange, entityPlayer.getBukkitEntity().getViewDistance()); @@ -192,12 +192,12 @@ + entityPlayer.playerNaturallySpawnedEvent.callEvent(); + } + // Paper end - PlayerNaturallySpawnCreaturesEvent -+ boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit -+ filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, this.spawnFriendlies, this.spawnEnemies, flag, this.level); // CraftBukkit ++ boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit ++ filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit } else { filteredSpawningCategories = List.of(); } -@@ -559,7 +_,13 @@ +@@ -553,7 +_,13 @@ @Override public void setSpawnSettings(boolean spawnSettings) { @@ -211,7 +211,7 @@ } public String getChunkDebugData(ChunkPos chunkPos) { -@@ -632,12 +_,18 @@ +@@ -625,12 +_,18 @@ @Override public 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 700e812b324d..d0eb6ed42506 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -65,13 +_,15 @@ +@@ -65,12 +_,14 @@ private Vec3 lastSentMovement; private int tickCount; private int teleportDelay; @@ -8,8 +8,7 @@ + private List lastPassengers = com.google.common.collect.ImmutableList.of(); // Paper - optimize passenger checks private boolean wasRiding; private boolean wasOnGround; - @Nullable - private List> trackedDataValues; + private @Nullable List> trackedDataValues; + private final Set trackedPlayers; // Paper - public ServerEntity(ServerLevel level, Entity entity, int updateInterval, boolean trackDelta, ServerEntity.Synchronizer synchronizer) { @@ -86,9 +85,9 @@ this.entity.hurtMarked = false; this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityMotionPacket(this.entity)); } -@@ -268,7 +_,10 @@ - +@@ -269,7 +_,10 @@ public void sendPairingData(ServerPlayer player, Consumer> consumer) { + this.entity.updateDataBeforeSync(); if (this.entity.isRemoved()) { - LOGGER.warn("Fetching packet for removed entity {}", this.entity); + // CraftBukkit start - Remove useless error spam, just return @@ -98,7 +97,7 @@ } Packet addEntityPacket = this.entity.getAddEntityPacket(this); -@@ -279,6 +_,11 @@ +@@ -280,6 +_,11 @@ if (this.entity instanceof LivingEntity livingEntity) { Collection syncableAttributes = livingEntity.getAttributes().getSyncableAttributes(); @@ -110,7 +109,7 @@ if (!syncableAttributes.isEmpty()) { consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes)); } -@@ -295,8 +_,9 @@ +@@ -296,8 +_,9 @@ } if (!list.isEmpty()) { @@ -121,7 +120,7 @@ } if (!this.entity.getPassengers().isEmpty()) { -@@ -343,6 +_,11 @@ +@@ -344,6 +_,11 @@ if (this.entity instanceof LivingEntity) { Set attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync(); if (!attributesToSync.isEmpty()) { 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 c1e8249b8bd8..1bbc0a2e82a1 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 -@@ -187,7 +_,7 @@ +@@ -193,7 +_,7 @@ final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; @@ -8,8 +8,8 @@ + public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type final EntityTickList entityTickList = new EntityTickList(); private final ServerWaypointManager waypointManager; - public final PersistentEntitySectionManager entityManager; -@@ -215,25 +_,170 @@ + private final EnvironmentAttributeSystem environmentAttributes; +@@ -221,25 +_,170 @@ private final RandomSequences randomSequences; final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); @@ -154,7 +154,7 @@ ) { - super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates()); + // CraftBukkit start -+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs ++ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.identifier(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs + this.levelStorageAccess = levelStorageAccess; + this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); + this.levelLoadListener = new net.minecraft.server.level.progress.LoggingLevelLoadListener(false, this); @@ -183,7 +183,7 @@ boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityPersistentStorage = new EntityStorage( -@@ -255,8 +_,8 @@ +@@ -261,8 +_,8 @@ server.getStructureManager(), dispatcher, chunkGenerator, @@ -194,7 +194,7 @@ flag, this.entityManager::updateChunkStatus, () -> server.overworld().getDataStorage() -@@ -275,7 +_,7 @@ +@@ -283,7 +_,7 @@ this.chunkSource.chunkScanner(), this.registryAccess(), server.getStructureManager(), @@ -203,7 +203,7 @@ chunkGenerator, this.chunkSource.randomState(), this, -@@ -283,9 +_,9 @@ +@@ -291,9 +_,9 @@ seed, fixerUpper ); @@ -216,10 +216,10 @@ } else { this.dragonFight = null; } -@@ -294,7 +_,15 @@ - this.gameEventDispatcher = new GameEventDispatcher(this); - this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); +@@ -304,7 +_,15 @@ this.waypointManager = new ServerWaypointManager(); + this.environmentAttributes = EnvironmentAttributeSystem.builder().addDefaultLayers(this).build(); + this.updateSkyBrightness(); - } + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + } @@ -233,7 +233,7 @@ @Deprecated @VisibleForTesting -@@ -306,8 +_,8 @@ +@@ -316,8 +_,8 @@ this.serverLevelData.setClearWeatherTime(clearTime); this.serverLevelData.setRainTime(weatherTime); this.serverLevelData.setThunderTime(weatherTime); @@ -244,10 +244,10 @@ } @Override -@@ -334,12 +_,25 @@ +@@ -349,12 +_,25 @@ - int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); - if (this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) { + int i = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE); + if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { + // Paper start - create time skip event - move up calculations + final long newDayTime = this.levelData.getDayTime() + 24000L; + org.bukkit.event.world.TimeSkipEvent event = new org.bukkit.event.world.TimeSkipEvent( @@ -256,7 +256,7 @@ + (newDayTime - newDayTime % 24000L) - this.getDayTime() + ); + // Paper end - create time skip event - move up calculations - if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + if (this.getGameRules().get(GameRules.ADVANCE_TIME)) { - long l = this.levelData.getDayTime() + 24000L; - this.setDayTime(l - l % 24000L); + // Paper start - call time skip event if gamerule is enabled @@ -270,10 +270,10 @@ - this.wakeUpAllPlayers(); + if (!event.isCancelled()) this.wakeUpAllPlayers(); // Paper - only wake up players if time skip event is not cancelled - if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { + if (this.getGameRules().get(GameRules.ADVANCE_WEATHER) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -354,9 +_,9 @@ +@@ -369,9 +_,9 @@ if (!this.isDebug() && runsNormally) { long l = this.getGameTime(); profilerFiller.push("blockTicks"); @@ -285,7 +285,7 @@ profilerFiller.pop(); } -@@ -374,7 +_,7 @@ +@@ -389,7 +_,7 @@ this.handlingTick = false; profilerFiller.pop(); @@ -294,7 +294,7 @@ if (hasActiveTickets) { this.resetEmptyTime(); } -@@ -478,11 +_,13 @@ +@@ -498,11 +_,13 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("iceandsnow"); @@ -308,7 +308,7 @@ profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { -@@ -525,12 +_,12 @@ +@@ -545,12 +_,12 @@ int minBlockZ = pos.getMinBlockZ(); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("thunder"); @@ -317,13 +317,13 @@ BlockPos blockPos = this.findLightningTargetAround(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); if (this.isRainingAt(blockPos)) { DifficultyInstance currentDifficultyAt = this.getCurrentDifficultyAt(blockPos); - boolean flag = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) + boolean flag = this.getGameRules().get(GameRules.SPAWN_MOBS) - && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * 0.01 + && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01) // Paper - Configurable spawn chances for skeleton horses && !this.getBlockState(blockPos.below()).is(BlockTags.LIGHTNING_RODS); if (flag) { SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -538,7 +_,7 @@ +@@ -558,7 +_,7 @@ skeletonHorse.setTrap(true); skeletonHorse.setAge(0); skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); @@ -332,7 +332,7 @@ } } -@@ -546,7 +_,7 @@ +@@ -566,7 +_,7 @@ if (lightningBolt != null) { lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos)); lightningBolt.setVisualOnly(flag); @@ -341,7 +341,7 @@ } } } -@@ -560,7 +_,7 @@ +@@ -580,7 +_,7 @@ BlockPos blockPos = heightmapPos.below(); Biome biome = this.getBiome(heightmapPos).value(); if (biome.shouldFreeze(this, blockPos)) { @@ -350,8 +350,8 @@ } if (this.isRaining()) { -@@ -572,10 +_,10 @@ - if (layersValue < Math.min(_int, 8)) { +@@ -592,10 +_,10 @@ + if (layersValue < Math.min(i, 8)) { BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1); Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos); - this.setBlockAndUpdate(heightmapPos, blockState1); @@ -363,7 +363,7 @@ } } -@@ -600,6 +_,12 @@ +@@ -620,6 +_,12 @@ } protected BlockPos findLightningTargetAround(BlockPos pos) { @@ -376,12 +376,12 @@ BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional optional = this.findLightningRod(heightmapPos); if (optional.isPresent()) { -@@ -607,11 +_,12 @@ +@@ -627,11 +_,12 @@ } else { AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0); List entitiesOfClass = this.getEntitiesOfClass( -- LivingEntity.class, aabb, entity -> entity != null && entity.isAlive() && this.canSeeSky(entity.blockPosition()) -+ LivingEntity.class, aabb, entity -> entity != null && entity.isAlive() && this.canSeeSky(entity.blockPosition()) && !entity.isSpectator() // Paper - Fix lightning being able to hit spectators (MC-262422) +- LivingEntity.class, aabb, entity -> entity.isAlive() && this.canSeeSky(entity.blockPosition()) ++ LivingEntity.class, aabb, entity -> entity.isAlive() && this.canSeeSky(entity.blockPosition()) && !entity.isSpectator() // Paper - Fix lightning being able to hit spectators (MC-262422) ); if (!entitiesOfClass.isEmpty()) { return entitiesOfClass.get(this.random.nextInt(entitiesOfClass.size())).blockPosition(); @@ -390,7 +390,7 @@ if (heightmapPos.getY() == this.getMinY() - 1) { heightmapPos = heightmapPos.above(2); } -@@ -702,8 +_,8 @@ +@@ -740,8 +_,8 @@ this.serverLevelData.setThunderTime(thunderTime); this.serverLevelData.setRainTime(rainTime); this.serverLevelData.setClearWeatherTime(clearWeatherTime); @@ -401,7 +401,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -724,6 +_,7 @@ +@@ -762,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -409,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -746,14 +_,47 @@ +@@ -784,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -461,7 +461,7 @@ } public void resetEmptyTime() { -@@ -775,18 +_,46 @@ +@@ -813,18 +_,46 @@ } } @@ -508,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -795,10 +_,12 @@ +@@ -833,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -521,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -829,6 +_,7 @@ +@@ -867,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -529,7 +529,7 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -845,11 +_,18 @@ +@@ -883,11 +_,18 @@ this.entityManager.autoSave(); } } @@ -549,7 +549,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -914,18 +_,40 @@ +@@ -951,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -559,7 +559,7 @@ + } + + @Override -+ public boolean addFreshEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end } @@ -570,7 +570,7 @@ + return this.addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public boolean addWithUUID(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addWithUUID(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end } @@ -583,7 +583,7 @@ + this.addDuringTeleport(entity, null); + } + -+ public void addDuringTeleport(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public void addDuringTeleport(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + // CraftBukkit end if (entity instanceof ServerPlayer serverPlayer) { this.addPlayer(serverPlayer); @@ -593,13 +593,13 @@ } } -@@ -948,41 +_,120 @@ +@@ -985,41 +_,120 @@ this.entityManager.addNewEntity(player); } - private boolean addEntity(Entity entity) { + // CraftBukkit start -+ private boolean addEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ private boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason spawnReason) { + org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot + entity.generation = false; // Paper - Don't fire sync event during generation; Reset flag if it was added during a ServerLevel generation process + // Paper start - extra debug info @@ -707,7 +707,7 @@ + } + // Paper end - Add BlockBreakProgressUpdateEvent for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { - if (serverPlayer != null && serverPlayer.level() == this && serverPlayer.getId() != breakerId) { + if (serverPlayer.level() == this && serverPlayer.getId() != breakerId) { double d = pos.getX() - serverPlayer.getX(); double d1 = pos.getY() - serverPlayer.getY(); double d2 = pos.getZ() - serverPlayer.getZ(); @@ -719,7 +719,7 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1057,7 +_,7 @@ +@@ -1094,7 +_,7 @@ pos.getX(), pos.getY(), pos.getZ(), @@ -728,7 +728,7 @@ this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false) ); -@@ -1069,6 +_,11 @@ +@@ -1106,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -740,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1081,17 +_,28 @@ +@@ -1118,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -769,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1103,15 +_,23 @@ +@@ -1140,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -793,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1161,6 +_,44 @@ +@@ -1198,6 +_,44 @@ WeightedList blockParticles, Holder explosionSound ) { @@ -832,15 +832,15 @@ + ParticleOptions largeExplosionParticles, + WeightedList blockParticles, + Holder explosionSound, -+ @Nullable java.util.function.Consumer configurator ++ java.util.function.@Nullable Consumer configurator + ) { + // CraftBukkit end Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; - case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -@@ -1169,10 +_,17 @@ + case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY); +@@ -1206,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; - case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); + case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; + case STANDARD -> Explosion.BlockInteraction.DESTROY; // CraftBukkit - handle custom explosion type }; @@ -856,7 +856,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1181,6 +_,8 @@ +@@ -1218,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); } } @@ -864,8 +864,8 @@ + return serverExplosion; // CraftBukkit } - private Explosion.BlockInteraction getDestroyType(GameRules.Key decayGameRule) { -@@ -1251,19 +_,55 @@ + private Explosion.BlockInteraction getDestroyType(GameRule decayGameRule) { +@@ -1287,19 +_,55 @@ public int sendParticles( T options, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed ) { @@ -924,19 +924,19 @@ if (this.sendParticles(serverPlayer, overrideLimiter, x, y, z, clientboundLevelParticlesPacket)) { i++; } -@@ -1352,7 +_,7 @@ +@@ -1383,7 +_,7 @@ + } - @Nullable - public BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { + public @Nullable BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipKnownStructures) { - if (!this.server.getWorldData().worldGenOptions().generateStructures()) { + if (!this.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1404,10 +_,36 @@ - @Nullable +@@ -1435,10 +_,36 @@ + @Override - public MapItemSavedData getMapData(MapId mapId) { + public @Nullable MapItemSavedData getMapData(MapId mapId) { - return this.getServer().overworld().getDataStorage().get(MapItemSavedData.type(mapId)); + // Paper start - Call missing map initialize event and set id + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); @@ -971,7 +971,7 @@ this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1417,7 +_,19 @@ +@@ -1448,7 +_,19 @@ @Override public void setRespawnData(LevelData.RespawnData respawnData) { @@ -992,7 +992,7 @@ } @Override -@@ -1454,6 +_,11 @@ +@@ -1485,6 +_,11 @@ this.debugSynchronizers.dropPoi(blockPos); })); optional1.ifPresent(holder -> this.getServer().execute(() -> { @@ -1004,7 +1004,7 @@ PoiRecord poiRecord = this.getPoiManager().add(blockPos, (Holder)holder); if (poiRecord != null) { this.debugSynchronizers.registerPoi(poiRecord); -@@ -1608,12 +_,12 @@ +@@ -1638,12 +_,12 @@ } public boolean isFlat() { @@ -1018,8 +1018,8 @@ + return this.serverLevelData.worldGenOptions().seed(); // CraftBukkit } - @Nullable -@@ -1664,6 +_,7 @@ + public @Nullable EndDragonFight getDragonFight() { +@@ -1693,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1027,13 +1027,13 @@ return this.entityManager.getEntityGetter(); } -@@ -1772,6 +_,28 @@ +@@ -1808,6 +_,28 @@ return this.serverLevelData.getGameRules(); } + // Paper start - respect global sound events gamerule + public List getPlayersForGlobalSoundGamerule() { -+ return this.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players(); ++ return this.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players(); + } + + public double getGlobalSoundRangeSquared(java.util.function.Function rangeFunction) { @@ -1056,7 +1056,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1800,6 +_,7 @@ +@@ -1852,6 +_,7 @@ if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) { ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter); } @@ -1064,7 +1064,7 @@ } @Override -@@ -1813,17 +_,24 @@ +@@ -1865,17 +_,24 @@ @Override public void onTickingStart(Entity entity) { @@ -1076,7 +1076,7 @@ public void onTickingEnd(Entity entity) { ServerLevel.this.entityTickList.remove(entity); + // Paper start - Reset pearls when they stop being ticked -+ if (ServerLevel.this.paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && ServerLevel.this.paperConfig().misc.legacyEnderPearlBehavior && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) { ++ if (ServerLevel.this.paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && ServerLevel.this.paperConfig().misc.legacyEnderPearlBehavior && entity instanceof net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl pearl) { + pearl.setOwner(null); + } + // Paper end - Reset pearls when they stop being ticked @@ -1090,7 +1090,7 @@ if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); if (serverPlayer.isReceivingWaypoints()) { -@@ -1838,7 +_,7 @@ +@@ -1890,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1099,7 +1099,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1855,10 +_,52 @@ +@@ -1907,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1152,7 +1152,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1867,7 +_,7 @@ +@@ -1919,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1161,7 +1161,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1885,6 +_,15 @@ +@@ -1937,6 +_,15 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); ServerLevel.this.debugSynchronizers.dropEntity(entity); @@ -1177,7 +1177,7 @@ } @Override -@@ -1892,4 +_,24 @@ +@@ -1944,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 749a6ba25710..3bb9f5251dd3 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,16 +1,16 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -254,7 +_,8 @@ +@@ -251,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; - public String language = "en_us"; + public String language = null; // Paper - default to null + public java.util.Locale adventure$locale = java.util.Locale.US; // Paper - @Nullable - private Vec3 startingToFallPosition; - @Nullable -@@ -303,6 +_,13 @@ + private @Nullable Vec3 startingToFallPosition; + private @Nullable Vec3 enteredNetherPosition; + private @Nullable Vec3 enteredLavaOnVehiclePosition; +@@ -295,6 +_,13 @@ } } @@ -24,7 +24,7 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack stack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, stack)); -@@ -338,6 +_,32 @@ +@@ -330,6 +_,32 @@ } } @@ -57,7 +57,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -366,10 +_,43 @@ +@@ -356,10 +_,43 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -77,7 +77,7 @@ + public int patrolSpawnDelay; // Paper - Pillager patrol spawn settings and per player options + // Paper start - cancellable death event + public boolean queueHealthUpdatePacket; -+ public @Nullable net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; ++ public net.minecraft.network.protocol.game.@Nullable ClientboundSetHealthPacket queuedHealthUpdatePacket; + // Paper end - cancellable death event + // CraftBukkit start + public @Nullable String lastKnownName; // Better rename detection @@ -96,12 +96,12 @@ + public boolean suppressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready + // CraftBukkit end + public boolean isRealPlayer; // Paper -+ public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent -+ public @Nullable org.bukkit.event.player.PlayerQuitEvent.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 ++ 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 public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); -@@ -380,8 +_,14 @@ +@@ -370,8 +_,14 @@ this.recipeBook = new ServerRecipeBook((recipe, output) -> server.getRecipeManager().listDisplaysForRecipe(recipe, output)); this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -117,7 +117,7 @@ } @Override -@@ -399,6 +_,7 @@ +@@ -389,6 +_,7 @@ this.seenCredits = input.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC) .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent())); @@ -125,7 +125,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -@@ -406,6 +_,19 @@ +@@ -396,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)); -@@ -433,12 +_,24 @@ +@@ -423,12 +_,24 @@ if (!this.getShoulderEntityRight().isEmpty()) { output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight()); } @@ -171,7 +171,7 @@ ValueOutput valueOutput = output.child("RootVehicle"); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID()); rootVehicle.save(valueOutput.child("Entity")); -@@ -450,7 +_,7 @@ +@@ -440,7 +_,7 @@ if (!optional.isEmpty()) { ServerLevel serverLevel = this.level(); Entity entity = EntityType.loadEntityRecursive( @@ -180,7 +180,7 @@ ); if (entity != null) { UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null); -@@ -467,10 +_,10 @@ +@@ -457,10 +_,10 @@ if (!this.isPassenger()) { LOGGER.warn("Couldn't reattach entity to player"); @@ -193,7 +193,7 @@ } } } -@@ -482,6 +_,7 @@ +@@ -472,6 +_,7 @@ ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls"); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -201,7 +201,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -514,6 +_,16 @@ +@@ -504,6 +_,16 @@ } } @@ -218,7 +218,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -571,6 +_,11 @@ +@@ -568,6 +_,11 @@ @Override public void tick() { @@ -227,10 +227,10 @@ + this.joining = false; + } + // CraftBukkit end - this.tickClientLoadTimeout(); + this.connection.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -578,9 +_,18 @@ +@@ -575,9 +_,18 @@ this.invulnerableTime--; } @@ -252,7 +252,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -639,10 +_,10 @@ +@@ -636,10 +_,10 @@ public void doTick() { try { @@ -265,7 +265,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -672,7 +_,7 @@ +@@ -669,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; -@@ -703,6 +_,12 @@ +@@ -700,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -287,7 +287,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -716,6 +_,21 @@ +@@ -713,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -309,8 +309,8 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -740,7 +_,7 @@ - if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { +@@ -737,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()) { - this.heal(1.0F); @@ -318,7 +318,7 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -760,6 +_,7 @@ +@@ -757,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); if (this.fallDistance > 0.5 || this.isInWater() || this.getAbilities().flying || this.isSleeping() || this.isInPowderSnow) { @@ -326,7 +326,7 @@ this.removeEntitiesOnShoulder(); } } -@@ -804,35 +_,64 @@ +@@ -801,35 +_,64 @@ @Override public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -398,7 +398,7 @@ } @Override -@@ -869,15 +_,36 @@ +@@ -866,15 +_,36 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { @@ -408,8 +408,8 @@ - @Override - public void die(DamageSource damageSource) { - this.gameEvent(GameEvent.ENTITY_DIE); -- boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); -- if (_boolean) { +- boolean flag = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); +- if (flag) { - Component deathMessage = this.getCombatTracker().getDeathMessage(); + this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points)); // CraftBukkit - Use our scores instead + } @@ -444,7 +444,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -894,6 +_,65 @@ +@@ -891,6 +_,65 @@ } ) ); @@ -456,13 +456,13 @@ + @Override + public void die(DamageSource damageSource) { + // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check -+ boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); final boolean showDeathMessage = _boolean; // Paper - OBFHELPER ++ boolean flag = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); final boolean showDeathMessage = flag; // Paper - OBFHELPER + // CraftBukkit start - fire PlayerDeathEvent + if (this.isRemoved()) { + return; + } + List loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior -+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); ++ boolean keepInventory = this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || this.isSpectator(); + if (!keepInventory) { + for (ItemStack item : this.getInventory().getContents()) { + if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { @@ -510,7 +510,7 @@ Team team = this.getTeam(); if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); -@@ -903,7 +_,7 @@ +@@ -900,7 +_,7 @@ this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); } } else { @@ -519,7 +519,7 @@ } this.removeEntitiesOnShoulder(); -@@ -911,11 +_,35 @@ +@@ -908,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -558,7 +558,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -949,10 +_,10 @@ +@@ -946,10 +_,10 @@ if (entity != this) { super.awardKillScore(entity, damageSource); Scoreboard scoreboard = this.level().getScoreboard(); @@ -571,7 +571,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -964,12 +_,11 @@ +@@ -961,12 +_,11 @@ } private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] criteria) { @@ -586,7 +586,7 @@ } } } -@@ -980,9 +_,20 @@ +@@ -977,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -609,15 +609,15 @@ } } -@@ -992,25 +_,95 @@ +@@ -989,25 +_,95 @@ } private boolean isPvpAllowed() { -- return this.server.isPvpAllowed(); +- return this.level().isPvpAllowed(); - } - - public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean useCharge, TeleportTransition.PostTeleportTransition postTeleportTransition) { -+ return this.level().getWorld().getPVP(); // CraftBukkit - this.server.isPvpAllowed() -> this.level().getWorld().getPVP() ++ return this.level().getWorld().getPVP(); // CraftBukkit - this.level().isPvpAllowed() -> this.level().getWorld().getPVP() + } + + // Paper start @@ -713,9 +713,9 @@ } public boolean isReceivingWaypoints() { -@@ -1043,14 +_,16 @@ - Block block = blockState.getBlock(); - if (block instanceof RespawnAnchorBlock && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) && RespawnAnchorBlock.canSetSpawn(level)) { +@@ -1042,14 +_,16 @@ + && (flag || blockState.getValue(RespawnAnchorBlock.CHARGE) > 0) + && RespawnAnchorBlock.canSetSpawn(level, blockPos)) { Optional optional = RespawnAnchorBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos); + Runnable consumeAnchorCharge = null; // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) if (!flag && useCharge && optional.isPresent()) { @@ -726,14 +726,14 @@ - return optional.map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F)); + return optional.map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F, false, true, finalConsumeAnchorCharge)); // Paper - Fix SPIGOT-5989 (don't use charge until after respawn event) - } else if (block instanceof BedBlock && BedBlock.canSetSpawn(level)) { + } else if (block instanceof BedBlock && level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, blockPos).canSetSpawn(level)) { return BedBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos, blockState.getValue(BedBlock.FACING), yaw) - .map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F)); + .map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, 0.0F, true, false, null)); // Paper - Fix SPIGOT-5989 } else if (!flag) { return Optional.empty(); } else { -@@ -1058,7 +_,7 @@ +@@ -1057,7 +_,7 @@ BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 @@ -742,15 +742,15 @@ : Optional.empty(); } } -@@ -1076,6 +_,7 @@ - @Nullable +@@ -1074,6 +_,7 @@ + @Override - public ServerPlayer teleport(TeleportTransition teleportTransition) { + public @Nullable ServerPlayer teleport(TeleportTransition teleportTransition) { + if (this.isSleeping()) return null; // CraftBukkit - SPIGOT-3154 if (this.isRemoved()) { return null; } else { -@@ -1085,13 +_,48 @@ +@@ -1083,13 +_,48 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.level(); @@ -802,7 +802,7 @@ this.connection.resetPosition(); teleportTransition.postTeleportTransition().onTransition(this); return this; -@@ -1102,18 +_,19 @@ +@@ -1100,18 +_,19 @@ this.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); PlayerList playerList = this.server.getPlayerList(); playerList.sendPlayerPermissionLevel(this); @@ -824,7 +824,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1128,6 +_,15 @@ +@@ -1126,6 +_,15 @@ this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -840,7 +840,7 @@ return this; } } -@@ -1142,12 +_,26 @@ +@@ -1140,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -870,39 +870,44 @@ this.enteredNetherPosition = null; } } -@@ -1163,12 +_,11 @@ +@@ -1161,11 +_,12 @@ this.containerMenu.broadcastChanges(); } - @Override - public Either startSleepInBed(BlockPos bedPos) { - Direction direction = this.level().getBlockState(bedPos).getValue(HorizontalDirectionalBlock.FACING); +- if (!this.isSleeping() && this.isAlive()) { +- BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); + // CraftBukkit start - moved bed result checks from below into separate method + private Either getBedResult(BlockPos bedPos, Direction direction) { - if (this.isSleeping() || !this.isAlive()) { - return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -- } else if (!this.level().dimensionType().natural()) { -+ } else if (!this.level().dimensionType().natural() && !this.level().dimensionType().bedWorks()) { // CraftBukkit - moved bed result checks from below into separate method - return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_HERE); - } else if (!this.bedInRange(bedPos, direction)) { - return Either.left(Player.BedSleepingProblem.TOO_FAR_AWAY); -@@ -1176,7 +_,7 @@ - return Either.left(Player.BedSleepingProblem.OBSTRUCTED); - } else { - this.setRespawnPosition( -- new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true -+ new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED // Paper - Add PlayerSetSpawnEvent - ); - if (this.level().isBrightOutside()) { - return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); -@@ -1196,7 +_,34 @@ - } ++ BedRule bedRule = this.level().environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, bedPos); ++ if (bedRule.explodes()) { ++ return Either.left(Player.BedSleepingProblem.EXPLOSION); ++ } else if (!this.isSleeping() && this.isAlive()) { + boolean canSleep = bedRule.canSleep(this.level()); + boolean canSetSpawn = bedRule.canSetSpawn(this.level()); + if (!canSetSpawn && !canSleep) { +@@ -1177,7 +_,7 @@ + } else { + if (canSetSpawn) { + this.setRespawnPosition( +- new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true ++ new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(this.level().dimension(), bedPos, this.getYRot(), this.getXRot()), false), true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED // Paper - Add PlayerSetSpawnEvent + ); } -- Either either = super.startSleepInBed(bedPos).ifRight(unit -> { -+ // CraftBukkit start -+ return Either.right(Unit.INSTANCE); +@@ -1199,7 +_,37 @@ + } + } + +- Either either = super.startSleepInBed(bedPos).ifRight(unit -> { ++ // CraftBukkit start ++ return Either.right(Unit.INSTANCE); ++ } + } ++ } else { ++ return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); + } + } + @@ -926,12 +931,23 @@ + + { + { -+ Either either = super.startSleepInBed(bedPos, force).ifRight(unit -> { -+ // CraftBukkit end - this.awardStat(Stats.SLEEP_IN_BED); - CriteriaTriggers.SLEPT_IN_BED.trigger(this); - }); -@@ -1232,21 +_,29 @@ ++ Either either = super.startSleepInBed(bedPos, force).ifRight(unit -> { ++ // CraftBukkit end + this.awardStat(Stats.SLEEP_IN_BED); + CriteriaTriggers.SLEPT_IN_BED.trigger(this); + }); +@@ -1209,10 +_,7 @@ + + this.level().updateSleepingPlayerList(); + return either; +- } + } +- } else { +- return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); + } + } + +@@ -1238,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { @@ -959,12 +975,12 @@ - return super.isInvulnerableTo(level, damageSource) + return (super.isInvulnerableTo(level, damageSource) // Paper - disable player cramming; || this.isChangingDimension() && !damageSource.is(DamageTypes.ENDER_PEARL) -- || !this.hasClientLoaded(); -+ || !this.hasClientLoaded()) || (!this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; +- || !this.connection.hasClientLoaded(); ++ || !this.connection.hasClientLoaded()) || (!this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; } @Override -@@ -1294,8 +_,9 @@ +@@ -1300,8 +_,9 @@ this.connection.send(new ClientboundShowDialogPacket(dialog)); } @@ -975,7 +991,7 @@ } @Override -@@ -1303,12 +_,39 @@ +@@ -1309,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { @@ -1016,7 +1032,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1316,10 +_,14 @@ +@@ -1322,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -1033,7 +1049,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1332,14 +_,25 @@ +@@ -1338,27 +_,49 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1056,13 +1072,39 @@ - this.nextContainerCounter(); + // this.nextContainerCounter(); // CraftBukkit - moved up int inventoryColumns = horse.getInventoryColumns(); - this.connection.send(new ClientboundHorseScreenOpenPacket(this.containerCounter, inventoryColumns, horse.getId())); + this.connection.send(new ClientboundMountScreenOpenPacket(this.containerCounter, inventoryColumns, horse.getId())); - this.containerMenu = new HorseInventoryMenu(this.containerCounter, this.getInventory(), inventory, horse, inventoryColumns); + this.containerMenu = container; // CraftBukkit this.initMenu(this.containerMenu); } -@@ -1361,10 +_,30 @@ + @Override + public void openNautilusInventory(AbstractNautilus nautilus, Container inventory) { ++ // Paper start - Inventory open hook ++ this.nextContainerCounter(); // moved up from below ++ AbstractContainerMenu menu = new NautilusInventoryMenu(this.containerCounter, this.getInventory(), inventory, nautilus, nautilus.getInventoryColumns()); ++ menu.setTitle(nautilus.getDisplayName()); ++ menu = org.bukkit.craftbukkit.event.CraftEventFactory.callInventoryOpenEvent(this, menu); ++ ++ if (menu == null) { ++ inventory.stopOpen(this); ++ return; ++ } ++ // Paper end + if (this.containerMenu != this.inventoryMenu) { + this.closeContainer(); + } + +- this.nextContainerCounter(); ++ // this.nextContainerCounter(); Paper - Move Up + int inventoryColumns = nautilus.getInventoryColumns(); + this.connection.send(new ClientboundMountScreenOpenPacket(this.containerCounter, inventoryColumns, nautilus.getId())); +- this.containerMenu = new NautilusInventoryMenu(this.containerCounter, this.getInventory(), inventory, nautilus, inventoryColumns); ++ this.containerMenu = menu; // Paper - Moved up declaration + this.initMenu(this.containerMenu); + } + +@@ -1380,10 +_,30 @@ @Override public void closeContainer() { @@ -1093,7 +1135,7 @@ @Override public void doCloseContainer() { this.containerMenu.removed(this); -@@ -1387,19 +_,19 @@ +@@ -1406,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1116,7 +1158,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1410,13 +_,13 @@ +@@ -1429,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1133,7 +1175,7 @@ } } } else if (this.isFallFlying()) { -@@ -1458,13 +_,13 @@ +@@ -1479,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1149,7 +1191,7 @@ } @Override -@@ -1495,9 +_,9 @@ +@@ -1516,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1161,7 +1203,7 @@ } } -@@ -1510,6 +_,13 @@ +@@ -1533,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1175,7 +1217,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1521,6 +_,7 @@ +@@ -1544,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1183,7 +1225,7 @@ } @Override -@@ -1555,12 +_,12 @@ +@@ -1578,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1198,16 +1240,16 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1571,7 +_,7 @@ +@@ -1594,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); - this.setHealth(this.getMaxHealth()); + // this.setHealth(this.getMaxHealth()); // CraftBukkit - if (this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) { + if (this.level().getGameRules().get(GameRules.KEEP_INVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1587,7 +_,7 @@ +@@ -1610,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1216,7 +1258,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1630,9 +_,22 @@ +@@ -1653,9 +_,22 @@ CriteriaTriggers.EFFECTS_CHANGED.trigger(this, null); } @@ -1240,7 +1282,7 @@ } @Override -@@ -1641,7 +_,7 @@ +@@ -1664,7 +_,7 @@ } @Override @@ -1249,7 +1291,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1650,7 +_,7 @@ +@@ -1673,7 +_,7 @@ this.setCamera(this); } @@ -1257,8 +1299,8 @@ + boolean flag = super.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera, cause); // CraftBukkit if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); - } -@@ -1688,9 +_,19 @@ + this.connection.resetFlyingTicks(); +@@ -1712,9 +_,18 @@ } public boolean setGameMode(GameType gameMode) { @@ -1266,8 +1308,7 @@ + org.bukkit.event.player.PlayerGameModeChangeEvent event = this.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null); + return event != null && !event.isCancelled(); + } -+ @Nullable -+ public org.bukkit.event.player.PlayerGameModeChangeEvent setGameMode(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, @Nullable net.kyori.adventure.text.Component message) { ++ public org.bukkit.event.player.@Nullable PlayerGameModeChangeEvent setGameMode(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.@Nullable Component message) { boolean isSpectator = this.isSpectator(); - if (!this.gameMode.changeGameModeForPlayer(gameMode)) { - return false; @@ -1280,7 +1321,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1706,7 +_,7 @@ +@@ -1731,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1289,7 +1330,7 @@ } } -@@ -1762,8 +_,13 @@ +@@ -1786,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundChatType) { @@ -1304,7 +1345,7 @@ } } -@@ -1774,7 +_,42 @@ +@@ -1798,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1315,7 +1356,7 @@ + map.put(com.destroystokyo.paper.ClientOption.CHAT_VISIBILITY, com.destroystokyo.paper.ClientOption.ChatVisibility.valueOf(clientInformation.chatVisibility().name())); + map.put(com.destroystokyo.paper.ClientOption.CHAT_COLORS_ENABLED, clientInformation.chatColors()); + map.put(com.destroystokyo.paper.ClientOption.SKIN_PARTS, new com.destroystokyo.paper.PaperSkinParts(clientInformation.modelCustomisation())); -+ map.put(com.destroystokyo.paper.ClientOption.MAIN_HAND, clientInformation.mainHand() == HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT); ++ map.put(com.destroystokyo.paper.ClientOption.MAIN_HAND, clientInformation.mainHand() == net.minecraft.world.entity.HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT); + map.put(com.destroystokyo.paper.ClientOption.TEXT_FILTERING_ENABLED, clientInformation.textFilteringEnabled()); + map.put(com.destroystokyo.paper.ClientOption.ALLOW_SERVER_LISTINGS, clientInformation.allowsListing()); + map.put(com.destroystokyo.paper.ClientOption.PARTICLE_VISIBILITY, com.destroystokyo.paper.ClientOption.ParticleVisibility.valueOf(clientInformation.particleStatus().name())); @@ -1325,7 +1366,7 @@ + if (this.getMainArm() != clientInformation.mainHand()) { + org.bukkit.event.player.PlayerChangedMainHandEvent event = new org.bukkit.event.player.PlayerChangedMainHandEvent( + this.getBukkitEntity(), -+ clientInformation.mainHand() == HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT ++ clientInformation.mainHand() == net.minecraft.world.entity.HumanoidArm.LEFT ? org.bukkit.inventory.MainHand.LEFT : org.bukkit.inventory.MainHand.RIGHT + ); + this.server.server.getPluginManager().callEvent(event); + } @@ -1347,7 +1388,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1860,8 +_,23 @@ +@@ -1883,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1372,10 +1413,10 @@ } if (entityToSpectate != null) { -@@ -1895,11 +_,11 @@ +@@ -1917,11 +_,11 @@ + } - @Nullable - public Component getTabListDisplayName() { + public @Nullable Component getTabListDisplayName() { - return null; + return this.listName; // CraftBukkit } @@ -1386,17 +1427,17 @@ } @Override -@@ -1930,11 +_,62 @@ +@@ -1951,11 +_,62 @@ } - public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) { + public void setRespawnPosition(ServerPlayer.@Nullable RespawnConfig respawnConfig, boolean displayInChat) { - if (displayInChat && respawnConfig != null && !respawnConfig.isSamePosition(this.respawnConfig)) { - this.sendSystemMessage(SPAWN_SET_MESSAGE); + // Paper start - Add PlayerSetSpawnEvent + this.setRespawnPosition(respawnConfig, displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.UNKNOWN); + } + -+ public boolean setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) { ++ public boolean setRespawnPosition(ServerPlayer.@Nullable RespawnConfig respawnConfig, boolean displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) { + org.bukkit.Location spawnLoc = null; + boolean actuallyDisplayInChat = false; + if (respawnConfig != null) { @@ -1451,13 +1492,13 @@ } public SectionPos getLastSectionPos() { -@@ -1964,16 +_,23 @@ +@@ -1975,16 +_,23 @@ } @Override - public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem) { - ItemEntity itemEntity = super.drop(droppedItem, dropAround, traceItem); -+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { // Paper - Extend dropItem API ++ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent, java.util.function.@Nullable Consumer entityOperation) { // Paper - Extend dropItem API + ItemEntity itemEntity = super.drop(droppedItem, dropAround, traceItem, callEvent, entityOperation); // Paper - Extend dropItem API + ItemStack itemStack = itemEntity != null ? itemEntity.getItem() : ItemStack.EMPTY; // Paper - move up if (traceItem) { @@ -1480,7 +1521,25 @@ return itemEntity; } -@@ -2096,9 +_,9 @@ +@@ -2036,7 +_,7 @@ + super.updateUsingItem(usingItem); + } + +- public void drop(boolean dropStack) { ++ public boolean drop(boolean dropStack) { // Paper - add back success return + Inventory inventory = this.getInventory(); + ItemStack itemStack = inventory.removeFromSelected(dropStack); + this.containerMenu +@@ -2046,7 +_,7 @@ + this.stopUsingItem(); + } + +- this.drop(itemStack, false, true); ++ return this.drop(itemStack, false, true) != null; // Paper - add back success return + } + + @Override +@@ -2109,9 +_,9 @@ } @Override @@ -1492,7 +1551,7 @@ if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2215,7 +_,7 @@ +@@ -2233,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { @@ -1501,7 +1560,7 @@ return TicketType.ENDER_PEARL.timeout(); } -@@ -2245,9 +_,11 @@ +@@ -2263,9 +_,11 @@ } } @@ -1516,7 +1575,7 @@ } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2267,4 +_,135 @@ +@@ -2285,4 +_,135 @@ ); public static final ServerPlayer.SavedPosition EMPTY = new ServerPlayer.SavedPosition(Optional.empty(), Optional.empty(), Optional.empty()); } @@ -1535,7 +1594,7 @@ + } + } + -+ public @Nullable org.bukkit.WeatherType weatherType = null; ++ public org.bukkit.@Nullable WeatherType weatherType = null; + + public void setPlayerWeather(org.bukkit.WeatherType type, boolean plugin) { + if (!plugin && this.weatherType != null) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 2c7b90a2f63e..6ca72d6b2ed8 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -47,16 +_,38 @@ +@@ -46,16 +_,37 @@ private BlockPos delayedDestroyPos = BlockPos.ZERO; private int delayedTickStart; private int lastSentState = -1; @@ -19,8 +19,7 @@ + return event != null && !event.isCancelled(); + } + -+ @Nullable -+ public org.bukkit.event.player.PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause playerGameModeChangeCause, @Nullable net.kyori.adventure.text.Component cancelMessage) { ++ public org.bukkit.event.player.@Nullable PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause playerGameModeChangeCause, net.kyori.adventure.text.@Nullable Component cancelMessage) { + // Paper end - Expand PlayerGameModeChangeEvent if (gameModeForPlayer == this.gameModeForPlayer) { - return false; @@ -40,7 +39,7 @@ Abilities abilities = this.player.getAbilities(); this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); if (abilities.flying && gameModeForPlayer != GameType.SPECTATOR && this.isInRangeOfGround()) { -@@ -67,13 +_,13 @@ +@@ -66,13 +_,13 @@ this.level .getServer() .getPlayerList() @@ -56,7 +55,7 @@ } } -@@ -107,10 +_,11 @@ +@@ -105,10 +_,11 @@ } public void tick() { @@ -71,7 +70,7 @@ this.hasDelayedDestroy = false; } else { float f = this.incrementDestroyProgress(blockState, this.delayedDestroyPos, this.delayedTickStart); -@@ -120,7 +_,13 @@ +@@ -118,7 +_,13 @@ } } } else if (this.isDestroyingBlock) { @@ -86,15 +85,15 @@ if (blockState.isAir()) { this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); this.lastSentState = -1; -@@ -151,6 +_,7 @@ +@@ -149,6 +_,7 @@ public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction face, int maxBuildHeight, int sequence) { - if (!this.player.canInteractWithBlock(pos, 1.0)) { + if (!this.player.isWithinBlockInteractionRange(pos, 1.0)) { + if (true) return; // Paper - Don't allow digging into unloaded chunks; Don't notify if unreasonably far away this.debugLogging(pos, false, sequence, "too far"); } else if (pos.getY() > maxBuildHeight) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); -@@ -158,16 +_,35 @@ +@@ -156,16 +_,35 @@ } else { if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) { if (!this.level.mayInteract(this.player, pos)) { @@ -132,7 +131,7 @@ if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.debugLogging(pos, false, sequence, "block action restricted"); -@@ -177,7 +_,7 @@ +@@ -175,7 +_,7 @@ this.destroyProgressStart = this.gameTicks; float f = 1.0F; BlockState blockState = this.level.getBlockState(pos); @@ -141,7 +140,7 @@ EnchantmentHelper.onHitBlock( this.level, this.player.getMainHandItem(), -@@ -192,6 +_,23 @@ +@@ -190,6 +_,23 @@ f = blockState.getDestroyProgress(this.player, this.player.level(), pos); } @@ -165,7 +164,7 @@ if (!blockState.isAir() && f >= 1.0F) { this.destroyAndAck(pos, sequence, "insta mine"); } else { -@@ -232,14 +_,22 @@ +@@ -230,14 +_,22 @@ this.debugLogging(pos, true, sequence, "stopped destroying"); } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; @@ -190,7 +189,7 @@ } } } -@@ -255,17 +_,64 @@ +@@ -253,17 +_,64 @@ public boolean destroyBlock(BlockPos pos) { BlockState blockState = this.level.getBlockState(pos); @@ -257,7 +256,7 @@ BlockState blockState1 = block.playerWillDestroy(this.level, pos, blockState, this.player); boolean flag = this.level.removeBlock(pos, false); if (SharedConstants.DEBUG_BLOCK_BREAK) { -@@ -276,19 +_,44 @@ +@@ -274,19 +_,44 @@ block.destroy(this.level, pos, blockState1); } @@ -309,7 +308,7 @@ } } } -@@ -323,7 +_,7 @@ +@@ -321,7 +_,7 @@ } if (!player.isUsingItem()) { @@ -318,7 +317,7 @@ } return interactionResult; -@@ -331,15 +_,47 @@ +@@ -329,15 +_,47 @@ } } @@ -368,7 +367,7 @@ return InteractionResult.CONSUME; } else { return InteractionResult.PASS; -@@ -364,7 +_,7 @@ +@@ -362,7 +_,7 @@ } } @@ -377,7 +376,7 @@ UseOnContext useOnContext = new UseOnContext(player, hand, hitResult); InteractionResult interactionResult1; if (player.hasInfiniteMaterials()) { -@@ -381,6 +_,11 @@ +@@ -379,6 +_,11 @@ return interactionResult1; } else { 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 432a0d32d1c1..350485061772 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 @@ -1,6 +1,25 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -19,6 +_,11 @@ +@@ -9,11 +_,13 @@ + + public record TicketType(long timeout, @TicketType.Flags int flags) { + public static final long NO_TIMEOUT = 0L; +- public static final int FLAG_PERSIST = 1; +- public static final int FLAG_LOADING = 2; +- public static final int FLAG_SIMULATION = 4; +- public static final int FLAG_KEEP_DIMENSION_ACTIVE = 8; +- public static final int FLAG_CAN_EXPIRE_IF_UNLOADED = 16; ++ // Paper start - diff on change - all listed in Flags annotation ++ public static final int FLAG_PERSIST = 1; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_LOADING = 2; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_SIMULATION = 4; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_KEEP_DIMENSION_ACTIVE = 8; // Paper - diff on change - all listed in Flags annotation ++ public static final int FLAG_CAN_EXPIRE_IF_UNLOADED = 16; // Paper - diff on change - all listed in Flags annotation ++ // Paper end - diff on change - all listed in Flags annotation + public static final TicketType PLAYER_SPAWN = register("player_spawn", 20L, FLAG_LOADING); + public static final TicketType SPAWN_SEARCH = register("spawn_search", 1L, FLAG_LOADING); + public static final TicketType DRAGON = register("dragon", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); +@@ -23,6 +_,11 @@ public static final TicketType PORTAL = register("portal", 300L, FLAG_PERSIST | FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE); public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, FLAG_LOADING | FLAG_SIMULATION | FLAG_KEEP_DIMENSION_ACTIVE); public static final TicketType UNKNOWN = register("unknown", 1L, FLAG_CAN_EXPIRE_IF_UNLOADED | FLAG_LOADING); @@ -10,10 +29,10 @@ + 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(String name, long timeout, int flags) { + private static TicketType register(String name, long timeout, @TicketType.Flags int flags) { return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, flags)); -@@ -44,7 +_,14 @@ - return (this.flags & 16) != 0; +@@ -48,12 +_,20 @@ + return (this.flags & FLAG_CAN_EXPIRE_IF_UNLOADED) != 0; } + // Paper start - chunk-gc config @@ -27,4 +46,10 @@ + return this.timeout() != 0L; + // Paper end - chunk-gc config } + + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, 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 7f48377c41bc..bf4502922504 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 -@@ -151,6 +_,28 @@ +@@ -150,6 +_,28 @@ return chessboardDistance < this.generatingStep.directDependencies().size(); } @@ -29,7 +29,7 @@ @Override public BlockState getBlockState(BlockPos pos) { return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -@@ -198,7 +_,8 @@ +@@ -196,7 +_,8 @@ if (blockState.isAir()) { return false; } else { @@ -39,7 +39,7 @@ BlockEntity blockEntity = blockState.hasBlockEntity() ? this.getBlockEntity(pos) : null; Block.dropResources(blockState, this.level, pos, blockEntity, entity, ItemStack.EMPTY); } -@@ -242,6 +_,7 @@ +@@ -239,6 +_,7 @@ } } @@ -47,7 +47,7 @@ @Override public boolean ensureCanWrite(BlockPos pos) { int sectionPosX = SectionPos.blockToSectionCoord(pos.getX()); -@@ -259,6 +_,8 @@ +@@ -256,6 +_,8 @@ return true; } else { @@ -56,7 +56,7 @@ Util.logAndPauseIfInIde( "Detected setBlock in a far chunk [" + sectionPosX -@@ -270,6 +_,12 @@ +@@ -267,6 +_,12 @@ + this.generatingStep.targetStatus() + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get()) ); @@ -69,7 +69,7 @@ return false; } } -@@ -280,7 +_,7 @@ +@@ -277,7 +_,7 @@ return false; } else { ChunkAccess chunk = this.getChunk(pos); @@ -78,7 +78,7 @@ if (blockState != null) { this.level.updatePOIOnBlockStateChange(pos, blockState, state); } -@@ -294,6 +_,17 @@ +@@ -291,6 +_,17 @@ chunk.removeBlockEntity(pos); } } else { @@ -96,7 +96,7 @@ CompoundTag compoundTag = new CompoundTag(); compoundTag.putInt("x", pos.getX()); compoundTag.putInt("y", pos.getY()); -@@ -319,6 +_,13 @@ +@@ -316,6 +_,13 @@ @Override public boolean addFreshEntity(Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch b/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch index 2fde9483e16e..f935b67dc439 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/progress/LoggingLevelLoadListener.java.patch @@ -31,14 +31,14 @@ case PREPARE_GLOBAL_SPAWN: + // Paper start - log dimension + if (this.level != null) { -+ LOGGER.info("Selecting spawn point for world '{}'...", this.level.dimension().location()); ++ LOGGER.info("Selecting spawn point for world '{}'...", this.level.dimension().identifier()); + } else { LOGGER.info("Selecting global world spawn..."); + } break; case LOAD_INITIAL_CHUNKS: + if (this.level != null) { -+ LOGGER.info("Loading {} persistent chunks for world '{}'...", totalChunks, this.level.dimension().location()); ++ LOGGER.info("Loading {} persistent chunks for world '{}'...", totalChunks, this.level.dimension().identifier()); + } else { LOGGER.info("Loading {} persistent chunks...", totalChunks); + } diff --git a/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch new file mode 100644 index 000000000000..84488a498354 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/network/EventLoopGroupHolder.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/server/network/EventLoopGroupHolder.java ++++ b/net/minecraft/server/network/EventLoopGroupHolder.java +@@ -48,11 +_,20 @@ + return LocalIoHandler.newFactory(); + } + }; ++ // Paper start - Unix domain socket support ++ private static final EventLoopGroupHolder EPOLL_UNIX_DOMAIN = new EventLoopGroupHolder("Unix Domain Socket", io.netty.channel.epoll.EpollDomainSocketChannel.class, io.netty.channel.epoll.EpollServerDomainSocketChannel.class) { ++ @Override ++ protected IoHandlerFactory ioHandlerFactory() { ++ return EpollIoHandler.newFactory(); ++ } ++ }; ++ // Paper end - Unix domain socket support + private final String type; + private final Class channelCls; + private final Class serverChannelCls; + private volatile @Nullable EventLoopGroup group; + ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - use variant with address param + public static EventLoopGroupHolder remote(boolean tryNativeTransport) { + if (tryNativeTransport) { + if (KQueue.isAvailable()) { +@@ -66,6 +_,25 @@ + + return NIO; + } ++ ++ // Paper start - Unix domain socket support ++ public static EventLoopGroupHolder remote(java.net.SocketAddress address, boolean tryNativeTransport) { ++ if (tryNativeTransport) { ++ if (KQueue.isAvailable()) { ++ return KQUEUE; ++ } ++ ++ if (Epoll.isAvailable()) { ++ if (address instanceof io.netty.channel.unix.DomainSocketAddress) { ++ return EPOLL_UNIX_DOMAIN; ++ } else { ++ return EPOLL; ++ } ++ } ++ } ++ return NIO; ++ } ++ // Paper end - Unix domain socket support + + public static EventLoopGroupHolder local() { + return LOCAL; 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 b3ea5ea045c8..0f41a4c322e1 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 @@ -19,7 +19,7 @@ + // CraftBukkit end + public final java.util.Map packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks + private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit -+ protected static final net.minecraft.resources.ResourceLocation MINECRAFT_BRAND = net.minecraft.resources.ResourceLocation.withDefaultNamespace("brand"); // Paper - Brand support ++ protected static final net.minecraft.resources.Identifier MINECRAFT_BRAND = net.minecraft.resources.Identifier.withDefaultNamespace("brand"); // Paper - Brand support + // Paper start - retain certain values + public @Nullable String playerBrand; + public final java.util.Set pluginMessagerChannels; @@ -60,8 +60,8 @@ } + // Paper start -+ public static final net.minecraft.resources.ResourceLocation CUSTOM_REGISTER = net.minecraft.resources.ResourceLocation.withDefaultNamespace("register"); -+ private static final net.minecraft.resources.ResourceLocation CUSTOM_UNREGISTER = net.minecraft.resources.ResourceLocation.withDefaultNamespace("unregister"); ++ public static final net.minecraft.resources.Identifier CUSTOM_REGISTER = net.minecraft.resources.Identifier.withDefaultNamespace("register"); ++ private static final net.minecraft.resources.Identifier CUSTOM_UNREGISTER = net.minecraft.resources.Identifier.withDefaultNamespace("unregister"); + // Paper end + @Override @@ -73,7 +73,7 @@ + + net.minecraft.network.protocol.PacketUtils.ensureRunningOnSameThread(packet, this, this.server.packetProcessor()); + -+ final net.minecraft.resources.ResourceLocation identifier = packet.payload().type().id(); ++ final net.minecraft.resources.Identifier identifier = packet.payload().type().id(); + final byte[] data = discardedPayload.data(); + try { + final boolean registerChannel = CUSTOM_REGISTER.equals(identifier); diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch index 7eb2aa20a0ef..4f05492b68cd 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -55,12 +_,26 @@ - private SynchronizeRegistriesTask synchronizeRegistriesTask; - @Nullable - private PrepareSpawnTask prepareSpawnTask; +@@ -52,12 +_,26 @@ + public ClientInformation clientInformation; + private @Nullable SynchronizeRegistriesTask synchronizeRegistriesTask; + private @Nullable PrepareSpawnTask prepareSpawnTask; + public io.papermc.paper.connection.PaperPlayerConfigurationConnection paperConnection; // Paper public ServerConfigurationPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) { @@ -28,7 +28,7 @@ @Override protected GameProfile playerProfile() { -@@ -69,6 +_,11 @@ +@@ -66,6 +_,11 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -40,7 +40,7 @@ LOGGER.info("{} ({}) lost connection: {}", this.gameProfile.name(), this.gameProfile.id(), details.reason().getString()); if (this.prepareSpawnTask != null) { this.prepareSpawnTask.close(); -@@ -84,10 +_,15 @@ +@@ -81,10 +_,15 @@ } public void startConfiguration() { @@ -57,7 +57,7 @@ } LayeredRegistryAccess layeredRegistryAccess = this.server.registries(); -@@ -100,11 +_,12 @@ +@@ -97,11 +_,12 @@ this.synchronizeRegistriesTask = new SynchronizeRegistriesTask(list, layeredRegistryAccess); this.configurationTasks.add(this.synchronizeRegistriesTask); this.addOptionalTasks(); @@ -71,7 +71,7 @@ this.configurationTasks.add(this.prepareSpawnTask); this.configurationTasks.add(new JoinWorldTask()); this.startNextTask(); -@@ -135,12 +_,14 @@ +@@ -132,12 +_,14 @@ @Override public void handleClientInformation(ServerboundClientInformationPacket packet) { this.clientInformation = packet.information(); @@ -87,7 +87,7 @@ this.finishCurrentTask(ServerResourcePackConfigurationTask.TYPE); } } -@@ -174,7 +_,7 @@ +@@ -171,7 +_,7 @@ return; } @@ -96,7 +96,7 @@ if (component != null) { this.disconnect(component); return; -@@ -234,4 +_,29 @@ +@@ -231,4 +_,29 @@ this.startNextTask(); } } 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 88bee1b4283c..d4308c9813fd 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,19 +1,6 @@ --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -50,10 +_,10 @@ - public class ServerConnectionListener { - private static final Logger LOGGER = LogUtils.getLogger(); - public static final Supplier SERVER_EVENT_GROUP = Suppliers.memoize( -- () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Server IO #%d").setDaemon(true).build()) -+ () -> new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - public static final Supplier SERVER_EPOLL_EVENT_GROUP = Suppliers.memoize( -- () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build()) -+ () -> new EpollEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()) // Paper - ); - final MinecraftServer server; - public volatile boolean running; -@@ -65,12 +_,35 @@ +@@ -48,9 +_,31 @@ this.running = true; } @@ -36,34 +23,17 @@ + public void startTcpServerListener(SocketAddress address) throws IOException { + // Paper end - Unix domain socket support synchronized (this.channels) { -- Class clazz; -+ Class clazz; // Paper - Unix domain socket support - EventLoopGroup eventLoopGroup; - if (Epoll.isAvailable() && this.server.isEpollEnabled()) { -+ // Paper start - Unix domain socket support -+ if (address instanceof io.netty.channel.unix.DomainSocketAddress) { -+ clazz = io.netty.channel.epoll.EpollServerDomainSocketChannel.class; -+ } else { - clazz = EpollServerSocketChannel.class; -+ } -+ // Paper end - Unix domain socket support - eventLoopGroup = SERVER_EPOLL_EVENT_GROUP.get(); - LOGGER.info("Using epoll channel type"); - } else { -@@ -79,6 +_,12 @@ - LOGGER.info("Using default channel type"); - } - +- EventLoopGroupHolder eventLoopGroupHolder = EventLoopGroupHolder.remote(this.server.useNativeTransport()); ++ EventLoopGroupHolder eventLoopGroupHolder = EventLoopGroupHolder.remote(address, this.server.useNativeTransport()); // Paper - Unix domain socket support + // Paper start - Warn people with console access that HAProxy is in use. + if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.proxyProtocol) { + LOGGER.warn("Using HAProxy, please ensure the server port is adequately firewalled."); + } + // Paper end - Warn people with console access that HAProxy is in use. -+ this.channels .add( new ServerBootstrap() -@@ -102,22 +_,64 @@ +@@ -74,22 +_,64 @@ Connection connection = (Connection)(rateLimitPacketsPerSecond > 0 ? new RateKickingConnection(rateLimitPacketsPerSecond) : new Connection(PacketFlow.SERVERBOUND)); @@ -107,7 +77,7 @@ } } ) - .group(eventLoopGroup) + .group(eventLoopGroupHolder.eventLoopGroup()) - .localAddress(address, port) + .localAddress(address) // Paper - Unix domain socket support + .option(ChannelOption.AUTO_READ, false) // CraftBukkit @@ -130,7 +100,7 @@ public SocketAddress startMemoryChannel() { ChannelFuture channelFuture; synchronized (this.channels) { -@@ -169,6 +_,13 @@ +@@ -141,6 +_,13 @@ public void tick() { synchronized (this.connections) { @@ -144,7 +114,7 @@ Iterator iterator = this.connections.iterator(); while (iterator.hasNext()) { -@@ -188,6 +_,7 @@ +@@ -160,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 8f7d4b54292f..b59453759987 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,7 +1,7 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -211,6 +_,38 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -214,6 +_,38 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; +// CraftBukkit start @@ -39,7 +39,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements GameProtocols.Context, -@@ -229,7 +_,9 @@ +@@ -234,7 +_,9 @@ private int tickCount; private int ackBlockChangesUpTo = -1; private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); @@ -49,7 +49,7 @@ private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -255,14 +_,33 @@ +@@ -258,7 +_,23 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -68,22 +68,22 @@ + private float lastYaw = Float.MAX_VALUE; + private boolean justTeleported = false; + // CraftBukkit end - @Nullable - private RemoteChatSession chatSession; + private @Nullable RemoteChatSession chatSession; + private boolean hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); private int nextChatIndex; - private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault(); - private final FutureChain chatMessageChain; +@@ -267,6 +_,9 @@ private boolean waitingForSwitchToConfig; + private boolean waitingForRespawn; + private int clientLoadedTimeoutTimer; + private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper - Limit client sign length + private final io.papermc.paper.event.packet.ClientTickEndEvent tickEndEvent; // Paper - add client tick end event + public final io.papermc.paper.connection.PaperPlayerGameConnection playerGameConnection; // Paper public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie cookie) { super(server, connection, cookie); -@@ -271,8 +_,22 @@ +@@ -276,8 +_,22 @@ player.connection = this; player.getTextFilter().join(); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); @@ -108,7 +108,7 @@ @Override public void tick() { -@@ -285,11 +_,13 @@ +@@ -290,11 +_,13 @@ this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -123,7 +123,7 @@ } } } -@@ -305,8 +_,8 @@ +@@ -310,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 +134,7 @@ return true; } } else { -@@ -324,8 +_,8 @@ +@@ -329,8 +_,8 @@ this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { @@ -145,7 +145,7 @@ return true; } } else { -@@ -338,6 +_,12 @@ +@@ -343,6 +_,12 @@ this.aboveGroundVehicleTickCount = 0; } @@ -158,7 +158,7 @@ return false; } -@@ -398,11 +_,37 @@ +@@ -408,11 +_,37 @@ @Override public void handlePlayerInput(ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -176,14 +176,14 @@ + this.cserver.getPluginManager().callEvent(event); + + // Technically the player input and the flag is desynced, but this is previous behavior.. so should be fine? -+ if (!event.isCancelled() && this.player.hasClientLoaded()) { ++ if (!event.isCancelled() && this.hasClientLoaded()) { + // Only set the shift key status if the shift input has changed and the event has not been cancelled + this.player.setShiftKeyDown(packet.input().shift()); + } + } + // Paper end - PlayerToggleSneakEvent this.player.setLastClientInput(packet.input()); - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { this.player.resetLastActionTime(); - this.player.setShiftKeyDown(packet.input().shift()); - } @@ -198,13 +198,13 @@ } private static boolean containsInvalidValues(double x, double y, double z, float yRot, float xRot) { -@@ -421,17 +_,29 @@ +@@ -431,17 +_,29 @@ public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { - this.disconnect(Component.translatable("multiplayer.disconnect.invalid_vehicle_movement")); + this.disconnect(Component.translatable("multiplayer.disconnect.invalid_vehicle_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_VEHICLE_MOVEMENT); // Paper - kick event cause - } else if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) { + } else if (!this.updateAwaitingTeleport() && this.hasClientLoaded()) { Entity rootVehicle = this.player.getRootVehicle(); + // Paper start - Don't allow vehicle movement from players while teleporting + if (this.awaitingPositionFromClient != null || this.player.isImmobile() || rootVehicle.isRemoved()) { @@ -232,7 +232,7 @@ float f = Mth.wrapDegrees(packet.yRot()); float f1 = Mth.wrapDegrees(packet.xRot()); double d3 = d - this.vehicleFirstGoodX; -@@ -439,16 +_,61 @@ +@@ -449,16 +_,61 @@ double d5 = d2 - this.vehicleFirstGoodZ; double d6 = rootVehicle.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -298,7 +298,7 @@ boolean flag = rootVehicle.verticalCollisionBelow; if (rootVehicle instanceof LivingEntity livingEntity && livingEntity.onClimbable()) { livingEntity.resetFallDistance(); -@@ -465,7 +_,7 @@ +@@ -475,7 +_,7 @@ d5 = d2 - rootVehicle.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; @@ -307,7 +307,7 @@ flag1 = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(d7)); } -@@ -479,6 +_,57 @@ +@@ -489,6 +_,57 @@ } rootVehicle.absSnapTo(d, d1, d2, f, f1); @@ -365,7 +365,7 @@ this.player.level().getChunkSource().move(this.player); Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); this.handlePlayerKnownMovement(vec3); -@@ -509,7 +_,7 @@ +@@ -519,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -374,7 +374,7 @@ return; } -@@ -526,12 +_,20 @@ +@@ -536,12 +_,20 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -386,16 +386,16 @@ public void handleAcceptPlayerLoad(ServerboundPlayerLoadedPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + // Paper start - PlayerLoadedWorldEvent -+ if (this.player.hasClientLoaded()) { ++ if (this.hasClientLoaded()) { + return; + } + final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent(this.player.getBukkitEntity(), false); + event.callEvent(); + // Paper end - PlayerLoadedWorldEvent - this.player.setClientLoaded(true); + this.markClientLoaded(); } -@@ -553,6 +_,7 @@ +@@ -563,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -403,7 +403,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -568,25 +_,110 @@ +@@ -578,25 +_,110 @@ } } @@ -519,25 +519,25 @@ } ); } -@@ -596,7 +_,7 @@ +@@ -604,7 +_,7 @@ + @Override + public void handleSetCommandBlock(ServerboundSetCommandBlockPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); - if (!this.server.isCommandBlockEnabled()) { - this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); -- } else if (!this.player.canUseGameMasterBlocks()) { -+ } else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission +- if (!this.player.canUseGameMasterBlocks()) { ++ if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock baseCommandBlock = null; -@@ -651,7 +_,7 @@ +@@ -665,7 +_,7 @@ + @Override + public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); - if (!this.server.isCommandBlockEnabled()) { - this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); -- } else if (!this.player.canUseGameMasterBlocks()) { -+ } else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission +- if (!this.player.canUseGameMasterBlocks()) { ++ if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -679,11 +_,11 @@ +@@ -703,11 +_,11 @@ boolean flag = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack cloneItemStack = blockState.getCloneItemStack(serverLevel, blockPos, flag); if (!cloneItemStack.isEmpty()) { @@ -551,8 +551,8 @@ } } } -@@ -710,27 +_,40 @@ - if (entityOrPart != null && this.player.canInteractWithEntity(entityOrPart, 3.0)) { +@@ -734,27 +_,40 @@ + if (entityOrPart != null && this.player.isWithinEntityInteractionRange(entityOrPart, 3.0)) { ItemStack pickResult = entityOrPart.getPickResult(); if (pickResult != null && !pickResult.isEmpty()) { - this.tryPickItem(pickResult); @@ -598,7 +598,7 @@ } } -@@ -908,6 +_,13 @@ +@@ -932,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); int item = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu merchantMenu) { @@ -612,7 +612,7 @@ if (!merchantMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, merchantMenu); return; -@@ -920,6 +_,51 @@ +@@ -944,6 +_,51 @@ @Override public void handleEditBook(ServerboundEditBookPacket packet) { @@ -664,7 +664,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List list = Lists.newArrayList(); -@@ -934,10 +_,14 @@ +@@ -958,10 +_,14 @@ } private void updateBookContents(List pages, int index) { @@ -680,7 +680,7 @@ } } -@@ -950,7 +_,8 @@ +@@ -974,7 +_,8 @@ itemStack.set( DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, list, true) ); @@ -690,7 +690,7 @@ } } -@@ -998,27 +_,35 @@ +@@ -1022,27 +_,35 @@ public void handleMovePlayer(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))) { @@ -704,7 +704,7 @@ this.resetPosition(); } - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { - float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); - float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot())); + float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); final float toYaw = f; // Paper - OBFHELPER @@ -733,7 +733,7 @@ double x = this.player.getX(); double y = this.player.getY(); double z = this.player.getZ(); -@@ -1027,6 +_,16 @@ +@@ -1051,6 +_,16 @@ double d5 = d2 - this.firstGoodZ; double d6 = this.player.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -750,7 +750,7 @@ if (this.player.isSleeping()) { if (d7 > 1.0) { this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); -@@ -1036,36 +_,108 @@ +@@ -1060,36 +_,108 @@ if (serverLevel.tickRateManager().runsNormally()) { this.receivedMovePacketCount++; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -869,7 +869,7 @@ double verticalDelta = d4; d3 = d - this.player.getX(); d4 = d1 - this.player.getY(); -@@ -1075,20 +_,100 @@ +@@ -1099,21 +_,101 @@ d5 = d2 - this.player.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -880,7 +880,8 @@ + && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold // Spigot && !this.player.isSleeping() && !this.player.isCreative() - && !this.player.isSpectator()) { + && !this.player.isSpectator() + && !this.player.isInPostImpulseGraceTime()) { - flag2 = true; + // Paper start - Add fail move event + io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY, @@ -979,7 +980,7 @@ this.player.absSnapTo(d, d1, d2, f, f1); boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); this.clientIsFloating = verticalDelta >= -0.03125 -@@ -1123,7 +_,7 @@ +@@ -1148,7 +_,7 @@ this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); } else { @@ -988,7 +989,7 @@ this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); this.player.removeLatestMovementRecording(); } -@@ -1159,6 +_,7 @@ +@@ -1183,6 +_,7 @@ this.player.getXRot() ); } @@ -996,7 +997,7 @@ return true; } else { -@@ -1182,10 +_,77 @@ +@@ -1206,10 +_,77 @@ } public void teleport(double x, double y, double z, float yRot, float xRot) { @@ -1075,7 +1076,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1193,12 +_,20 @@ +@@ -1217,12 +_,20 @@ this.player.teleportSetPosition(posMoveRotation, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1093,17 +1094,17 @@ public void handlePlayerAction(ServerboundPlayerActionPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1207,32 +_,95 @@ +@@ -1247,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { - ItemStack itemInHand = this.player.getItemInHand(InteractionHand.OFF_HAND); + ItemStack itemInHand1 = this.player.getItemInHand(InteractionHand.OFF_HAND); - this.player.setItemInHand(InteractionHand.OFF_HAND, this.player.getItemInHand(InteractionHand.MAIN_HAND)); -- this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand); +- this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand1); + // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394) -+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemInHand); ++ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemInHand1); + CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(InteractionHand.MAIN_HAND)); + PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(this.getCraftPlayer(), mainHand.clone(), offHand.clone()); + this.cserver.getPluginManager().callEvent(swapItemsEvent); @@ -1116,7 +1117,7 @@ + this.player.setItemInHand(InteractionHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); + } + if (swapItemsEvent.getMainHandItem().equals(mainHand)) { -+ this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand); ++ this.player.setItemInHand(InteractionHand.MAIN_HAND, itemInHand1); + } else { + this.player.setItemInHand(InteractionHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); + } @@ -1163,7 +1164,7 @@ case ABORT_DESTROY_BLOCK: case STOP_DESTROY_BLOCK: + // Paper start - Don't allow digging into unloaded chunks -+ if (this.player.level().getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4) == null || !this.player.canInteractWithBlock(pos, 1.0)) { ++ if (this.player.level().getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4) == null || !this.player.isWithinBlockInteractionRange(pos, 1.0)) { + this.player.connection.ackBlockChangesUpTo(packet.getSequence()); + return; + } @@ -1194,7 +1195,7 @@ return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1250,9 +_,31 @@ +@@ -1290,9 +_,31 @@ } } @@ -1223,10 +1224,10 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit + if (!this.checkLimit(packet.timestamp)) return; // Spigot - check limit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1261,6 +_,11 @@ +@@ -1301,6 +_,11 @@ if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { BlockHitResult hitResult = packet.getHitResult(); Vec3 location = hitResult.getLocation(); @@ -1236,9 +1237,9 @@ + } + // Paper end - improve distance check BlockPos blockPos = hitResult.getBlockPos(); - if (this.player.canInteractWithBlock(blockPos, 1.0)) { + if (this.player.isWithinBlockInteractionRange(blockPos, 1.0)) { Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); -@@ -1270,7 +_,8 @@ +@@ -1310,7 +_,8 @@ this.player.resetLastActionTime(); int maxY = this.player.level().getMaxY(); if (blockPos.getY() <= maxY) { @@ -1248,7 +1249,7 @@ InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, serverLevel, itemInHand, hand, hitResult); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, hitResult.getBlockPos(), itemInHand.copy()); -@@ -1283,10 +_,10 @@ +@@ -1323,10 +_,10 @@ Component component = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component, true); } else if (interactionResult instanceof InteractionResult.Success success @@ -1261,7 +1262,7 @@ } else { Component component1 = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component1, true); -@@ -1294,13 +_,8 @@ +@@ -1334,13 +_,8 @@ this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos)); this.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction))); @@ -1277,16 +1278,16 @@ } } } -@@ -1310,6 +_,8 @@ +@@ -1350,6 +_,8 @@ @Override public void handleUseItem(ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit + if (!this.checkLimit(packet.timestamp)) return; // Spigot - check limit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.level(); -@@ -1323,6 +_,48 @@ +@@ -1363,6 +_,48 @@ this.player.absSnapRotationTo(f, f1); } @@ -1335,7 +1336,7 @@ if (this.player.gameMode.useItem(this.player, serverLevel, itemInHand, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1338,7 +_,7 @@ +@@ -1378,7 +_,7 @@ for (ServerLevel serverLevel : this.server.getAllLevels()) { Entity entity = packet.getEntity(serverLevel); if (entity != null) { @@ -1344,7 +1345,7 @@ return; } } -@@ -1355,24 +_,50 @@ +@@ -1395,24 +_,50 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -1369,7 +1370,7 @@ + this.removePlayerFromWorld(null); + } + -+ private void removePlayerFromWorld(@Nullable net.kyori.adventure.text.Component quitMessage) { ++ private void removePlayerFromWorld(net.kyori.adventure.text.@Nullable Component quitMessage) { + // Paper end - Fix kick event leave message not being sent this.chatMessageChain.close(); + // CraftBukkit start - Replace vanilla quit message handling with our own. @@ -1397,7 +1398,7 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo); -@@ -1382,20 +_,38 @@ +@@ -1422,20 +_,38 @@ @Override public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1436,7 +1437,7 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.message(), false, () -> { -@@ -1407,25 +_,45 @@ +@@ -1447,25 +_,45 @@ return; } @@ -1489,7 +1490,7 @@ ParseResults parseResults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseResults)) { LOGGER.error( -@@ -1442,28 +_,57 @@ +@@ -1482,28 +_,57 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), true, () -> { @@ -1550,7 +1551,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { -@@ -1527,14 +_,20 @@ +@@ -1567,14 +_,20 @@ return dispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -1575,7 +1576,7 @@ } } -@@ -1546,7 +_,7 @@ +@@ -1586,7 +_,7 @@ var10000 = Optional.of(lastSeenMessages); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1584,7 +1585,7 @@ return Optional.empty(); } -@@ -1564,22 +_,81 @@ +@@ -1604,22 +_,81 @@ return false; } @@ -1672,7 +1673,7 @@ } } -@@ -1590,7 +_,7 @@ +@@ -1630,7 +_,7 @@ this.lastSeenMessages.applyOffset(packet.offset()); } catch (LastSeenMessagesValidator.ValidationException var5) { LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getPlainTextName(), var5.getMessage()); @@ -1681,7 +1682,7 @@ } } } -@@ -1598,7 +_,40 @@ +@@ -1638,7 +_,40 @@ @Override public void handleAnimate(ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -1722,10 +1723,10 @@ this.player.swing(packet.getHand()); } -@@ -1606,6 +_,22 @@ +@@ -1646,6 +_,21 @@ public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { + // CraftBukkit start + if (this.player.isRemoved()) return; + switch (packet.getAction()) { @@ -1741,11 +1742,10 @@ + } + } + // CraftBukkit end -+ this.player.resetLastActionTime(); switch (packet.getAction()) { case START_SPRINTING: -@@ -1650,6 +_,14 @@ +@@ -1690,6 +_,14 @@ } public void sendPlayerChatMessage(PlayerChatMessage chatMessage, ChatType.Bound boundChatType) { @@ -1760,7 +1760,7 @@ this.send( new ClientboundPlayerChatPacket( this.nextChatIndex++, -@@ -1672,9 +_,11 @@ +@@ -1712,9 +_,11 @@ } if (i > 4096) { @@ -1773,7 +1773,7 @@ } public void sendDisguisedChatMessage(Component message, ChatType.Bound boundChatType) { -@@ -1685,6 +_,17 @@ +@@ -1725,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1791,12 +1791,12 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1700,9 +_,16 @@ +@@ -1740,9 +_,16 @@ @Override public void handleInteract(ServerboundInteractPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); + if (this.player.isImmobile()) return; // CraftBukkit - if (this.player.hasClientLoaded()) { + if (this.hasClientLoaded()) { final ServerLevel serverLevel = this.player.level(); final Entity target = packet.getTarget(serverLevel); + // Spigot start @@ -1808,12 +1808,12 @@ this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); if (target != null) { -@@ -1711,16 +_,54 @@ +@@ -1751,16 +_,54 @@ } AABB boundingBox = target.getBoundingBox(); -- if (this.player.canInteractWithEntity(boundingBox, 3.0)) { -+ if (this.player.canInteractWithEntity(boundingBox, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience value for interact range +- if (packet.isWithinRange(this.player, boundingBox, 3.0)) { ++ if (packet.isWithinRange(this.player, boundingBox, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience value for interact range packet.dispatch( new ServerboundInteractPacket.Handler() { - private void performInteraction(InteractionHand hand, ServerGamePacketListenerImpl.EntityInteraction entityInteraction) { @@ -1846,7 +1846,7 @@ + // Refresh the current entity metadata + target.refreshEntityData(ServerGamePacketListenerImpl.this.player); + // SPIGOT-7136 - Allays -+ if (target instanceof net.minecraft.world.entity.animal.allay.Allay || target instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync ++ if (target instanceof net.minecraft.world.entity.animal.allay.Allay || target instanceof net.minecraft.world.entity.animal.equine.AbstractHorse) { // Paper - Fix horse armor desync + ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket( + target.getId(), java.util.Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()) + .map((slot) -> com.mojang.datafixers.util.Pair.of(slot, ((LivingEntity) target).getItemBySlot(slot).copy())) @@ -1868,7 +1868,7 @@ ItemStack itemStack1 = success.wasItemInteraction() ? itemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(ServerGamePacketListenerImpl.this.player, itemStack1, target); if (success.swingSource() == InteractionResult.SwingSource.SERVER) { -@@ -1732,13 +_,13 @@ +@@ -1772,13 +_,13 @@ @Override public void onInteraction(InteractionHand hand) { @@ -1884,7 +1884,7 @@ ); } -@@ -1746,14 +_,14 @@ +@@ -1786,7 +_,7 @@ public void onAttack() { if (!(target instanceof ItemEntity) && !(target instanceof ExperienceOrb) @@ -1893,7 +1893,8 @@ && !(target instanceof AbstractArrow abstractArrow && !abstractArrow.isAttackable())) { ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(InteractionHand.MAIN_HAND); if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { - ServerGamePacketListenerImpl.this.player.attack(target); +@@ -1795,7 +_,7 @@ + } } } else { - ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked")); @@ -1901,7 +1902,7 @@ ServerGamePacketListenerImpl.LOGGER .warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getPlainTextName()); } -@@ -1762,6 +_,27 @@ +@@ -1804,6 +_,27 @@ ); } } @@ -1929,31 +1930,32 @@ } } -@@ -1774,7 +_,7 @@ +@@ -1816,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; - this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION); + this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION, RespawnReason.END_PORTAL); // CraftBukkit this.resetPosition(); + this.restartClientLoadTimerAfterRespawn(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); - } else { -@@ -1782,11 +_,11 @@ +@@ -1825,12 +_,12 @@ return; } - this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED); + this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED, RespawnReason.DEATH); // CraftBukkit this.resetPosition(); + this.restartClientLoadTimerAfterRespawn(); if (this.server.isHardcore()) { - this.player.setGameMode(GameType.SPECTATOR); -- this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS).set(false, this.server); +- 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().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS).set(false, this.player.level()); // CraftBukkit - per-world ++ this.player.level().getGameRules().set(GameRules.SPECTATORS_GENERATE_CHUNKS, false, this.player.level()); // CraftBukkit - per-world } } break; -@@ -1797,16 +_,27 @@ +@@ -1841,16 +_,27 @@ @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { @@ -1983,7 +1985,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); -@@ -1822,7 +_,298 @@ +@@ -1866,7 +_,298 @@ } else { boolean flag = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -2283,7 +2285,7 @@ for (Entry entry : Int2ObjectMaps.fastIterable(packet.changedSlots())) { this.player.containerMenu.setRemoteSlotUnsafe(entry.getIntKey(), entry.getValue()); -@@ -1835,6 +_,8 @@ +@@ -1879,6 +_,8 @@ } else { this.player.containerMenu.broadcastChanges(); } @@ -2292,7 +2294,7 @@ } } } -@@ -1842,6 +_,14 @@ +@@ -1886,6 +_,14 @@ @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { @@ -2307,12 +2309,12 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1858,9 +_,44 @@ +@@ -1902,9 +_,44 @@ return; } + // Paper start - Add PlayerRecipeBookClickEvent -+ NamespacedKey recipeName = org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(recipeHolder.id().location()); ++ NamespacedKey recipeName = org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(recipeHolder.id().identifier()); + boolean makeAll = packet.useMaxItems(); + com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent paperEvent = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent( + this.player.getBukkitEntity(), recipeName, makeAll @@ -2353,7 +2355,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, recipeFromDisplay.display().display())); } -@@ -1874,6 +_,7 @@ +@@ -1918,6 +_,7 @@ @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2361,7 +2363,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1883,6 +_,7 @@ +@@ -1927,6 +_,7 @@ if (flag) { this.player.containerMenu.broadcastChanges(); } @@ -2369,7 +2371,7 @@ } } } -@@ -1899,10 +_,48 @@ +@@ -1943,10 +_,48 @@ boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); @@ -2418,7 +2420,7 @@ } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -1916,15 +_,38 @@ +@@ -1960,15 +_,38 @@ @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { @@ -2458,7 +2460,7 @@ if (!(serverLevel.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity)) { return; } -@@ -1936,14 +_,32 @@ +@@ -1980,14 +_,32 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); @@ -2492,7 +2494,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != isModelPartShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -1959,7 +_,7 @@ +@@ -2003,7 +_,7 @@ packet.difficulty().getDisplayName() ); } else { @@ -2501,7 +2503,7 @@ } } -@@ -1973,7 +_,7 @@ +@@ -2017,7 +_,7 @@ packet.mode().getShortDisplayName().getString() ); } else { @@ -2510,7 +2512,7 @@ } } -@@ -1993,7 +_,7 @@ +@@ -2037,7 +_,7 @@ ProfilePublicKey.Data data2 = data.profilePublicKey(); if (!Objects.equals(data1, data2)) { if (data1 != null && data2.expiresAt().isBefore(data1.expiresAt())) { @@ -2519,7 +2521,7 @@ } else { try { SignatureValidator signatureValidator = this.server.services().profileKeySignatureValidator(); -@@ -2004,8 +_,8 @@ +@@ -2048,8 +_,8 @@ this.resetPlayerChatState(data.validate(this.player.getGameProfile(), signatureValidator)); } catch (ProfilePublicKey.ValidationException var6) { @@ -2530,7 +2532,7 @@ } } } -@@ -2016,11 +_,13 @@ +@@ -2060,11 +_,13 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -2545,7 +2547,7 @@ } } -@@ -2038,27 +_,32 @@ +@@ -2082,27 +_,32 @@ private void resetPlayerChatState(RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2579,7 +2581,30 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -2089,4 +_,80 @@ +@@ -2130,13 +_,21 @@ + } + + public boolean hasClientLoaded() { +- return !this.waitingForRespawn && this.clientLoadedTimeoutTimer <= 0; ++ return !this.waitingForRespawn; // Paper - Add PlayerLoadedWorldEvent + } + + public void tickClientLoadTimeout() { + if (this.clientLoadedTimeoutTimer > 0) { + this.clientLoadedTimeoutTimer--; + } ++ // Paper start - Add PlayerLoadedWorldEvent ++ if (this.clientLoadedTimeoutTimer <= 0) { ++ this.waitingForRespawn = false; ++ ++ final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent(this.player.getBukkitEntity(), true); ++ event.callEvent(); ++ } ++ // Paper end - Add PlayerLoadedWorldEvent + } + + private void markClientLoaded() { +@@ -2156,4 +_,80 @@ interface EntityInteraction { InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); } 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 9c74541405f7..309f08241a73 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 @@ -1,7 +1,7 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -45,9 +_,16 @@ - import org.apache.commons.lang3.Validate; +@@ -46,9 +_,16 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; +// CraftBukkit start @@ -17,26 +17,26 @@ private static final int MAX_TICKS_BEFORE_LOGIN = 600; private final byte[] challenge; final MinecraftServer server; -@@ -55,21 +_,36 @@ +@@ -56,10 +_,15 @@ + final ServerActivityMonitor serverActivityMonitor; public volatile ServerLoginPacketListenerImpl.State state = ServerLoginPacketListenerImpl.State.HELLO; private int tick; - @Nullable -- String requestedUsername; -+ public String requestedUsername; // Paper - @Nullable - public GameProfile authenticatedProfile; +- @Nullable String requestedUsername; ++ public @Nullable String requestedUsername; // Paper - public + public @Nullable GameProfile authenticatedProfile; private final String serverId = ""; - private final boolean transferred; + public final boolean transferred; // Paper + public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding + private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support -+ public @Nullable java.util.UUID requestedUuid; // Paper ++ public java.util.@Nullable UUID requestedUuid; // Paper + private final io.papermc.paper.connection.PaperPlayerLoginConnection paperLoginConnection; // Paper - Config API + private volatile boolean disconnecting = false; // Paper - Fix disconnect still ticking login public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) { this.server = server; - this.connection = connection; +@@ -67,10 +_,20 @@ + 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 @@ -56,7 +56,7 @@ if (this.state == ServerLoginPacketListenerImpl.State.VERIFYING) { this.verifyLoginAndFinishConnectionSetup(Objects.requireNonNull(this.authenticatedProfile)); } -@@ -79,11 +_,23 @@ +@@ -80,11 +_,23 @@ this.finishLoginAndWaitForClient(this.authenticatedProfile); } @@ -80,7 +80,7 @@ @Override public boolean isAcceptingMessages() { return this.connection.isConnected(); -@@ -94,6 +_,7 @@ +@@ -95,6 +_,7 @@ LOGGER.info("Disconnecting {}: {}", this.getUserName(), reason.getString()); this.connection.send(new ClientboundLoginDisconnectPacket(reason)); this.connection.disconnect(reason); @@ -88,7 +88,7 @@ } catch (Exception var3) { LOGGER.error("Error whilst disconnecting player", (Throwable)var3); } -@@ -116,7 +_,14 @@ +@@ -117,7 +_,14 @@ @Override public void handleHello(ServerboundHelloPacket packet) { Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet"); @@ -104,7 +104,7 @@ this.requestedUsername = packet.name(); GameProfile singleplayerProfile = this.server.getSingleplayerProfile(); if (singleplayerProfile != null && this.requestedUsername.equalsIgnoreCase(singleplayerProfile.name())) { -@@ -126,7 +_,32 @@ +@@ -127,7 +_,32 @@ this.state = ServerLoginPacketListenerImpl.State.KEY; this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true)); } else { @@ -138,7 +138,7 @@ } } } -@@ -138,7 +_,7 @@ +@@ -139,7 +_,7 @@ private void verifyLoginAndFinishConnectionSetup(GameProfile profile) { PlayerList playerList = this.server.getPlayerList(); @@ -147,7 +147,7 @@ if (component != null) { this.disconnect(component); } else { -@@ -150,7 +_,7 @@ +@@ -151,7 +_,7 @@ ); } @@ -156,7 +156,7 @@ if (flag) { this.state = ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT; } else { -@@ -162,6 +_,7 @@ +@@ -163,6 +_,7 @@ private void finishLoginAndWaitForClient(GameProfile profile) { this.state = ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING; this.connection.send(new ClientboundLoginFinishedPacket(profile)); @@ -164,7 +164,7 @@ } @Override -@@ -185,7 +_,8 @@ +@@ -186,7 +_,8 @@ throw new IllegalStateException("Protocol error", var7); } @@ -174,7 +174,7 @@ @Override public void run() { String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); -@@ -197,11 +_,17 @@ +@@ -198,12 +_,18 @@ .hasJoinedServer(string1, string, this.getAddress()); if (profileResult != null) { GameProfile gameProfile = profileResult.profile(); @@ -185,6 +185,7 @@ + gameProfile = ServerLoginPacketListenerImpl.this.callPlayerPreLoginEvents(gameProfile); // Paper - Add more fields to AsyncPlayerPreLoginEvent + // CraftBukkit end ServerLoginPacketListenerImpl.LOGGER.info("UUID of player {} is {}", gameProfile.name(), gameProfile.id()); + ServerLoginPacketListenerImpl.this.serverActivityMonitor.reportLoginActivity(); ServerLoginPacketListenerImpl.this.startClientVerification(gameProfile); } else if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Failed to verify username but will let them in anyway!"); @@ -193,7 +194,7 @@ } else { ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", string1); -@@ -209,11 +_,16 @@ +@@ -211,11 +_,16 @@ } catch (AuthenticationUnavailableException var4) { if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) { ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!"); @@ -212,7 +213,7 @@ } } -@@ -224,18 +_,113 @@ +@@ -225,18 +_,113 @@ ? ((InetSocketAddress)remoteAddress).getAddress() : null; } @@ -330,7 +331,7 @@ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"); this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); CommonListenerCookie commonListenerCookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred); -@@ -254,8 +_,31 @@ +@@ -255,8 +_,31 @@ @Override public void handleCookieResponse(ServerboundCookieResponsePacket packet) { 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 55476434f5a2..616349a9566f 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 @@ -1,8 +1,8 @@ --- a/net/minecraft/server/network/config/PrepareSpawnTask.java +++ b/net/minecraft/server/network/config/PrepareSpawnTask.java -@@ -37,10 +_,17 @@ - @Nullable - private PrepareSpawnTask.State state; +@@ -36,10 +_,17 @@ + final LevelLoadListener loadListener; + private PrepareSpawnTask.@Nullable State state; - public PrepareSpawnTask(MinecraftServer server, NameAndId nameAndId) { + // Paper start - passthrough profile and packet listener @@ -21,7 +21,7 @@ } @Override -@@ -50,15 +_,57 @@ +@@ -49,15 +_,57 @@ .getPlayerList() .loadPlayerData(this.nameAndId) .map(compoundTag -> TagValueInput.create(scopedCollector, this.server.registryAccess(), compoundTag)); @@ -83,7 +83,7 @@ CompletableFuture completableFuture = savedPosition.position() .map(CompletableFuture::completedFuture) .orElseGet(() -> PlayerSpawnFinder.findSpawn(serverLevel, respawnData.pos())); -@@ -113,11 +_,12 @@ +@@ -112,10 +_,11 @@ } final class Preparing implements PrepareSpawnTask.State { @@ -93,13 +93,12 @@ + private ServerLevel spawnLevel; // Paper - remove final + private CompletableFuture spawnPosition; // Paper - remove final + private Vec2 spawnAngle; // Paper - remove final - @Nullable - private CompletableFuture chunkLoadFuture; + private @Nullable CompletableFuture chunkLoadFuture; + private @Nullable CompletableFuture eventFuture; // Paper private final ChunkLoadCounter chunkLoadCounter = new ChunkLoadCounter(); Preparing(final ServerLevel spawnLevel, final CompletableFuture spawnPosition, final Vec2 spawnAngle) { -@@ -137,6 +_,50 @@ +@@ -134,6 +_,50 @@ } else { Vec3 vec3 = this.spawnPosition.join(); if (this.chunkLoadFuture == null) { @@ -150,7 +149,7 @@ ChunkPos chunkPos = new ChunkPos(BlockPos.containing(vec3)); this.chunkLoadCounter .track( -@@ -177,15 +_,48 @@ +@@ -174,15 +_,48 @@ public ServerPlayer spawn(Connection connection, CommonListenerCookie cookie) { ChunkPos chunkPos = new ChunkPos(BlockPos.containing(this.spawnPosition)); this.spawnLevel.waitForEntities(chunkPos, 3); diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch index c58986091655..83ebfe93a472 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/EmptyNotificationService.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/notifications/EmptyNotificationService.java +++ b/net/minecraft/server/notifications/EmptyNotificationService.java -@@ -65,7 +_,7 @@ +@@ -69,7 +_,7 @@ } @Override -- public void onGameRuleChanged(String key, GameRules.Value value) { -+ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value) { // Paper - per-world game rules (add level param) +- public void onGameRuleChanged(GameRule rule, T value) { ++ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value) { // Paper - per-world game rules (add level param) } @Override 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 1ee81048e872..9caace376939 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,13 +1,13 @@ --- a/net/minecraft/server/notifications/NotificationManager.java +++ b/net/minecraft/server/notifications/NotificationManager.java -@@ -87,8 +_,8 @@ +@@ -92,8 +_,8 @@ } @Override -- public void onGameRuleChanged(String key, GameRules.Value value) { -- this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(key, value)); -+ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value) { // Paper - per-world game rules (add level param) -+ this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(level, key, value)); // Paper - per-world game rules (add level param) +- public void onGameRuleChanged(GameRule rule, T value) { +- this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(rule, value)); ++ public void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value) { // Paper - per-world game rules (add level param) ++ this.notificationServices.forEach(notificationService -> notificationService.onGameRuleChanged(level, rule, value)); // Paper - per-world game rules (add level param) } @Override diff --git a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch index 366caf0f5fb5..735ae3988d81 100644 --- a/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/notifications/NotificationService.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/notifications/NotificationService.java +++ b/net/minecraft/server/notifications/NotificationService.java -@@ -36,7 +_,7 @@ +@@ -38,7 +_,7 @@ void playerUnbanned(NameAndId nameAndId); -- void onGameRuleChanged(String key, GameRules.Value value); -+ void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, String key, GameRules.Value value); // Paper - per-world game rules (add level param) +- void onGameRuleChanged(GameRule rule, T value); ++ void onGameRuleChanged(net.minecraft.server.level.ServerLevel level, GameRule rule, T value); // Paper - per-world game rules (add level param) void statusHeartbeat(); } diff --git a/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch b/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch index 344f5284c4a9..95ae2eebfd30 100644 --- a/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/packs/PathPackResources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/PathPackResources.java +++ b/net/minecraft/server/packs/PathPackResources.java -@@ -124,6 +_,12 @@ +@@ -120,6 +_,12 @@ try (DirectoryStream directoryStream = Files.newDirectoryStream(path)) { for (Path path1 : directoryStream) { String string = path1.getFileName().toString(); @@ -10,6 +10,6 @@ + continue; + } + // Paper end - Improve logging and errors - if (ResourceLocation.isValidNamespace(string)) { + if (Identifier.isValidNamespace(string)) { set.add(string); } else { diff --git a/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch b/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch index ee3142e9b547..dbb1f23f29a0 100644 --- a/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/packs/repository/ServerPacksSource.java.patch @@ -5,14 +5,14 @@ return new VanillaPackResourcesBuilder() .setMetadata(BUILT_IN_METADATA) - .exposeNamespace("minecraft") -+ .exposeNamespace("minecraft", ResourceLocation.PAPER_NAMESPACE) // Paper ++ .exposeNamespace("minecraft", Identifier.PAPER_NAMESPACE) // Paper .applyDevelopmentConfig() .pushJarResources() .build(VANILLA_PACK_INFO); -@@ -68,15 +_,26 @@ - @Nullable +@@ -66,15 +_,26 @@ + @Override - protected Pack createBuiltinPack(String id, Pack.ResourcesSupplier resources, Component title) { + protected @Nullable Pack createBuiltinPack(String id, Pack.ResourcesSupplier resources, Component title) { - return Pack.readMetaAndCreate(createBuiltInPackLocation(id, title), resources, PackType.SERVER_DATA, FEATURE_SELECTION_CONFIG); + // Paper start - custom built-in pack + final PackLocationInfo info; diff --git a/paper-server/patches/sources/net/minecraft/server/permissions/PermissionProviderCheck.java.patch b/paper-server/patches/sources/net/minecraft/server/permissions/PermissionProviderCheck.java.patch new file mode 100644 index 000000000000..205aa6425bd4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/permissions/PermissionProviderCheck.java.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/server/permissions/PermissionProviderCheck.java ++++ b/net/minecraft/server/permissions/PermissionProviderCheck.java +@@ -2,9 +_,21 @@ + + import java.util.function.Predicate; + +-public record PermissionProviderCheck(PermissionCheck test) implements Predicate { ++public record PermissionProviderCheck(PermissionCheck test, java.util.concurrent.atomic.AtomicReference> vanillaNode) implements Predicate { // Paper - Vanilla Command permission checking + @Override + public boolean test(T permissionsSupplier) { ++ // Paper start - Vanilla Command permission checking ++ com.mojang.brigadier.tree.CommandNode currentCommand = vanillaNode.get(); ++ if (currentCommand != null && permissionsSupplier instanceof net.minecraft.commands.CommandSourceStack commandSourceStack && this.test instanceof net.minecraft.server.permissions.PermissionCheck.Require req) { ++ return commandSourceStack.hasPermission(req.permission(), org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand)); ++ } ++ // Paper end - Vanilla Command permission checking + return this.test.check(permissionsSupplier.permissions()); + } ++ ++ // Paper start - Vanilla Command permission checking ++ public PermissionProviderCheck(final PermissionCheck test) { ++ this(test, new java.util.concurrent.atomic.AtomicReference<>(null)); ++ } ++ // Paper end - Vanilla Command permission checking + } 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 ae8148986ac3..adebe9c189b2 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/BanListEntry.java +++ b/net/minecraft/server/players/BanListEntry.java -@@ -28,7 +_,7 @@ +@@ -26,7 +_,7 @@ } protected BanListEntry(@Nullable T user, JsonObject entryData) { @@ -9,7 +9,7 @@ Date date; try { -@@ -103,4 +_,22 @@ +@@ -99,4 +_,22 @@ return false; } } diff --git a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch index a3f47d46dee6..cdbf2f1a6c97 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/CachedUserNameToIdResolver.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/CachedUserNameToIdResolver.java +++ b/net/minecraft/server/players/CachedUserNameToIdResolver.java -@@ -45,6 +_,10 @@ +@@ -46,6 +_,10 @@ private final Gson gson = new GsonBuilder().create(); private final File file; private final AtomicLong operationCount = new AtomicLong(); @@ -11,7 +11,7 @@ public CachedUserNameToIdResolver(GameProfileRepository profileRepository, File file) { this.profileRepository = profileRepository; -@@ -53,23 +_,27 @@ +@@ -54,23 +_,27 @@ } private void safeAdd(CachedUserNameToIdResolver.GameProfileInfo profileInfo) { @@ -41,7 +41,7 @@ } @Override -@@ -89,7 +_,7 @@ +@@ -90,7 +_,7 @@ Date time = instance.getTime(); CachedUserNameToIdResolver.GameProfileInfo gameProfileInfo = new CachedUserNameToIdResolver.GameProfileInfo(nameAndId, time); this.safeAdd(gameProfileInfo); @@ -50,7 +50,7 @@ return gameProfileInfo; } -@@ -97,9 +_,24 @@ +@@ -98,9 +_,24 @@ return this.operationCount.incrementAndGet(); } @@ -75,7 +75,7 @@ CachedUserNameToIdResolver.GameProfileInfo gameProfileInfo = this.profilesByName.get(string); boolean flag = false; if (gameProfileInfo != null && new Date().getTime() >= gameProfileInfo.expirationDate.getTime()) { -@@ -113,8 +_,13 @@ +@@ -114,8 +_,13 @@ if (gameProfileInfo != null) { gameProfileInfo.setLastAccess(this.getNextOperation()); optional = Optional.of(gameProfileInfo.nameAndId()); @@ -90,7 +90,7 @@ if (optional1.isPresent()) { optional = Optional.of(this.addInternal(optional1.get()).nameAndId()); flag = false; -@@ -123,15 +_,17 @@ +@@ -124,15 +_,17 @@ } } @@ -110,7 +110,7 @@ CachedUserNameToIdResolver.GameProfileInfo gameProfileInfo = this.profilesByUUID.get(uuid); if (gameProfileInfo == null) { return Optional.empty(); -@@ -139,6 +_,7 @@ +@@ -140,6 +_,7 @@ gameProfileInfo.setLastAccess(this.getNextOperation()); return Optional.of(gameProfileInfo.nameAndId()); } @@ -118,7 +118,7 @@ } private static DateFormat createDateFormat() { -@@ -163,6 +_,11 @@ +@@ -164,6 +_,11 @@ return (List)var9; } catch (FileNotFoundException var7) { @@ -130,7 +130,7 @@ } catch (JsonParseException | IOException var8) { LOGGER.warn("Failed to load profile cache {}", this.file, var8); } -@@ -172,23 +_,51 @@ +@@ -173,23 +_,51 @@ @Override public void save() { diff --git a/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch b/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch index a4ff1aa54164..d8dcdd205edc 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/NameAndId.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/NameAndId.java +++ b/net/minecraft/server/players/NameAndId.java -@@ -49,4 +_,10 @@ +@@ -48,4 +_,10 @@ UUID uuid = UUIDUtil.createOfflinePlayerUUID(name); return new NameAndId(uuid, name); } diff --git a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch index b19ec1420d2b..c7f7b5f5feb2 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch @@ -46,7 +46,7 @@ } } -@@ -318,6 +_,37 @@ +@@ -317,6 +_,37 @@ private void movePlayerFile(File file3, String oldFileName, String newFileName) { File file4 = new File(worldPlayersDirectory, oldFileName + ".dat"); File file5 = new File(file3, newFileName + ".dat"); 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 f21e8fc306bc..b90e3c916231 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 @@ -1,8 +1,8 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -110,14 +_,16 @@ +@@ -114,14 +_,16 @@ private static final int SEND_PLAYER_INFO_INTERVAL = 600; - private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); + 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 @@ -20,7 +20,7 @@ public final PlayerDataStorage playerIo; private final LayeredRegistryAccess registries; private int viewDistance; -@@ -125,9 +_,17 @@ +@@ -129,9 +_,17 @@ private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -38,7 +38,7 @@ this.server = server; this.registries = registries; this.playerIo = playerIo; -@@ -137,23 +_,19 @@ +@@ -141,23 +_,19 @@ this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); } @@ -67,7 +67,7 @@ LevelData levelData = serverLevel.getLevelData(); ServerGamePacketListenerImpl serverGamePacketListenerImpl = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); connection.setupInboundProtocol( -@@ -170,8 +_,8 @@ +@@ -175,8 +_,8 @@ levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -75,10 +75,10 @@ - this.getSimulationDistance(), + serverLevel.spigotConfig.viewDistance, // Spigot - view distance + serverLevel.spigotConfig.simulationDistance, // Spigot - simulation distance - _boolean1, - !_boolean, - _boolean2, -@@ -179,6 +_,7 @@ + flag1, + !flag, + flag2, +@@ -184,6 +_,7 @@ this.server.enforceSecureProfile() ) ); @@ -86,7 +86,7 @@ serverGamePacketListenerImpl.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverGamePacketListenerImpl.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); serverGamePacketListenerImpl.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); -@@ -198,23 +_,128 @@ +@@ -203,24 +_,129 @@ mutableComponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), string); } @@ -187,6 +187,7 @@ + // Paper - move loading pearls / parent vehicle up player.initInventoryMenu(); this.server.notificationManager().playerJoined(player); + serverGamePacketListenerImpl.resumeFlushing(); + // Paper start - Configurable player collision; Add to collideRule team if needed + final net.minecraft.world.scores.Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard(); + final PlayerTeam collideRuleTeam = scoreboard.getPlayerTeam(this.collideRuleTeamName); @@ -219,7 +220,7 @@ } public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { -@@ -236,31 +_,40 @@ +@@ -242,31 +_,40 @@ } } @@ -241,7 +242,7 @@ } @Override - public void onLerpSize(WorldBorder border, double oldSize, double newSize, long time) { + public void onLerpSize(WorldBorder border, double oldSize, double newSize, long time, long startTime) { - PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(border), level.dimension()); + PlayerList.this.broadcastWorldborder(new ClientboundSetBorderLerpSizePacket(border), level.dimension()); // Paper - virtual world border API } @@ -265,7 +266,7 @@ } @Override -@@ -284,57 +_,137 @@ +@@ -290,56 +_,137 @@ } protected void save(ServerPlayer player) { @@ -285,11 +286,11 @@ } - public void remove(ServerPlayer player) { -+ public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component ++ public net.kyori.adventure.text.@Nullable Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component + // Paper start - Fix kick event leave message not being sent + return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); + } -+ public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { ++ public net.kyori.adventure.text.@Nullable Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { + // Paper end - Fix kick event leave message not being sent ServerLevel serverLevel = player.level(); player.awardStat(Stats.LEAVE_GAME); @@ -332,7 +333,7 @@ - rootVehicle.getPassengersAndSelf().forEach(entity -> entity.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER)); + rootVehicle.getPassengersAndSelf().forEach(entity -> { + // Paper start - Fix villager boat exploit -+ if (entity instanceof net.minecraft.world.entity.npc.AbstractVillager villager) { ++ if (entity instanceof net.minecraft.world.entity.npc.villager.AbstractVillager villager) { + final net.minecraft.world.entity.player.Player human = villager.getTradingPlayer(); + if (human != null) { + villager.setTradingPlayer(null); @@ -377,8 +378,7 @@ - this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID()))); - } - -- @Nullable -- public Component canPlayerLogin(SocketAddress socketAddress, NameAndId nameAndId) { +- public @Nullable Component canPlayerLogin(SocketAddress socketAddress, NameAndId nameAndId) { - if (this.bans.isBanned(nameAndId)) { - UserBanListEntry userBanListEntry = this.bans.get(nameAndId); + // CraftBukkit start @@ -400,7 +400,7 @@ + } + + // Paper start - PlayerLoginEvent -+ public record LoginResult(@Nullable Component message, @org.jetbrains.annotations.NotNull org.bukkit.event.player.PlayerLoginEvent.Result result) { ++ public record LoginResult(@Nullable Component message, org.bukkit.event.player.PlayerLoginEvent.Result result) { + public static LoginResult ALLOW = new net.minecraft.server.players.PlayerList.LoginResult(null, org.bukkit.event.player.PlayerLoginEvent.Result.ALLOWED); + + public boolean isAllowed() { @@ -417,7 +417,7 @@ MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned.reason", userBanListEntry.getReasonMessage()); if (userBanListEntry.getExpires() != null) { mutableComponent.append( -@@ -342,9 +_,11 @@ +@@ -347,9 +_,11 @@ ); } @@ -432,7 +432,7 @@ } else if (this.ipBans.isBanned(socketAddress)) { IpBanListEntry ipBanListEntry = this.ipBans.get(socketAddress); MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipBanListEntry.getReasonMessage()); -@@ -354,19 +_,18 @@ +@@ -359,19 +_,18 @@ ); } @@ -457,7 +457,7 @@ set.add(serverPlayer); } } -@@ -377,23 +_,31 @@ +@@ -382,23 +_,31 @@ } for (ServerPlayer serverPlayer2 : set) { @@ -494,7 +494,7 @@ serverPlayer.copyRespawnPosition(player); } -@@ -401,17 +_,26 @@ +@@ -406,17 +_,26 @@ serverPlayer.addTag(string); } @@ -522,7 +522,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -421,9 +_,15 @@ +@@ -426,9 +_,15 @@ this.sendPlayerPermissionLevel(serverPlayer); level.addRespawnedPlayer(serverPlayer); this.players.add(serverPlayer); @@ -538,7 +538,7 @@ ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); if (!keepInventory && respawnConfig != null) { LevelData.RespawnData respawnData = respawnConfig.respawnData(); -@@ -449,6 +_,29 @@ +@@ -454,6 +_,29 @@ } } @@ -568,7 +568,7 @@ return serverPlayer; } -@@ -457,23 +_,58 @@ +@@ -462,23 +_,58 @@ } public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) { @@ -590,7 +590,7 @@ + + public void sendPlayerPermissionLevel(ServerPlayer player, boolean recalculatePermissions) { + // Paper end - avoid recalculating permissions if possible - int profilePermissions = this.server.getProfilePermissions(player.nameAndId()); + LevelBasedPermissionSet profilePermissions = this.server.getProfilePermissions(player.nameAndId()); - this.sendPlayerPermissionLevel(player, profilePermissions); + this.sendPlayerPermissionLevel(player, profilePermissions, recalculatePermissions); // Paper - avoid recalculating permissions if possible } @@ -630,20 +630,20 @@ public void broadcastAll(Packet packet) { for (ServerPlayer serverPlayer : this.players) { serverPlayer.connection.send(packet); -@@ -559,6 +_,12 @@ +@@ -564,6 +_,12 @@ } - private void sendPlayerPermissionLevel(ServerPlayer player, int permLevel) { + private void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions) { + // Paper start - Add sendOpLevel API -+ this.sendPlayerPermissionLevel(player, permLevel, true); ++ this.sendPlayerPermissionLevel(player, permissions, true); + } + -+ public void sendPlayerPermissionLevel(ServerPlayer player, int permLevel, boolean recalculatePermissions) { ++ public void sendPlayerPermissionLevel(ServerPlayer player, LevelBasedPermissionSet permissions, boolean recalculatePermissions) { + // Paper end - Add sendOpLevel API if (player.connection != null) { - byte b; - if (permLevel <= 0) { -@@ -572,9 +_,48 @@ + byte b = switch (permissions.level()) { + case ALL -> EntityEvent.PERMISSION_LEVEL_ALL; +@@ -575,9 +_,48 @@ player.connection.send(new ClientboundEntityEventPacket(player, b)); } @@ -694,10 +694,10 @@ public boolean isWhiteListed(NameAndId nameAndId) { return !this.isUsingWhitelist() || this.ops.contains(nameAndId) || this.whitelist.contains(nameAndId); } -@@ -587,21 +_,17 @@ +@@ -589,21 +_,17 @@ + } - @Nullable - public ServerPlayer getPlayerByName(String username) { + public @Nullable ServerPlayer getPlayerByName(String username) { - int size = this.players.size(); - - for (int i = 0; i < size; i++) { @@ -722,7 +722,7 @@ if (serverPlayer != except && serverPlayer.level().dimension() == dimension) { double d = x - serverPlayer.getX(); double d1 = y - serverPlayer.getY(); -@@ -614,9 +_,11 @@ +@@ -616,9 +_,11 @@ } public void saveAll() { @@ -734,9 +734,9 @@ } public UserWhiteList getWhiteList() { -@@ -643,10 +_,18 @@ +@@ -645,10 +_,18 @@ player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); - player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); + player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().get(GameRules.ADVANCE_TIME))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getRespawnData())); + // Paper start + player.connection.send(new ClientboundSetChunkCacheRadiusPacket(level.spigotConfig.viewDistance)); @@ -756,7 +756,7 @@ } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -655,8 +_,21 @@ +@@ -657,8 +_,21 @@ public void sendAllPlayerInfo(ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -771,15 +771,15 @@ + player.refreshEntityData(player); // CraftBukkit - SPIGOT-7218: sync metadata player.connection.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); + // CraftBukkit start - from GameRules -+ int i = player.level().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; ++ int i = player.level().getGameRules().get(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23; + player.connection.send(new ClientboundEntityEventPacket(player, (byte) i)); -+ float immediateRespawn = player.level().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; ++ float immediateRespawn = player.level().getGameRules().get(GameRules.IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; + player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, immediateRespawn)); + // CraftBukkit end } public int getPlayerCount() { -@@ -705,9 +_,26 @@ +@@ -706,9 +_,26 @@ } public void removeAll() { @@ -809,7 +809,7 @@ } public void broadcastSystemMessage(Component message, boolean overlay) { -@@ -730,20 +_,39 @@ +@@ -731,20 +_,39 @@ } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound boundChatType) { @@ -852,43 +852,32 @@ flag1 |= flag2 && message.isFullyFiltered(); } -@@ -756,15 +_,21 @@ +@@ -757,13 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } - public ServerStatsCounter getPlayerStats(Player player) { -- GameProfile gameProfile = player.getGameProfile(); -- UUID uuid = gameProfile.id(); -- ServerStatsCounter serverStatsCounter = this.stats.get(uuid); + // CraftBukkit start + public ServerStatsCounter getPlayerStats(ServerPlayer player) { -+ ServerStatsCounter serverstatisticmanager = player.getStats(); -+ return serverstatisticmanager == null ? this.getPlayerStats(player.getUUID(), player.getGameProfile().name()) : serverstatisticmanager; // Paper - use username and not display name + GameProfile gameProfile = player.getGameProfile(); +- return this.stats.computeIfAbsent(gameProfile.id(), uuid -> { ++ ServerStatsCounter playerStatsCounter = player.getStats(); ++ if (playerStatsCounter == null) { ++ return this.getPlayerStats(gameProfile); ++ } else { ++ return playerStatsCounter; ++ } + } -+ -+ public ServerStatsCounter getPlayerStats(UUID uuid, String displayName) { -+ ServerPlayer player = this.getPlayer(uuid); -+ ServerStatsCounter serverStatsCounter = player == null ? null : player.getStats(); -+ // CraftBukkit end - if (serverStatsCounter == null) { - File file = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); - File file1 = new File(file, uuid + ".json"); - if (!file1.exists()) { -- File file2 = new File(file, gameProfile.name() + ".json"); -+ File file2 = new File(file, displayName + ".json"); // CraftBukkit - Path path = file2.toPath(); - if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { - file2.renameTo(file1); -@@ -772,7 +_,7 @@ - } - - serverStatsCounter = new ServerStatsCounter(this.server, file1); -- this.stats.put(uuid, serverStatsCounter); -+ // this.stats.put(uuid, serverStatsCounter); // CraftBukkit - } ++ public ServerStatsCounter getPlayerStats(GameProfile gameProfile) { + Path path = this.locateStatsFile(gameProfile); + return new ServerStatsCounter(this.server, path); +- }); + } ++ // CraftBukkit end - return serverStatsCounter; -@@ -780,11 +_,11 @@ + private Path locateStatsFile(GameProfile profile) { + Path worldPath = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR); +@@ -790,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -902,7 +891,7 @@ } playerAdvancements.setPlayer(player); -@@ -838,11 +_,34 @@ +@@ -842,11 +_,34 @@ } public void reloadResources() { diff --git a/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch index efea418a123a..b0d0b8a25fb1 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/StoredUserList.java.patch @@ -9,10 +9,10 @@ protected final NotificationService notificationService; public StoredUserList(File file, NotificationService notificationService) { -@@ -60,8 +_,11 @@ +@@ -59,8 +_,11 @@ + } - @Nullable - public V get(K user) { + public @Nullable V get(K user) { - this.removeExpired(); - return this.map.get(this.getKeyForUser(user)); + // Paper start - Use ConcurrentHashMap in StoredUserList @@ -23,16 +23,7 @@ } public boolean remove(K user) { -@@ -98,7 +_,7 @@ - } - - public boolean isEmpty() { -- return this.map.size() < 1; -+ return this.map.isEmpty(); // Paper - Use ConcurrentHashMap in StoredUserList - } - - protected String getKeyForUser(K user) { -@@ -106,21 +_,12 @@ +@@ -105,21 +_,12 @@ } protected boolean contains(K entry) { @@ -56,7 +47,7 @@ } protected abstract StoredUserEntry createEntry(JsonObject entryData); -@@ -130,6 +_,7 @@ +@@ -129,6 +_,7 @@ } public void save() throws IOException { @@ -64,7 +55,7 @@ JsonArray jsonArray = new JsonArray(); this.map.values().stream().map(storedEntry -> Util.make(new JsonObject(), storedEntry::serialize)).forEach(jsonArray::add); -@@ -154,7 +_,14 @@ +@@ -153,7 +_,14 @@ this.map.put(this.getKeyForUser(storedUserEntry.getUser()), (V)storedUserEntry); } } diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch index d0e4e10eae85..ef6f7fc283cd 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/RconConsoleSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/rcon/RconConsoleSource.java +++ b/net/minecraft/server/rcon/RconConsoleSource.java -@@ -13,8 +_,13 @@ +@@ -14,8 +_,13 @@ private static final Component RCON_COMPONENT = Component.literal("Rcon"); private final StringBuffer buffer = new StringBuffer(); private final MinecraftServer server; @@ -15,8 +15,8 @@ this.server = server; } -@@ -32,6 +_,17 @@ - this, Vec3.atLowerCornerOf(serverLevel.getRespawnData().pos()), Vec2.ZERO, serverLevel, 4, "Rcon", RCON_COMPONENT, this.server, null +@@ -41,6 +_,17 @@ + null ); } + diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch index d1a66ee01a94..a2323578dd66 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/QueryThreadGs4.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/rcon/thread/QueryThreadGs4.java +++ b/net/minecraft/server/rcon/thread/QueryThreadGs4.java -@@ -106,13 +_,32 @@ +@@ -105,13 +_,32 @@ NetworkDataOutputStream networkDataOutputStream = new NetworkDataOutputStream(1460); networkDataOutputStream.write(0); networkDataOutputStream.writeBytes(this.getIdentBytes(requestPacket.getSocketAddress())); @@ -39,7 +39,7 @@ this.sendTo(networkDataOutputStream.toByteArray(), requestPacket); LOGGER.debug("Status [{}]", socketAddress); } -@@ -147,31 +_,75 @@ +@@ -146,31 +_,75 @@ this.rulesResponse.writeString("splitnum"); this.rulesResponse.write(128); this.rulesResponse.write(0); diff --git a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch index 62a462ca730b..bd7388039ad4 100644 --- a/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/rcon/thread/RconThread.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/rcon/thread/RconThread.java +++ b/net/minecraft/server/rcon/thread/RconThread.java -@@ -57,7 +_,7 @@ - @Nullable - public static RconThread create(ServerInterface serverInterface) { +@@ -56,7 +_,7 @@ + + public static @Nullable RconThread create(ServerInterface serverInterface) { DedicatedServerProperties properties = serverInterface.getProperties(); - String serverIp = serverInterface.getServerIp(); + String serverIp = properties.rconIp; // Paper - Configurable rcon ip if (serverIp.isEmpty()) { serverIp = "0.0.0.0"; } -@@ -104,6 +_,14 @@ +@@ -103,6 +_,14 @@ this.clients.clear(); } diff --git a/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch b/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch deleted file mode 100644 index 9b3c295fd0bd..000000000000 --- a/paper-server/patches/sources/net/minecraft/server/waypoints/ServerWaypointManager.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/waypoints/ServerWaypointManager.java -+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java -@@ -102,7 +_,7 @@ - } - - private static boolean isLocatorBarEnabledFor(ServerPlayer player) { -- return player.level().getServer().getGameRules().getBoolean(GameRules.RULE_LOCATOR_BAR); -+ return player.level().getGameRules().getBoolean(GameRules.RULE_LOCATOR_BAR); // Paper - per world gamerules - } - - private void createConnection(ServerPlayer player, WaypointTransmitter waypoint) { diff --git a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch index 0ba528b7a58f..5b95b1fbe6b1 100644 --- a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch +++ b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java -@@ -68,9 +_,21 @@ - LOGGER.error("Couldn't parse statistics file {}", file, var5); +@@ -75,9 +_,21 @@ + LOGGER.error("Couldn't parse statistics file {}", file, var9); } } + // Paper start - Moved after stat fetching for player state file @@ -9,8 +9,8 @@ + // Disables saving any forced stats, so it stays at the same value (without enabling disableStatSaving) + // Fixes stat initialization to not cause a NullPointerException + // Spigot start -+ for (Map.Entry entry : org.spigotmc.SpigotConfig.forcedStats.entrySet()) { -+ Stat wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats ++ for (Map.Entry entry : org.spigotmc.SpigotConfig.forcedStats.entrySet()) { ++ Stat wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats + this.stats.put(wrapper, entry.getValue().intValue()); + } + // Spigot end @@ -20,14 +20,14 @@ public void save() { + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot try { - FileUtils.writeStringToFile(this.file, this.toJson()); - } catch (IOException var2) { -@@ -80,6 +_,8 @@ + FileUtil.createDirectoriesSafe(this.file.getParent()); + +@@ -91,6 +_,8 @@ @Override public void setValue(Player player, Stat stat, int value) { + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot -+ if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final net.minecraft.resources.ResourceLocation key && org.spigotmc.SpigotConfig.forcedStats.get(key) != null) return; // Paper - disable saving forced stats ++ if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final net.minecraft.resources.Identifier key && org.spigotmc.SpigotConfig.forcedStats.get(key) != null) return; // Paper - disable saving forced stats super.setValue(player, stat, value); this.dirty.add(stat); } diff --git a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch index fc75f3c8b79a..482a0e180c8e 100644 --- a/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/tags/TagLoader.java.patch @@ -4,15 +4,15 @@ return list.isEmpty() ? Either.right(List.copyOf(set)) : Either.left(list); } -- public Map> build(Map> builders) { +- public Map> build(Map> builders) { + // Paper start - fire tag registrar events -+ public Map> build(Map> builders, @Nullable io.papermc.paper.tag.TagEventConfig eventConfig) { ++ public Map> build(Map> builders, io.papermc.paper.tag.@Nullable TagEventConfig eventConfig) { + builders = io.papermc.paper.tag.PaperTagListenerManager.INSTANCE.firePreFlattenEvent(builders, eventConfig); + // Paper end - final Map> map = new HashMap<>(); + final Map> map = new HashMap<>(); TagEntry.Lookup lookup = new TagEntry.Lookup() { - @Nullable -@@ -114,7 +_,7 @@ + @Override +@@ -112,7 +_,7 @@ ) .ifRight(list -> map.put(path, (List)list)) ); @@ -21,7 +21,7 @@ } public static void loadTagsFromNetwork(TagNetworkSerialization.NetworkPayload payload, WritableRegistry registry) { -@@ -122,16 +_,27 @@ +@@ -120,16 +_,27 @@ } public static List> loadTagsForExistingRegistries(ResourceManager resourceManager, RegistryAccess registryAccess) { @@ -48,10 +48,10 @@ TagLoader> tagLoader = new TagLoader<>(TagLoader.ElementLookup.fromWritableRegistry(registry), Registries.tagsDirPath(resourceKey)); - tagLoader.build(tagLoader.load(resourceManager)) + tagLoader.build(tagLoader.load(resourceManager), io.papermc.paper.tag.PaperTagListenerManager.INSTANCE.createEventConfig(registry, cause)) // Paper - tag lifecycle - add registrar event cause - .forEach((resourceLocation, list) -> registry.bindTag(TagKey.create(resourceKey, resourceLocation), (List>)list)); + .forEach((identifier, list) -> registry.bindTag(TagKey.create(resourceKey, identifier), (List>)list)); } -@@ -139,12 +_,12 @@ +@@ -137,12 +_,12 @@ return tags.entrySet().stream().collect(Collectors.toUnmodifiableMap(entry -> TagKey.create(registryKey, entry.getKey()), Entry::getValue)); } diff --git a/paper-server/patches/sources/net/minecraft/Util.java.patch b/paper-server/patches/sources/net/minecraft/util/Util.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/Util.java.patch rename to paper-server/patches/sources/net/minecraft/util/Util.java.patch index df31260643f2..df53cdc99793 100644 --- a/paper-server/patches/sources/net/minecraft/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/Util.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/Util.java -+++ b/net/minecraft/Util.java -@@ -91,9 +_,25 @@ +--- a/net/minecraft/util/Util.java ++++ b/net/minecraft/util/Util.java +@@ -95,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,7 +28,7 @@ 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"); -@@ -112,6 +_,7 @@ +@@ -116,6 +_,7 @@ .findFirst() .orElseThrow(() -> new IllegalStateException("No jar file system provider found")); private static Consumer thePauser = string -> {}; @@ -36,7 +36,7 @@ public static Collector, ?, Map> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); -@@ -134,7 +_,7 @@ +@@ -138,7 +_,7 @@ } public static long getNanos() { @@ -45,7 +45,7 @@ } public static long getEpochMillis() { -@@ -145,9 +_,10 @@ +@@ -149,9 +_,10 @@ return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now()); } @@ -58,7 +58,7 @@ if (i <= 0) { directExecutorService = MoreExecutors.newDirectExecutorService(); } else { -@@ -172,16 +_,30 @@ +@@ -176,16 +_,30 @@ super.onTermination(throwOnTermination); } }; @@ -91,10 +91,11 @@ } private static int getMaxThreads() { -@@ -232,6 +_,21 @@ +@@ -235,6 +_,21 @@ + return thread; })); } - ++ + // Paper start - Separate dimension data IO pool + private static TracingExecutor makeExtraIoExecutor(String namePrefix) { + AtomicInteger atomicInteger = new AtomicInteger(1); @@ -109,25 +110,6 @@ + })); + } + // Paper end - Separate dimension data IO pool -+ + public static void throwAsRuntime(Throwable throwable) { throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); - } -@@ -1116,16 +_,7 @@ - } - - public void openUri(URI uri) { -- try { -- Process process = AccessController.doPrivileged( -- (PrivilegedExceptionAction)(() -> Runtime.getRuntime().exec(this.getOpenUriArguments(uri))) -- ); -- process.getInputStream().close(); -- process.getErrorStream().close(); -- process.getOutputStream().close(); -- } catch (IOException | PrivilegedActionException var3) { -- Util.LOGGER.error("Couldn't open location '{}'", uri, var3); -- } -+ throw new IllegalStateException("This method is not useful on dedicated servers."); // Paper - Fix warnings on build by removing client-only code - } - - public void openFile(File file) { 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 2b8d14d12c20..d89f25336169 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 -@@ -524,6 +_,24 @@ +@@ -534,6 +_,24 @@ Schema schema44 = builder.addSchema(1456, SAME_NAMESPACED); builder.addFixer(new EntityItemFrameDirectionFix(schema44, false)); Schema schema45 = builder.addSchema(1458, V1458::new); diff --git a/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch index f2f1d5f3aa93..92a4a56bc7e7 100644 --- a/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/parsing/packrat/Scope.java +++ b/net/minecraft/util/parsing/packrat/Scope.java -@@ -281,4 +_,36 @@ +@@ -279,4 +_,36 @@ return true; } 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 686f5748058b..e67149c78ee4 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 @@ -1,23 +1,22 @@ --- a/net/minecraft/util/random/WeightedList.java +++ b/net/minecraft/util/random/WeightedList.java -@@ -16,14 +_,14 @@ - import net.minecraft.util.ExtraCodecs; +@@ -16,13 +_,13 @@ import net.minecraft.util.RandomSource; + import org.jspecify.annotations.Nullable; -public final class WeightedList { +public class WeightedList { // Paper - non-final private static final int FLAT_THRESHOLD = 64; private final int totalWeight; private final List> items; - @Nullable - private final WeightedList.Selector selector; + private final WeightedList.@Nullable Selector selector; - WeightedList(List> items) { + protected WeightedList(List> items) { // Paper - protected this.items = List.copyOf(items); this.totalWeight = WeightedRandom.getTotalWeight(items, Weighted::weight); if (this.totalWeight == 0) { -@@ -129,7 +_,7 @@ +@@ -128,7 +_,7 @@ } public static class Builder { diff --git a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch index 31132f35d5e2..fe6961f40b5f 100644 --- a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -87,7 +_,7 @@ +@@ -89,7 +_,7 @@ boolean recreateRegionFiles ) { this.dimensions = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); @@ -9,12 +9,12 @@ this.eraseCache = eraseCache; this.dataFixer = dataFixer; this.levelStorage = levelStorage; -@@ -369,7 +_,7 @@ - int version = ChunkStorage.getVersion(compoundTag); +@@ -367,7 +_,7 @@ + int dataVersion = NbtUtils.getDataVersion(compoundTag); ChunkGenerator chunkGenerator = WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(dimension)).generator(); - CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag( -- dimension, () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer() -+ Registries.levelToLevelStem(dimension), () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer(), chunkPos, null // CraftBukkit + CompoundTag compoundTag1 = regionStorage.upgradeChunkTag( +- compoundTag, -1, ChunkMap.getChunkDataFixContextTag(dimension, chunkGenerator.getTypeNameForDataFixer()) ++ compoundTag, -1, ChunkMap.getChunkDataFixContextTag(Registries.levelToLevelStem(dimension), chunkGenerator.getTypeNameForDataFixer()), null // CraftBukkit ); ChunkPos chunkPos1 = new ChunkPos(compoundTag1.getIntOr("xPos", 0), compoundTag1.getIntOr("zPos", 0)); if (!chunkPos1.equals(chunkPos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/Container.java.patch b/paper-server/patches/sources/net/minecraft/world/Container.java.patch index 55c66d111110..b5e9379ac384 100644 --- a/paper-server/patches/sources/net/minecraft/world/Container.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/Container.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -28,9 +_,7 @@ +@@ -31,9 +_,7 @@ void setItem(int slot, ItemStack stack); @@ -11,7 +11,7 @@ default int getMaxStackSize(ItemStack stack) { return Math.min(this.getMaxStackSize(), stack.getMaxStackSize()); -@@ -123,4 +_,22 @@ +@@ -142,4 +_,22 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch b/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch index 71c9cd34dcb2..2b132d669a06 100644 --- a/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/InteractionResult.java.patch @@ -6,7 +6,7 @@ - public record Success(InteractionResult.SwingSource swingSource, InteractionResult.ItemContext itemContext) implements InteractionResult { + // Paper start - track more context in interaction result -+ public record PaperSuccessContext(@Nullable net.minecraft.core.BlockPos placedBlockPosition) { ++ public record PaperSuccessContext(net.minecraft.core.@Nullable BlockPos placedBlockPosition) { + static PaperSuccessContext DEFAULT = new PaperSuccessContext(null); + + public PaperSuccessContext placedBlockAt(final net.minecraft.core.BlockPos blockPos) { diff --git a/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch b/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch new file mode 100644 index 000000000000..300efc7b8464 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/LockCode.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/LockCode.java ++++ b/net/minecraft/world/LockCode.java +@@ -22,9 +_,15 @@ + } + } + ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - use new variant for event compatibility + public boolean canUnlock(Player player) { +- return player.isSpectator() || this.unlocksWith(player.getMainHandItem()); +- } ++ return player.isSpectator() || this.unlocksWith(player.getMainHandItem()); // Paper - diff on change ++ } ++ // Paper start - allow overriding key item ++ public boolean canUnlock(Player player, ItemStack keyItem) { ++ return player.isSpectator() || this.unlocksWith(keyItem); ++ } ++ // Paper end - allow overriding key item + + public static LockCode fromTag(ValueInput input) { + return input.read("lock", CODEC).orElse(NO_LOCK); 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 169adf2ef107..cf20d20fe90d 100644 --- a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/RandomizableContainer.java +++ b/net/minecraft/world/RandomizableContainer.java -@@ -27,7 +_,7 @@ +@@ -26,7 +_,7 @@ void setLootTable(@Nullable ResourceKey lootTable); @@ -9,7 +9,7 @@ this.setLootTable(lootTable); this.setLootTableSeed(seed); } -@@ -50,8 +_,9 @@ +@@ -48,8 +_,9 @@ default boolean tryLoadLootTable(ValueInput input) { ResourceKey resourceKey = input.read("LootTable", LootTable.KEY_CODEC).orElse(null); this.setLootTable(resourceKey); @@ -20,7 +20,7 @@ } default boolean trySaveLootTable(ValueOutput output) { -@@ -60,26 +_,42 @@ +@@ -58,26 +_,42 @@ return false; } else { output.store("LootTable", LootTable.KEY_CODEC, lootTable); @@ -65,15 +65,14 @@ LootParams.Builder builder = new LootParams.Builder((ServerLevel)level).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos)); if (player != null) { builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -88,4 +_,17 @@ +@@ -86,4 +_,16 @@ lootTable1.fill(this, builder.create(LootContextParamSets.CHEST), this.getLootTableSeed()); } } + + // Paper start - LootTable API -+ @Nullable + @org.jetbrains.annotations.Contract(pure = true) -+ default com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData() { ++ default com.destroystokyo.paper.loottable.@Nullable PaperLootableInventoryData lootableData() { + return null; // some containers don't really have a "replenish" ability like decorated pots + } + 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 893e6c97415d..5eeeade6049f 100644 --- a/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/SimpleContainer.java +++ b/net/minecraft/world/SimpleContainer.java -@@ -19,7 +_,90 @@ - @Nullable - private List listeners; +@@ -18,7 +_,90 @@ + public final NonNullList items; + private @Nullable List listeners; + // Paper start - add fields and methods + public List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; -+ protected @Nullable org.bukkit.inventory.InventoryHolder bukkitOwner; // Paper - annotation ++ protected org.bukkit.inventory.@Nullable InventoryHolder bukkitOwner; // Paper - annotation + + @Override + public List getContents() { @@ -40,7 +40,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + // Paper start - Add missing InventoryHolders + if (this.bukkitOwner == null && this.bukkitOwnerCreator != null) { + this.bukkitOwner = this.bukkitOwnerCreator.get(); @@ -50,7 +50,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + // Paper start - Fix inventories returning null Locations + // When the block inventory does not have a tile state that implements getLocation, e. g. composters + if (this.bukkitOwner instanceof org.bukkit.inventory.BlockInventoryHolder blockInventoryHolder) { @@ -77,7 +77,7 @@ + } + + // Paper start - Add missing InventoryHolders -+ private @Nullable java.util.function.Supplier bukkitOwnerCreator; ++ private java.util.function.@Nullable Supplier bukkitOwnerCreator; + + public SimpleContainer(java.util.function.Supplier bukkitOwnerCreator, int size) { + this(size); @@ -85,7 +85,7 @@ + } + // Paper end - Add missing InventoryHolders + -+ public SimpleContainer(int size, @Nullable org.bukkit.inventory.InventoryHolder owner) { ++ public SimpleContainer(int size, org.bukkit.inventory.@Nullable InventoryHolder owner) { + this.bukkitOwner = owner; + // Paper end this.size = size; 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 11b79f9cfbfb..9f7b4e9b5d5c 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 @@ -25,7 +25,7 @@ this.entries.add(combatEntry); this.lastDamageTime = this.mob.tickCount; this.takingDamage = true; -@@ -147,6 +_,13 @@ +@@ -145,6 +_,13 @@ public void recheckStatus() { int i = this.inCombat ? 300 : 100; if (this.takingDamage && (!this.mob.isAlive() || this.mob.tickCount - this.lastDamageTime > i)) { 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 dc1afa4718ed..f546b59ffca7 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,18 +1,15 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -20,6 +_,92 @@ - private final Entity directEntity; - @Nullable - private final Vec3 damageSourcePosition; +@@ -17,6 +_,86 @@ + private final @Nullable Entity causingEntity; + private final @Nullable Entity directEntity; + private final @Nullable Vec3 damageSourcePosition; + // CraftBukkit start -+ @Nullable -+ private org.bukkit.event.entity.EntityDamageEvent.DamageCause knownCause; // When the damage event cause is known by the context of the call rather than the damage source data ++ private org.bukkit.event.entity.EntityDamageEvent.@Nullable DamageCause knownCause; // When the damage event cause is known by the context of the call rather than the damage source data + @Nullable + private Entity eventEntityDamager = null; // Relevant entity set when the game doesn't normally set a causingEntity/directEntity -+ @Nullable -+ private org.bukkit.block.Block eventBlockDamager; // Relevant block set. damageSourcePosition is only used for bad respawn point explosion or custom damage -+ @Nullable -+ private org.bukkit.block.BlockState fromBlockSnapshot; // Captured block snapshot when the eventBlockDamager is not relevant (e.g. for bad respawn point explosions the block is already removed) ++ private org.bukkit.block.@Nullable Block eventBlockDamager; // Relevant block set. damageSourcePosition is only used for bad respawn point explosion or custom damage ++ private org.bukkit.block.@Nullable BlockState fromBlockSnapshot; // Captured block snapshot when the eventBlockDamager is not relevant (e.g. for bad respawn point explosions the block is already removed) + private boolean critical; // Supports arrows and sweeping damage + + public DamageSource knownCause(final org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) { @@ -21,8 +18,7 @@ + return damageSource; + } + -+ @Nullable -+ public org.bukkit.event.entity.EntityDamageEvent.DamageCause knownCause() { ++ public org.bukkit.event.entity.EntityDamageEvent.@Nullable DamageCause knownCause() { + return this.knownCause; + } + @@ -40,12 +36,11 @@ + return damageSource; + } + -+ @Nullable -+ public org.bukkit.block.Block eventBlockDamager() { ++ public org.bukkit.block.@Nullable Block eventBlockDamager() { + return this.eventBlockDamager; + } + -+ public DamageSource eventBlockDamager(final net.minecraft.world.level.LevelAccessor level, final @Nullable net.minecraft.core.BlockPos pos) { ++ public DamageSource eventBlockDamager(final net.minecraft.world.level.LevelAccessor level, final net.minecraft.core.@Nullable BlockPos pos) { + if (pos == null) { + return this; + } @@ -55,8 +50,7 @@ + return damageSource; + } + -+ @Nullable -+ public org.bukkit.block.BlockState causingBlockSnapshot() { ++ public org.bukkit.block.@Nullable BlockState causingBlockSnapshot() { + return this.fromBlockSnapshot; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch index b131cd898a81..1d9da101bd4a 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java -@@ -86,6 +_,7 @@ +@@ -85,6 +_,7 @@ public void applyInstantenousEffect( ServerLevel level, @Nullable Entity source, @Nullable Entity indirectSource, LivingEntity entity, int amplifier, double health ) { diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch index 7743e56b9ef7..4a5dad6b1167 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -219,7 +_,7 @@ +@@ -218,7 +_,7 @@ return false; } else { int i = this.isInfiniteDuration() ? entity.tickCount : this.duration; @@ -9,7 +9,7 @@ return false; } else { this.tickDownDuration(); -@@ -415,7 +_,7 @@ +@@ -414,7 +_,7 @@ .apply(instance, MobEffectInstance.Details::create) ) ); @@ -18,7 +18,7 @@ codec -> StreamCodec.composite( ByteBufCodecs.VAR_INT, MobEffectInstance.Details::amplifier, -@@ -427,7 +_,7 @@ +@@ -426,7 +_,7 @@ MobEffectInstance.Details::showParticles, ByteBufCodecs.BOOL, MobEffectInstance.Details::showIcon, diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch index 16be8c581898..54b2f1ba668e 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectUtil.java +++ b/net/minecraft/world/effect/MobEffectUtil.java -@@ -47,18 +_,38 @@ +@@ -55,18 +_,38 @@ public static List addEffectToPlayersAround( ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration ) { @@ -13,7 +13,7 @@ + return addEffectToPlayersAround(level, source, pos, radius, effect, duration, cause, null); + } + -+ public static List addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate playerPredicate) { ++ public static List addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, java.util.function.@Nullable Predicate playerPredicate) { + // Paper end - Add ElderGuardianAppearanceEvent + // CraftBukkit end Holder effect1 = effect.getEffect(); diff --git a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch index dedc162cba80..3e0ba111f71b 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/WeavingMobEffect.java.patch @@ -3,7 +3,7 @@ @@ -27,11 +_,11 @@ @Override public void onMobRemoved(ServerLevel level, LivingEntity entity, int amplifier, Entity.RemovalReason reason) { - if (reason == Entity.RemovalReason.KILLED && (entity instanceof Player || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { + if (reason == Entity.RemovalReason.KILLED && (entity instanceof Player || level.getGameRules().get(GameRules.MOB_GRIEFING))) { - this.spawnCobwebsRandomlyAround(level, entity.getRandom(), entity.blockPosition()); + this.spawnCobwebsRandomlyAround(level, entity.getRandom(), entity.blockPosition(), entity); // Paper - Fire EntityChangeBlockEvent in more places } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch index 455f0c3cfdc4..b7db5c0cfc47 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch @@ -8,7 +8,7 @@ protected AgeableMob(EntityType type, Level level) { super(type, level); -@@ -70,6 +_,7 @@ +@@ -68,6 +_,7 @@ } public void ageUp(int amount, boolean forced) { @@ -16,7 +16,7 @@ int age = this.getAge(); int previousAge = age; age += amount * 20; -@@ -109,6 +_,7 @@ +@@ -107,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("Age", this.getAge()); output.putInt("ForcedAge", this.forcedAge); @@ -24,7 +24,7 @@ } @Override -@@ -116,6 +_,7 @@ +@@ -114,6 +_,7 @@ super.readAdditionalSaveData(input); this.setAge(input.getIntOr("Age", 0)); this.forcedAge = input.getIntOr("ForcedAge", 0); @@ -32,7 +32,7 @@ } @Override -@@ -130,7 +_,7 @@ +@@ -128,7 +_,7 @@ @Override public void aiStep() { super.aiStep(); 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 dff1e208fb69..0acae96c2e8e 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java -@@ -191,7 +_,7 @@ +@@ -189,7 +_,7 @@ private void serverTick(ServerLevel level) { if (this.duration != -1 && this.tickCount - this.waitTime >= this.duration) { @@ -9,7 +9,7 @@ } else { boolean isWaiting = this.isWaiting(); boolean flag = this.tickCount < this.waitTime; -@@ -204,7 +_,7 @@ +@@ -202,7 +_,7 @@ if (this.radiusPerTick != 0.0F) { radius += this.radiusPerTick; if (radius < 0.5F) { @@ -18,7 +18,7 @@ return; } -@@ -220,6 +_,7 @@ +@@ -218,6 +_,7 @@ this.potionContents.forEachEffect(list::add, this.potionDurationScale); List entitiesOfClass = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); if (!entitiesOfClass.isEmpty()) { @@ -26,7 +26,7 @@ for (LivingEntity livingEntity : entitiesOfClass) { if (!this.victims.containsKey(livingEntity) && livingEntity.isAffectedByPotions() -@@ -228,6 +_,17 @@ +@@ -226,6 +_,17 @@ double d1 = livingEntity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; if (d2 <= radius * radius) { @@ -44,7 +44,7 @@ this.victims.put(livingEntity, this.tickCount + this.reapplicationDelay); for (MobEffectInstance mobEffectInstance : list) { -@@ -236,14 +_,14 @@ +@@ -234,14 +_,14 @@ .value() .applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance.getAmplifier(), 0.5); } else { @@ -61,7 +61,7 @@ return; } -@@ -253,7 +_,7 @@ +@@ -251,7 +_,7 @@ if (this.durationOnUse != 0 && this.duration != -1) { this.duration = this.duration + this.durationOnUse; if (this.duration <= 0) { 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 f4ed7d2fec50..4fc0f5ec4bb7 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,9 +1,9 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -150,6 +_,105 @@ +@@ -153,6 +_,105 @@ import org.slf4j.Logger; - public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter { + public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter { + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; + static boolean isLevelAtLeast(ValueInput input, int level) { @@ -82,9 +82,9 @@ + } + } + // Paper end - Share random for entities to make them more random -+ public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason ++ public org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason + -+ private volatile @Nullable org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile ++ private volatile org.bukkit.craftbukkit.entity.@Nullable CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile + + public org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntity() { + if (this.bukkitEntity == null) { @@ -99,14 +99,14 @@ + return this.bukkitEntity; + } + // Paper start -+ public @Nullable org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntityRaw() { ++ public org.bukkit.craftbukkit.entity.@Nullable CraftEntity getBukkitEntityRaw() { + return this.bukkitEntity; + } + // Paper end private static final Logger LOGGER = LogUtils.getLogger(); public static final String TAG_ID = "id"; public static final String TAG_UUID = "UUID"; -@@ -227,7 +_,7 @@ +@@ -228,7 +_,7 @@ public double yOld; public double zOld; public boolean noPhysics; @@ -124,16 +124,15 @@ private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -275,7 +_,7 @@ - private boolean onGroundNoBlocks = false; - private float crystalSoundIntensity; - private int lastCrystalSoundPlayTick; -- public boolean hasVisualFire; +@@ -278,6 +_,7 @@ + public 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 - @Nullable - private BlockState inBlockState = null; + private @Nullable BlockState inBlockState = null; public static final int MAX_MOVEMENTS_HANDELED_PER_TICK = 100; -@@ -284,6 +_,41 @@ + private final ArrayDeque movementThisTick = new ArrayDeque<>(100); +@@ -285,6 +_,40 @@ private final LongSet visitedBlocks = new LongOpenHashSet(); private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); private CustomData customData = CustomData.EMPTY; @@ -145,8 +144,7 @@ + public boolean inWorld = false; + public boolean generation; + public int maxAirTicks = this.getDefaultMaxAirSupply(); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ @Nullable // Paper - Refresh ProjectileSource for projectiles -+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only ++ public org.bukkit.projectiles.@Nullable ProjectileSource projectileSource; // For projectiles only // Paper - Refresh ProjectileSource for projectiles + public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled + public boolean persistentInvisibility = false; + public @Nullable BlockPos lastLavaContact; @@ -175,7 +173,7 @@ public Entity(EntityType type, Level level) { this.type = type; -@@ -305,6 +_,7 @@ +@@ -306,6 +_,7 @@ this.entityData = builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -183,7 +181,7 @@ } public boolean isColliding(BlockPos pos, BlockState state) { -@@ -317,6 +_,12 @@ +@@ -318,6 +_,12 @@ return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; } @@ -196,7 +194,7 @@ public boolean isSpectator() { return false; } -@@ -369,7 +_,7 @@ +@@ -370,7 +_,7 @@ } public boolean addTag(String tag) { @@ -205,7 +203,7 @@ } public boolean removeTag(String tag) { -@@ -377,12 +_,18 @@ +@@ -378,12 +_,18 @@ } public void kill(ServerLevel level) { @@ -220,13 +218,13 @@ + this.discard(null); + } + -+ public final void discard(@Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { ++ public final void discard(org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { + this.remove(Entity.RemovalReason.DISCARDED, cause); + // CraftBukkit end } protected abstract void defineSynchedData(SynchedEntityData.Builder builder); -@@ -391,6 +_,48 @@ +@@ -392,6 +_,48 @@ return this.entityData; } @@ -275,7 +273,7 @@ @Override public boolean equals(Object other) { return other instanceof Entity && ((Entity)other).id == this.id; -@@ -402,7 +_,13 @@ +@@ -403,7 +_,13 @@ } public void remove(Entity.RemovalReason reason) { @@ -284,13 +282,13 @@ + this.remove(reason, null); + } + -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { + this.setRemoved(reason, eventCause); + // CraftBukkit end } public void onClientRemoval() { -@@ -412,6 +_,15 @@ +@@ -413,6 +_,15 @@ } public void setPose(Pose pose) { @@ -306,7 +304,7 @@ this.entityData.set(DATA_POSE, pose); } -@@ -435,6 +_,32 @@ +@@ -436,6 +_,32 @@ } public void setRot(float yRot, float xRot) { @@ -339,7 +337,7 @@ this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -444,8 +_,8 @@ +@@ -445,8 +_,8 @@ } public void setPos(double x, double y, double z) { @@ -350,7 +348,7 @@ } protected final AABB makeBoundingBox() { -@@ -475,12 +_,28 @@ +@@ -480,12 +_,28 @@ } public void tick() { @@ -376,10 +374,10 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("entityBaseTick"); + if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups + this.computeSpeed(); this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { - this.stopRiding(); -@@ -490,7 +_,7 @@ +@@ -496,7 +_,7 @@ this.boardingCooldown--; } @@ -388,7 +386,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -518,6 +_,10 @@ +@@ -524,6 +_,10 @@ if (this.isInLava()) { this.fallDistance *= 0.5; @@ -399,7 +397,7 @@ } this.checkBelowWorld(); -@@ -534,11 +_,16 @@ +@@ -549,11 +_,16 @@ } public void setSharedFlagOnFire(boolean isOnFire) { @@ -418,7 +416,7 @@ this.onBelowWorld(); } } -@@ -566,15 +_,41 @@ +@@ -581,15 +_,41 @@ } public void lavaIgnite() { @@ -462,7 +460,7 @@ && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -589,6 +_,20 @@ +@@ -604,6 +_,20 @@ } public final void igniteForSeconds(float seconds) { @@ -483,7 +481,7 @@ this.igniteForTicks(Mth.floor(seconds * 20.0F)); } -@@ -613,7 +_,7 @@ +@@ -628,7 +_,7 @@ } protected void onBelowWorld() { @@ -492,7 +490,7 @@ } public boolean isFree(double x, double y, double z) { -@@ -669,7 +_,28 @@ +@@ -684,7 +_,28 @@ return this.onGround; } @@ -521,7 +519,7 @@ if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.horizontalCollision = false; -@@ -752,6 +_,27 @@ +@@ -767,6 +_,27 @@ block.updateEntityMovementAfterFallOn(this.level(), this); } } @@ -549,7 +547,7 @@ if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission movementEmission = this.getMovementEmission(); -@@ -765,6 +_,13 @@ +@@ -780,6 +_,13 @@ profilerFiller.pop(); } } @@ -563,7 +561,7 @@ } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { -@@ -946,7 +_,7 @@ +@@ -961,7 +_,7 @@ } protected BlockPos getOnPos(float yOffset) { @@ -572,7 +570,7 @@ BlockPos blockPos = this.mainSupportingBlockPos.get(); if (!(yOffset > 1.0E-5F)) { return blockPos; -@@ -1201,7 +_,7 @@ +@@ -1216,7 +_,7 @@ if (flag2) { try { boolean flag4 = flag || aabb.intersects(pos); @@ -581,7 +579,7 @@ blockState.entityInside(this.level(), pos, this, stepBasedCollector, flag4); this.onInsideBlock(blockState); } catch (Throwable var20) { -@@ -1215,7 +_,7 @@ +@@ -1230,7 +_,7 @@ } if (flag3) { @@ -590,7 +588,7 @@ blockState.getFluidState().entityInside(this.level(), pos, this, stepBasedCollector); } -@@ -1652,6 +_,7 @@ +@@ -1666,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -598,7 +596,7 @@ } public void absSnapTo(double x, double y, double z) { -@@ -1661,6 +_,7 @@ +@@ -1675,6 +_,7 @@ this.yo = y; this.zo = d1; this.setPos(d, y, d1); @@ -606,7 +604,7 @@ } public void snapTo(Vec3 pos) { -@@ -1685,6 +_,7 @@ +@@ -1699,6 +_,7 @@ this.setXRot(xRot); this.setOldPosAndRot(); this.reapplyPosition(); @@ -614,7 +612,7 @@ } public final void setOldPosAndRot() { -@@ -1751,6 +_,7 @@ +@@ -1765,6 +_,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -622,30 +620,32 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Mth.absMax(d, d1); -@@ -1784,7 +_,21 @@ - } +@@ -1801,7 +_,23 @@ public void push(double x, double y, double z) { -- this.setDeltaMovement(this.getDeltaMovement().add(x, y, z)); -+ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent -+ this.push(x, y, z, null); + if (Double.isFinite(x) && Double.isFinite(y) && Double.isFinite(z)) { +- this.setDeltaMovement(this.getDeltaMovement().add(x, y, z)); ++ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent ++ this.push(x, y, z, null); ++ } + } + + public void push(double x, double y, double z, @Nullable Entity pushingEntity) { -+ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(x, y, z); -+ if (pushingEntity != null) { -+ io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent event = new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(this.getBukkitEntity(), io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.PUSH, pushingEntity.getBukkitEntity(), delta); -+ if (!event.callEvent()) { -+ return; ++ { ++ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(x, y, z); ++ if (pushingEntity != null) { ++ io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent event = new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(this.getBukkitEntity(), io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.PUSH, pushingEntity.getBukkitEntity(), delta); ++ if (!event.callEvent()) { ++ return; ++ } ++ delta = event.getKnockback(); + } -+ delta = event.getKnockback(); -+ } -+ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ())); -+ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - this.hasImpulse = true; ++ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ())); ++ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + this.needsSync = true; + } } - -@@ -1891,8 +_,20 @@ +@@ -1909,8 +_,20 @@ } public boolean isPushable() { @@ -666,7 +666,7 @@ public void awardKillScore(Entity entity, DamageSource damageSource) { if (entity instanceof ServerPlayer) { -@@ -1919,15 +_,23 @@ +@@ -1937,15 +_,23 @@ } public boolean saveAsPassenger(ValueOutput output) { @@ -694,7 +694,7 @@ return true; } } -@@ -1938,14 +_,35 @@ +@@ -1956,14 +_,35 @@ } public void saveWithoutId(ValueOutput output) { @@ -730,7 +730,7 @@ output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); -@@ -1953,7 +_,29 @@ +@@ -1971,7 +_,29 @@ output.putBoolean("OnGround", this.onGround()); output.putBoolean("Invulnerable", this.invulnerable); output.putInt("PortalCooldown", this.portalCooldown); @@ -760,7 +760,7 @@ output.storeNullable("CustomName", ComponentSerialization.CODEC, this.getCustomName()); if (this.isCustomNameVisible()) { output.putBoolean("CustomNameVisible", this.isCustomNameVisible()); -@@ -1976,9 +_,12 @@ +@@ -1994,9 +_,12 @@ output.putInt("TicksFrozen", this.getTicksFrozen()); } @@ -775,7 +775,7 @@ if (!this.tags.isEmpty()) { output.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); -@@ -1988,13 +_,13 @@ +@@ -2006,13 +_,13 @@ output.store("data", CustomData.CODEC, this.customData); } @@ -791,7 +791,7 @@ valueOutputList.discardLast(); } } -@@ -2003,6 +_,34 @@ +@@ -2021,6 +_,34 @@ output.discard("Passengers"); } } @@ -826,7 +826,7 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved"); -@@ -2014,7 +_,7 @@ +@@ -2032,7 +_,7 @@ public void load(ValueInput input) { try { Vec3 vec3 = input.read("Pos", Vec3.CODEC).orElse(Vec3.ZERO); @@ -834,8 +834,8 @@ + Vec3 vec31 = input.read("Motion", Vec3.CODEC).orElse(Vec3.ZERO); vec31 = io.papermc.paper.util.MCUtil.sanitizeNanInf(vec31, 0D); // Paper - avoid setting NaN values Vec2 vec2 = input.read("Rotation", Vec2.CODEC).orElse(Vec2.ZERO); this.setDeltaMovement(Math.abs(vec31.x) > 10.0 ? 0.0 : vec31.x, Math.abs(vec31.y) > 10.0 ? 0.0 : vec31.y, Math.abs(vec31.z) > 10.0 ? 0.0 : vec31.z); - this.hasImpulse = true; -@@ -2046,7 +_,20 @@ + this.needsSync = true; +@@ -2064,7 +_,20 @@ this.setNoGravity(input.getBooleanOr("NoGravity", false)); this.setGlowingTag(input.getBooleanOr("Glowing", false)); this.setTicksFrozen(input.getIntOr("TicksFrozen", 0)); @@ -857,7 +857,7 @@ this.customData = input.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); this.tags.clear(); input.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); -@@ -2057,6 +_,59 @@ +@@ -2075,6 +_,59 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } @@ -903,7 +903,7 @@ + if (spawnReason == null) { + if (spawnedViaMobSpawner) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; -+ } else if (this instanceof Mob && (this instanceof net.minecraft.world.entity.animal.Animal || this instanceof net.minecraft.world.entity.animal.AbstractFish) && !((Mob) this).removeWhenFarAway(0.0)) { ++ } else if (this instanceof Mob && (this instanceof net.minecraft.world.entity.animal.Animal || this instanceof net.minecraft.world.entity.animal.fish.AbstractFish) && !((Mob) this).removeWhenFarAway(0.0)) { + if (!input.getBooleanOr("PersistenceRequired", false)) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL; + } @@ -917,17 +917,17 @@ } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); -@@ -2071,13 +_,24 @@ +@@ -2088,13 +_,24 @@ + } - @Nullable - public final String getEncodeId() { + public final @Nullable String getEncodeId() { + // Paper start - Raw entity serialization API + return getEncodeId(false); + } + public final @Nullable String getEncodeId(boolean includeNonSaveable) { + // Paper end - Raw entity serialization API EntityType type = this.getType(); - ResourceLocation key = EntityType.getKey(type); + Identifier key = EntityType.getKey(type); - return !type.canSerialize() ? null : key.toString(); + return (type.canSerialize() || includeNonSaveable) ? key.toString() : null; // Paper - Raw entity serialization API } @@ -942,16 +942,16 @@ + protected abstract void addAdditionalSaveData(ValueOutput output); - @Nullable -@@ -2092,11 +_,62 @@ + public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemLike item) { +@@ -2106,11 +_,60 @@ + } - @Nullable - public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset) { + public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset) { + // Paper start - Restore vanilla drops behavior + return this.spawnAtLocation(level, stack, offset, null); + } + -+ public record DefaultDrop(Item item, org.bukkit.inventory.ItemStack stack, @Nullable java.util.function.Consumer dropConsumer) { ++ public record DefaultDrop(Item item, org.bukkit.inventory.ItemStack stack, java.util.function.@Nullable Consumer dropConsumer) { + public DefaultDrop(final ItemStack stack, final java.util.function.Consumer dropConsumer) { + this(stack.getItem(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), dropConsumer); + } @@ -965,8 +965,7 @@ + } + } + -+ @Nullable -+ public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset, @Nullable java.util.function.Consumer delayedAddConsumer) { ++ public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, Vec3 offset, java.util.function.@Nullable Consumer delayedAddConsumer) { + // Paper end - Restore vanilla drops behavior if (stack.isEmpty()) { return null; @@ -994,8 +993,7 @@ + return this.spawnAtLocation(level, itemEntity); + } + } -+ @Nullable -+ public ItemEntity spawnAtLocation(ServerLevel level, ItemEntity itemEntity) { ++ public @Nullable ItemEntity spawnAtLocation(ServerLevel level, ItemEntity itemEntity) { + { + // Paper end - Call EntityDropItemEvent + // CraftBukkit start @@ -1008,7 +1006,7 @@ level.addFreshEntity(itemEntity); return itemEntity; } -@@ -2142,6 +_,15 @@ +@@ -2155,6 +_,15 @@ for (Leashable leashable1 : list) { if (leashable1.canHaveALeashAttachedTo(this)) { @@ -1024,7 +1022,7 @@ leashable1.setLeashedTo(this, true); flag = true; } -@@ -2156,7 +_,7 @@ +@@ -2169,7 +_,7 @@ } ItemStack itemInHand = player.getItemInHand(hand); @@ -1033,7 +1031,7 @@ itemInHand.hurtAndBreak(1, player, hand); return InteractionResult.SUCCESS; } else if (this instanceof Mob mob -@@ -2169,11 +_,13 @@ +@@ -2182,11 +_,13 @@ if (this.isAlive() && this instanceof Leashable leashable2) { if (leashable2.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1051,9 +1049,9 @@ this.gameEvent(GameEvent.ENTITY_INTERACT, player); this.playSound(SoundEvents.LEAD_UNTIED); -@@ -2186,9 +_,22 @@ - if (itemInHand1.is(Items.LEAD) && !(leashable2.getLeashHolder() instanceof Player)) { - if (!this.level().isClientSide() && leashable2.canHaveALeashAttachedTo(player)) { +@@ -2203,9 +_,22 @@ + + if (leashable2.canHaveALeashAttachedTo(player)) { if (leashable2.isLeashed()) { - leashable2.dropLeash(); + // Paper start - EntityUnleashEvent @@ -1075,7 +1073,7 @@ leashable2.setLeashedTo(player, true); this.playSound(SoundEvents.LEAD_TIED); itemInHand1.shrink(1); -@@ -2203,7 +_,12 @@ +@@ -2219,7 +_,12 @@ } public boolean shearOffAllLeashConnections(@Nullable Player player) { @@ -1089,7 +1087,7 @@ if (flag && this.level() instanceof ServerLevel serverLevel) { serverLevel.playSound(null, this.blockPosition(), SoundEvents.SHEARS_SNIP, player != null ? player.getSoundSource() : this.getSoundSource()); } -@@ -2212,15 +_,38 @@ +@@ -2228,15 +_,38 @@ } public boolean dropAllLeashConnections(@Nullable Player player) { @@ -1132,7 +1130,7 @@ } if (flag) { -@@ -2244,7 +_,9 @@ +@@ -2260,7 +_,9 @@ this.gameEvent(GameEvent.SHEAR, player); this.playSound(equippable.shearingSound().value()); if (this.level() instanceof ServerLevel serverLevel) { @@ -1142,7 +1140,7 @@ CriteriaTriggers.PLAYER_SHEARED_EQUIPMENT.trigger((ServerPlayer)player, itemBySlot, mob); } -@@ -2317,11 +_,11 @@ +@@ -2333,11 +_,11 @@ } public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { @@ -1156,7 +1154,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2331,6 +_,27 @@ +@@ -2347,6 +_,27 @@ } if (force || this.canRide(entity) && entity.canAddPassenger(this)) { @@ -1184,7 +1182,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2363,10 +_,16 @@ +@@ -2379,10 +_,16 @@ } public void removeVehicle() { @@ -1202,7 +1200,7 @@ Entity.RemovalReason removalReason = this.getRemovalReason(); if (removalReason == null || removalReason.shouldDestroy()) { this.level().gameEvent(this, GameEvent.ENTITY_DISMOUNT, entity.position); -@@ -2375,7 +_,13 @@ +@@ -2391,7 +_,13 @@ } public void stopRiding() { @@ -1217,7 +1215,7 @@ } protected void addPassenger(Entity passenger) { -@@ -2397,10 +_,43 @@ +@@ -2413,10 +_,43 @@ } } @@ -1262,7 +1260,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2409,6 +_,7 @@ +@@ -2425,6 +_,7 @@ passenger.boardingCooldown = 60; } @@ -1270,18 +1268,17 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2505,8 +_,8 @@ +@@ -2524,7 +_,8 @@ TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); if (portalDestination != null) { ServerLevel level = portalDestination.newLevel(); -- if (serverLevel.getServer().isAllowedToEnterPortal(level) -- && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level))) { +- if (serverLevel.isAllowedToEnterPortal(level) && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level)) + if (this instanceof ServerPlayer // CraftBukkit - always call event for players -+ || (level != null && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level)))) { // CraftBukkit ++ || (level != null && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level))) // CraftBukkit + ) + { this.teleport(portalDestination); - } - } -@@ -2587,7 +_,7 @@ +@@ -2607,7 +_,7 @@ } public boolean isCrouching() { @@ -1290,7 +1287,7 @@ } public boolean isSprinting() { -@@ -2603,7 +_,7 @@ +@@ -2623,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1299,7 +1296,7 @@ } public boolean isVisuallyCrawling() { -@@ -2611,6 +_,13 @@ +@@ -2631,6 +_,13 @@ } public void setSwimming(boolean swimming) { @@ -1313,15 +1310,15 @@ this.setSharedFlag(FLAG_SWIMMING, swimming); } -@@ -2649,6 +_,7 @@ +@@ -2668,6 +_,7 @@ + } - @Nullable - public PlayerTeam getTeam() { + public @Nullable PlayerTeam getTeam() { + if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - Perf: Disable Scoreboards for non players by default return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2665,7 +_,11 @@ +@@ -2684,7 +_,11 @@ } public void setInvisible(boolean invisible) { @@ -1334,7 +1331,7 @@ } public boolean getSharedFlag(int flag) { -@@ -2682,7 +_,7 @@ +@@ -2701,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1343,7 +1340,7 @@ } public int getAirSupply() { -@@ -2690,10 +_,22 @@ +@@ -2709,10 +_,22 @@ } public void setAirSupply(int airSupply) { @@ -1367,7 +1364,7 @@ this.setTicksFrozen(0); } -@@ -2720,11 +_,43 @@ +@@ -2739,11 +_,43 @@ public void thunderHit(ServerLevel level, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1415,7 +1412,7 @@ } public void onAboveBubbleColumn(boolean downwards, BlockPos pos) { -@@ -2880,26 +_,30 @@ +@@ -2899,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1449,7 +1446,7 @@ ); } -@@ -2923,6 +_,13 @@ +@@ -2942,6 +_,13 @@ } public void restoreFrom(Entity entity) { @@ -1463,10 +1460,10 @@ try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, entity.registryAccess()); entity.saveWithoutId(tagValueOutput); -@@ -2935,7 +_,65 @@ +@@ -2953,7 +_,65 @@ + } - @Nullable - public Entity teleport(TeleportTransition teleportTransition) { + public @Nullable Entity teleport(TeleportTransition teleportTransition) { + // Paper start - Fix item duplication and teleport issues + if ((!this.isAlive() || !this.valid) && (teleportTransition.newLevel() != this.level)) { + LOGGER.warn("Illegal Entity Teleport {} to {}:{}", this, teleportTransition.newLevel(), teleportTransition.position(), new Throwable()); @@ -1529,7 +1526,7 @@ ServerLevel level = teleportTransition.newLevel(); boolean flag = level.dimension() != serverLevel.dimension(); if (!teleportTransition.asPassenger()) { -@@ -2985,10 +_,15 @@ +@@ -3002,10 +_,15 @@ profilerFiller.pop(); return null; } else { @@ -1546,7 +1543,7 @@ for (Entity entity2 : list) { entity2.startRiding(entityx, true, false); -@@ -3078,9 +_,17 @@ +@@ -3095,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1567,7 +1564,7 @@ } if (this instanceof WaypointTransmitter waypointTransmitter && this.level instanceof ServerLevel serverLevel) { -@@ -3097,6 +_,7 @@ +@@ -3114,6 +_,7 @@ } public boolean canTeleport(Level fromLevel, Level toLevel) { @@ -1575,7 +1572,7 @@ if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { for (Entity entity : this.getPassengers()) { if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.seenCredits) { -@@ -3204,13 +_,19 @@ +@@ -3220,13 +_,19 @@ return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE); } @@ -1598,7 +1595,7 @@ } public void teleportTo(double x, double y, double z) { -@@ -3319,7 +_,26 @@ +@@ -3335,7 +_,26 @@ } public final void setBoundingBox(AABB bb) { @@ -1626,7 +1623,7 @@ } public final float getEyeHeight(Pose pose) { -@@ -3346,6 +_,12 @@ +@@ -3363,6 +_,12 @@ } public void stopSeenByPlayer(ServerPlayer player) { @@ -1639,16 +1636,7 @@ } public float rotate(Rotation transformRotation) { -@@ -3374,7 +_,7 @@ - } - - @Nullable -- public LivingEntity getControllingPassenger() { -+ public net.minecraft.world.entity.LivingEntity getControllingPassenger() { - return null; - } - -@@ -3406,21 +_,32 @@ +@@ -3421,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1682,7 +1670,7 @@ } public int countPlayerPassengers() { -@@ -3428,6 +_,7 @@ +@@ -3443,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1690,7 +1678,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3510,9 +_,38 @@ +@@ -3523,9 +_,38 @@ return 0; } @@ -1708,7 +1696,7 @@ + + @Override + public boolean acceptsSuccess() { -+ return ((ServerLevel) Entity.this.level()).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_SENDCOMMANDFEEDBACK); ++ return ((ServerLevel) Entity.this.level()).getGameRules().get(net.minecraft.world.level.gamerules.GameRules.COMMAND_BLOCK_OUTPUT); + } + + @Override @@ -1725,12 +1713,12 @@ + public CommandSourceStack createCommandSourceStackForNameResolution(ServerLevel level) { return new CommandSourceStack( -- CommandSource.NULL, this.position(), this.getRotationVector(), level, 0, this.getPlainTextName(), this.getDisplayName(), level.getServer(), this -+ this.commandSource, this.position(), this.getRotationVector(), level, 0, this.getPlainTextName(), this.getDisplayName(), level.getServer(), this // CraftBukkit - ); - } - -@@ -3570,6 +_,11 @@ +- CommandSource.NULL, ++ this.commandSource, // CraftBukkit + this.position(), + this.getRotationVector(), + level, +@@ -3591,6 +_,11 @@ vec3 = vec3.add(flow); i++; } @@ -1742,17 +1730,17 @@ } } } -@@ -3668,7 +_,9 @@ - } +@@ -3690,7 +_,9 @@ public void setDeltaMovement(Vec3 deltaMovement) { -+ synchronized (this.posLock) { // Paper - detailed watchdog information - this.deltaMovement = deltaMovement; -+ } // Paper - detailed watchdog information + if (deltaMovement.isFinite()) { ++ synchronized (this.posLock) { // Paper - detailed watchdog information + this.deltaMovement = deltaMovement; ++ } // Paper - detailed watchdog information + } } - public void addDeltaMovement(Vec3 addend) { -@@ -3731,9 +_,35 @@ +@@ -3756,9 +_,35 @@ return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale); } @@ -1788,14 +1776,14 @@ int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); -@@ -3755,7 +_,18 @@ +@@ -3780,7 +_,18 @@ serverLevel.getWaypointManager().updatePlayer(serverPlayer); } } - } + // Paper start - Fix MC-44654 + if (this.getType().updateInterval() == Integer.MAX_VALUE) { -+ this.hasImpulse = true; ++ this.needsSync = true; + } + // Paper end - Fix MC-44654 + } @@ -1808,7 +1796,7 @@ } public void checkDespawn() { -@@ -3808,6 +_,12 @@ +@@ -3832,6 +_,12 @@ return this.getTicksFrozen() > 0; } @@ -1821,18 +1809,18 @@ public float getYRot() { return this.yRot; } -@@ -3859,7 +_,9 @@ +@@ -3882,7 +_,9 @@ } @Override - public final void setRemoved(Entity.RemovalReason removalReason) { -+ public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit + final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { this.removalReason = removalReason; } -@@ -3871,12 +_,28 @@ +@@ -3894,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); @@ -1861,7 +1849,7 @@ @Override public void setLevelCallback(EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -4073,4 +_,14 @@ +@@ -4097,4 +_,14 @@ return this.save; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch index 52e052d9b0fa..0a2cd6195a45 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityReference.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityReference.java +++ b/net/minecraft/world/entity/EntityReference.java -@@ -150,4 +_,15 @@ +@@ -140,4 +_,15 @@ public int hashCode() { return this.getUUID().hashCode(); } 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 f9fd5c447e5e..54535b61d022 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 -@@ -185,6 +_,7 @@ +@@ -189,6 +_,7 @@ import org.slf4j.Logger; public class EntityType implements FeatureElement, EntityTypeTest { @@ -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(); -@@ -1265,6 +_,22 @@ +@@ -1290,6 +_,22 @@ boolean shouldOffsetY, boolean shouldOffsetYMore ) { @@ -31,7 +31,7 @@ Consumer consumer; if (spawnedFrom != null) { consumer = createDefaultStackConfig(level, spawnedFrom, owner); -@@ -1272,7 +_,7 @@ +@@ -1297,7 +_,7 @@ consumer = entity -> {}; } @@ -40,7 +40,7 @@ } public static Consumer createDefaultStackConfig(Level level, ItemStack stack, @Nullable LivingEntity owner) { -@@ -1289,21 +_,58 @@ +@@ -1314,19 +_,54 @@ public static Consumer appendCustomEntityStackConfig(Consumer consumer, Level level, ItemStack stack, @Nullable LivingEntity owner) { TypedEntityData> typedEntityData = stack.get(DataComponents.ENTITY_DATA); @@ -56,21 +56,17 @@ + // CraftBukkit end } - @Nullable - public T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason) { + public @Nullable T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason) { - return this.spawn(level, null, pos, spawnReason, false, false); + // CraftBukkit start + return this.spawn(level, pos, spawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } -+ -+ @Nullable -+ public T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { ++ public @Nullable T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason spawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + return this.spawn(level, null, pos, spawnReason, false, false, creatureSpawnReason); + // CraftBukkit End } - @Nullable - public T spawn( + public @Nullable T spawn( ServerLevel level, @Nullable Consumer consumer, BlockPos pos, EntitySpawnReason spawnReason, boolean shouldOffsetY, boolean shouldOffsetYMore ) { + // CraftBukkit start @@ -102,7 +98,7 @@ if (entity instanceof Mob mob) { mob.playAmbientSound(); } -@@ -1358,6 +_,13 @@ +@@ -1382,6 +_,13 @@ if (level.isClientSide() || !entity.getType().onlyOpCanSetNbt() || owner instanceof Player player && server.getPlayerList().isOp(player.nameAndId())) { @@ -116,7 +112,7 @@ entityData.loadInto(entity); } } -@@ -1429,10 +_,28 @@ +@@ -1452,10 +_,28 @@ } public static Optional create(ValueInput input, Level level, EntitySpawnReason spawnReason) { @@ -147,7 +143,7 @@ ); } -@@ -1588,8 +_,23 @@ +@@ -1606,8 +_,23 @@ return this.builtInRegistryHolder; } 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 744ae96e3aca..77020cd48c6a 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 @@ -1,14 +1,12 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -44,13 +_,59 @@ - @Nullable - private Player followingPlayer; +@@ -43,13 +_,57 @@ + public int count = 1; + private @Nullable Player followingPlayer; private final InterpolationHandler interpolation = new InterpolationHandler(this); + // Paper start -+ @Nullable -+ public java.util.UUID sourceEntityId; -+ @Nullable -+ public java.util.UUID triggerEntityId; ++ public java.util.@Nullable UUID sourceEntityId; ++ public java.util.@Nullable UUID triggerEntityId; + public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; + private void loadPaperNBT(ValueInput input) { @@ -40,7 +38,7 @@ + // Paper start - add reasons for orbs + this(level, x, y, z, value, null, null, null); + } -+ public ExperienceOrb(Level level, double x, double y, double z, int value, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { ++ public ExperienceOrb(Level level, double x, double y, double z, int value, org.bukkit.entity.ExperienceOrb.@Nullable SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { + this(level, new Vec3(x, y, z), Vec3.ZERO, value, reason, triggerId, sourceId); + // Paper end - add reasons for orbs } @@ -50,7 +48,7 @@ + // Paper start - add reasons for orbs + this(level, pos, direction, value, null, null, null); + } -+ public ExperienceOrb(Level level, Vec3 pos, Vec3 direction, int value, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { ++ public ExperienceOrb(Level level, Vec3 pos, Vec3 direction, int value, org.bukkit.entity.ExperienceOrb.@Nullable SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { + // Paper end - add reasons for orbs this(EntityType.EXPERIENCE_ORB, level); + // Paper start - add reasons for orbs @@ -61,7 +59,7 @@ this.setPos(pos); if (!level.isClientSide()) { this.setYRot(this.random.nextFloat() * 360.0F); -@@ -147,12 +_,13 @@ +@@ -146,12 +_,13 @@ this.age++; if (this.age >= 6000) { @@ -76,7 +74,7 @@ if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr(this) > 64.0) { Player nearestPlayer = this.level().getNearestPlayer(this, 8.0); if (nearestPlayer != null && !nearestPlayer.isSpectator() && !nearestPlayer.isDeadOrDying()) { -@@ -162,7 +_,24 @@ +@@ -161,7 +_,24 @@ } } @@ -102,14 +100,14 @@ Vec3 vec3 = new Vec3( this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(), -@@ -193,18 +_,24 @@ +@@ -192,18 +_,24 @@ } public static void awardWithDirection(ServerLevel level, Vec3 pos, Vec3 direction, int amount) { + // Paper start - add reason to orbs + awardWithDirection(level, pos, direction, amount, null, null, null); + } -+ public static void awardWithDirection(ServerLevel level, Vec3 pos, Vec3 direction, int amount, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { ++ public static void awardWithDirection(ServerLevel level, Vec3 pos, Vec3 direction, int amount, org.bukkit.entity.ExperienceOrb.@Nullable SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { + // Paper end - add reason to orbs while (amount > 0) { int experienceValue = getExperienceValue(amount); @@ -129,7 +127,7 @@ List entities = level.getEntities( EntityTypeTest.forClass(ExperienceOrb.class), aabb, experienceOrb1 -> canMerge(experienceOrb1, randomInt, amount) ); -@@ -223,13 +_,18 @@ +@@ -222,13 +_,18 @@ } private static boolean canMerge(ExperienceOrb orb, int amount, int other) { @@ -150,7 +148,7 @@ } private void setUnderwaterMovement() { -@@ -254,7 +_,7 @@ +@@ -253,7 +_,7 @@ this.markHurt(); this.health = (int)(this.health - amount); if (this.health <= 0) { @@ -159,7 +157,7 @@ } return true; -@@ -265,32 +_,34 @@ +@@ -264,32 +_,34 @@ protected void addAdditionalSaveData(ValueOutput output) { output.putShort("Health", (short)this.health); output.putShort("Age", (short)this.age); @@ -200,7 +198,7 @@ } } } -@@ -304,9 +_,19 @@ +@@ -303,9 +_,19 @@ ItemStack itemStack = randomItemWith.get().itemStack(); int i = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.level(), itemStack, value); int min = Math.min(i, itemStack.getDamageValue()); @@ -221,7 +219,7 @@ if (i1 > 0) { return this.repairPlayerItems(player, i1); } -@@ -352,6 +_,24 @@ +@@ -351,6 +_,24 @@ } public static int getExperienceValue(int expValue) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch index a047e73e5938..64ff18b39efb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Interaction.java +++ b/net/minecraft/world/entity/Interaction.java -@@ -101,9 +_,16 @@ +@@ -99,9 +_,16 @@ @Override public boolean skipAttackInteraction(Entity entity) { if (entity instanceof Player player) { 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 abff20c395c0..568f7284c189 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 @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/Leashable.java +++ b/net/minecraft/world/entity/Leashable.java -@@ -80,6 +_,11 @@ +@@ -79,6 +_,11 @@ } - default void writeLeashData(ValueOutput output, @Nullable Leashable.LeashData leashData) { + default void writeLeashData(ValueOutput output, Leashable.@Nullable LeashData leashData) { + // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin + if (leashData != null && leashData.leashHolder != null && leashData.leashHolder.pluginRemoved) { + return; @@ -12,7 +12,7 @@ output.storeNullable("leash", Leashable.LeashData.CODEC, leashData); } -@@ -99,7 +_,9 @@ +@@ -98,7 +_,9 @@ } if (entity.tickCount > 100) { @@ -22,7 +22,7 @@ entity.setLeashData(null); } } -@@ -123,7 +_,9 @@ +@@ -122,7 +_,9 @@ entity.onLeashRemoved(); if (entity.level() instanceof ServerLevel serverLevel) { if (dropItem) { @@ -32,16 +32,16 @@ } if (broadcastPacket) { -@@ -143,7 +_,15 @@ +@@ -142,7 +_,15 @@ if (leashData != null && leashData.leashHolder != null) { if (!entity.canInteractWithLevel() || !leashData.leashHolder.canInteractWithLevel()) { -- if (level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { +- if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { + // Paper start - Expand EntityUnleashEvent + final org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent( + entity.getBukkitEntity(), + !entity.isAlive() ? org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH : org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.HOLDER_GONE, -+ level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !entity.pluginRemoved ++ level.getGameRules().get(GameRules.ENTITY_DROPS) && !entity.pluginRemoved + ); + event.callEvent(); + if (event.isDropLeash()) { // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin @@ -49,7 +49,7 @@ entity.dropLeash(); } else { entity.removeLeash(); -@@ -154,8 +_,7 @@ +@@ -153,8 +_,7 @@ if (leashHolder != null && leashHolder.level() == entity.level()) { double d = entity.leashDistanceTo(leashHolder); entity.whenLeashedTo(leashHolder); @@ -59,7 +59,7 @@ entity.leashTooFarBehaviour(); } else if (d > entity.leashElasticDistance() - leashHolder.getBbWidth() - entity.getBbWidth() && entity.checkElasticInteractions(leashHolder, leashData)) { -@@ -175,6 +_,12 @@ +@@ -174,6 +_,12 @@ entity.checkFallDistanceAccumulation(); } @@ -72,7 +72,7 @@ default double leashSnapDistance() { return 12.0; } -@@ -196,7 +_,25 @@ +@@ -195,7 +_,25 @@ } default void leashTooFarBehaviour() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch index d7c433bcf233..ebe1f9fbce02 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -40,6 +_,7 @@ - private ServerPlayer cause; +@@ -39,6 +_,7 @@ + private @Nullable ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; + public boolean isEffect; // Paper - Properly handle lightning effects api public LightningBolt(EntityType type, Level level) { super(type, level); -@@ -77,7 +_,7 @@ +@@ -75,7 +_,7 @@ @Override public void tick() { super.tick(); @@ -17,7 +17,7 @@ if (this.level().isClientSide()) { this.level() .playLocalSound( -@@ -108,7 +_,7 @@ +@@ -106,7 +_,7 @@ } this.powerLightningRod(); @@ -26,7 +26,7 @@ this.gameEvent(GameEvent.LIGHTNING_STRIKE); } } -@@ -131,7 +_,7 @@ +@@ -129,7 +_,7 @@ } } @@ -35,7 +35,7 @@ } else if (this.life < -this.random.nextInt(10)) { this.flashes--; this.life = 1; -@@ -140,10 +_,10 @@ +@@ -138,10 +_,10 @@ } } @@ -48,37 +48,31 @@ List entities = this.level() .getEntities( this, -@@ -169,44 +_,57 @@ +@@ -167,34 +_,43 @@ } private void spawnFire(int extraIgnitions) { -- if (!this.visualOnly && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { -+ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { // Paper - prevent any fire if only effect - BlockPos blockPos = this.blockPosition(); - BlockState state = BaseFireBlock.getState(this.level(), blockPos); - if (this.level().getBlockState(blockPos).isAir() && state.canSurvive(this.level(), blockPos)) { -- this.level().setBlockAndUpdate(blockPos, state); -- this.blocksSetOnFire++; -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos, this).isCancelled()) { -+ this.level().setBlockAndUpdate(blockPos, state); -+ this.blocksSetOnFire++; -+ } -+ // CraftBukkit end - } +- if (!this.visualOnly && this.level() instanceof ServerLevel serverLevel) { ++ if (!this.visualOnly && !this.isEffect && this.level() instanceof ServerLevel serverLevel) { // Paper - Properly handle lightning effects api + BlockPos var7 = this.blockPosition(); + if (serverLevel.canSpreadFireAround(var7)) { + BlockState state = BaseFireBlock.getState(serverLevel, var7); + if (serverLevel.getBlockState(var7).isAir() && state.canSurvive(serverLevel, var7)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), var7, this).isCancelled()) { // CraftBukkit + serverLevel.setBlockAndUpdate(var7, state); + this.blocksSetOnFire++; ++ } // CraftBukkit + } - for (int i = 0; i < extraIgnitions; i++) { - BlockPos blockPos1 = blockPos.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); - state = BaseFireBlock.getState(this.level(), blockPos1); - if (this.level().getBlockState(blockPos1).isAir() && state.canSurvive(this.level(), blockPos1)) { -- this.level().setBlockAndUpdate(blockPos1, state); -- this.blocksSetOnFire++; -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { -+ this.level().setBlockAndUpdate(blockPos1, state); -+ this.blocksSetOnFire++; -+ } -+ // CraftBukkit end + for (int i = 0; i < extraIgnitions; i++) { + BlockPos blockPos1 = var7.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); + state = BaseFireBlock.getState(serverLevel, blockPos1); + if (serverLevel.getBlockState(blockPos1).isAir() && state.canSurvive(serverLevel, blockPos1)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { // CraftBukkit + serverLevel.setBlockAndUpdate(blockPos1, state); + this.blocksSetOnFire++; ++ } // CraftBukkit + } } } } @@ -87,16 +81,21 @@ - private static void clearCopperOnLightningStrike(Level level, BlockPos pos) { + private static void clearCopperOnLightningStrike(Level level, BlockPos pos, Entity lightning) { // Paper - Call EntityChangeBlockEvent BlockState blockState = level.getBlockState(pos); - if (blockState.getBlock() instanceof WeatheringCopper) { -- level.setBlockAndUpdate(pos, WeatheringCopper.getFirst(level.getBlockState(pos))); -+ // Paper start - Call EntityChangeBlockEvent -+ BlockState newBlockState = WeatheringCopper.getFirst(level.getBlockState(pos)); -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(lightning, pos, newBlockState)) { -+ level.setBlockAndUpdate(pos, newBlockState); -+ } -+ // Paper end - Call EntityChangeBlockEvent + boolean flag = HoneycombItem.WAX_OFF_BY_BLOCK.get().get(blockState.getBlock()) != null; + boolean flag1 = blockState.getBlock() instanceof WeatheringCopper; + if (flag1 || flag) { + if (flag1) { +- level.setBlockAndUpdate(pos, WeatheringCopper.getFirst(level.getBlockState(pos))); ++ // Paper start - Call EntityChangeBlockEvent ++ BlockState newBlockState = WeatheringCopper.getFirst(level.getBlockState(pos)); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(lightning, pos, newBlockState)) { ++ level.setBlockAndUpdate(pos, newBlockState); ++ } ++ // Paper end - Call EntityChangeBlockEvent + } + BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); - int i = level.random.nextInt(3) + 3; +@@ -202,16 +_,16 @@ for (int i1 = 0; i1 < i; i1++) { int i2 = level.random.nextInt(8) + 1; @@ -116,7 +115,7 @@ if (optional.isEmpty()) { break; } -@@ -215,11 +_,17 @@ +@@ -220,11 +_,17 @@ } } 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 6065b2410d00..c93d29f0a0d9 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,7 +1,7 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -140,6 +_,17 @@ - import org.jetbrains.annotations.Contract; +@@ -143,6 +_,17 @@ + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; +// CraftBukkit start @@ -18,7 +18,7 @@ public abstract class LivingEntity extends Entity implements Attackable, WaypointTransmitter { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -266,11 +_,24 @@ +@@ -268,11 +_,25 @@ ); protected final EntityEquipment equipment; private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); @@ -32,6 +32,7 @@ + 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 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 protected LivingEntity(EntityType type, Level level) { @@ -44,7 +45,7 @@ this.equipment = this.createEquipment(); this.blocksBuilding = true; this.reapplyPosition(); -@@ -372,7 +_,13 @@ +@@ -371,7 +_,13 @@ double d1 = Math.min(0.2F + d / 15.0, 2.5); int i = (int)(150.0 * d1); @@ -59,7 +60,7 @@ } } -@@ -557,7 +_,7 @@ +@@ -556,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, EntityEvent.POOF); @@ -68,7 +69,7 @@ } } -@@ -662,7 +_,7 @@ +@@ -658,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -77,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -674,10 +_,15 @@ +@@ -670,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -94,12 +95,12 @@ this.level() .playSeededSound( null, -@@ -704,12 +_,12 @@ +@@ -700,12 +_,12 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause if ((reason == Entity.RemovalReason.KILLED || reason == Entity.RemovalReason.DISCARDED) && this.level() instanceof ServerLevel serverLevel) { this.triggerOnDeathMobEffects(serverLevel, reason); } @@ -109,7 +110,7 @@ this.brain.clearMemories(); } -@@ -726,11 +_,17 @@ +@@ -722,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -127,25 +128,21 @@ output.putFloat("Health", this.getHealth()); output.putShort("HurtTime", (short)this.hurtTime); output.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -764,8 +_,15 @@ +@@ -760,7 +_,12 @@ } } -- @Nullable -- public ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { +- public @Nullable ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { + // Paper start - Extend dropItem API -+ @Nullable -+ public final ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { ++ public final @Nullable ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { + return this.drop(stack, randomizeMotion, includeThrower, true, null); + } -+ -+ @Nullable -+ public ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { ++ public @Nullable ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower, boolean callEvent, java.util.function.@Nullable Consumer entityOperation) { + // Paper end - Extend dropItem API if (stack.isEmpty()) { return null; } else if (this.level().isClientSide()) { -@@ -774,6 +_,31 @@ +@@ -769,6 +_,31 @@ } else { ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); if (itemEntity != null) { @@ -177,7 +174,7 @@ this.level().addFreshEntity(itemEntity); } -@@ -783,7 +_,22 @@ +@@ -778,7 +_,22 @@ @Override protected void readAdditionalSaveData(ValueInput input) { @@ -201,8 +198,8 @@ if (this.level() != null && !this.level().isClientSide()) { input.read("attributes", AttributeInstance.Packed.LIST_CODEC).ifPresent(this.getAttributes()::apply); } -@@ -795,6 +_,11 @@ - this.activeEffects.put(mobEffectInstance.getEffect(), mobEffectInstance); +@@ -791,6 +_,11 @@ + this.effectsDirty = true; } + // CraftBukkit start @@ -213,7 +210,7 @@ this.setHealth(input.getFloatOr("Health", this.getMaxHealth())); this.hurtTime = input.getShortOr("HurtTime", (short)0); this.deathTime = input.getShortOr("DeathTime", (short)0); -@@ -802,6 +_,7 @@ +@@ -798,6 +_,7 @@ input.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); @@ -221,7 +218,7 @@ boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -809,11 +_,13 @@ +@@ -805,11 +_,13 @@ }); this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false)); input.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { @@ -235,8 +232,8 @@ }, this::clearSleepingPos); input.read("Brain", Codec.PASSTHROUGH).ifPresent(dynamic -> this.brain = this.makeBrain((Dynamic)dynamic)); this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player"); -@@ -824,15 +_,44 @@ - this.locatorBarIcon = input.read("locator_bar_icon", Waypoint.Icon.CODEC).orElseGet(Waypoint.Icon::new); +@@ -826,15 +_,44 @@ + this.updateDirtyEffects(); } + // CraftBukkit start @@ -280,10 +277,11 @@ iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); } else if (mobEffectInstance.getDuration() % 600 == 0) { -@@ -842,6 +_,17 @@ +@@ -843,6 +_,18 @@ + } } catch (ConcurrentModificationException var6) { } - ++ + // CraftBukkit start + this.isTickingEffects = false; + for (ProcessableEffect effect : this.effectsToProcess) { @@ -295,10 +293,10 @@ + } + this.effectsToProcess.clear(); + // CraftBukkit end - if (this.effectsDirty) { - this.updateInvisibilityStatus(); - this.updateGlowingStatus(); -@@ -949,15 +_,33 @@ + } else { + for (MobEffectInstance mobEffectInstance1 : this.activeEffects.values()) { + mobEffectInstance1.tickClient(); +@@ -953,15 +_,33 @@ } public boolean removeAllEffects() { @@ -336,7 +334,7 @@ } } -@@ -984,21 +_,57 @@ +@@ -987,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -396,16 +394,14 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -1037,11 +_,37 @@ +@@ -1039,11 +_,35 @@ + } - @Nullable - public final MobEffectInstance removeEffectNoUpdate(Holder effect) { -+// CraftBukkit start + public final @Nullable MobEffectInstance removeEffectNoUpdate(Holder effect) { ++ // CraftBukkit start + return this.removeEffectNoUpdate(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } -+ -+ @Nullable -+ public MobEffectInstance removeEffectNoUpdate(Holder effect, EntityPotionEffectEvent.Cause cause) { ++ public @Nullable MobEffectInstance removeEffectNoUpdate(Holder effect, EntityPotionEffectEvent.Cause cause) { + if (this.isTickingEffects) { + this.effectsToProcess.add(new ProcessableEffect(effect, cause)); + return null; @@ -420,7 +416,7 @@ + if (event.isCancelled()) { + return null; + } -+// CraftBukkit end ++ // CraftBukkit end return this.activeEffects.remove(effect); } @@ -435,7 +431,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1132,17 +_,62 @@ +@@ -1134,17 +_,62 @@ } public void heal(float amount) { @@ -499,7 +495,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1154,7 +_,7 @@ +@@ -1156,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -508,7 +504,7 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1170,35 +_,58 @@ +@@ -1172,35 +_,58 @@ ItemStack useItem = this.getUseItem(); float originAmount = amount; @@ -575,7 +571,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1213,7 +_,7 @@ +@@ -1215,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -584,7 +580,7 @@ this.markHurt(); } -@@ -1228,8 +_,16 @@ +@@ -1230,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -602,7 +598,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1238,19 +_,19 @@ +@@ -1240,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { @@ -627,7 +623,7 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1276,6 +_,12 @@ +@@ -1278,6 +_,12 @@ } public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { @@ -640,7 +636,7 @@ if (damageAmount <= 0.0F) { return 0.0F; } else { -@@ -1300,10 +_,12 @@ +@@ -1302,10 +_,12 @@ } float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); @@ -654,7 +650,7 @@ return f; } -@@ -1314,6 +_,59 @@ +@@ -1316,6 +_,59 @@ } } @@ -714,7 +710,7 @@ public void playSecondaryHurtSound(DamageSource damageSource) { if (damageSource.is(DamageTypes.THORNS)) { SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; -@@ -1346,12 +_,24 @@ +@@ -1347,12 +_,24 @@ return EntityReference.getPlayer(this.lastHurtByPlayer, this.level()); } @@ -740,7 +736,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1361,18 +_,39 @@ +@@ -1362,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -786,7 +782,7 @@ + // CraftBukkit end serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); - this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); + itemStack.causeUseVibration(this, GameEvent.ITEM_INTERACT_FINISH); @@ -1431,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); @@ -795,9 +791,9 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1440,68 +_,147 @@ - } +@@ -1441,68 +_,147 @@ + this.stopUsingItem(); if (!this.level().isClientSide() && this.hasCustomName()) { - LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); + if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot @@ -869,7 +865,7 @@ boolean var6 = false; - if (entitySource instanceof WitherBoss) { + if (this.dead && entitySource instanceof WitherBoss) { // Paper - if (serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { BlockPos blockPos = this.blockPosition(); BlockState blockState = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) { @@ -937,7 +933,7 @@ if (!this.wasExperienceConsumed() && ( this.isAlwaysExperienceDropper() - || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) + || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && level.getGameRules().get(GameRules.MOB_DROPS) )) { - ExperienceOrb.award(level, this.position(), this.getExperienceReward(level, entity)); - } @@ -956,7 +952,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1605,9 +_,14 @@ +@@ -1606,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -967,13 +963,13 @@ + public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events strength *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); - if (!(strength <= 0.0)) { -- this.hasImpulse = true; +- this.needsSync = true; + if (true || !(strength <= 0.0)) { // CraftBukkit - Call event even when force is 0 -+ // this.hasImpulse = true; // CraftBukkit - Move down ++ // this.needsSync = true; // CraftBukkit - Move down Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1616,11 +_,22 @@ +@@ -1617,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -991,13 +987,13 @@ + return; + } + -+ this.hasImpulse = true; ++ this.needsSync = true; + this.setDeltaMovement(deltaMovement.add(event.getKnockback().getX(), event.getKnockback().getY(), event.getKnockback().getZ())); // Paper - knockback events + // CraftBukkit end } } -@@ -1705,7 +_,7 @@ +@@ -1712,7 +_,7 @@ @Override public boolean isAlive() { @@ -1006,7 +1002,7 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1739,9 +_,14 @@ +@@ -1746,9 +_,14 @@ boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1022,7 +1018,7 @@ return true; } else { return flag; -@@ -1806,7 +_,7 @@ +@@ -1813,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1031,7 +1027,7 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1819,7 +_,8 @@ +@@ -1826,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { @@ -1041,7 +1037,7 @@ int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1856,24 +_,201 @@ +@@ -1863,24 +_,201 @@ } } @@ -1143,14 +1139,14 @@ + + if (damageSource.getEntity() instanceof net.minecraft.world.entity.player.Player) { + // Paper start - PlayerAttackEntityCooldownResetEvent -+ //((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired ++ //((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetOnlyAttackStrengthTicker(); // Moved from Player in order to make the cooldown reset get called after the damage event is fired + if (damageSource.getEntity() instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) damageSource.getEntity(); + if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getAttackStrengthScale(0F)).callEvent()) { -+ player.resetAttackStrengthTicker(); ++ player.resetOnlyAttackStrengthTicker(); + } + } else { -+ ((net.minecraft.world.entity.player.Player) damageSource.getEntity()).resetAttackStrengthTicker(); ++ ((net.minecraft.world.entity.player.Player) damageSource.getEntity()).resetOnlyAttackStrengthTicker(); + } + // Paper end - PlayerAttackEntityCooldownResetEvent + } @@ -1253,7 +1249,7 @@ } public CombatTracker getCombatTracker() { -@@ -1902,7 +_,17 @@ +@@ -1908,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1272,7 +1268,16 @@ } public final int getStingerCount() { -@@ -2059,7 +_,7 @@ +@@ -1955,7 +_,7 @@ + @Override + public void handleDamageEvent(DamageSource damageSource) { + this.walkAnimation.setSpeed(1.5F); +- this.invulnerableTime = 20; ++ this.invulnerableTime = this.invulnerableDuration; // Paper - configurable invulnerable duration + this.hurtDuration = 10; + this.hurtTime = this.hurtDuration; + SoundEvent hurtSound = this.getHurtSound(damageSource); +@@ -2084,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1281,7 +1286,7 @@ } protected void updateSwingTime() { -@@ -2155,8 +_,15 @@ +@@ -2187,8 +_,15 @@ } public void setItemSlot(EquipmentSlot slot, ItemStack stack) { @@ -1299,7 +1304,7 @@ public float getArmorCoverPercentage() { int i = 0; -@@ -2248,14 +_,27 @@ +@@ -2280,14 +_,27 @@ return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } @@ -1327,7 +1332,7 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2415,8 +_,10 @@ +@@ -2470,8 +_,10 @@ } public void stopFallFlying() { @@ -1338,7 +1343,16 @@ } private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { -@@ -2626,37 +_,15 @@ +@@ -2615,7 +_,7 @@ + + public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { + if (strength > 0.0F && target instanceof LivingEntity livingEntity) { +- livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); ++ livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events + this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); + } + } +@@ -2691,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1385,9 +1399,9 @@ profilerFiller.pop(); if (this.isFallFlying()) { -@@ -2686,16 +_,39 @@ - @Nullable - private Map collectEquipmentChanges() { +@@ -2806,16 +_,39 @@ + + private @Nullable Map collectEquipmentChanges() { Map map = null; + // Paper start - EntityEquipmentChangedEvent + record EquipmentChangeImpl(org.bukkit.inventory.ItemStack oldItem, org.bukkit.inventory.ItemStack newItem) implements io.papermc.paper.event.entity.EntityEquipmentChangedEvent.EquipmentChange { @@ -1425,7 +1439,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2720,6 +_,8 @@ +@@ -2840,6 +_,8 @@ } } } @@ -1434,7 +1448,7 @@ } return map; -@@ -2751,7 +_,7 @@ +@@ -2871,7 +_,7 @@ list.add(Pair.of(equipmentSlot, itemStack1)); this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); @@ -1443,7 +1457,7 @@ } protected void tickHeadTurn(float yBodyRot) { -@@ -2837,8 +_,10 @@ +@@ -2957,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1454,7 +1468,7 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2879,7 +_,7 @@ +@@ -2999,7 +_,7 @@ profilerFiller.pop(); if (this.level() instanceof ServerLevel serverLevel) { profilerFiller.push("freezing"); @@ -1463,7 +1477,7 @@ this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); } -@@ -2900,6 +_,20 @@ +@@ -3020,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1484,7 +1498,7 @@ if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -2922,6 +_,7 @@ +@@ -3042,6 +_,7 @@ this.checkFallDistanceAccumulation(); if (!this.level().isClientSide()) { if (!this.canGlide()) { @@ -1492,7 +1506,7 @@ this.setSharedFlag(Entity.FLAG_FALL_FLYING, false); return; } -@@ -2961,10 +_,25 @@ +@@ -3081,10 +_,25 @@ } protected void pushEntities() { @@ -1506,20 +1520,20 @@ + return; + } + -+ int _int = ((ServerLevel) this.level()).getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); -+ if (_int <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) { ++ int i = ((ServerLevel) this.level()).getGameRules().get(GameRules.MAX_ENTITY_CRAMMING); ++ if (i <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) { + return; + } + // Paper end - don't run getEntities if we're not going to use its result List pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox()); if (!pushableEntities.isEmpty()) { if (this.level() instanceof ServerLevel serverLevel) { -- int _int = serverLevel.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); +- int i = serverLevel.getGameRules().get(GameRules.MAX_ENTITY_CRAMMING); + // Paper - don't run getEntities if we're not going to use its result; moved up - if (_int > 0 && pushableEntities.size() > _int - 1 && this.random.nextInt(4) == 0) { - int i = 0; + if (i > 0 && pushableEntities.size() > i - 1 && this.random.nextInt(4) == 0) { + int i1 = 0; -@@ -2980,7 +_,16 @@ +@@ -3100,7 +_,16 @@ } } @@ -1536,7 +1550,7 @@ this.doPush(entity1); } } -@@ -2989,16 +_,32 @@ +@@ -3109,16 +_,32 @@ protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); @@ -1570,7 +1584,7 @@ this.autoSpinAttackTicks = 0; } -@@ -3021,10 +_,10 @@ +@@ -3141,10 +_,10 @@ } @Override @@ -1584,7 +1598,7 @@ this.dismountVehicle(vehicle); } } -@@ -3051,7 +_,7 @@ +@@ -3171,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1593,7 +1607,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3063,7 +_,7 @@ +@@ -3183,7 +_,7 @@ && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { ((ServerLevel)this.level()) .getChunkSource() @@ -1602,7 +1616,7 @@ } } -@@ -3077,7 +_,8 @@ +@@ -3197,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1612,7 +1626,7 @@ } } -@@ -3097,13 +_,27 @@ +@@ -3217,13 +_,27 @@ @Override public boolean isPickable() { @@ -1643,7 +1657,7 @@ @Override public float getYHeadRot() { -@@ -3134,7 +_,7 @@ +@@ -3254,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1652,7 +1666,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3161,6 +_,15 @@ +@@ -3281,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1668,7 +1682,7 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3178,6 +_,11 @@ +@@ -3297,6 +_,11 @@ return null; } else { double d = this.getEyeY() - 0.3F; @@ -1680,7 +1694,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); itemEntity.setPickUpDelay(40); if (includeThrower) { -@@ -3209,7 +_,12 @@ +@@ -3328,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1694,7 +1708,7 @@ this.completeUsingItem(); } } -@@ -3235,10 +_,19 @@ +@@ -3354,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { @@ -1716,7 +1730,7 @@ if (!this.level().isClientSide()) { this.setLivingEntityFlag(LIVING_ENTITY_FLAG_IS_USING, true); this.setLivingEntityFlag(LIVING_ENTITY_FLAG_OFF_HAND, hand == InteractionHand.OFF_HAND); -@@ -3262,7 +_,10 @@ +@@ -3384,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1728,7 +1742,7 @@ } } } -@@ -3301,7 +_,38 @@ +@@ -3423,7 +_,38 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1768,7 +1782,7 @@ if (itemStack != this.useItem) { this.setItemInHand(usedItemHand, itemStack); } -@@ -3331,6 +_,7 @@ +@@ -3457,6 +_,7 @@ ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { this.useItem = itemInHand; @@ -1776,7 +1790,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3350,7 +_,10 @@ +@@ -3477,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1788,7 +1802,7 @@ } public boolean isBlocking() { -@@ -3374,6 +_,60 @@ +@@ -3500,6 +_,60 @@ } } @@ -1813,7 +1827,7 @@ + return this.level().clip(raytrace); + } + -+ public @Nullable net.minecraft.world.phys.EntityHitResult getTargetEntity(int maxDistance) { ++ public net.minecraft.world.phys.@Nullable EntityHitResult getTargetEntity(int maxDistance) { + if (maxDistance < 1 || maxDistance > 120) { + throw new IllegalArgumentException("maxDistance must be between 1-120"); + } @@ -1849,7 +1863,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3392,6 +_,12 @@ +@@ -3518,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1862,7 +1876,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3414,16 +_,39 @@ +@@ -3540,16 +_,39 @@ } if (flag1) { @@ -1905,7 +1919,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, EntityEvent.TELEPORT); -@@ -3433,7 +_,7 @@ +@@ -3559,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 594d9cb62a2f..29c973aa71df 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,8 +1,8 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -90,6 +_,14 @@ - import net.minecraft.world.phys.Vec3; +@@ -92,6 +_,14 @@ import net.minecraft.world.ticks.ContainerSingleItem; + import org.jspecify.annotations.Nullable; +// CraftBukkit start +import org.bukkit.event.entity.CreatureSpawnEvent; @@ -15,16 +15,16 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashable, Targeting { private static final EntityDataAccessor DATA_MOB_FLAGS_ID = SynchedEntityData.defineId(Mob.class, EntityDataSerializers.BYTE); private static final int MOB_FLAG_NO_AI = 1; -@@ -125,6 +_,7 @@ +@@ -127,6 +_,7 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; -+ public @Nullable net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper - Allow nerfed mobs to jump and float ++ public net.minecraft.world.entity.ai.goal.@Nullable FloatGoal goalFloat; // Paper - Allow nerfed mobs to jump and float public GoalSelector targetSelector; - @Nullable - private LivingEntity target; + private @Nullable LivingEntity target; + private final Sensing sensing; @@ -139,6 +_,8 @@ - private Leashable.LeashData leashData; + private Leashable.@Nullable LeashData leashData; private BlockPos homePosition = BlockPos.ZERO; private int homeRadius = -1; + public boolean aware = true; // CraftBukkit @@ -45,7 +45,7 @@ protected void registerGoals() { } -@@ -235,7 +_,39 @@ +@@ -232,7 +_,39 @@ } public void setTarget(@Nullable LivingEntity target) { @@ -53,7 +53,7 @@ + this.setTarget(target, EntityTargetEvent.TargetReason.UNKNOWN); + } + -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable EntityTargetEvent.TargetReason reason) { ++ public boolean setTarget(@Nullable LivingEntity target, EntityTargetEvent.@Nullable TargetReason reason) { + if (this.getTarget() == target) { + return false; + } @@ -85,7 +85,7 @@ } @Override -@@ -375,13 +_,27 @@ +@@ -371,13 +_,27 @@ if (this.isNoAi()) { output.putBoolean("NoAI", this.isNoAi()); } @@ -115,7 +115,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -393,6 +_,13 @@ +@@ -389,6 +_,13 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -141,7 +141,7 @@ this.pickUpItem(serverLevel, itemEntity); } } -@@ -470,18 +_,24 @@ +@@ -509,18 +_,24 @@ protected void pickUpItem(ServerLevel level, ItemEntity entity) { ItemStack item = entity.getItem(); @@ -168,7 +168,7 @@ EquipmentSlot equipmentSlotForItem = this.getEquipmentSlotForItem(stack); if (!this.isEquippableInSlot(stack, equipmentSlotForItem)) { return ItemStack.EMPTY; -@@ -494,10 +_,18 @@ +@@ -533,10 +_,18 @@ canReplaceCurrentItem = itemBySlot.isEmpty(); } @@ -188,7 +188,7 @@ } ItemStack itemStack = equipmentSlotForItem.limit(stack); -@@ -611,25 +_,38 @@ +@@ -649,25 +_,38 @@ return this.isPassenger(); } @@ -241,7 +241,7 @@ this.noActionTime = 0; } } -@@ -641,6 +_,15 @@ +@@ -679,6 +_,15 @@ @Override protected final void serverAiStep() { this.noActionTime++; @@ -257,9 +257,9 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("sensing"); this.sensing.tick(); -@@ -815,14 +_,69 @@ +@@ -853,14 +_,69 @@ public boolean stillValid(Player player) { - return player.getVehicle() == Mob.this || player.canInteractWithEntity(Mob.this, 4.0); + return player.getVehicle() == Mob.this || player.isWithinEntityInteractionRange(Mob.this, 4.0); } + + // Paper start @@ -292,7 +292,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + if (Mob.this.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder inventoryHolder) { + return inventoryHolder; + } @@ -327,7 +327,7 @@ ItemStack itemBySlot = this.getItemBySlot(equipmentSlot); float f = this.dropChances.byEquipment(equipmentSlot); if (f != 0.0F) { -@@ -842,7 +_,13 @@ +@@ -880,7 +_,13 @@ } this.spawnAtLocation(level, itemBySlot); @@ -341,7 +341,7 @@ } } } -@@ -866,7 +_,9 @@ +@@ -904,7 +_,9 @@ set.add(equipmentSlot); } else if (this.dropChances.isPreserved(equipmentSlot)) { this.setItemSlot(equipmentSlot, ItemStack.EMPTY); @@ -351,8 +351,8 @@ } } } -@@ -1161,6 +_,21 @@ - public T convertTo( +@@ -1195,6 +_,21 @@ + public @Nullable T convertTo( EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion ) { + // Paper start - entity zap event - allow cancellation of conversion post creation @@ -361,19 +361,19 @@ + + @Nullable + public T convertTo( -+ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason ++ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason + ) { + return this.convertTo(entityType, conversionParams, spawnReason, e -> { afterConversion.finalizeConversion(e); return true; }, transformReason, creatureSpawnReason); + } + @Nullable + public T convertTo( -+ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.CancellingAfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason ++ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.CancellingAfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason + ) { + // Paper end - entity zap event - allow cancellation of conversion post creation if (this.isRemoved()) { return null; } else { -@@ -1169,13 +_,23 @@ +@@ -1203,13 +_,23 @@ return null; } else { conversionParams.type().convert(this, mob, conversionParams); @@ -400,27 +400,26 @@ } return mob; -@@ -1185,7 +_,18 @@ - - @Nullable - public T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion) { +@@ -1220,7 +_,17 @@ + public @Nullable T convertTo( + EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion + ) { - return this.convertTo(entityType, conversionParams, EntitySpawnReason.CONVERSION, afterConversion); + // Paper start - entity zap event - allow cancellation of conversion post creation + return this.convertTo(entityType, conversionParams, afterConversion, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ @Nullable -+ public T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason) { ++ public @Nullable T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.AfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason) { + return this.convertTo(entityType, conversionParams, e -> { afterConversion.finalizeConversion(e); return true; }, transformReason, creatureSpawnReason); + } -+ @Nullable -+ public T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.CancellingAfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason) { ++ ++ public @Nullable T convertTo(EntityType entityType, ConversionParams conversionParams, ConversionParams.CancellingAfterConversion afterConversion, EntityTransformEvent.@Nullable TransformReason transformReason, CreatureSpawnEvent.@Nullable SpawnReason creatureSpawnReason) { + return this.convertTo(entityType, conversionParams, EntitySpawnReason.CONVERSION, afterConversion, transformReason, creatureSpawnReason); + // Paper end - entity zap event - allow cancellation of conversion post creation } - @Nullable -@@ -1227,7 +_,17 @@ + @Override +@@ -1261,7 +_,17 @@ public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { boolean flag = super.startRiding(entity, force, triggerEvents); if (flag && this.isLeashed()) { @@ -439,12 +438,3 @@ } return flag; -@@ -1310,7 +_,7 @@ - float knockback = this.getKnockback(target, damageSource); - if (knockback > 0.0F && target instanceof LivingEntity livingEntity) { - livingEntity.knockback( -- knockback * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) -+ knockback * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // CraftBukkit // Paper - knockback events - ); - this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch index e1f064ef586b..1b8348e43ee4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch @@ -1,12 +1,10 @@ --- a/net/minecraft/world/entity/NeutralMob.java +++ b/net/minecraft/world/entity/NeutralMob.java -@@ -36,9 +_,11 @@ - if (level instanceof ServerLevel serverLevel) { - UUID uuid = input.read("AngryAt", UUIDUtil.CODEC).orElse(null); - this.setPersistentAngerTarget(uuid); -- if ((uuid != null ? serverLevel.getEntity(uuid) : null) instanceof LivingEntity livingEntity) { -- this.setTarget(livingEntity); -- } +@@ -50,7 +_,11 @@ + + if (level instanceof ServerLevel) { + this.setPersistentAngerTarget(EntityReference.read(input, "angry_at")); +- this.setTarget(EntityReference.getLivingEntity(this.getPersistentAngerTarget(), level)); + // Paper - Prevent entity loading causing async lookups; Moved diff to separate method + // If this entity already survived its first tick, e.g. is loaded and ticked in sync, actively + // tick the initial persistent anger. @@ -15,35 +13,30 @@ } } -@@ -91,7 +_,7 @@ +@@ -117,7 +_,7 @@ default void stopBeingAngry() { this.setLastHurtByMob(null); this.setPersistentAngerTarget(null); - this.setTarget(null); + this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit - this.setRemainingPersistentAngerTime(0); + this.setPersistentAngerEndTime(-1L); } -@@ -102,8 +_,24 @@ +@@ -127,7 +_,19 @@ void setTarget(@Nullable LivingEntity target); -+ boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason); // CraftBukkit ++ boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason); // CraftBukkit + boolean canAttack(LivingEntity entity); - @Nullable - LivingEntity getTarget(); + @Nullable LivingEntity getTarget(); + + // Paper start - Prevent entity loading causing async lookups + // Update last hurt when ticking + default void tickInitialPersistentAnger(Level level) { -+ UUID uuid = getPersistentAngerTarget(); -+ if (uuid == null) { -+ return; -+ } -+ -+ if (level.getEntity(uuid) instanceof LivingEntity target) { ++ LivingEntity target = EntityReference.getLivingEntity(this.getPersistentAngerTarget(), level); ++ if (target != null) { + this.setTarget(target, null); + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch index 03644b2736f1..cc8c0bbb2921 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch @@ -23,9 +23,9 @@ byte b = this.entityData.get(DATA_FLAGS_ID); if (sitting) { this.entityData.set(DATA_FLAGS_ID, (byte)(b | 1)); -@@ -215,7 +_,12 @@ +@@ -213,7 +_,12 @@ if (this.level() instanceof ServerLevel serverLevel - && serverLevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) + && serverLevel.getGameRules().get(GameRules.SHOW_DEATH_MESSAGES) && this.getOwner() instanceof ServerPlayer serverPlayer) { - serverPlayer.sendSystemMessage(this.getCombatTracker().getDeathMessage()); + // Paper start - Add TameableDeathMessageEvent @@ -37,7 +37,7 @@ } super.die(damageSource); -@@ -258,7 +_,14 @@ +@@ -256,7 +_,14 @@ if (!this.canTeleportTo(new BlockPos(x, y, z))) { return false; } else { 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 e0094dde9c77..38c76aeede01 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 -@@ -151,20 +_,20 @@ +@@ -148,20 +_,20 @@ double baseValue = this.getBaseValue(); for (AttributeModifier attributeModifier : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_VALUE)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch index 0963597315bb..b2374f012ca5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java -@@ -148,4 +_,12 @@ +@@ -147,4 +_,12 @@ } } } 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 ae547448e8b2..266bf345f9a1 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 -@@ -10,7 +_,7 @@ +@@ -11,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) -@@ -52,10 +_,10 @@ +@@ -53,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,7 +22,7 @@ ); public static final Holder MINING_EFFICIENCY = register( "mining_efficiency", new RangedAttribute("attribute.name.mining_efficiency", 0.0, 0.0, 1024.0).setSyncable(true) -@@ -64,7 +_,7 @@ +@@ -65,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( 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 32e15ef453ba..4f07a53c89a7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java +++ b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java -@@ -110,7 +_,9 @@ +@@ -108,7 +_,9 @@ Block block = blockState.getBlock(); Block block1 = level.getBlockState(this.aboveFarmlandPos.below()).getBlock(); if (block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockState)) { @@ -10,7 +10,7 @@ } if (blockState.isAir() && block1 instanceof FarmBlock && owner.hasFarmSeeds()) { -@@ -121,9 +_,11 @@ +@@ -119,9 +_,11 @@ boolean flag = false; if (!item.isEmpty() && item.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) && item.getItem() instanceof BlockItem blockItem) { BlockState blockState1 = blockItem.getBlock().defaultBlockState(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch index abad8cfd918c..2158504f91e1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PoiCompetitorScan.java.patch @@ -24,7 +24,7 @@ + if (other == villager) { + continue; + } -+ if (!(other instanceof final net.minecraft.world.entity.npc.Villager otherVillager)) { ++ if (!(other instanceof final net.minecraft.world.entity.npc.villager.Villager otherVillager)) { + continue; + } + if (!other.isAlive()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch index 851e1cc6a9f9..6d62fb17905f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java +++ b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java -@@ -323,7 +_,10 @@ +@@ -320,7 +_,10 @@ } else { boolean flag1 = this.isWantedBlock(mob, transportItemTarget.state) && !this.isPositionAlreadyVisited(visitedPositions, unreachablePositions, transportItemTarget, level) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index e92a3969ffe1..4ecb07b24c57 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -5,10 +5,10 @@ if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockPos = this.mob.blockPosition(); - if (IS_EDIBLE.test(this.level.getBlockState(blockPos))) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING)) { + final BlockState blockState = this.level.getBlockState(blockPos); // Paper - fix wrong block state + if (IS_EDIBLE.test(blockState)) { // Paper - fix wrong block state -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - fix wrong block state ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING))) { // CraftBukkit // Paper - fix wrong block state this.level.destroyBlock(blockPos, false); } @@ -16,8 +16,8 @@ } else { BlockPos blockPos1 = blockPos.below(); if (this.level.getBlockState(blockPos1).is(Blocks.GRASS_BLOCK)) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - Fix wrong block state +- if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().get(GameRules.MOB_GRIEFING))) { // CraftBukkit // Paper - Fix wrong block state this.level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, blockPos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockPos1, Blocks.DIRT.defaultBlockState(), Block.UPDATE_CLIENTS); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch index 32807a319e00..29d8247ac576 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java +++ b/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -@@ -72,7 +_,7 @@ +@@ -71,7 +_,7 @@ public void tick() { boolean shouldTryTeleportToOwner = this.tamable.shouldTryTeleportToOwner(); if (!shouldTryTeleportToOwner) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index 776d692c9ace..a42f7a01a855 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -12,10 +12,10 @@ level.removeBlock(posWithBlock, false); if (!level.isClientSide()) { for (int i = 0; i < 20; i++) { -@@ -124,13 +_,16 @@ +@@ -123,13 +_,16 @@ + } - @Nullable - private BlockPos getPosWithBlock(BlockPos pos, BlockGetter level) { + private @Nullable BlockPos getPosWithBlock(BlockPos pos, BlockGetter level) { - if (level.getBlockState(pos).is(this.blockToRemove)) { + net.minecraft.world.level.block.state.BlockState block = level.getBlockStateIfLoaded(pos); // Paper - Prevent AI rules from loading chunks + if (block == null) return null; // Paper - Prevent AI rules from loading chunks @@ -31,7 +31,7 @@ return blockPos; } } -@@ -141,7 +_,7 @@ +@@ -140,7 +_,7 @@ @Override protected boolean isValidTarget(LevelReader level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch index acde7d31dd3c..84ac8fe4b87e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/SwellGoal.java +++ b/net/minecraft/world/entity/ai/goal/SwellGoal.java -@@ -21,6 +_,14 @@ +@@ -20,6 +_,14 @@ return this.creeper.getSwellDir() > 0 || target != null && this.creeper.distanceToSqr(target) < 9.0; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch index cd8fcb07995b..1a838aa9c160 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/ai/goal/TemptGoal.java +++ b/net/minecraft/world/entity/ai/goal/TemptGoal.java -@@ -24,7 +_,7 @@ +@@ -23,7 +_,7 @@ + private double pz; private double pRotX; private double pRotY; - @Nullable -- protected Player player; -+ protected LivingEntity player; // CraftBukkit +- protected @Nullable Player player; ++ protected @Nullable LivingEntity player; // CraftBukkit private int calmDown; private boolean isRunning; private final Predicate items; -@@ -57,6 +_,15 @@ +@@ -56,6 +_,15 @@ } else { this.player = getServerLevel(this.mob) .getNearestPlayer(this.targetingConditions.range(this.mob.getAttributeValue(Attributes.TEMPT_RANGE)), this.mob); @@ -25,7 +25,7 @@ return this.player != null; } } -@@ -123,7 +_,7 @@ +@@ -122,7 +_,7 @@ this.mob.getNavigation().stop(); } @@ -34,7 +34,7 @@ this.mob.getNavigation().moveTo(player, this.speedModifier); } -@@ -142,7 +_,7 @@ +@@ -141,7 +_,7 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch index 2635d672a76a..66d7c33c3395 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java -@@ -47,7 +_,7 @@ +@@ -46,7 +_,7 @@ @Override public void start() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch index 6c395ee1f3e7..b1cd473fdd52 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java -@@ -59,7 +_,7 @@ +@@ -58,7 +_,7 @@ @Override public void start() { @@ -9,7 +9,7 @@ this.targetMob = this.mob.getTarget(); this.timestamp = this.mob.getLastHurtByMobTimestamp(); this.unseenMemoryTicks = 300; -@@ -114,6 +_,6 @@ +@@ -113,6 +_,6 @@ } protected void alertOther(Mob mob, LivingEntity target) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch index 3a53b1a47b8a..d2987e4f20d7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java -@@ -73,7 +_,7 @@ +@@ -72,7 +_,7 @@ @Override public void start() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch index a452b371fec3..0c6f02b444d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java -@@ -63,7 +_,7 @@ +@@ -62,7 +_,7 @@ } } @@ -9,7 +9,7 @@ return true; } } -@@ -83,7 +_,7 @@ +@@ -82,7 +_,7 @@ @Override public void stop() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index ac04f3da30b0..788c01d186c7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,49 +1,46 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -131,7 +_,13 @@ +@@ -124,7 +_,12 @@ + } - @Nullable - public Path createPath(BlockPos pos, int reachRange) { + public @Nullable Path createPath(BlockPos pos, int reachRange) { - return this.createPath(ImmutableSet.of(pos), 8, false, reachRange); + // Paper start - EntityPathfindEvent + return this.createPath(pos, null, reachRange); + } -+ @Nullable -+ public Path createPath(BlockPos target, @Nullable Entity entity, int reachRange) { ++ public @Nullable Path createPath(BlockPos target, @Nullable Entity entity, int reachRange) { + return this.createPath(ImmutableSet.of(target), entity, 8, false, reachRange); + // Paper end - EntityPathfindEvent } - @Nullable -@@ -141,7 +_,7 @@ + public @Nullable Path createPath(BlockPos pos, int reachRange, int followRange) { +@@ -132,7 +_,7 @@ + } - @Nullable - public Path createPath(Entity entity, int reachRange) { + public @Nullable Path createPath(Entity entity, int reachRange) { - return this.createPath(ImmutableSet.of(entity.blockPosition()), 16, true, reachRange); + return this.createPath(ImmutableSet.of(entity.blockPosition()), entity, 16, true, reachRange); // Paper - EntityPathfindEvent } - @Nullable -@@ -151,6 +_,18 @@ + protected @Nullable Path createPath(Set targets, int regionOffset, boolean offsetUpward, int reachRange) { +@@ -140,6 +_,16 @@ + } - @Nullable - protected Path createPath(Set targets, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { + protected @Nullable Path createPath(Set targets, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { + // Paper start - EntityPathfindEvent + return this.createPath(targets, null, regionOffset, offsetUpward, reachRange, followRange); + } + -+ @Nullable -+ protected Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange) { ++ protected @Nullable Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange) { + return this.createPath(targets, target, regionOffset, offsetUpward, reachRange, this.getMaxPathLength()); + } + -+ @Nullable -+ protected Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { ++ protected @Nullable Path createPath(Set targets, @Nullable Entity target, int regionOffset, boolean offsetUpward, int reachRange, float followRange) { + // Paper end - EntityPathfindEvent if (targets.isEmpty()) { return null; } else if (this.mob.getY() < this.level.getMinY()) { -@@ -160,6 +_,23 @@ +@@ -149,6 +_,23 @@ } else if (this.path != null && !this.path.isDone() && targets.contains(this.targetPos)) { return this.path; } else { @@ -67,7 +64,7 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("pathfind"); BlockPos blockPos = offsetUpward ? this.mob.blockPosition().above() : this.mob.blockPosition(); -@@ -177,6 +_,11 @@ +@@ -166,6 +_,11 @@ } } @@ -79,7 +76,7 @@ public boolean moveTo(double x, double y, double z, double speedModifier) { return this.moveTo(this.createPath(x, y, z, 1), speedModifier); } -@@ -186,8 +_,23 @@ +@@ -175,8 +_,23 @@ } public boolean moveTo(Entity entity, double speedModifier) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch index e5e2bb810f52..470cc35f4485 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java -@@ -16,9 +_,9 @@ +@@ -15,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch index 0a3a0a535061..ac8b07e679f5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java +++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java -@@ -38,7 +_,19 @@ +@@ -48,7 +_,19 @@ .collect(Collectors.toList()); if (!list.isEmpty()) { Player player = list.get(0); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch index fff018b75467..43f464a614ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -88,7 +_,7 @@ +@@ -84,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ return false; } -@@ -142,13 +_,13 @@ +@@ -138,13 +_,13 @@ this.yHeadRot = this.random.nextInt(360); } @@ -25,7 +25,7 @@ this.setResting(false); if (!isSilent) { level.levelEvent(null, LevelEvent.SOUND_BAT_LIFTOFF, blockPos, 0); -@@ -181,7 +_,7 @@ +@@ -177,7 +_,7 @@ float f1 = Mth.wrapDegrees(f - this.getYRot()); this.zza = 0.5F; this.setYRot(this.getYRot() + f1); @@ -34,7 +34,7 @@ this.setResting(true); } } -@@ -206,7 +_,7 @@ +@@ -202,7 +_,7 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { 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 a0e5270649be..a39cced042b7 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 @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -41,6 +_,7 @@ +@@ -39,6 +_,7 @@ + private static final int DEFAULT_IN_LOVE_TIME = 0; public int inLove = 0; - @Nullable - public EntityReference loveCause; + public @Nullable EntityReference loveCause; + public @Nullable ItemStack breedItem; // CraftBukkit - Add breedItem variable protected Animal(EntityType type, Level level) { super(type, level); -@@ -80,9 +_,13 @@ +@@ -78,9 +_,13 @@ } @Override @@ -24,7 +24,7 @@ } @Override -@@ -138,8 +_,9 @@ +@@ -136,8 +_,9 @@ if (this.isFood(itemInHand)) { int age = this.getAge(); if (player instanceof ServerPlayer serverPlayer && age == 0 && this.canFallInLove()) { @@ -35,7 +35,7 @@ this.playEatingSound(); return InteractionResult.SUCCESS_SERVER; } -@@ -166,8 +_,23 @@ +@@ -164,8 +_,23 @@ return this.inLove <= 0; } @@ -60,7 +60,7 @@ if (player instanceof ServerPlayer serverPlayer) { this.loveCause = EntityReference.of(serverPlayer); } -@@ -205,23 +_,45 @@ +@@ -202,23 +_,45 @@ if (breedOffspring != null) { breedOffspring.setBaby(true); breedOffspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); @@ -105,9 +105,9 @@ this.resetLove(); animal.resetLove(); level.broadcastEntityEvent(this, EntityEvent.IN_LOVE_HEARTS); -- if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- if (level.getGameRules().get(GameRules.MOB_DROPS)) { - level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1)); -+ if (experience > 0 && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - Call EntityBreedEvent ++ if (experience > 0 && level.getGameRules().get(GameRules.MOB_DROPS)) { // Paper - Call EntityBreedEvent + level.addFreshEntity(new ExperienceOrb(level, this.position(), net.minecraft.world.phys.Vec3.ZERO, experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, player, baby)); // Paper - Call EntityBreedEvent, add spawn context } } 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 ef8378b2a1cf..ec19e8dbe40e 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 -@@ -113,6 +_,7 @@ +@@ -112,6 +_,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,7 +8,7 @@ public Allay(EntityType type, Level level) { super(type, level); -@@ -126,6 +_,12 @@ +@@ -125,6 +_,12 @@ ); } @@ -21,7 +21,7 @@ @Override protected Brain.Provider brainProvider() { return Brain.provider(MEMORY_TYPES, SENSOR_TYPES); -@@ -233,7 +_,7 @@ +@@ -232,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) { -@@ -301,7 +_,12 @@ +@@ -300,7 +_,12 @@ ItemStack itemInHand = player.getItemInHand(hand); ItemStack itemInHand1 = this.getItemInHand(InteractionHand.MAIN_HAND); if (this.isDancing() && itemInHand.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, itemInHand); -@@ -400,6 +_,7 @@ +@@ -399,6 +_,7 @@ } private boolean shouldStopDancing() { @@ -52,7 +52,7 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), GameEvent.JUKEBOX_PLAY.value().notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); -@@ -452,7 +_,7 @@ +@@ -451,7 +_,7 @@ super.readAdditionalSaveData(input); this.readInventoryFromTag(input); this.vibrationData = input.read("listener", VibrationSystem.Data.CODEC).orElseGet(VibrationSystem.Data::new); @@ -61,7 +61,7 @@ } @Override -@@ -471,15 +_,17 @@ +@@ -470,15 +_,17 @@ this.entityData.set(DATA_CAN_DUPLICATE, duplicationCooldown == 0L); } 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 714cacd93e93..81ee48b69608 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,9 +1,9 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -138,10 +_,12 @@ +@@ -137,10 +_,12 @@ ArmadilloAi.updateActivity(this); profilerFiller.pop(); - if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { + 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); @@ -13,7 +13,7 @@ this.scuteTime = this.pickNextScuteDropTime(); } -@@ -278,8 +_,11 @@ +@@ -277,8 +_,11 @@ } @Override @@ -27,7 +27,7 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (damageSource.getEntity() instanceof LivingEntity) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -290,6 +_,7 @@ +@@ -289,6 +_,7 @@ this.rollOut(); } } @@ -35,7 +35,7 @@ } @Override -@@ -308,7 +_,9 @@ +@@ -307,7 +_,9 @@ return false; } else { if (this.level() instanceof ServerLevel serverLevel) { 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 ebe3a364c64b..db1f768482cf 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 @@ -9,7 +9,7 @@ } public Axolotl.Variant getVariant() { -@@ -450,10 +_,10 @@ +@@ -448,10 +_,10 @@ if (effect == null || effect.endsWithin(2399)) { int i = effect != null ? effect.getDuration() : 0; int min = Math.min(2400, 100 + i); @@ -22,7 +22,7 @@ } @Override -@@ -539,6 +_,13 @@ +@@ -530,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.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch index aaf4047d34b9..f215390a758b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/bee/Bee.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/Bee.java -+++ b/net/minecraft/world/entity/animal/Bee.java +--- a/net/minecraft/world/entity/animal/bee/Bee.java ++++ b/net/minecraft/world/entity/animal/bee/Bee.java @@ -149,10 +_,26 @@ Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; @@ -56,7 +56,7 @@ } } -@@ -486,7 +_,11 @@ +@@ -480,7 +_,11 @@ if (this.hivePos == null) { return null; } else { @@ -69,7 +69,7 @@ } } -@@ -519,6 +_,7 @@ +@@ -513,6 +_,7 @@ } public void setRolling(boolean isRolling) { @@ -77,7 +77,7 @@ this.setFlag(FLAG_ROLL, isRolling); } -@@ -575,7 +_,7 @@ +@@ -569,7 +_,7 @@ if (beeInteractionEffect != null) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide()) { @@ -86,7 +86,7 @@ } return InteractionResult.SUCCESS; -@@ -644,8 +_,9 @@ +@@ -637,8 +_,9 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -97,7 +97,7 @@ } } -@@ -987,7 +_,7 @@ +@@ -979,7 +_,7 @@ } } @@ -106,7 +106,7 @@ Bee.this.level().levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, blockPos, 15); Bee.this.level().setBlockAndUpdate(blockPos, blockState1); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1011,7 +_,7 @@ +@@ -1003,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Bee && this.mob.hasLineOfSight(target)) { @@ -115,7 +115,7 @@ } } } -@@ -1169,7 +_,7 @@ +@@ -1160,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 08a4d7d4a009..39caee1ceda0 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 -@@ -403,12 +_,12 @@ +@@ -411,12 +_,12 @@ } else { boolean flag = this.getHealth() < this.getMaxHealth(); if (flag) { @@ -15,7 +15,7 @@ } boolean isBaby = this.isBaby(); -@@ -468,9 +_,13 @@ +@@ -474,9 +_,13 @@ } @Override @@ -31,25 +31,25 @@ } @Override -@@ -565,7 +_,7 @@ +@@ -571,7 +_,7 @@ } public void sitDown() { - if (!this.isCamelSitting()) { + if (!this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), true).callEvent()) { // Paper - Add EntityToggleSitEvent - this.makeSound(SoundEvents.CAMEL_SIT); + this.makeSound(this.getSitDownSound()); this.setPose(Pose.SITTING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -574,7 +_,7 @@ +@@ -580,7 +_,7 @@ } public void standUp() { - if (this.isCamelSitting()) { + if (this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) { // Paper - Add EntityToggleSitEvent - this.makeSound(SoundEvents.CAMEL_STAND); + this.makeSound(this.getStandUpSound()); this.setPose(Pose.STANDING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -583,6 +_,7 @@ +@@ -597,6 +_,7 @@ } public void standUpInstantly() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch index 7c745c39beb0..b462eb81c29d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/chicken/Chicken.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Chicken.java -+++ b/net/minecraft/world/entity/animal/Chicken.java -@@ -112,10 +_,12 @@ +--- a/net/minecraft/world/entity/animal/chicken/Chicken.java ++++ b/net/minecraft/world/entity/animal/chicken/Chicken.java +@@ -113,10 +_,12 @@ this.flap = this.flap + this.flapping * 2.0F; if (this.level() instanceof ServerLevel serverLevel && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/cow/AbstractCow.java.patch index b66d5d65f7a6..396d38adc60d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/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/AbstractCow.java -+++ b/net/minecraft/world/entity/animal/AbstractCow.java -@@ -84,8 +_,15 @@ +--- a/net/minecraft/world/entity/animal/cow/AbstractCow.java ++++ b/net/minecraft/world/entity/animal/cow/AbstractCow.java +@@ -85,8 +_,15 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch index 3b17e1eada52..c0e2f6acbeff 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/cow/MushroomCow.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/MushroomCow.java -+++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -118,7 +_,17 @@ +--- a/net/minecraft/world/entity/animal/cow/MushroomCow.java ++++ b/net/minecraft/world/entity/animal/cow/MushroomCow.java +@@ -116,7 +_,17 @@ return InteractionResult.SUCCESS; } else if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverLevel) { @@ -19,7 +19,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand.asEquipmentSlot()); } -@@ -172,15 +_,31 @@ +@@ -170,15 +_,31 @@ @Override public void shear(ServerLevel level, SoundSource source, ItemStack shears) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch index b3a85bb49fb2..1fdf4e400bf8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/dolphin/Dolphin.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Dolphin.java -+++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -100,6 +_,13 @@ +--- a/net/minecraft/world/entity/animal/dolphin/Dolphin.java ++++ b/net/minecraft/world/entity/animal/dolphin/Dolphin.java +@@ -98,6 +_,13 @@ return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING); } @@ -14,7 +14,7 @@ @Override public float getAgeScale() { return this.isBaby() ? 0.65F : 1.0F; -@@ -184,7 +_,7 @@ +@@ -182,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -23,7 +23,7 @@ } @Override -@@ -217,11 +_,15 @@ +@@ -215,11 +_,15 @@ if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ItemStack item = entity.getItem(); if (this.canHoldItem(item)) { @@ -40,7 +40,7 @@ } } } -@@ -488,7 +_,7 @@ +@@ -479,7 +_,7 @@ @Override public void start() { @@ -49,7 +49,7 @@ } @Override -@@ -507,7 +_,7 @@ +@@ -498,7 +_,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { @@ -58,7 +58,7 @@ } } } -@@ -577,7 +_,7 @@ +@@ -568,7 +_,7 @@ 0.3F * Mth.cos(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) + Mth.sin(f1) * f2 ); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch similarity index 73% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch index afe3272470b2..f0d60ff3e63d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -+++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -@@ -73,6 +_,12 @@ +--- a/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java ++++ b/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java +@@ -74,6 +_,12 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch index 9586c105fd5b..52883f8e6a3b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractHorse.java.patch @@ -1,14 +1,14 @@ ---- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java -+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java +--- a/net/minecraft/world/entity/animal/equine/AbstractHorse.java ++++ b/net/minecraft/world/entity/animal/equine/AbstractHorse.java @@ -124,6 +_,7 @@ + protected boolean canGallop = true; protected int gallopSoundCounter; - @Nullable - public EntityReference owner; + public @Nullable EntityReference owner; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected AbstractHorse(EntityType type, Level level) { super(type, level); -@@ -253,7 +_,7 @@ +@@ -252,7 +_,7 @@ } @Override @@ -17,7 +17,7 @@ return !this.isVehicle(); } -@@ -304,7 +_,7 @@ +@@ -299,7 +_,7 @@ public void createInventory() { SimpleContainer simpleContainer = this.inventory; @@ -26,7 +26,7 @@ if (simpleContainer != null) { int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -398,7 +_,7 @@ +@@ -391,7 +_,7 @@ } public int getMaxTemper() { @@ -35,7 +35,7 @@ } @Override -@@ -457,7 +_,7 @@ +@@ -454,7 +_,7 @@ i1 = 5; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -44,7 +44,7 @@ } } else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) { f = 10.0F; -@@ -465,12 +_,12 @@ +@@ -462,12 +_,12 @@ i1 = 10; if (!this.level().isClientSide() && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -59,7 +59,7 @@ flag = true; } -@@ -541,7 +_,7 @@ +@@ -538,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -68,7 +68,7 @@ } if (this.canEatGrass()) { -@@ -643,6 +_,16 @@ +@@ -640,6 +_,16 @@ } } @@ -85,7 +85,7 @@ @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { if (this.isVehicle() || this.isBaby()) { -@@ -795,6 +_,7 @@ +@@ -791,6 +_,7 @@ output.putInt("Temper", this.getTemper()); output.putBoolean("Tame", this.isTamed()); EntityReference.store(this.owner, output, "Owner"); @@ -93,7 +93,7 @@ } @Override -@@ -805,6 +_,7 @@ +@@ -801,6 +_,7 @@ this.setTemper(input.getIntOr("Temper", 0)); this.setTamed(input.getBooleanOr("Tame", false)); this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level()); @@ -101,7 +101,7 @@ } @Override -@@ -893,6 +_,17 @@ +@@ -888,6 +_,17 @@ @Override public void handleStartJump(int jumpPower) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch similarity index 78% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch index 478d49854eec..514774700575 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/Llama.java.patch @@ -1,11 +1,11 @@ ---- a/net/minecraft/world/entity/animal/horse/Llama.java -+++ b/net/minecraft/world/entity/animal/horse/Llama.java -@@ -77,18 +_,19 @@ - @Nullable - private Llama caravanHead; - @Nullable -- private Llama caravanTail; -+ public Llama caravanTail; // Paper - public +--- a/net/minecraft/world/entity/animal/equine/Llama.java ++++ b/net/minecraft/world/entity/animal/equine/Llama.java +@@ -75,18 +_,19 @@ + .scale(0.5F); + boolean didSpit; + private @Nullable Llama caravanHead; +- private @Nullable Llama caravanTail; ++ public @Nullable Llama caravanTail; // Paper - public public Llama(EntityType type, Level level) { super(type, level); @@ -22,7 +22,7 @@ this.entityData.set(DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength))); } -@@ -194,12 +_,12 @@ +@@ -191,12 +_,12 @@ f = 10.0F; if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) { flag = true; @@ -37,7 +37,7 @@ flag = true; } -@@ -313,7 +_,7 @@ +@@ -308,7 +_,7 @@ @Override public int getMaxTemper() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch similarity index 65% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonHorse.java.patch index cb9143e8fccf..43ae42746bd0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/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/horse/SkeletonHorse.java -+++ b/net/minecraft/world/entity/animal/horse/SkeletonHorse.java -@@ -125,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/equine/SkeletonHorse.java ++++ b/net/minecraft/world/entity/animal/equine/SkeletonHorse.java +@@ -126,7 +_,7 @@ public void aiStep() { super.aiStep(); if (this.isTrap() && this.trapTime++ >= 18000) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch index bd666de5d378..0017eebc7c21 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java -+++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java +--- a/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java ++++ b/net/minecraft/world/entity/animal/equine/SkeletonTrapGoal.java @@ -18,6 +_,7 @@ public class SkeletonTrapGoal extends Goal { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/equine/TraderLlama.java.patch index a446a4d6fe3c..6fe1f4c67b78 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/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/horse/TraderLlama.java -+++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java -@@ -89,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/equine/TraderLlama.java ++++ b/net/minecraft/world/entity/animal/equine/TraderLlama.java +@@ -88,7 +_,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { this.removeLeash(); @@ -9,7 +9,7 @@ } } } -@@ -148,7 +_,7 @@ +@@ -146,7 +_,7 @@ @Override public void start() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Cat.java.patch index 3091bda0f3e8..4f297d72d1fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/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/Cat.java -+++ b/net/minecraft/world/entity/animal/Cat.java -@@ -374,6 +_,11 @@ +--- a/net/minecraft/world/entity/animal/feline/Cat.java ++++ b/net/minecraft/world/entity/animal/feline/Cat.java +@@ -372,6 +_,11 @@ if (item instanceof DyeItem dyeItem) { DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -12,7 +12,7 @@ if (!this.level().isClientSide()) { this.setCollarColor(dyeColor); itemInHand.consume(1, player); -@@ -386,7 +_,7 @@ +@@ -384,7 +_,7 @@ if (!this.level().isClientSide()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -21,7 +21,7 @@ this.playEatingSound(); } -@@ -448,7 +_,7 @@ +@@ -446,7 +_,7 @@ } private void tryToTame(Player player) { @@ -30,7 +30,7 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); -@@ -582,15 +_,20 @@ +@@ -579,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, @@ -55,12 +55,12 @@ ); } -@@ -617,7 +_,7 @@ +@@ -613,7 +_,7 @@ + } static class CatTemptGoal extends TemptGoal { - @Nullable -- private Player selectedPlayer; -+ private LivingEntity selectedPlayer; // CraftBukkit +- private @Nullable Player selectedPlayer; ++ private @Nullable LivingEntity selectedPlayer; // CraftBukkit private final Cat cat; public CatTemptGoal(Cat cat, double speedModifier, Predicate items, boolean canScare) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/feline/Ocelot.java.patch index e9414924cb20..0a20cf90d180 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/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/Ocelot.java -+++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -128,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/feline/Ocelot.java ++++ b/net/minecraft/world/entity/animal/feline/Ocelot.java +@@ -129,7 +_,7 @@ @Override public boolean removeWhenFarAway(double distanceToClosestPlayer) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java.patch similarity index 62% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java.patch index 94cfc94803e6..6663fc08d964 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/AbstractSchoolingFish.java -+++ b/net/minecraft/world/entity/animal/AbstractSchoolingFish.java -@@ -51,6 +_,7 @@ +--- a/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java ++++ b/net/minecraft/world/entity/animal/fish/AbstractSchoolingFish.java +@@ -50,6 +_,7 @@ } public void stopFollowing() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/Pufferfish.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fish/Pufferfish.java.patch index 8372769dbe9a..604051d9c6b6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/Pufferfish.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/Pufferfish.java -+++ b/net/minecraft/world/entity/animal/Pufferfish.java +--- a/net/minecraft/world/entity/animal/fish/Pufferfish.java ++++ b/net/minecraft/world/entity/animal/fish/Pufferfish.java @@ -97,24 +_,36 @@ public void tick() { if (!this.level().isClientSide() && this.isAlive() && this.isEffectiveAi()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch index d274fbeacd6d..a55197acb9e7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/fish/WaterAnimal.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/WaterAnimal.java -+++ b/net/minecraft/world/entity/animal/WaterAnimal.java +--- a/net/minecraft/world/entity/animal/fish/WaterAnimal.java ++++ b/net/minecraft/world/entity/animal/fish/WaterAnimal.java @@ -72,6 +_,10 @@ ) { int seaLevel = level.getSeaLevel(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/fox/Fox.java.patch index f47760008099..e9b25ee2248e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/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.java -+++ b/net/minecraft/world/entity/animal/Fox.java -@@ -432,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/fox/Fox.java ++++ b/net/minecraft/world/entity/animal/fox/Fox.java +@@ -440,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(); -@@ -449,6 +_,12 @@ +@@ -457,6 +_,12 @@ } public void setSitting(boolean sitting) { @@ -22,7 +22,7 @@ this.setFlag(FLAG_SITTING, sitting); } -@@ -508,19 +_,20 @@ +@@ -516,19 +_,20 @@ itemEntity.setPickUpDelay(40); itemEntity.setThrower(this); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); @@ -46,7 +46,7 @@ int count = item.getCount(); if (count > 1) { this.dropItemStack(item.split(count - 1)); -@@ -531,7 +_,7 @@ +@@ -539,7 +_,7 @@ this.setItemSlot(EquipmentSlot.MAINHAND, item.split(1)); this.setGuaranteedDrop(EquipmentSlot.MAINHAND); this.take(entity, item.getCount()); @@ -55,12 +55,12 @@ this.ticksSinceEaten = 0; } } -@@ -622,12 +_,12 @@ +@@ -630,12 +_,12 @@ } @Override - public void setTarget(@Nullable LivingEntity target) { -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { // CraftBukkit if (this.isDefending() && target == null) { this.setDefending(false); } @@ -70,7 +70,7 @@ } void wakeUp() { -@@ -691,15 +_,33 @@ +@@ -696,15 +_,33 @@ return this.getTrustedEntities().anyMatch(entityReference -> entityReference.matches(entity)); } @@ -89,7 +89,7 @@ ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND); - if (!itemBySlot.isEmpty()) { + boolean releaseMouth = false; -+ if (!itemBySlot.isEmpty() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Fix MC-153010 ++ if (!itemBySlot.isEmpty() && level.getGameRules().get(GameRules.MOB_DROPS)) { // Fix MC-153010 this.spawnAtLocation(level, itemBySlot); + releaseMouth = true; + } @@ -108,7 +108,7 @@ } public static boolean isPathClear(Fox fox, LivingEntity livingEntity) { -@@ -875,6 +_,19 @@ +@@ -877,6 +_,19 @@ fox.addTrustedEntity(loveCause1); } @@ -128,17 +128,17 @@ if (serverPlayer != null) { serverPlayer.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(serverPlayer, this.animal, this.partner, fox); -@@ -884,14 +_,12 @@ +@@ -886,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); - fox.setAge(-24000); - fox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); -- serverLevel.addFreshEntityWithPassengers(fox); -+ serverLevel.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason +- this.level.addFreshEntityWithPassengers(fox); ++ this.level.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason this.level.broadcastEntityEvent(this.animal, EntityEvent.IN_LOVE_HEARTS); -- if (serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { -+ if (experience > 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - call EntityBreedEvent +- if (this.level.getGameRules().get(GameRules.MOB_DROPS)) { ++ if (experience > 0 && this.level.getGameRules().get(GameRules.MOB_DROPS)) { // Paper - call EntityBreedEvent this.level .addFreshEntity( - new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1) @@ -146,7 +146,7 @@ ); } } -@@ -955,6 +_,7 @@ +@@ -957,6 +_,7 @@ private void pickSweetBerries(BlockState state) { int ageValue = 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 86555d969696..ae9192ae64c2 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 -@@ -287,7 +_,12 @@ +@@ -285,7 +_,12 @@ @Override public void spawnChildFromBreeding(ServerLevel level, Animal partner) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch index f503b6b31023..3b1480d7f079 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/ShootTongue.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/ShootTongue.java +++ b/net/minecraft/world/entity/animal/frog/ShootTongue.java -@@ -96,7 +_,7 @@ +@@ -94,7 +_,7 @@ if (entity.isAlive()) { frog.doHurtTarget(level, entity); if (!entity.isAlive()) { 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 1cb6e9741ef7..2d3ea622dc8d 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 @@ -31,8 +31,8 @@ + this.ageLocked = input.getBooleanOr("AgeLocked", false); // Paper } - @Nullable -@@ -173,13 +_,19 @@ + @Override +@@ -170,13 +_,19 @@ @Override public void saveToBucketTag(ItemStack stack) { Bucketable.saveDefaultDataToBucketTag(this, stack); @@ -53,7 +53,7 @@ } @Override -@@ -211,6 +_,7 @@ +@@ -208,6 +_,7 @@ } private void ageUp(int offset) { @@ -61,13 +61,13 @@ this.setAge(this.age + offset * 20); } -@@ -223,12 +_,17 @@ +@@ -220,12 +_,17 @@ private void ageUp() { if (this.level() instanceof ServerLevel serverLevel) { - this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> { + Frog converted = this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> { // CraftBukkit - mob.finalizeSpawn(serverLevel, this.level().getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); + mob.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); mob.setPersistenceRequired(); mob.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); this.playSound(SoundEvents.TADPOLE_GROW_UP, 0.15F, 1.0F); 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 25ba8b853664..a05540f3cdf0 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 -@@ -235,13 +_,22 @@ +@@ -234,13 +_,22 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { @@ -25,7 +25,7 @@ this.playEatingSound(); } -@@ -347,8 +_,7 @@ +@@ -346,8 +_,7 @@ double d1 = Mth.randomBetween(this.random, 0.3F, 0.7F); double d2 = Mth.randomBetween(this.random, -0.2F, 0.2F); ItemEntity itemEntity = new ItemEntity(this.level(), vec3.x(), vec3.y(), vec3.z(), itemStack, d, d1, d2); @@ -35,7 +35,7 @@ } } -@@ -379,4 +_,15 @@ +@@ -378,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/coppergolem/CopperGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch index 67806aa82794..51f378361e74 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/CopperGolem.java.patch @@ -1,7 +1,7 @@ ---- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java -+++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java -@@ -58,8 +_,8 @@ - import net.minecraft.world.phys.Vec3; +--- a/net/minecraft/world/entity/animal/golem/CopperGolem.java ++++ b/net/minecraft/world/entity/animal/golem/CopperGolem.java +@@ -57,8 +_,8 @@ + import org.jspecify.annotations.Nullable; public class CopperGolem extends AbstractGolem implements ContainerUser, Shearable { - private static final long IGNORE_WEATHERING_TICK = -2L; @@ -11,16 +11,16 @@ private static final int WEATHERING_TICK_FROM = 504000; private static final int WEATHERING_TICK_TO = 552000; private static final int SPIN_ANIMATION_MIN_COOLDOWN = 200; -@@ -78,7 +_,7 @@ - private BlockPos openedChestPos; - @Nullable - private UUID lastLightningBoltUUID; +@@ -75,7 +_,7 @@ + ); + private @Nullable BlockPos openedChestPos; + private @Nullable UUID lastLightningBoltUUID; - private long nextWeatheringTick = -1L; + public long nextWeatheringTick = -1L; // Paper - public private int idleAnimationStartTick = 0; private final AnimationState idleAnimationState = new AnimationState(); private final AnimationState interactionGetItemAnimationState = new AnimationState(); -@@ -222,7 +_,15 @@ +@@ -219,7 +_,15 @@ Level level = this.level(); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (level instanceof ServerLevel serverLevel) { @@ -37,7 +37,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand); } -@@ -285,20 +_,27 @@ +@@ -282,20 +_,27 @@ private void turnToStatue(ServerLevel level) { BlockPos blockPos = this.blockPosition(); @@ -70,8 +70,8 @@ + this.discard(null); // Paper - add Bukkit remove cause this.playSound(SoundEvents.COPPER_GOLEM_BECOME_STATUE); if (this.isLeashed()) { - if (level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { -@@ -429,12 +_,32 @@ + if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { +@@ -425,12 +_,32 @@ } @Override @@ -108,7 +108,7 @@ @Override public boolean readyForShearing() { -@@ -448,9 +_,13 @@ +@@ -444,9 +_,13 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/golem/IronGolem.java.patch index de8e39c3864c..9f6fe1934d89 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/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/IronGolem.java -+++ b/net/minecraft/world/entity/animal/IronGolem.java -@@ -107,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/golem/IronGolem.java ++++ b/net/minecraft/world/entity/animal/golem/IronGolem.java +@@ -106,7 +_,7 @@ @Override protected void doPush(Entity entity) { if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) { @@ -9,7 +9,7 @@ } super.doPush(entity); -@@ -306,7 +_,7 @@ +@@ -304,7 +_,7 @@ BlockPos blockPos = this.blockPosition(); BlockPos blockPos1 = blockPos.below(); BlockState blockState = level.getBlockState(blockPos1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch index a98d84c3be5d..be61f67cc4f6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/golem/SnowGolem.java.patch @@ -1,14 +1,14 @@ ---- a/net/minecraft/world/entity/animal/SnowGolem.java -+++ b/net/minecraft/world/entity/animal/SnowGolem.java +--- a/net/minecraft/world/entity/animal/golem/SnowGolem.java ++++ b/net/minecraft/world/entity/animal/golem/SnowGolem.java @@ -92,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel) { - if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { + if (serverLevel.environmentAttributes().getValue(EnvironmentAttributes.SNOW_GOLEM_MELTS, this.position())) { - this.hurtServer(serverLevel, this.damageSources().onFire(), 1.0F); + this.hurtServer(serverLevel, this.damageSources().onFire().knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.MELTING), 1.0F); // CraftBukkit } - if (!serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (!serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { @@ -107,7 +_,7 @@ int floor2 = Mth.floor(this.getZ() + (i / 2 % 2 * 2 - 1) * 0.25F); BlockPos blockPos = new BlockPos(floor, floor1, floor2); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch index b405dfdb247f..860f951bc384 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/HappyGhast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/happyghast/HappyGhast.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/HappyGhast.java -+++ b/net/minecraft/world/entity/animal/HappyGhast.java +--- a/net/minecraft/world/entity/animal/happyghast/HappyGhast.java ++++ b/net/minecraft/world/entity/animal/happyghast/HappyGhast.java @@ -306,8 +_,12 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch new file mode 100644 index 000000000000..3e97ee09d173 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java ++++ b/net/minecraft/world/entity/animal/nautilus/AbstractNautilus.java +@@ -258,7 +_,7 @@ + boolean hasEffect = player.hasEffect(MobEffects.BREATH_OF_THE_NAUTILUS); + boolean flag = level.getGameTime() % 40L == 0L; + if (!hasEffect || flag) { +- player.addEffect(new MobEffectInstance(MobEffects.BREATH_OF_THE_NAUTILUS, 60, 0, true, true, true)); ++ player.addEffect(new MobEffectInstance(MobEffects.BREATH_OF_THE_NAUTILUS, 60, 0, true, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.NAUTILUS); // Paper - Add cause + } + } + } +@@ -400,7 +_,7 @@ + + if (this.isFood(itemInHand) && this.getHealth() < this.getMaxHealth()) { + FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); +- this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F); ++ this.heal(foodProperties != null ? 2 * foodProperties.nutrition() : 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add regain reason + this.usePlayerItem(player, hand, itemInHand); + this.playEatingSound(); + return InteractionResult.SUCCESS; +@@ -422,7 +_,7 @@ + } + + private void tryToTame(Player player) { +- if (this.random.nextInt(3) == 0) { ++ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call + this.tame(player); + this.navigation.stop(); + this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); +@@ -477,7 +_,7 @@ + + protected void createInventory() { + SimpleContainer simpleContainer = this.inventory; +- this.inventory = new SimpleContainer(this.getInventorySize()); ++ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractNautilus) this.getBukkitEntity()); // Paper - add owner + if (simpleContainer != null) { + int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); + 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 new file mode 100644 index 000000000000..cc0fc86f7522 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/nautilus/Nautilus.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/world/entity/animal/nautilus/Nautilus.java ++++ b/net/minecraft/world/entity/animal/nautilus/Nautilus.java +@@ -109,8 +_,14 @@ + + @Override + public int getMaxAirSupply() { +- return 300; +- } ++ return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() ++ } ++ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() ++ @Override ++ public int getDefaultMaxAirSupply() { ++ return NAUTILUS_TOTAL_AIR_SUPPLY; ++ } ++ // CraftBukkit end + + protected void handleAirSupply(ServerLevel level, int airSupply) { + if (this.isAlive() && !this.isInWater()) { +@@ -120,7 +_,7 @@ + this.hurtServer(level, this.damageSources().dryOut(), 2.0F); + } + } else { +- this.setAirSupply(300); ++ this.setAirSupply(this.maxAirTicks); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + } + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/panda/Panda.java.patch index 3dd7c3341de6..8df23114de3b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/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.java -+++ b/net/minecraft/world/entity/animal/Panda.java -@@ -129,6 +_,7 @@ +--- a/net/minecraft/world/entity/animal/panda/Panda.java ++++ b/net/minecraft/world/entity/animal/panda/Panda.java +@@ -130,6 +_,7 @@ } public void sit(boolean sitting) { @@ -18,7 +18,7 @@ } } - if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + 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 @@ -39,7 +39,7 @@ } } -@@ -626,8 +_,9 @@ +@@ -625,8 +_,9 @@ this.usePlayerItem(player, hand, itemInHand); this.ageUp((int)(-this.getAge() / 20 * 0.1F), true); } else if (!this.level().isClientSide() && this.getAge() == 0 && this.canFallInLove()) { @@ -50,7 +50,7 @@ } else { if (!(this.level() instanceof ServerLevel serverLevel) || this.isSitting() || this.isInWater()) { return InteractionResult.PASS; -@@ -637,7 +_,9 @@ +@@ -636,7 +_,9 @@ this.eat(true); ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty() && !player.hasInfiniteMaterials()) { @@ -60,7 +60,7 @@ } this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemInHand.getItem(), 1)); -@@ -859,7 +_,7 @@ +@@ -855,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Panda && mob.isAggressive()) { @@ -69,7 +69,7 @@ } } } -@@ -1088,7 +_,9 @@ +@@ -1084,7 +_,9 @@ public void stop() { ItemStack itemBySlot = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch index bd95bd002b39..7db0b4f6b0e1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/Parrot.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Parrot.java -+++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -265,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/parrot/Parrot.java ++++ b/net/minecraft/world/entity/animal/parrot/Parrot.java +@@ -269,7 +_,7 @@ } if (!this.level().isClientSide()) { @@ -9,7 +9,7 @@ this.tame(player); this.level().broadcastEntityEvent(this, EntityEvent.TAMING_SUCCEEDED); } else { -@@ -286,7 +_,7 @@ +@@ -290,7 +_,7 @@ } } else { this.usePlayerItem(player, hand, itemInHand); @@ -18,7 +18,7 @@ if (player.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE); } -@@ -381,8 +_,8 @@ +@@ -383,8 +_,8 @@ } @Override @@ -29,7 +29,7 @@ } @Override -@@ -397,8 +_,13 @@ +@@ -399,8 +_,13 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java.patch similarity index 74% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java.patch index 1ad868188882..74075655549d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/ShoulderRidingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/animal/ShoulderRidingEntity.java -+++ b/net/minecraft/world/entity/animal/ShoulderRidingEntity.java +--- a/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java ++++ b/net/minecraft/world/entity/animal/parrot/ShoulderRidingEntity.java @@ -24,7 +_,7 @@ this.saveWithoutId(tagValueOutput); tagValueOutput.putString("id", this.getEncodeId()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch similarity index 64% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch index 472c9720c0fd..c7a3748e36b4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pig.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/pig/Pig.java.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/world/entity/animal/Pig.java -+++ b/net/minecraft/world/entity/animal/Pig.java -@@ -215,7 +_,14 @@ - } - +--- a/net/minecraft/world/entity/animal/pig/Pig.java ++++ b/net/minecraft/world/entity/animal/pig/Pig.java +@@ -212,7 +_,14 @@ + ZombifiedPiglin zombifiedPiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), mob -> { + mob.populateDefaultEquipmentSlots(this.getRandom(), level.getCurrentDifficultyAt(this.blockPosition())); mob.setPersistenceRequired(); - }); + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch index 4cbf9b68f433..6c26de099a9b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/rabbit/Rabbit.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Rabbit.java -+++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -98,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/rabbit/Rabbit.java ++++ b/net/minecraft/world/entity/animal/rabbit/Rabbit.java +@@ -99,7 +_,7 @@ super(type, level); this.jumpControl = new Rabbit.RabbitJumpControl(this); this.moveControl = new Rabbit.RabbitMoveControl(this); @@ -9,7 +9,7 @@ } @Override -@@ -591,9 +_,11 @@ +@@ -589,9 +_,11 @@ if (this.canRaid && block instanceof CarrotBlock) { int ageValue = blockState.getValue(CarrotBlock.AGE); if (ageValue == 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 b9fb8d4ec5e7..bb206b657c75 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 @@ -57,7 +57,7 @@ if (itemEntity != null) { itemEntity.setDeltaMovement( itemEntity.getDeltaMovement() -@@ -281,6 +_,7 @@ +@@ -279,6 +_,7 @@ @Override public void ate() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch similarity index 72% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch index e7d710d0d619..b6389c8fc3e5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Squid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/squid/Squid.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Squid.java -+++ b/net/minecraft/world/entity/animal/Squid.java -@@ -47,7 +_,7 @@ +--- a/net/minecraft/world/entity/animal/squid/Squid.java ++++ b/net/minecraft/world/entity/animal/squid/Squid.java +@@ -48,7 +_,7 @@ public Squid(EntityType type, Level level) { super(type, level); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch index df21684efb8e..f65385287f30 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/turtle/Turtle.java.patch @@ -1,16 +1,16 @@ ---- a/net/minecraft/world/entity/animal/Turtle.java -+++ b/net/minecraft/world/entity/animal/Turtle.java -@@ -261,7 +_,9 @@ +--- 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 serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (!this.isBaby() && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.MOB_DROPS)) { + this.forceDrops = true; // CraftBukkit this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.TURTLE_GROW, this::spawnAtLocation); + this.forceDrops = false; // CraftBukkit } } -@@ -286,7 +_,7 @@ +@@ -277,7 +_,7 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { @@ -19,7 +19,7 @@ } @Override -@@ -313,6 +_,10 @@ +@@ -304,6 +_,10 @@ if (loveCause == null && this.partner.getLoveCause() != null) { loveCause = this.partner.getLoveCause(); } @@ -30,16 +30,16 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); -@@ -326,7 +_,7 @@ +@@ -317,7 +_,7 @@ this.partner.resetLove(); RandomSource random = this.animal.getRandom(); - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (getServerLevel(this.level).getGameRules().get(GameRules.MOB_DROPS)) { - this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), random.nextInt(7) + 1)); + if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.position(), Vec3.ZERO, event.getExperience(), org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, loveCause, this.turtle)); // Paper - Add EntityFertilizeEggEvent event } } } -@@ -349,7 +_,7 @@ +@@ -340,7 +_,7 @@ && ( this.turtle.hasEgg() || this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 && !this.turtle.homePos.closerToCenterThan(this.turtle.position(), 64.0) @@ -48,7 +48,7 @@ } @Override -@@ -457,14 +_,20 @@ +@@ -448,14 +_,20 @@ BlockPos blockPos = 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 95f8141bb627..73a3cd945133 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 -@@ -400,16 +_,18 @@ +@@ -397,16 +_,18 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -22,7 +22,7 @@ ItemStack bodyArmorItem = this.getBodyArmorItem(); int damageValue = bodyArmorItem.getDamageValue(); int maxDamage = bodyArmorItem.getMaxDamage(); -@@ -429,6 +_,7 @@ +@@ -426,6 +_,7 @@ ); } } @@ -30,7 +30,7 @@ } private boolean canArmorAbsorb(DamageSource damageSource) { -@@ -439,7 +_,7 @@ +@@ -436,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); } -@@ -464,7 +_,7 @@ +@@ -461,7 +_,7 @@ this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); float f = foodProperties != null ? foodProperties.nutrition() : 1.0F; @@ -48,7 +48,7 @@ return InteractionResult.SUCCESS; } -@@ -493,7 +_,7 @@ +@@ -490,7 +_,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -57,7 +57,7 @@ return InteractionResult.SUCCESS.withoutItem(); } -@@ -502,6 +_,13 @@ +@@ -499,6 +_,13 @@ DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -71,12 +71,12 @@ this.setCollarColor(dyeColor); itemInHand.consume(1, player); return InteractionResult.SUCCESS; -@@ -516,7 +_,7 @@ +@@ -513,7 +_,7 @@ } private void tryToTame(Player player) { - if (this.random.nextInt(3) == 0) { -+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call and isCancelled check. ++ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call this.tame(player); this.navigation.stop(); this.setTarget(null); 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 f2476c893834..5d79a91cff04 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 -@@ -89,6 +_,10 @@ +@@ -86,6 +_,10 @@ private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); @@ -11,7 +11,7 @@ public EnderDragon(EntityType type, Level level) { super(EntityType.ENDER_DRAGON, level); -@@ -104,6 +_,7 @@ +@@ -101,6 +_,7 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -19,7 +19,7 @@ } public void setDragonFight(EndDragonFight dragonFight) { -@@ -122,6 +_,19 @@ +@@ -119,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 cos = Mth.cos(this.flapTime * (float) (Math.PI * 2)); -@@ -213,7 +_,7 @@ +@@ -210,7 +_,7 @@ } Vec3 flyTargetLocation = currentPhase.getFlyTargetLocation(); @@ -48,7 +48,7 @@ double d = flyTargetLocation.x - this.getX(); double d1 = flyTargetLocation.y - this.getY(); double d2 = flyTargetLocation.z - this.getZ(); -@@ -368,7 +_,12 @@ +@@ -365,7 +_,12 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -62,7 +62,7 @@ } } -@@ -398,7 +_,7 @@ +@@ -395,7 +_,7 @@ double d2 = entity.getX() - d; double d3 = entity.getZ() - d1; double max = Math.max(d2 * d2 + d3 * d3, 0.1); @@ -71,7 +71,7 @@ if (!this.phaseManager.getCurrentPhase().isSitting() && livingEntity.getLastHurtByMobTimestamp() < entity.tickCount - 2) { DamageSource damageSource = this.damageSources().mobAttack(this); entity.hurtServer(level, damageSource, 5.0F); -@@ -431,6 +_,7 @@ +@@ -428,6 +_,7 @@ int floor5 = Mth.floor(box.maxZ); boolean flag = false; boolean flag1 = false; @@ -79,10 +79,10 @@ for (int i = floor; i <= floor3; i++) { for (int i1 = floor1; i1 <= floor4; i1++) { -@@ -439,7 +_,11 @@ +@@ -436,7 +_,11 @@ BlockState blockState = level.getBlockState(blockPos); if (!blockState.isAir() && !blockState.is(BlockTags.DRAGON_TRANSPARENT)) { - if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockState.is(BlockTags.DRAGON_IMMUNE)) { + if (level.getGameRules().get(GameRules.MOB_GRIEFING) && !blockState.is(BlockTags.DRAGON_IMMUNE)) { - flag1 = level.removeBlock(blockPos, false) || flag1; + // CraftBukkit start - Add blocks to list rather than destroying them + //flag1 = level.removeBlock(blockPos, false) || flag1; @@ -92,7 +92,7 @@ } else { flag = true; } -@@ -448,6 +_,58 @@ +@@ -445,6 +_,58 @@ } } @@ -151,7 +151,7 @@ if (flag1) { BlockPos blockPos1 = new BlockPos( floor + this.random.nextInt(floor3 - floor + 1), -@@ -505,7 +_,15 @@ +@@ -502,7 +_,15 @@ @Override public void kill(ServerLevel level) { @@ -168,7 +168,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -527,18 +_,41 @@ +@@ -524,18 +_,41 @@ this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + f, this.getY() + 2.0 + f1, this.getZ() + f2, 0.0, 0.0, 0.0); } @@ -183,7 +183,7 @@ + // CraftBukkit end if (this.level() instanceof ServerLevel serverLevel) { -- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 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(serverLevel, this.position(), net.minecraft.world.phys.Vec3.ZERO, Mth.floor(i * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper @@ -199,7 +199,7 @@ + double deltaZ = this.getZ() - player.getZ(); + double distanceSquared = Mth.square(deltaX) + Mth.square(deltaZ); + final double soundRadiusSquared = serverLevel.getGlobalSoundRangeSquared(config -> config.dragonDeathSoundRadius); // Paper - respect global sound events gamerule -+ if (!serverLevel.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Paper - respect global sound events gamerule ++ if (!serverLevel.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Paper - respect global sound events gamerule + if (distanceSquared > Mth.square(viewDistance)) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; @@ -213,11 +213,11 @@ } } -@@ -551,15 +_,15 @@ +@@ -548,15 +_,15 @@ } if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverLevel1) { -- if (serverLevel1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- if (serverLevel1.getGameRules().get(GameRules.MOB_DROPS)) { - ExperienceOrb.award(serverLevel1, this.position(), Mth.floor(i * 0.2F)); + if (true) { // Paper - SPIGOT-2420: Already checked for the game rule when calculating the xp + ExperienceOrb.awardWithDirection(serverLevel1, this.position(), net.minecraft.world.phys.Vec3.ZERO, Mth.floor(i * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.world.entity.EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class), this); // Paper @@ -232,7 +232,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -741,6 +_,7 @@ +@@ -737,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); output.putInt("DragonDeathTime", this.dragonDeathTime); @@ -240,7 +240,7 @@ } @Override -@@ -748,6 +_,7 @@ +@@ -744,6 +_,7 @@ super.readAdditionalSaveData(input); input.getInt("DragonPhase").ifPresent(integer -> this.phaseManager.setPhase(EnderDragonPhase.getById(integer))); this.dragonDeathTime = input.getIntOr("DragonDeathTime", 0); @@ -248,7 +248,7 @@ } @Override -@@ -788,7 +_,7 @@ +@@ -784,7 +_,7 @@ EnderDragonPhase phase = currentPhase.getPhase(); Vec3 viewVector; if (phase == EnderDragonPhase.LANDING || phase == EnderDragonPhase.TAKEOFF) { @@ -257,7 +257,7 @@ float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F); float f = 6.0F / max; float xRot = this.getXRot(); -@@ -876,4 +_,19 @@ +@@ -871,4 +_,19 @@ protected float sanitizeScale(float scale) { return 1.0F; } @@ -266,7 +266,7 @@ + @Override + public int getExpReward(ServerLevel level, Entity entity) { + // CraftBukkit - Moved from #tickDeath method -+ boolean flag = level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); ++ boolean flag = level.getGameRules().get(GameRules.MOB_DROPS); + int i = 500; + + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch index 3c43f0ec62c7..50c8b1f6f662 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java -@@ -34,7 +_,7 @@ +@@ -33,7 +_,7 @@ public void doServerTick(ServerLevel level) { this.time++; if (this.targetLocation == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch index 9652e080af12..0ae3e07ca1ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java -@@ -53,7 +_,7 @@ +@@ -50,7 +_,7 @@ private void findNewTarget(ServerLevel level) { if (this.currentPath != null && this.currentPath.isDone()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch index bfc7cb63f7a4..0abf0d51e715 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java -@@ -52,7 +_,7 @@ +@@ -49,7 +_,7 @@ private void findNewTarget(ServerLevel level) { if (this.currentPath == null || this.currentPath.isDone()) { int i = this.dragon.findClosestNode(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch index 5b33dd00ad2f..dcadba51268e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java -@@ -51,7 +_,7 @@ +@@ -50,7 +_,7 @@ public void doServerTick(ServerLevel level) { if (this.targetLocation == null) { this.targetLocation = Vec3.atBottomCenterOf( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch index b5f3bda70f50..42a7a0356203 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java -@@ -94,7 +_,13 @@ +@@ -93,7 +_,13 @@ this.flame.setCustomParticle(PowerParticleOption.create(ParticleTypes.DRAGON_BREATH, 1.0F)); this.flame.setPotionDurationScale(0.25F); this.flame.addEffect(new MobEffectInstance(MobEffects.INSTANT_DAMAGE)); @@ -14,7 +14,7 @@ } } -@@ -107,7 +_,7 @@ +@@ -106,7 +_,7 @@ @Override public void end() { if (this.flame != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch index afcef46ed1de..b61e3572c5ce 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java -@@ -73,13 +_,16 @@ +@@ -70,13 +_,16 @@ double d6 = this.attackTarget.getY(0.5) - d3; double d7 = this.attackTarget.getZ() - d4; Vec3 vec32 = new Vec3(d5, d6, d7); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch index d81a699daa82..f58b95dd48cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java -@@ -24,7 +_,7 @@ +@@ -22,7 +_,7 @@ @Override public void doServerTick(ServerLevel level) { if (!this.firstTick && this.currentPath != null) { 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 980373b3f609..ff4d2ea48644 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 @@ -31,7 +31,7 @@ + double deltaZ = this.getZ() - player.getZ(); + double distanceSquared = Mth.square(deltaX) + Mth.square(deltaZ); + final double soundRadiusSquared = level.getGlobalSoundRangeSquared(config -> config.witherSpawnSoundRadius); // Paper - respect global sound events gamerule -+ if (!level.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule ++ if (!level.getGameRules().get(GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule + if (distanceSquared > Mth.square(viewDistance)) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; 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 8c0e896aba23..8e6296c6ae5b 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 @@ -116,7 +116,7 @@ @Override @@ -268,15 +_,32 @@ - } else if (!level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && damageSource.getEntity() instanceof Mob) { + } else if (!level.getGameRules().get(GameRules.MOB_GRIEFING) && damageSource.getEntity() instanceof Mob) { return false; } else if (damageSource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { - this.kill(level); @@ -289,7 +289,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -685,4 +_,13 @@ +@@ -683,4 +_,13 @@ .apply(instance, 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 7e31cac70397..040af54cf20e 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 @@ -51,22 +51,21 @@ this.dropItem(level, damageSource.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, damageSource.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -258,6 +_,14 @@ +@@ -258,6 +_,13 @@ return this.getEntityData().get(DATA_ITEM); } + // Paper start - Fix MC-123848 (spawn item frame drops above block) -+ @Nullable + @Override -+ public net.minecraft.world.entity.item.ItemEntity spawnAtLocation(ServerLevel serverLevel, ItemStack stack) { ++ public net.minecraft.world.entity.item.@Nullable ItemEntity spawnAtLocation(ServerLevel serverLevel, ItemStack stack) { + return this.spawnAtLocation(serverLevel, stack, this.getDirection() == Direction.DOWN ? -0.6F : 0.0F); + } + // Paper end + - @Nullable - public MapId getFramedMapId(ItemStack stack) { + public @Nullable MapId getFramedMapId(ItemStack stack) { return stack.get(DataComponents.MAP_ID); -@@ -272,13 +_,19 @@ + } +@@ -271,13 +_,19 @@ } public void setItem(ItemStack stack, boolean updateNeighbours) { @@ -87,7 +86,7 @@ this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } -@@ -305,6 +_,7 @@ +@@ -304,6 +_,7 @@ } private void onItemChanged(ItemStack item) { @@ -95,7 +94,7 @@ if (!item.isEmpty() && item.getFrame() != this) { item.setEntityRepresentation(this); } -@@ -373,7 +_,13 @@ +@@ -372,7 +_,13 @@ if (savedData != null && savedData.isTrackedCountOverLimit(256)) { return InteractionResult.FAIL; } else { @@ -110,7 +109,7 @@ this.gameEvent(GameEvent.BLOCK_CHANGE, player); itemInHand.consume(1, player); return InteractionResult.SUCCESS; -@@ -382,6 +_,13 @@ +@@ -381,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 65331b4049ae..f89a67b2afb9 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 @@ -35,7 +35,7 @@ public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos) { + return getOrCreateKnot(level, pos, null); + } -+ public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos, @Nullable org.apache.commons.lang3.mutable.MutableBoolean created) { ++ public static LeashFenceKnotEntity getOrCreateKnot(Level level, BlockPos pos, org.apache.commons.lang3.mutable.@Nullable MutableBoolean created) { + // Paper end - Track if a knot was created int x = pos.getX(); int y = pos.getY(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch index e448f719b00d..d7108d5cf4ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/painting/Painting.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/decoration/Painting.java -+++ b/net/minecraft/world/entity/decoration/Painting.java +--- a/net/minecraft/world/entity/decoration/painting/Painting.java ++++ b/net/minecraft/world/entity/decoration/painting/Painting.java @@ -149,21 +_,31 @@ @Override 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 b6351e4095a2..8c6c4c685462 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,14 +1,14 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -72,6 +_,7 @@ - public CompoundTag blockData; +@@ -71,6 +_,7 @@ + public @Nullable CompoundTag blockData; public boolean forceTickAfterTeleportToDuplicate; protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); + public boolean autoExpire = true; // Paper - Expand FallingBlock API public FallingBlockEntity(EntityType type, Level level) { super(type, level); -@@ -97,6 +_,7 @@ +@@ -96,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(fallingBlockEntity); return fallingBlockEntity; -@@ -147,13 +_,22 @@ +@@ -146,13 +_,22 @@ @Override public void tick() { if (this.blockState.isAir()) { @@ -30,7 +30,7 @@ this.applyEffectsFromBlocks(); + // Paper start - Configurable falling blocks height nerf + if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { -+ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { + this.spawnAtLocation(serverLevel, block); + } + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD); @@ -40,13 +40,13 @@ this.handlePortal(); if (this.level() instanceof ServerLevel serverLevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockPos = this.blockPosition(); -@@ -174,12 +_,12 @@ +@@ -173,12 +_,12 @@ } if (!this.onGround() && !flag1) { - if (this.time > 100 && (blockPos.getY() <= this.level().getMinY() || blockPos.getY() > this.level().getMaxY()) || this.time > 600) { + if ((this.time > 100 && autoExpire) && (blockPos.getY() <= this.level().getMinY() || blockPos.getY() > this.level().getMaxY()) || (this.time > 600 && autoExpire)) { // Paper - Expand FallingBlock API - if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + if (this.dropItem && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { this.spawnAtLocation(serverLevel, block); } @@ -55,7 +55,7 @@ } } else { BlockState blockState = this.level().getBlockState(blockPos); -@@ -197,11 +_,17 @@ +@@ -196,11 +_,17 @@ this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); } @@ -74,10 +74,10 @@ if (block instanceof Fallable fallable) { fallable.onLand(this.level(), blockPos, this.blockState, blockState, this); } -@@ -226,19 +_,19 @@ +@@ -225,19 +_,19 @@ } } - } else if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + } else if (this.dropItem && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause this.callOnBrokenAfterFall(block, blockPos); @@ -86,7 +86,7 @@ } else { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause - if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + if (this.dropItem && serverLevel.getGameRules().get(GameRules.ENTITY_DROPS)) { this.callOnBrokenAfterFall(block, blockPos); this.spawnAtLocation(serverLevel, block); } @@ -97,7 +97,7 @@ this.callOnBrokenAfterFall(block, blockPos); } } -@@ -298,6 +_,7 @@ +@@ -297,6 +_,7 @@ } output.putBoolean("CancelDrop", this.cancelDrop); @@ -105,7 +105,7 @@ } @Override -@@ -309,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(float fallDamagePerDistance, int fallDamageMax) { -@@ -367,7 +_,7 @@ +@@ -365,7 +_,7 @@ ResourceKey resourceKey1 = this.level().dimension(); boolean flag = (resourceKey1 == Level.END || resourceKey == Level.END) && resourceKey1 != resourceKey; Entity entity = super.teleport(teleportTransition); 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 cf980acc7fa4..4fda90eca2b9 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,8 +1,8 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -53,6 +_,9 @@ - @Nullable - public UUID target; +@@ -51,6 +_,9 @@ + public @Nullable EntityReference thrower; + public @Nullable UUID target; public final float bobOffs = this.random.nextFloat() * (float) Math.PI * 2.0F; + public boolean canMobPickup = true; // Paper - Item#canEntityPickup + private int despawnRate = -1; // Paper - Alternative item-despawn-rate @@ -10,7 +10,7 @@ public ItemEntity(EntityType type, Level level) { super(type, level); -@@ -60,7 +_,12 @@ +@@ -58,7 +_,12 @@ } public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack stack) { @@ -24,7 +24,7 @@ } public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack stack, double deltaX, double deltaY, double deltaZ) { -@@ -70,6 +_,14 @@ +@@ -68,6 +_,14 @@ this.setItem(stack); } @@ -39,7 +39,7 @@ @Override public boolean dampensVibrations() { return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS); -@@ -107,7 +_,7 @@ +@@ -104,7 +_,7 @@ @Override public void tick() { if (this.getItem().isEmpty()) { @@ -48,7 +48,7 @@ } else { super.tick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { -@@ -135,11 +_,15 @@ +@@ -132,11 +_,15 @@ } } @@ -66,7 +66,7 @@ f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; } -@@ -172,8 +_,14 @@ +@@ -169,8 +_,14 @@ } } @@ -83,7 +83,7 @@ } } } -@@ -198,9 +_,18 @@ +@@ -195,9 +_,18 @@ private void mergeWithNeighbours() { if (this.isMergable()) { @@ -103,7 +103,7 @@ this.tryToMerge(itemEntity); if (this.isRemoved()) { break; -@@ -212,7 +_,7 @@ +@@ -209,7 +_,7 @@ private boolean isMergable() { ItemStack item = this.getItem(); @@ -112,7 +112,7 @@ } private void tryToMerge(ItemEntity itemEntity) { -@@ -245,11 +_,16 @@ +@@ -242,11 +_,16 @@ } private static void merge(ItemEntity destinationEntity, ItemStack destinationStack, ItemEntity originEntity, ItemStack originStack) { @@ -130,7 +130,7 @@ } } -@@ -277,12 +_,17 @@ +@@ -274,12 +_,17 @@ } else if (!this.getItem().canBeHurtBy(damageSource)) { return false; } else { @@ -149,7 +149,7 @@ } return true; -@@ -304,6 +_,11 @@ +@@ -301,6 +_,11 @@ if (!this.getItem().isEmpty()) { output.store("Item", ItemStack.CODEC, this.getItem()); } @@ -161,7 +161,7 @@ } @Override -@@ -314,8 +_,17 @@ +@@ -311,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)); @@ -180,7 +180,7 @@ } } -@@ -325,10 +_,73 @@ +@@ -322,10 +_,73 @@ ItemStack item = this.getItem(); Item item1 = item.getItem(); int count = item.getCount(); @@ -255,7 +255,7 @@ item.setCount(count); } -@@ -366,6 +_,7 @@ +@@ -362,6 +_,7 @@ public void setItem(ItemStack stack) { this.getEntityData().set(DATA_ITEM, stack); @@ -263,7 +263,7 @@ } @Override -@@ -418,7 +_,7 @@ +@@ -414,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 f0625f340d7d..2c49055d3d3f 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,8 +1,8 @@ --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -28,6 +_,12 @@ - import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; + import org.jspecify.annotations.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -13,15 +13,15 @@ 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); -@@ -52,6 +_,7 @@ - public EntityReference owner; +@@ -51,6 +_,7 @@ + public @Nullable EntityReference owner; private boolean usedPortal; public float explosionPower = 4.0F; + public boolean isIncendiary = false; // CraftBukkit public PrimedTnt(EntityType type, Level level) { super(type, level); -@@ -61,7 +_,7 @@ +@@ -60,7 +_,7 @@ public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) { this(EntityType.TNT, level); this.setPos(x, y, z); @@ -30,7 +30,7 @@ this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02); this.setFuse(80); this.xo = x; -@@ -93,10 +_,17 @@ +@@ -92,10 +_,17 @@ @Override public void tick() { @@ -48,7 +48,7 @@ this.setDeltaMovement(this.getDeltaMovement().scale(0.98)); if (this.onGround()) { this.setDeltaMovement(this.getDeltaMovement().multiply(0.7, -0.5, 0.7)); -@@ -105,20 +_,35 @@ +@@ -104,20 +_,35 @@ int i = this.getFuse() - 1; this.setFuse(i); if (i <= 0) { @@ -69,13 +69,13 @@ + // Paper start - Option to prevent TNT from moving in water + if (!this.isRemoved() && this.wasTouchingWater && this.level().paperConfig().fixes.preventTntFromMovingInWater) { + this.hurtMarked = true; -+ this.hasImpulse = true; ++ this.needsSync = true; + } + // Paper end - Option to prevent TNT from moving in water } private void explode() { - if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.TNT_EXPLODES)) { + // CraftBukkit start + ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + if (event.isCancelled()) { @@ -85,7 +85,7 @@ this.level() .explode( this, -@@ -127,8 +_,8 @@ +@@ -126,8 +_,8 @@ this.getX(), this.getY(0.0625), this.getZ(), @@ -96,7 +96,7 @@ Level.ExplosionInteraction.TNT ); } -@@ -202,4 +_,11 @@ +@@ -199,4 +_,11 @@ public final boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { 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 58cc6a6dfdec..65fc6a540624 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 @@ -22,7 +22,7 @@ @Override - public void setTarget(@Nullable LivingEntity target) { -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { // CraftBukkit if (!(target instanceof Goat)) { - super.setTarget(target); + return super.setTarget(target, reason); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 4b176b45835a..a7435e6abc0d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -120,9 +_,20 @@ +@@ -119,9 +_,20 @@ .add(Attributes.STEP_HEIGHT, 1.0); } @@ -14,7 +14,7 @@ - public void setTarget(@Nullable LivingEntity target) { - super.setTarget(target); + // CraftBukkit start - fire event -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { + if (!super.setTarget(target, reason)) { + return false; + } @@ -23,7 +23,7 @@ AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); if (target == null) { this.targetChangeTime = 0; -@@ -136,6 +_,7 @@ +@@ -135,6 +_,7 @@ attribute.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -31,7 +31,7 @@ } @Override -@@ -209,6 +_,15 @@ +@@ -207,6 +_,15 @@ } boolean isBeingStaredBy(Player player) { @@ -44,10 +44,10 @@ + + boolean isBeingStaredBy0(Player player) { + // Paper end - EndermanAttackPlayerEvent - return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, new double[]{this.getEyeY()}); + return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, this.getEyeY()); } -@@ -248,7 +_,7 @@ +@@ -246,7 +_,7 @@ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(); if (lightLevelDependentMagicValue > 0.5F && level.canSeeSky(this.blockPosition()) @@ -56,7 +56,7 @@ this.setTarget(null); this.teleport(); } -@@ -361,21 +_,25 @@ +@@ -358,21 +_,25 @@ AbstractThrownPotion abstractThrownPotion1 = damageSource.getDirectEntity() instanceof AbstractThrownPotion abstractThrownPotion ? abstractThrownPotion : null; @@ -83,7 +83,7 @@ return flag; } -@@ -400,6 +_,16 @@ +@@ -397,6 +_,16 @@ this.entityData.set(DATA_STARED_AT, true); } @@ -100,7 +100,7 @@ @Override public boolean requiresCustomPersistence() { return super.requiresCustomPersistence() || this.getCarriedBlock() != null; -@@ -459,16 +_,19 @@ +@@ -455,16 +_,19 @@ int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0); int floor2 = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0); BlockPos blockPos = new BlockPos(floor, floor1, floor2); @@ -121,7 +121,7 @@ } } } -@@ -566,7 +_,7 @@ +@@ -561,7 +_,7 @@ } else { if (this.target != null && !this.enderman.isPassenger()) { if (this.enderman.isBeingStaredBy((Player)this.target)) { @@ -130,7 +130,7 @@ this.enderman.teleport(); } -@@ -605,15 +_,18 @@ +@@ -600,15 +_,18 @@ int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0); int floor2 = Mth.floor(this.enderman.getZ() - 2.0 + random.nextDouble() * 4.0); BlockPos blockPos = new BlockPos(floor, floor1, floor2); 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 b7602f075136..e15e6f685444 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 @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/monster/Guardian.java +++ b/net/minecraft/world/entity/monster/Guardian.java -@@ -60,6 +_,7 @@ +@@ -58,6 +_,7 @@ + private int clientSideAttackTime; private boolean clientSideTouchedGround; - @Nullable - public RandomStrollGoal randomStrollGoal; + public @Nullable RandomStrollGoal randomStrollGoal; + public Guardian.GuardianAttackGoal guardianAttackGoal; // CraftBukkit - add field public Guardian(EntityType type, Level level) { super(type, level); -@@ -74,7 +_,7 @@ +@@ -72,7 +_,7 @@ protected void registerGoals() { MoveTowardsRestrictionGoal moveTowardsRestrictionGoal = new MoveTowardsRestrictionGoal(this, 1.0); this.randomStrollGoal = new RandomStrollGoal(this, 1.0, 80); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch index 574113a92e3a..65f2c4e2f0cf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch @@ -1,27 +1,31 @@ --- a/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -50,6 +_,11 @@ - @Nullable - public BlockPos anchorPoint; +@@ -49,6 +_,10 @@ + Vec3 moveTargetPoint = Vec3.ZERO; + @Nullable public BlockPos anchorPoint; Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE; + // Paper start -+ @Nullable -+ public java.util.UUID spawningEntity; ++ public java.util.@Nullable UUID spawningEntity; + public boolean shouldBurnInDay = true; + // Paper end public Phantom(EntityType type, Level level) { super(type, level); -@@ -139,7 +_,7 @@ - - @Override - public void aiStep() { -- if (this.isAlive() && this.isSunBurnTick()) { -+ if (this.isAlive() && this.shouldBurnInDay && this.isSunBurnTick()) { // Paper - shouldBurnInDay API - this.igniteForSeconds(8.0F); +@@ -136,6 +_,13 @@ } + } -@@ -174,6 +_,10 @@ ++ // Paper start ++ @Override ++ public boolean isSunBurnTick() { ++ return this.shouldBurnInDay && super.isSunBurnTick(); ++ } ++ // Paper end ++ + @Override + protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) { + } +@@ -164,6 +_,10 @@ super.readAdditionalSaveData(input); this.anchorPoint = input.read("anchor_pos", BlockPos.CODEC).orElse(null); this.setPhantomSize(input.getIntOr("size", 0)); @@ -32,7 +36,7 @@ } @Override -@@ -181,6 +_,10 @@ +@@ -171,6 +_,10 @@ super.addAdditionalSaveData(output); output.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint); output.putInt("size", this.getPhantomSize()); @@ -43,7 +47,7 @@ } @Override -@@ -254,8 +_,10 @@ +@@ -244,8 +_,10 @@ for (Player player : nearbyPlayers) { if (Phantom.this.canAttack(serverLevel, player, TargetingConditions.DEFAULT)) { 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 071ea14cdf53..a0e52436cfed 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 -@@ -156,12 +_,19 @@ +@@ -155,12 +_,19 @@ BlockState blockState = serverLevel.getBlockState(blockPos); Block block = blockState.getBlock(); if (block instanceof LeavesBlock) { @@ -20,7 +20,7 @@ } } -@@ -253,7 +_,7 @@ +@@ -250,7 +_,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Math.max(d * d + d1 * d1, 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 437dc3fa63e9..a709e8da5f32 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -277,8 +_,10 @@ +@@ -276,8 +_,10 @@ } @Override @@ -13,7 +13,7 @@ if (this.level().isClientSide()) { this.clientOldAttachPosition = this.blockPosition(); } -@@ -391,6 +_,14 @@ +@@ -388,6 +_,14 @@ && this.level().getWorldBorder().isWithinBounds(blockPos1) && this.level().noCollision(this, new AABB(blockPos1).deflate(1.0E-6))) { Direction direction = this.findAttachableSurface(blockPos1); @@ -28,7 +28,7 @@ if (direction != null) { this.unRide(); this.setAttachFace(direction); -@@ -455,7 +_,12 @@ +@@ -452,7 +_,12 @@ if (shulker != null) { shulker.setVariant(this.getVariant()); shulker.snapTo(vec3); 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 d3a8325d0377..69d673e3b825 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -119,7 +_,7 @@ +@@ -118,7 +_,7 @@ return true; } else { Player nearestPlayer = level.getNearestPlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 5.0, true); @@ -9,7 +9,7 @@ } } -@@ -170,9 +_,14 @@ +@@ -168,9 +_,14 @@ BlockPos blockPos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); BlockState blockState = levelAccessor.getBlockState(blockPos); if (InfestedBlock.isCompatibleHostBlock(blockState)) { @@ -25,16 +25,16 @@ } } } -@@ -212,6 +_,12 @@ +@@ -210,6 +_,12 @@ BlockState blockState = level.getBlockState(blockPos1); Block block = blockState.getBlock(); if (block instanceof InfestedBlock) { + // CraftBukkit start -+ BlockState afterState = getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? blockState.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(level.getBlockState(blockPos1)); // Paper - fix wrong block state ++ BlockState afterState = getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING) ? blockState.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(level.getBlockState(blockPos1)); // Paper - fix wrong block state + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockPos1, afterState)) { // Paper - fix wrong block state + continue; + } + // CraftBukkit end - if (getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (getServerLevel(level).getGameRules().get(GameRules.MOB_GRIEFING)) { level.destroyBlock(blockPos1, true, this.silverfish); } else { 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 index 0c16bf27fdb9..9ed5f13b01f3 100644 --- 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -58,6 +_,7 @@ +@@ -59,6 +_,7 @@ public float squish; public float oSquish; private boolean wasOnGround = false; @@ -8,7 +8,7 @@ public Slime(EntityType type, Level level) { super(type, level); -@@ -112,6 +_,7 @@ +@@ -113,6 +_,7 @@ super.addAdditionalSaveData(output); output.putInt("Size", this.getSize() - 1); output.putBoolean("wasOnGround", this.wasOnGround); @@ -16,7 +16,7 @@ } @Override -@@ -119,6 +_,7 @@ +@@ -120,6 +_,7 @@ this.setSize(input.getIntOr("Size", 0) + 1, false); super.readAdditionalSaveData(input); this.wasOnGround = input.getBooleanOr("wasOnGround", false); @@ -24,16 +24,16 @@ } public boolean isTiny() { -@@ -193,7 +_,7 @@ +@@ -194,7 +_,7 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(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(); -@@ -201,18 +_,43 @@ +@@ -202,18 +_,43 @@ int i = size / 2; int i1 = 2 + this.random.nextInt(3); PlayerTeam team = this.getTeam(); @@ -81,23 +81,20 @@ } @Override -@@ -278,9 +_,13 @@ +@@ -279,7 +_,11 @@ return checkMobSpawnRules(entityType, 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() > 50 -- && pos.getY() < 70 -+ && pos.getY() > minHeightSwamp // Paper - Replace rules for Height in Swamp Biomes -+ && pos.getY() < maxHeightSwamp // Paper - Replace rules for Height in Swamp Biomes - && random.nextFloat() < 0.5F - && random.nextFloat() < level.getMoonBrightness() - && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { -@@ -292,8 +_,11 @@ ++ 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 value = level.environmentAttributes().getValue(EnvironmentAttributes.SURFACE_SLIME_SPAWN_CHANCE, pos); + if (random.nextFloat() < value && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { + return checkMobSpawnRules(entityType, level, spawnReason, pos, random); +@@ -291,8 +_,11 @@ } ChunkPos chunkPos = new ChunkPos(pos); @@ -111,7 +108,7 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } } -@@ -352,6 +_,16 @@ +@@ -350,6 +_,16 @@ return super.getDefaultDimensions(pose).scale(this.getSize()); } @@ -128,7 +125,7 @@ static class SlimeAttackGoal extends Goal { private final Slime slime; private int growTiredTimer; -@@ -364,7 +_,16 @@ +@@ -362,7 +_,16 @@ @Override public boolean canUse() { LivingEntity target = this.slime.getTarget(); @@ -146,7 +143,7 @@ } @Override -@@ -376,7 +_,16 @@ +@@ -374,7 +_,16 @@ @Override public boolean canContinueToUse() { LivingEntity target = this.slime.getTarget(); @@ -164,7 +161,7 @@ } @Override -@@ -395,6 +_,13 @@ +@@ -393,6 +_,13 @@ slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage()); } } @@ -178,7 +175,7 @@ } static class SlimeFloatGoal extends Goal { -@@ -408,7 +_,7 @@ +@@ -406,7 +_,7 @@ @Override public boolean canUse() { @@ -187,7 +184,7 @@ } @Override -@@ -438,7 +_,7 @@ +@@ -436,7 +_,7 @@ @Override public boolean canUse() { @@ -196,7 +193,7 @@ } @Override -@@ -516,7 +_,7 @@ +@@ -514,7 +_,7 @@ @Override public boolean canUse() { @@ -205,7 +202,7 @@ && (this.slime.onGround() || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION)) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; } -@@ -526,6 +_,11 @@ +@@ -524,6 +_,11 @@ if (--this.nextRandomizeTime <= 0) { this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60)); this.chosenDegrees = this.slime.getRandom().nextInt(360); 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 146c0cc62788..7da583c2e8c5 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 -@@ -295,7 +_,14 @@ +@@ -294,7 +_,14 @@ || blockStateOnLegacy.is(BlockTags.STRIDER_WARM_BLOCKS) || this.getFluidHeight(FluidTags.LAVA) > 0.0; boolean flag1 = 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 0b1c9a9bdd8e..2c78ad8e6565 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Vex.java +++ b/net/minecraft/world/entity/monster/Vex.java -@@ -293,7 +_,7 @@ +@@ -288,7 +_,7 @@ @Override public void start() { Mob owner = Vex.this.getOwner(); @@ -9,7 +9,7 @@ super.start(); } } -@@ -352,7 +_,10 @@ +@@ -347,7 +_,10 @@ for (int i = 0; i < 3; i++) { BlockPos blockPos = boundOrigin.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index e31542a6160c..cebc12470b3a 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 @@ -21,7 +21,7 @@ } public void creakingDeathEffects(DamageSource damageSource) { -@@ -466,9 +_,9 @@ +@@ -447,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch index ebbd045b2016..1c8641669946 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Evoker.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/Evoker.java -+++ b/net/minecraft/world/entity/monster/Evoker.java +--- a/net/minecraft/world/entity/monster/illager/Evoker.java ++++ b/net/minecraft/world/entity/monster/illager/Evoker.java @@ -247,7 +_,7 @@ serverLevel.getScoreboard().addPlayerToTeam(vex.getScoreboardName(), team); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch index 59562e47c2b6..07a12f5fd228 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Illusioner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Illusioner.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Illusioner.java -+++ b/net/minecraft/world/entity/monster/Illusioner.java -@@ -172,7 +_,8 @@ +--- a/net/minecraft/world/entity/monster/illager/Illusioner.java ++++ b/net/minecraft/world/entity/monster/illager/Illusioner.java +@@ -174,7 +_,8 @@ @Override public void performRangedAttack(LivingEntity target, float distanceFactor) { @@ -10,7 +10,7 @@ ItemStack projectile = this.getProjectile(itemInHand); AbstractArrow mobArrow = ProjectileUtil.getMobArrow(this, projectile, distanceFactor, itemInHand); double d = target.getX() - this.getX(); -@@ -180,9 +_,21 @@ +@@ -182,9 +_,21 @@ double d2 = target.getZ() - this.getZ(); double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { @@ -33,7 +33,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -229,7 +_,7 @@ +@@ -231,7 +_,7 @@ @Override protected void performSpellCasting() { @@ -42,7 +42,7 @@ } @Override -@@ -261,7 +_,7 @@ +@@ -263,7 +_,7 @@ @Override protected void performSpellCasting() { @@ -50,4 +50,4 @@ + Illusioner.this.addEffect(new MobEffectInstance(MobEffects.INVISIBILITY, 1200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ILLUSION); // CraftBukkit } - @Nullable + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Pillager.java.patch similarity index 76% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Pillager.java.patch index 1df33fe9b19d..575d644e7872 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Pillager.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/Pillager.java -+++ b/net/minecraft/world/entity/monster/Pillager.java +--- a/net/minecraft/world/entity/monster/illager/Pillager.java ++++ b/net/minecraft/world/entity/monster/illager/Pillager.java @@ -215,7 +_,7 @@ this.onItemPickup(entity); ItemStack itemStack = this.inventory.addItem(item); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch index b959b59a0e50..5eaaf1fba832 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/SpellcasterIllager.java -+++ b/net/minecraft/world/entity/monster/SpellcasterIllager.java +--- a/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java ++++ b/net/minecraft/world/entity/monster/illager/SpellcasterIllager.java @@ -210,6 +_,11 @@ public void tick() { this.attackWarmupDelay--; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch index 3d00b8fa853d..9e3dfa15dd41 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/illager/Vindicator.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/Vindicator.java -+++ b/net/minecraft/world/entity/monster/Vindicator.java +--- a/net/minecraft/world/entity/monster/illager/Vindicator.java ++++ b/net/minecraft/world/entity/monster/illager/Vindicator.java @@ -183,7 +_,7 @@ static class VindicatorBreakDoorGoal extends BreakDoorGoal { 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 c56f122490b8..c8b899872eaf 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,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -99,9 +_,14 @@ +@@ -102,9 +_,14 @@ } protected void finishConversion(ServerLevel level) { 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 2a270086eedc..531622193478 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,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -124,6 +_,12 @@ - MemoryModuleType.ATE_RECENTLY, - MemoryModuleType.NEAREST_REPELLENT +@@ -129,6 +_,12 @@ + MemoryModuleType.SPEAR_ENGAGE_TIME, + MemoryModuleType.SPEAR_STATUS ); + // CraftBukkit start - Custom bartering and interest list + public java.util.Set allowedBarterItems = new java.util.HashSet<>(); @@ -13,7 +13,7 @@ public Piglin(EntityType type, Level level) { super(type, level); -@@ -136,6 +_,10 @@ +@@ -141,6 +_,10 @@ output.putBoolean("IsBaby", this.isBaby()); output.putBoolean("CannotHunt", this.cannotHunt); this.writeInventoryToTag(output); @@ -24,7 +24,7 @@ } @Override -@@ -144,6 +_,10 @@ +@@ -149,6 +_,10 @@ this.setBaby(input.getBooleanOr("IsBaby", false)); this.setCannotHunt(input.getBooleanOr("CannotHunt", false)); this.readInventoryFromTag(input); @@ -35,7 +35,7 @@ } @VisibleForDebug -@@ -310,7 +_,9 @@ +@@ -314,7 +_,9 @@ @Override protected void finishConversion(ServerLevel level) { PiglinAi.cancelAdmiring(level, this); @@ -45,7 +45,7 @@ super.finishConversion(level); } -@@ -386,7 +_,7 @@ +@@ -391,7 +_,7 @@ } protected void holdInOffHand(ItemStack stack) { @@ -54,7 +54,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, stack); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -411,15 +_,15 @@ +@@ -416,15 +_,15 @@ return false; } else { TagKey preferredWeaponType = this.getPreferredWeaponType(); 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 eb8eb63220ab..6ed008f0f724 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 -@@ -330,23 +_,32 @@ +@@ -336,23 +_,32 @@ protected static void pickUpItem(ServerLevel level, Piglin piglin, ItemEntity itemEntity) { stopWalking(piglin); ItemStack item; @@ -38,7 +38,7 @@ if (!flag) { putInInventory(piglin, item); } -@@ -355,7 +_,9 @@ +@@ -361,7 +_,9 @@ private static void holdInOffhand(ServerLevel level, Piglin piglin, ItemStack stack) { if (isHoldingItemInOffHand(piglin)) { @@ -48,7 +48,7 @@ } piglin.holdInOffHand(stack); -@@ -365,7 +_,7 @@ +@@ -371,7 +_,7 @@ ItemStack item = itemEntity.getItem(); ItemStack itemStack = item.split(1); if (item.isEmpty()) { @@ -57,7 +57,7 @@ } else { itemEntity.setItem(item); } -@@ -377,9 +_,14 @@ +@@ -383,9 +_,14 @@ ItemStack itemInHand = piglin.getItemInHand(InteractionHand.OFF_HAND); piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); if (piglin.isAdult()) { @@ -74,7 +74,7 @@ } else if (!isBarterCurrency) { boolean flag = !piglin.equipItemIfPossible(level, itemInHand).isEmpty(); if (!flag) { -@@ -390,7 +_,7 @@ +@@ -396,7 +_,7 @@ boolean isBarterCurrency = !piglin.equipItemIfPossible(level, itemInHand).isEmpty(); if (!isBarterCurrency) { ItemStack mainHandItem = piglin.getMainHandItem(); @@ -83,7 +83,7 @@ putInInventory(piglin, mainHandItem); } else { throwItems(piglin, Collections.singletonList(mainHandItem)); -@@ -403,7 +_,9 @@ +@@ -409,7 +_,9 @@ protected static void cancelAdmiring(ServerLevel level, Piglin piglin) { if (isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) { @@ -93,7 +93,7 @@ piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); } } -@@ -459,7 +_,7 @@ +@@ -465,7 +_,7 @@ return false; } else if (isAdmiringDisabled(piglin) && piglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -102,7 +102,7 @@ return isNotHoldingLovedItemInOffHand(piglin); } else { boolean canAddToInventory = piglin.canAddToInventory(stack); -@@ -468,11 +_,16 @@ +@@ -474,11 +_,16 @@ } else if (isFood(stack)) { return !hasEatenRecently(piglin) && canAddToInventory; } else { @@ -120,15 +120,15 @@ protected static boolean isLovedItem(ItemStack item) { return item.is(ItemTags.PIGLIN_LOVED); } -@@ -524,6 +_,7 @@ +@@ -530,6 +_,7 @@ } public static void angerNearbyPiglins(ServerLevel level, Player player, boolean requireLineOfSight) { + if (!player.level().paperConfig().entities.behavior.piglinsGuardChests) return; // Paper - Config option for Piglins guarding chests List entitiesOfClass = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0)); entitiesOfClass.stream().filter(PiglinAi::isIdle).filter(piglin -> !requireLineOfSight || BehaviorUtils.canSee(piglin, player)).forEach(piglin -> { - if (level.getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) { -@@ -548,7 +_,7 @@ + if (level.getGameRules().get(GameRules.UNIVERSAL_ANGER)) { +@@ -554,7 +_,7 @@ } protected static boolean canAdmire(Piglin piglin, ItemStack stack) { @@ -137,7 +137,7 @@ } protected static void wasHurtBy(ServerLevel level, Piglin piglin, LivingEntity entity) { -@@ -796,6 +_,11 @@ +@@ -802,6 +_,11 @@ return piglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -149,7 +149,7 @@ private static boolean isBarterCurrency(ItemStack stack) { return stack.is(BARTERING_ITEM); } -@@ -833,7 +_,7 @@ +@@ -839,7 +_,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(Piglin piglin) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch index e8f62ab1ae4b..108bb28ad52d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/AbstractSkeleton.java -+++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -64,6 +_,7 @@ +--- a/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java +@@ -66,6 +_,7 @@ AbstractSkeleton.this.setAggressive(true); } }; @@ -8,7 +8,7 @@ protected AbstractSkeleton(EntityType type, Level level) { super(type, level); -@@ -88,6 +_,16 @@ +@@ -90,6 +_,21 @@ return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25); } @@ -20,30 +20,26 @@ + public void setShouldBurnInDay(boolean shouldBurnInDay) { + this.shouldBurnInDay = shouldBurnInDay; + } ++ ++ @Override ++ public boolean isSunBurnTick() { ++ return this.shouldBurnInDay && super.isSunBurnTick(); ++ } + // Paper end - shouldBurnInDay API + @Override protected void playStepSound(BlockPos pos, BlockState block) { this.playSound(this.getStepSound(), 0.15F, 1.0F); -@@ -97,7 +_,7 @@ - - @Override - public void aiStep() { -- boolean isSunBurnTick = this.isSunBurnTick(); -+ boolean isSunBurnTick = this.shouldBurnInDay && this.isSunBurnTick(); // Paper - shouldBurnInDay API - if (isSunBurnTick) { - ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.HEAD); - if (!itemBySlot.isEmpty()) { -@@ -145,7 +_,7 @@ +@@ -120,7 +_,7 @@ this.populateDefaultEquipmentSlots(random, difficulty); this.populateDefaultEquipmentEnchantments(level, random, difficulty); this.reassessWeaponGoal(); - this.setCanPickUpLoot(random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); -+ this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot - if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { - LocalDate localDate = LocalDate.now(); - int i = localDate.get(ChronoField.DAY_OF_MONTH); -@@ -188,7 +_,8 @@ ++ this.setCanPickUpLoot(level.getLevel().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot + if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && SpecialDates.isHalloween() && random.nextFloat() < 0.25F) { + this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); + this.setDropChance(EquipmentSlot.HEAD, 0.0F); +@@ -158,7 +_,8 @@ @Override public void performRangedAttack(LivingEntity target, float distanceFactor) { @@ -53,7 +49,7 @@ ItemStack projectile = this.getProjectile(itemInHand); AbstractArrow arrow = this.getArrow(projectile, distanceFactor, itemInHand); double d = target.getX() - this.getX(); -@@ -196,9 +_,21 @@ +@@ -166,9 +_,21 @@ double d2 = target.getZ() - this.getZ(); double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { @@ -76,7 +72,7 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -222,11 +_,22 @@ +@@ -192,11 +_,22 @@ protected void readAdditionalSaveData(ValueInput input) { super.readAdditionalSaveData(input); this.reassessWeaponGoal(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch index 2661b9cf10e0..787f5c998ca1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Bogged.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/Bogged.java -+++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -74,7 +_,19 @@ +--- a/net/minecraft/world/entity/monster/skeleton/Bogged.java ++++ b/net/minecraft/world/entity/monster/skeleton/Bogged.java +@@ -72,7 +_,19 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverLevel) { @@ -21,7 +21,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, hand.asEquipmentSlot()); } -@@ -127,15 +_,33 @@ +@@ -125,15 +_,33 @@ @Override public void shear(ServerLevel level, SoundSource source, ItemStack shears) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch index 1176065314ba..828eee49ccaf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/Skeleton.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/Skeleton.java -+++ b/net/minecraft/world/entity/monster/Skeleton.java +--- a/net/minecraft/world/entity/monster/skeleton/Skeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/Skeleton.java @@ -93,11 +_,17 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch index b9f37bbe1c2f..aabf999cbe62 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/WitherSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/monster/WitherSkeleton.java -+++ b/net/minecraft/world/entity/monster/WitherSkeleton.java -@@ -96,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/WitherSkeleton.java +@@ -95,7 +_,7 @@ return false; } else { if (target instanceof LivingEntity) { @@ -9,7 +9,7 @@ } return true; -@@ -112,6 +_,6 @@ +@@ -111,6 +_,6 @@ @Override public boolean canBeAffected(MobEffectInstance effectInstance) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/CaveSpider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch similarity index 76% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/CaveSpider.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch index 8a80dbdffbd8..cf4e7adfc5c8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/CaveSpider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/CaveSpider.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/CaveSpider.java -+++ b/net/minecraft/world/entity/monster/CaveSpider.java +--- a/net/minecraft/world/entity/monster/spider/CaveSpider.java ++++ b/net/minecraft/world/entity/monster/spider/CaveSpider.java @@ -38,7 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/spider/Spider.java.patch index d2183db1be92..6448027f791a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/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.java -+++ b/net/minecraft/world/entity/monster/Spider.java -@@ -79,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/spider/Spider.java ++++ b/net/minecraft/world/entity/monster/spider/Spider.java +@@ -81,7 +_,7 @@ public void tick() { super.tick(); if (!this.level().isClientSide()) { @@ -9,7 +9,7 @@ } } -@@ -121,7 +_,7 @@ +@@ -123,7 +_,7 @@ @Override public boolean canBeAffected(MobEffectInstance effectInstance) { @@ -18,7 +18,7 @@ } public boolean isClimbing() { -@@ -165,7 +_,7 @@ +@@ -166,7 +_,7 @@ if (spawnGroupData instanceof Spider.SpiderEffectsGroupData spiderEffectsGroupData) { Holder holder = spiderEffectsGroupData.effect; if (holder != null) { 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 14e482b4939e..0cc4dc341d9a 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 -@@ -396,7 +_,7 @@ +@@ -395,7 +_,7 @@ public static void applyDarknessAround(ServerLevel level, Vec3 pos, @Nullable Entity source, int radius) { MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false); @@ -9,7 +9,7 @@ } @Override -@@ -440,6 +_,15 @@ +@@ -439,6 +_,15 @@ @VisibleForTesting public void increaseAngerAt(@Nullable Entity entity, int offset, boolean playListeningSound) { if (!this.isNoAi() && this.canTargetEntity(entity)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch similarity index 88% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Drowned.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Drowned.java.patch index 766d4594dab8..1aee8901a3a3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/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/Drowned.java -+++ b/net/minecraft/world/entity/monster/Drowned.java -@@ -86,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/zombie/Drowned.java ++++ b/net/minecraft/world/entity/monster/zombie/Drowned.java +@@ -89,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, (entity, level) -> this.okTarget(entity))); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch similarity index 67% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch index a8db491f9440..1fa36a18b826 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Husk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Husk.java.patch @@ -1,9 +1,9 @@ ---- a/net/minecraft/world/entity/monster/Husk.java -+++ b/net/minecraft/world/entity/monster/Husk.java -@@ -57,7 +_,7 @@ +--- a/net/minecraft/world/entity/monster/zombie/Husk.java ++++ b/net/minecraft/world/entity/monster/zombie/Husk.java +@@ -59,7 +_,7 @@ boolean flag = super.doHurtTarget(level, target); if (flag && this.getMainHandItem().isEmpty() && target instanceof LivingEntity) { - float effectiveDifficulty = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); + float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); - ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)effectiveDifficulty), this); + ((LivingEntity)target).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)effectiveDifficulty), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch index cfa31aeb21b8..2437917660cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/Zombie.java.patch @@ -1,16 +1,16 @@ ---- a/net/minecraft/world/entity/monster/Zombie.java -+++ b/net/minecraft/world/entity/monster/Zombie.java +--- a/net/minecraft/world/entity/monster/zombie/Zombie.java ++++ b/net/minecraft/world/entity/monster/zombie/Zombie.java @@ -67,9 +_,7 @@ public class Zombie extends Monster { - private static final ResourceLocation SPEED_MODIFIER_BABY_ID = ResourceLocation.withDefaultNamespace("baby"); + private static final Identifier SPEED_MODIFIER_BABY_ID = Identifier.withDefaultNamespace("baby"); - private static final AttributeModifier SPEED_MODIFIER_BABY = new AttributeModifier( - SPEED_MODIFIER_BABY_ID, 0.5, AttributeModifier.Operation.ADD_MULTIPLIED_BASE - ); + private final AttributeModifier babyModifier = new AttributeModifier(Zombie.SPEED_MODIFIER_BABY_ID, this.level().paperConfig().entities.behavior.babyZombieMovementModifier, AttributeModifier.Operation.ADD_MULTIPLIED_BASE); // Paper - Make baby speed configurable - private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge"); + private static final Identifier REINFORCEMENT_CALLER_CHARGE_ID = Identifier.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( - ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE + Identifier.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE @@ -90,13 +_,15 @@ private static final boolean DEFAULT_BABY = false; private static final boolean DEFAULT_CAN_BREAK_DOORS = false; @@ -37,7 +37,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -117,7 +_,7 @@ +@@ -118,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)); @@ -46,7 +46,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)); } -@@ -171,11 +_,16 @@ +@@ -172,11 +_,16 @@ @Override protected int getBaseExperienceReward(ServerLevel level) { @@ -64,7 +64,7 @@ } @Override -@@ -183,9 +_,9 @@ +@@ -184,9 +_,9 @@ this.getEntityData().set(DATA_BABY_ID, childZombie); if (this.level() != null && !this.level().isClientSide()) { AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); @@ -76,8 +76,8 @@ } } } -@@ -254,6 +_,13 @@ - super.aiStep(); +@@ -227,6 +_,13 @@ + super.tick(); } + // Paper start - Add more Zombie API @@ -90,18 +90,18 @@ public void startUnderWaterConversion(int conversionTime) { this.conversionTime = conversionTime; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); -@@ -267,31 +_,50 @@ +@@ -240,31 +_,50 @@ } - protected void convertToZombieType(EntityType entityType) { + protected void convertToZombieType(ServerLevel level, EntityType entityType) { - this.convertTo( + Zombie converted = this.convertTo( // CraftBukkit entityType, ConversionParams.single(this, true, true), -- zombie -> zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()) +- zombie -> zombie.handleAttributes(level.getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()) - ); + // CraftBukkit start -+ zombie -> { zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); }, ++ zombie -> { zombie.handleAttributes(level.getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); }, + org.bukkit.event.entity.EntityTransformEvent.TransformReason.DROWNED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DROWNED); + if (converted == null) { + ((org.bukkit.entity.Zombie) this.getBukkitEntity()).setConversionTime(-1); // CraftBukkit - SPIGOT-5208: End conversion to stop event spam @@ -150,7 +150,7 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { -@@ -324,13 +_,13 @@ +@@ -297,13 +_,13 @@ if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) { zombie.setPos(i1, i2, i3); @@ -167,9 +167,9 @@ AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); double d = modifier != null ? modifier.amount() : 0.0; -@@ -355,7 +_,12 @@ +@@ -328,7 +_,12 @@ if (flag) { - float effectiveDifficulty = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); + float effectiveDifficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) { - target.igniteForSeconds(2 * (int)effectiveDifficulty); + // CraftBukkit start @@ -181,7 +181,7 @@ } } -@@ -415,6 +_,7 @@ +@@ -390,6 +_,7 @@ output.putBoolean("CanBreakDoors", this.canBreakDoors()); output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -189,7 +189,7 @@ } @Override -@@ -429,13 +_,15 @@ +@@ -404,13 +_,15 @@ } else { this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } @@ -207,7 +207,7 @@ return flag; } -@@ -471,7 +_,7 @@ +@@ -445,7 +_,7 @@ spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData); float specialMultiplier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -216,7 +216,7 @@ } if (spawnGroupData == null) { -@@ -498,7 +_,7 @@ +@@ -472,7 +_,7 @@ chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken1.setChickenJockey(true); this.startRiding(chicken1, false, false); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch similarity index 94% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombieVillager.java.patch index e1e2648a7f26..7737670b825a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/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/ZombieVillager.java -+++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -170,12 +_,20 @@ +--- a/net/minecraft/world/entity/monster/zombie/ZombieVillager.java ++++ b/net/minecraft/world/entity/monster/zombie/ZombieVillager.java +@@ -167,12 +_,20 @@ } public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime) { @@ -24,7 +24,7 @@ } @Override -@@ -200,7 +_,7 @@ +@@ -197,7 +_,7 @@ } private void finishConversion(ServerLevel level) { @@ -33,7 +33,7 @@ EntityType.VILLAGER, ConversionParams.single(this, false, false), mob -> { -@@ -224,19 +_,24 @@ +@@ -223,19 +_,24 @@ mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); mob.refreshBrain(level); if (this.conversionStarter != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java.patch similarity index 79% rename from paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java.patch index aaf4a55a1b34..923e5403fa79 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java -+++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java +--- a/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java ++++ b/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java @@ -57,6 +_,7 @@ private static final int ALERT_RANGE_Y = 10; private static final UniformInt ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6); @@ -8,8 +8,8 @@ public ZombifiedPiglin(EntityType type, Level level) { super(type, level); -@@ -72,7 +_,7 @@ - protected void addBehaviourGoals() { +@@ -68,7 +_,7 @@ + this.goalSelector.addGoal(1, new SpearUseGoal<>(this, 1.0, 1.0, 10.0F, 2.0F)); this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); - this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers()); @@ -17,7 +17,7 @@ this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt)); this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true)); } -@@ -145,7 +_,7 @@ +@@ -141,7 +_,7 @@ .filter(zombifiedPiglin -> zombifiedPiglin != this) .filter(zombifiedPiglin -> zombifiedPiglin.getTarget() == null) .filter(zombifiedPiglin -> !zombifiedPiglin.isAlliedTo(this.getTarget())) @@ -26,12 +26,12 @@ } private void playAngerSound() { -@@ -153,18 +_,27 @@ +@@ -149,18 +_,27 @@ } @Override - public void setTarget(@Nullable LivingEntity target) { -+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit - signature ++ public boolean setTarget(@Nullable LivingEntity target, org.bukkit.event.entity.EntityTargetEvent.@Nullable TargetReason reason) { // CraftBukkit - signature if (this.getTarget() == null && target != null) { this.playFirstAngerSoundIn = FIRST_ANGER_SOUND_DELAY.sample(this.random); this.ticksUntilNextAlert = ALERT_INTERVAL.sample(this.random); @@ -43,16 +43,16 @@ @Override public void startPersistentAngerTimer() { -- this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random)); +- this.setTimeToRemainAngry(PERSISTENT_ANGER_TIME.sample(this.random)); + // CraftBukkit start -+ net.minecraft.world.entity.Entity entity = this.level().getEntity(this.getPersistentAngerTarget()); ++ net.minecraft.world.entity.Entity entity = EntityReference.getLivingEntity(this.getPersistentAngerTarget(), this.level()); + org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), PERSISTENT_ANGER_TIME.sample(this.random)); + if (!event.callEvent()) { + this.setPersistentAngerTarget(null); + this.hurtByTargetGoal.stop(); + return; + } -+ this.setRemainingPersistentAngerTime(event.getNewAnger()); ++ this.setTimeToRemainAngry(event.getNewAnger()); + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch deleted file mode 100644 index 08fa52754fdf..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/entity/npc/VillagerTrades.java -+++ b/net/minecraft/world/entity/npc/VillagerTrades.java -@@ -1747,7 +_,8 @@ - @Override - public MerchantOffer getOffer(Entity trader, RandomSource random) { - if (trader.level() instanceof ServerLevel serverLevel) { -- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, true); -+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps -+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps - if (blockPos != null) { - ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), (byte)2, true, true); - MapItem.renderBiomePreviewMap(serverLevel, itemStack); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch index fbfd47d8f601..f032420bf2ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/AbstractVillager.java.patch @@ -1,9 +1,9 @@ ---- a/net/minecraft/world/entity/npc/AbstractVillager.java -+++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -42,7 +_,7 @@ - private Player tradingPlayer; - @Nullable - protected MerchantOffers offers; +--- a/net/minecraft/world/entity/npc/villager/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/villager/AbstractVillager.java +@@ -43,7 +_,7 @@ + private static final int VILLAGER_INVENTORY_SIZE = 8; + private @Nullable Player tradingPlayer; + protected @Nullable MerchantOffers offers; - private final SimpleContainer inventory = new SimpleContainer(8); + private final SimpleContainer inventory = new SimpleContainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit - add argument @@ -23,20 +23,20 @@ + // Paper start - Villager#resetOffers + public void resetOffers() { + this.offers = new MerchantOffers(); -+ this.updateTrades(); ++ this.updateTrades((net.minecraft.server.level.ServerLevel) this.level()); + } + // Paper end - Villager#resetOffers + @Override public MerchantOffers getOffers() { - if (this.level().isClientSide()) { + if (this.level() instanceof ServerLevel serverLevel) { @@ -117,11 +_,24 @@ public void overrideXp(int xp) { } + // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent + @Override -+ public void processTrade(MerchantOffer offer, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent ++ public void processTrade(MerchantOffer offer, io.papermc.paper.event.player.@Nullable PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent + if (event == null || event.willIncreaseTradeUses()) { + offer.increaseUses(); + } @@ -57,9 +57,9 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, offer.getResult()); } -@@ -226,7 +_,20 @@ +@@ -225,7 +_,20 @@ while (i < maxNumbers && !list.isEmpty()) { - MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(this, this.random); + MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(level, this, this.random); if (offer != null) { - givenMerchantOffers.add(offer); + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch similarity index 85% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch index ba784f35d5a0..9065f2e46d63 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/Villager.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/npc/Villager.java -+++ b/net/minecraft/world/entity/npc/Villager.java +--- a/net/minecraft/world/entity/npc/villager/Villager.java ++++ b/net/minecraft/world/entity/npc/villager/Villager.java @@ -287,7 +_,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -23,7 +23,7 @@ } this.resendOffersToTradingPlayer(); -@@ -457,7 +_,12 @@ +@@ -452,7 +_,12 @@ int i = 2 - this.numberOfRestocksToday; if (i > 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -37,7 +37,7 @@ } } -@@ -478,6 +_,7 @@ +@@ -473,6 +_,7 @@ int playerReputation = this.getPlayerReputation(player); if (playerReputation != 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -45,7 +45,7 @@ merchantOffer.addToSpecialPriceDiff(-Mth.floor(playerReputation * merchantOffer.getPriceMultiplier())); } } -@@ -487,6 +_,7 @@ +@@ -482,6 +_,7 @@ int amplifier = effect.getAmplifier(); for (MerchantOffer merchantOffer1 : this.getOffers()) { @@ -53,7 +53,7 @@ double d = 0.3 + 0.0625 * amplifier; int i = (int)Math.floor(d * merchantOffer1.getBaseCostA().getCount()); merchantOffer1.addToSpecialPriceDiff(-Math.max(i, 1)); -@@ -595,7 +_,7 @@ +@@ -589,7 +_,7 @@ } if (offer.shouldRewardExp()) { @@ -62,7 +62,7 @@ } } -@@ -613,7 +_,7 @@ +@@ -607,7 +_,7 @@ @Override public void die(DamageSource damageSource) { @@ -71,7 +71,16 @@ Entity entity = damageSource.getEntity(); if (entity != null) { this.tellWitnessesThatIWasMurdered(entity); -@@ -781,12 +_,19 @@ +@@ -706,7 +_,7 @@ + return VillagerData.canLevelUp(level) && this.villagerXp >= VillagerData.getMaxXpPerLevel(level); + } + +- private void increaseMerchantCareer(ServerLevel level) { ++ public void increaseMerchantCareer(ServerLevel level) { // Paper - public + this.setVillagerData(this.getVillagerData().withLevel(this.getVillagerData().level() + 1)); + this.updateTrades(level); + } +@@ -773,12 +_,19 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { if (level.getDifficulty() != Difficulty.PEACEFUL) { @@ -93,10 +102,10 @@ if (witch == null) { super.thunderHit(level, lightning); } -@@ -826,6 +_,12 @@ +@@ -818,6 +_,12 @@ @Override - protected void updateTrades() { + protected void updateTrades(ServerLevel level) { + // Paper start - More vanilla friendly methods to update trades + this.updateTrades(TRADES_PER_LEVEL); + } @@ -106,14 +115,15 @@ VillagerData villagerData = this.getVillagerData(); ResourceKey resourceKey = villagerData.profession().unwrapKey().orElse(null); if (resourceKey != null) { -@@ -841,13 +_,15 @@ +@@ -833,13 +_,15 @@ VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.level()); if (itemListings != null) { MerchantOffers offers = this.getOffers(); -- this.addOffersFromItemListings(offers, itemListings, 2); -+ this.addOffersFromItemListings(offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades +- this.addOffersFromItemListings(level, offers, itemListings, 2); ++ this.addOffersFromItemListings((net.minecraft.server.level.ServerLevel) this.level(), offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades if (SharedConstants.DEBUG_UNLOCK_ALL_TRADES && villagerData.level() < map1.size()) { - this.increaseMerchantCareer(); +- this.increaseMerchantCareer(level); ++ this.increaseMerchantCareer((net.minecraft.server.level.ServerLevel) this.level()); } + return true; // Paper - More vanilla friendly methods to update trades } @@ -123,7 +133,7 @@ } public void gossip(ServerLevel level, Villager target, long gameTime) { -@@ -876,7 +_,7 @@ +@@ -868,7 +_,7 @@ List entitiesOfClass = level.getEntitiesOfClass(Villager.class, aabb); List list = entitiesOfClass.stream().filter(villager -> villager.wantsToSpawnGolem(gameTime)).limit(5L).toList(); if (list.size() >= minVillagerAmount) { @@ -132,7 +142,7 @@ EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, level, -@@ -885,9 +_,11 @@ +@@ -877,9 +_,11 @@ 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch new file mode 100644 index 000000000000..3df5d43063e8 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/villager/VillagerTrades.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/entity/npc/villager/VillagerTrades.java ++++ b/net/minecraft/world/entity/npc/villager/VillagerTrades.java +@@ -1737,7 +_,8 @@ + + @Override + public @Nullable MerchantOffer getOffer(ServerLevel level, Entity trader, RandomSource random) { +- BlockPos blockPos = level.findNearestMapStructure(this.destination, trader.blockPosition(), 100, true); ++ if (!level.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps ++ BlockPos blockPos = level.findNearestMapStructure(this.destination, trader.blockPosition(), 100, !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps + if (blockPos != null) { + ItemStack itemStack = MapItem.create(level, blockPos.getX(), blockPos.getZ(), (byte)2, true, true); + MapItem.renderBiomePreviewMap(level, itemStack); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch similarity index 87% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch index 5bdfd4e0a61c..ba03df93c684 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/world/entity/npc/WanderingTrader.java -+++ b/net/minecraft/world/entity/npc/WanderingTrader.java -@@ -51,6 +_,10 @@ - @Nullable - private BlockPos wanderTarget; +--- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java ++++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java +@@ -52,6 +_,10 @@ + private static final int DEFAULT_DESPAWN_DELAY = 0; + private @Nullable BlockPos wanderTarget; private int despawnDelay = 0; + // Paper start - Add more WanderingTrader API + public boolean canDrinkPotion = true; @@ -11,7 +11,7 @@ public WanderingTrader(EntityType type, Level level) { super(type, level); -@@ -66,7 +_,7 @@ +@@ -67,7 +_,7 @@ this, PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, @@ -20,7 +20,7 @@ ) ); this.goalSelector -@@ -76,7 +_,7 @@ +@@ -77,7 +_,7 @@ this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch index 346f7737d69c..f88caff4d5cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/npc/WanderingTraderSpawner.java -+++ b/net/minecraft/world/entity/npc/WanderingTraderSpawner.java +--- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java ++++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTraderSpawner.java @@ -38,36 +_,45 @@ public WanderingTraderSpawner(ServerLevelData serverLevelData) { @@ -34,7 +34,7 @@ + this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength; + this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin; + } - if (level.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING)) { + if (level.getGameRules().get(GameRules.SPAWN_WANDERING_TRADERS)) { - if (--this.tickDelay <= 0) { - this.tickDelay = 1200; - this.spawnDelay -= 1200; 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 8bc9726328e5..cd2ff98d5e90 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,16 +1,16 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -148,7 +_,7 @@ - private static final boolean DEFAULT_IGNORE_FALL_DAMAGE_FROM_CURRENT_IMPULSE = false; +@@ -151,7 +_,7 @@ private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; + public static final float CREATIVE_ENTITY_INTERACTION_RANGE_MODIFIER_VALUE = 2.0F; final Inventory inventory; - protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(); + protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(this); // CraftBukkit - add "this" to constructor public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -179,6 +_,18 @@ - public Entity currentExplosionCause; +@@ -177,6 +_,18 @@ + public @Nullable Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse = false; private int currentImpulseContextResetGraceTime = 0; + public boolean affectsSpawning = true; // Paper - Affects Spawning API @@ -28,7 +28,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -246,6 +_,13 @@ +@@ -244,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -51,7 +51,7 @@ } private boolean isEquipped(Item item) { -@@ -431,6 +_,18 @@ +@@ -428,6 +_,18 @@ } } @@ -70,7 +70,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -442,8 +_,14 @@ +@@ -439,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide() && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -87,7 +87,7 @@ super.rideTick(); } } -@@ -704,10 +_,10 @@ +@@ -699,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -100,7 +100,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -719,7 +_,14 @@ +@@ -714,7 +_,14 @@ } } @@ -116,7 +116,7 @@ } } } -@@ -731,7 +_,7 @@ +@@ -726,7 +_,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { @@ -125,7 +125,7 @@ } } -@@ -741,9 +_,29 @@ +@@ -736,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -158,7 +158,7 @@ } @Override -@@ -757,7 +_,12 @@ +@@ -752,7 +_,12 @@ } @Override @@ -172,7 +172,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -769,7 +_,7 @@ +@@ -764,7 +_,7 @@ } if (var8 != 0.0F) { @@ -181,7 +181,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -779,6 +_,7 @@ +@@ -774,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -189,7 +189,7 @@ } public boolean isTextFilteringEnabled() { -@@ -862,14 +_,16 @@ +@@ -860,14 +_,16 @@ } @Override @@ -209,14 +209,13 @@ } @Override -@@ -948,8 +_,17 @@ +@@ -946,15 +_,25 @@ } public void attack(Entity target) { -- if (target.isAttackable()) { -- if (!target.skipAttackInteraction(this)) { +- if (!this.cannotAttack(target)) { + // Paper start - PlayerAttackEntityEvent -+ boolean willAttack = target.isAttackable() && !target.skipAttackInteraction(this); // Vanilla logic ++ boolean willAttack = !this.cannotAttack(target); // Vanilla logic + io.papermc.paper.event.player.PrePlayerAttackEntityEvent playerAttackEntityEvent = new io.papermc.paper.event.player.PrePlayerAttackEntityEvent( + (org.bukkit.entity.Player) this.getBukkitEntity(), + target.getBukkitEntity(), @@ -224,175 +223,152 @@ + ); + + if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable. -+ { + // Paper end - PlayerAttackEntityEvent - float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); - ItemStack weaponItem = this.getWeaponItem(); - DamageSource damageSource = Optional.ofNullable(weaponItem.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this)); -@@ -957,18 +_,25 @@ - float attackStrengthScale = this.getAttackStrengthScale(0.5F); - f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F; - f1 *= attackStrengthScale; -- this.resetAttackStrengthTicker(); -+ // this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt - if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) -- && target instanceof Projectile projectile -- && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { -- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); -- } else { -+ && target instanceof Projectile projectile) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, f1, false)) { -+ return; -+ } -+ if (projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { -+ this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); -+ return; -+ } -+ } -+ { -+ // CraftBukkit end - if (f > 0.0F || f1 > 0.0F) { - boolean flag = attackStrengthScale > 0.9F; - boolean flag1; - if (this.isSprinting() && flag) { -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility - flag1 = true; - } else { - flag1 = false; -@@ -984,7 +_,9 @@ - && !this.isPassenger() - && target instanceof LivingEntity - && !this.isSprinting(); -+ flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits - if (flag2) { -+ damageSource = damageSource.critical(); // Paper - critical damage API - f *= 1.5F; - } - -@@ -1011,17 +_,23 @@ - if (target instanceof LivingEntity livingEntity1) { - livingEntity1.knockback( - f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) -+ , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events - ); - } else { - target.push( - -Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)) * f4 * 0.5F, - 0.1, - Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) * f4 * 0.5F -+ , this // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - ); - } - - this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); -+ // Paper start - Configurable sprint interruption on attack -+ if (!this.level().paperConfig().misc.disableSprintInterruptionOnAttack) { - this.setSprinting(false); -+ } -+ // Paper end - Configurable sprint interruption on attack - } - - if (flag3) { -@@ -1035,42 +_,59 @@ - && !(livingEntity2 instanceof ArmorStand armorStand && armorStand.isMarker()) - && this.distanceToSqr(livingEntity2) < 9.0) { - float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource) * attackStrengthScale; -- if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource, f6)) { -+ // Paper start - Only apply knockback if the event is not cancelled -+ livingEntity2.lastDamageCancelled = false; -+ if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6) && !livingEntity2.lastDamageCancelled) { -+ // Paper end - Only apply knockback if the event is not cancelled - livingEntity2.knockback( - 0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) -+ , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // Paper - knockback events - ); - EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity2, damageSource); - } - } - } - -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility - this.sweepAttack(); - } - - if (target instanceof ServerPlayer && target.hurtMarked) { -+ // CraftBukkit start - Add Velocity Event -+ boolean cancelled = false; -+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) target.getBukkitEntity(); -+ org.bukkit.util.Vector velocity = org.bukkit.craftbukkit.util.CraftVector.toBukkit(deltaMovement); + float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); + ItemStack weaponItem = this.getWeaponItem(); +- DamageSource damageSource = this.createAttackSource(weaponItem); ++ DamageSource damageSource = this.createAttackSource(weaponItem); final DamageSource dmgSourceFinal = damageSource; // Paper - damage events + float attackStrengthScale = this.getAttackStrengthScale(0.5F); + float f1 = attackStrengthScale * (this.getEnchantedDamage(target, f, damageSource) - f); + f *= this.baseDamageScaleFactor(); + this.onAttack(); +- if (!this.deflectProjectile(target)) { ++ final float dmgFinal = f1; // Paper - damage events ++ if (!this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, dmgSourceFinal, dmgFinal, false))) { + if (f > 0.0F || f1 > 0.0F) { + boolean flag = attackStrengthScale > 0.9F; + boolean flag1; +@@ -967,7 +_,9 @@ + + f += weaponItem.getItem().getAttackDamageBonus(target, f, damageSource); + boolean flag2 = flag && this.canCriticalAttack(target); ++ flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits + if (flag2) { ++ damageSource = damageSource.critical(); // Paper - critical damage API + f *= 1.5F; + } + +@@ -1013,11 +_,12 @@ + return !target.isAttackable() || target.skipAttackInteraction(this); + } + +- private boolean deflectProjectile(Entity target) { ++ private boolean deflectProjectile(Entity target, java.util.function.BooleanSupplier callEvent) { // Paper - damage events + if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) + && target instanceof Projectile projectile ++ && callEvent.getAsBoolean() // Paper - damage events + && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, EntityReference.of(this), true)) { +- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); ++ this.makeSound(SoundEvents.PLAYER_ATTACK_NODAMAGE); // Paper - Use makeSound to avoid duplicating client-side sound for source player + return true; + } else { + return false; +@@ -1110,21 +_,43 @@ + public void causeExtraKnockback(Entity target, float strength, Vec3 currentMovement) { + if (strength > 0.0F) { + if (target instanceof LivingEntity livingEntity) { +- livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); ++ livingEntity.knockback(strength, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events + } else { + target.push( + -Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)) * strength, 0.1, Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) * strength ++ , this // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + ); + } + + this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 1.0, 0.6)); ++ // Paper start - Configurable sprint interruption on attack ++ if (!this.level().paperConfig().misc.disableSprintInterruptionOnAttack) { + this.setSprinting(false); ++ } ++ // Paper end - Configurable sprint interruption on attack + } + + if (target instanceof ServerPlayer && target.hurtMarked) { ++ // CraftBukkit start - Add Velocity Event ++ boolean cancelled = false; ++ org.bukkit.entity.Player player = (org.bukkit.entity.Player) target.getBukkitEntity(); ++ org.bukkit.util.Vector velocity = org.bukkit.craftbukkit.util.CraftVector.toBukkit(currentMovement); + -+ org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity.clone()); -+ this.level().getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity.clone()); ++ this.level().getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ cancelled = true; -+ } else if (!velocity.equals(event.getVelocity())) { -+ player.setVelocity(event.getVelocity()); -+ } ++ if (event.isCancelled()) { ++ cancelled = true; ++ } else if (!velocity.equals(event.getVelocity())) { ++ player.setVelocity(event.getVelocity()); ++ } + -+ if (!cancelled) { - ((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target)); - target.hurtMarked = false; - target.setDeltaMovement(deltaMovement); -+ } -+ // CraftBukkit end - } - - if (flag2) { -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility - this.crit(target); - } - - if (!flag2 && !flag3) { - if (flag) { -- this.level() -- .playSound( -- null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F -+ sendSoundEffect( -+ this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F // Paper - send while respecting visibility - ); - } else { -- this.level() -- .playSound( -- null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F -+ sendSoundEffect( -+ this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F // Paper - send while respecting visibility - ); - } - } -@@ -1118,10 +_,10 @@ - } - } - -- this.causeFoodExhaustion(0.1F); -+ this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value - } else { -- this.level() -- .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); -+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility -+ // CraftBukkit end - } ++ if (!cancelled) { + ((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target)); + target.hurtMarked = false; + target.setDeltaMovement(currentMovement); ++ } ++ // CraftBukkit end + } + } + +@@ -1145,7 +_,10 @@ + && !(livingEntity instanceof ArmorStand armorStand && armorStand.isMarker()) + && this.distanceToSqr(livingEntity) < 9.0) { + float f1 = this.getEnchantedDamage(livingEntity, var12, damageSource) * strengthScale; +- if (livingEntity.hurtServer(serverLevel, damageSource, f1)) { ++ // Paper start - Only apply knockback if the event is not canceled ++ livingEntity.lastDamageCancelled = false; ++ if (livingEntity.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f1) && !livingEntity.lastDamageCancelled) { ++ // Paper end - Only apply knockback if the event is not canceled + livingEntity.knockback(0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))); + EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource); } +@@ -1177,7 +_,16 @@ + + @Override + public boolean stabAttack(EquipmentSlot slot, Entity target, float damageAmount, boolean damage, boolean knockback, boolean dismount) { +- if (this.cannotAttack(target)) { ++ // Paper start - PlayerAttackEntityEvent ++ boolean cannotAttack = this.cannotAttack(target); // Vanilla logic ++ io.papermc.paper.event.player.PrePlayerAttackEntityEvent playerAttackEntityEvent = new io.papermc.paper.event.player.PrePlayerAttackEntityEvent( ++ (org.bukkit.entity.Player) this.getBukkitEntity(), ++ target.getBukkitEntity(), ++ !cannotAttack ++ ); ++ ++ if (!playerAttackEntityEvent.callEvent() || cannotAttack) { // Logic moved to cannotAttack local variable. ++ // Paper end - PlayerAttackEntityEvent + return false; + } else { + ItemStack itemBySlot = this.getItemBySlot(slot); +@@ -1188,7 +_,8 @@ + damageAmount *= this.baseDamageScaleFactor(); + } + +- if (knockback && this.deflectProjectile(target)) { ++ final float dmgFinal = f; // Paper - damage events ++ if (knockback && this.deflectProjectile(target, () -> !org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(target, damageSource, dmgFinal, false))) { // Paper - damage events + return true; + } else { + float f1 = damage ? damageAmount + f : 0.0F; +@@ -1216,7 +_,7 @@ + this.setLastHurtMob(target); + this.itemAttackInteraction(target, itemBySlot, damageSource, flag); + this.damageStatsAndHearts(target, f2); +- this.causeFoodExhaustion(0.1F); ++ this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value + return true; } -@@ -1156,8 +_,8 @@ + } +@@ -1227,8 +_,8 @@ } @Override - public void remove(Entity.RemovalReason reason) { - super.remove(reason); -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause + super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause this.inventoryMenu.removed(this); if (this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1225,6 +_,12 @@ +@@ -1296,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -405,7 +381,7 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1336,7 +_,7 @@ +@@ -1407,7 +_,7 @@ @Override public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { @@ -414,7 +390,7 @@ return false; } else { if (fallDistance >= 2.0) { -@@ -1377,7 +_,15 @@ +@@ -1448,7 +_,15 @@ } public void startFallFlying() { @@ -431,7 +407,16 @@ } @Override -@@ -1483,15 +_,35 @@ +@@ -1546,7 +_,7 @@ + + if (levels > 0 && this.experienceLevel % 5 == 0 && this.lastLevelUpTime < this.tickCount - 100.0F) { + float f = this.experienceLevel > 30 ? 1.0F : this.experienceLevel / 30.0F; +- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_LEVELUP, this.getSoundSource(), f * 0.75F, 1.0F); ++ Player.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_LEVELUP, this.getSoundSource(), f * 0.75F, 1.0F); // Paper - send while respecting visibility + this.lastLevelUpTime = this.tickCount; + } + } +@@ -1554,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -469,7 +454,16 @@ } } } -@@ -1760,17 +_,32 @@ +@@ -1821,7 +_,7 @@ + + @Override + public void onAttack() { +- this.resetOnlyAttackStrengthTicker(); ++ // this.resetOnlyAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt + super.onAttack(); + } + +@@ -1856,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -504,7 +498,7 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -1779,6 +_,7 @@ +@@ -1875,6 +_,7 @@ } } @@ -512,25 +506,10 @@ return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -1865,12 +_,20 @@ - } - - public boolean hasClientLoaded() { -- return this.clientLoaded || this.clientLoadedTimeoutTimer <= 0; -+ return this.clientLoaded; // Paper - Add PlayerLoadedWorldEvent - } - - public void tickClientLoadTimeout() { - if (!this.clientLoaded) { - this.clientLoadedTimeoutTimer--; -+ // Paper start - Add PlayerLoadedWorldEvent -+ if (this.clientLoadedTimeoutTimer <= 0) { -+ this.clientLoaded = true; -+ -+ final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent((org.bukkit.craftbukkit.entity.CraftPlayer) getBukkitEntity(), true); -+ event.callEvent(); -+ } -+ // Paper end - Add PlayerLoadedWorldEvent - } +@@ -2055,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")); ++ public static final Player.BedSleepingProblem EXPLOSION = new Player.BedSleepingProblem(null); // Paper - Added to properly handle explosions in bed events } - + } 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 e667ea089ee1..81c63120251b 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 -@@ -98,7 +_,7 @@ +@@ -96,7 +_,7 @@ } if (--this.lifeTicks < 0) { @@ -9,7 +9,7 @@ } } } -@@ -107,7 +_,7 @@ +@@ -105,7 +_,7 @@ LivingEntity owner = this.getOwner(); if (target.isAlive() && !target.isInvulnerable() && target != owner) { if (owner == 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 69a8e815ddb3..060c0ec1b92e 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 -@@ -73,6 +_,12 @@ +@@ -72,6 +_,12 @@ } public void signalTo(Vec3 pos) { @@ -13,7 +13,7 @@ Vec3 vec3 = pos.subtract(this.position()); double d = vec3.horizontalDistance(); if (d > 12.0) { -@@ -81,8 +_,10 @@ +@@ -80,8 +_,10 @@ this.target = pos; } @@ -24,7 +24,7 @@ } @Override -@@ -103,7 +_,7 @@ +@@ -102,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 9a9d61c83368..15e4b962ee8e 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,23 +1,23 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -49,6 +_,7 @@ +@@ -48,6 +_,7 @@ + public int life = 0; public int lifetime = 0; - @Nullable - public LivingEntity attachedToEntity; -+ @Nullable public java.util.UUID spawningEntity; // Paper + public @Nullable LivingEntity attachedToEntity; ++ public java.util.@Nullable UUID spawningEntity; // Paper public FireworkRocketEntity(EntityType type, Level level) { super(type, level); -@@ -164,7 +_,7 @@ +@@ -163,7 +_,7 @@ } if (!this.noPhysics && this.isAlive() && hitResultOnMoveVector.getType() != HitResult.Type.MISS) { - this.hitTargetOrDeflectSelf(hitResultOnMoveVector); + this.preHitTargetOrDeflectSelf(hitResultOnMoveVector); // CraftBukkit - projectile hit event - this.hasImpulse = true; + this.needsSync = true; } -@@ -188,7 +_,11 @@ +@@ -187,7 +_,11 @@ } if (this.life > this.lifetime && this.level() instanceof ServerLevel serverLevel) { @@ -30,7 +30,7 @@ } } -@@ -196,14 +_,18 @@ +@@ -195,14 +_,18 @@ level.broadcastEntityEvent(this, EntityEvent.FIREWORKS_EXPLODE); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(level); @@ -51,7 +51,7 @@ } } -@@ -212,7 +_,11 @@ +@@ -211,7 +_,11 @@ BlockPos blockPos = new BlockPos(result.getBlockPos()); this.level().getBlockState(blockPos).entityInside(this.level(), blockPos, this, InsideBlockEffectApplier.NOOP, true); if (this.level() instanceof ServerLevel serverLevel && this.hasExplosion()) { @@ -64,7 +64,7 @@ } super.onHitBlock(result); -@@ -284,6 +_,7 @@ +@@ -283,6 +_,7 @@ output.putInt("LifeTime", this.lifetime); output.store("FireworksItem", ItemStack.CODEC, this.getItem()); output.putBoolean("ShotAtAngle", this.entityData.get(DATA_SHOT_AT_ANGLE)); @@ -72,7 +72,7 @@ } @Override -@@ -293,6 +_,7 @@ +@@ -292,6 +_,7 @@ this.lifetime = input.getIntOr("LifeTime", 0); this.entityData.set(DATA_ID_FIREWORKS_ITEM, input.read("FireworksItem", ItemStack.CODEC).orElse(getDefaultItem())); this.entityData.set(DATA_SHOT_AT_ANGLE, input.getBooleanOr("ShotAtAngle", false)); 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 1e6738898fc7..ebdb125b7d61 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 -@@ -71,10 +_,26 @@ +@@ -69,10 +_,26 @@ private final int lureSpeed; private final InterpolationHandler interpolationHandler = new InterpolationHandler(this); @@ -27,7 +27,7 @@ } public FishingHook(EntityType type, Level level) { -@@ -155,12 +_,12 @@ +@@ -152,12 +_,12 @@ super.tick(); Player playerOwner = this.getPlayerOwner(); if (playerOwner == null) { @@ -42,7 +42,7 @@ return; } } else { -@@ -178,12 +_,14 @@ +@@ -175,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; } -@@ -198,6 +_,7 @@ +@@ -195,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; } } -@@ -264,13 +_,13 @@ +@@ -261,13 +_,13 @@ } } @@ -81,7 +81,7 @@ } @Override -@@ -301,11 +_,11 @@ +@@ -298,11 +_,11 @@ ServerLevel serverLevel = (ServerLevel)this.level(); int i = 1; BlockPos blockPos = pos.above(); @@ -95,7 +95,7 @@ i--; } -@@ -315,6 +_,10 @@ +@@ -312,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 -= i; -@@ -338,6 +_,12 @@ +@@ -335,6 +_,12 @@ serverLevel.sendParticles(ParticleTypes.FISHING, d, d1, d2, 0, -f2, 0.01, f1, 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 d3 = this.getY() + 0.5; serverLevel.sendParticles( -@@ -389,14 +_,31 @@ +@@ -386,14 +_,31 @@ } if (this.timeUntilLured <= 0) { @@ -155,7 +155,7 @@ public boolean calculateOpenWater(BlockPos pos) { FishingHook.OpenWaterType openWaterType = FishingHook.OpenWaterType.INVALID; -@@ -455,15 +_,31 @@ +@@ -452,15 +_,31 @@ protected void readAdditionalSaveData(ValueInput input) { } @@ -187,7 +187,7 @@ } else if (this.nibble > 0) { LootParams lootParams = new LootParams.Builder((ServerLevel)this.level()) .withParameter(LootContextParams.ORIGIN, this.position()) -@@ -477,18 +_,27 @@ +@@ -474,18 +_,27 @@ for (ItemStack itemStack : randomItems) { ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemStack); @@ -221,7 +221,7 @@ if (itemStack.is(ItemTags.FISHES)) { playerOwner.awardStat(Stats.FISH_CAUGHT, 1); } -@@ -498,10 +_,24 @@ +@@ -495,10 +_,24 @@ } if (this.onGround()) { @@ -247,19 +247,19 @@ return i; } else { return 0; -@@ -531,9 +_,9 @@ +@@ -528,9 +_,9 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause this.updateOwnerInfo(null); - super.remove(reason); + super.remove(reason, cause); // CraftBukkit - add Bukkit remove cause } @Override -@@ -581,7 +_,7 @@ +@@ -576,7 +_,7 @@ if (this.getPlayerOwner() == null) { int data = packet.getData(); LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(data), data); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch index 552cc853b5a7..bbddee96ba82 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -45,6 +_,7 @@ +@@ -44,6 +_,7 @@ + private boolean leftOwnerChecked; public boolean hasBeenShot = false; - @Nullable - private Entity lastDeflectedBy; + private @Nullable Entity lastDeflectedBy; + protected boolean hitCancelled = false; // CraftBukkit - Projectile(EntityType type, Level level) { + protected Projectile(EntityType type, Level level) { super(type, level); -@@ -52,12 +_,25 @@ +@@ -51,12 +_,25 @@ protected void setOwner(@Nullable EntityReference owner) { this.owner = owner; @@ -31,18 +31,18 @@ + } + // Paper end - Refresh ProjectileSource for projectiles + - @Nullable @Override - public Entity getOwner() { -@@ -85,6 +_,7 @@ + public @Nullable Entity getOwner() { + return EntityReference.getEntity(this.owner, this.level()); +@@ -83,6 +_,7 @@ @Override protected void readAdditionalSaveData(ValueInput input) { this.setOwner(EntityReference.read(input, "Owner")); -+ if (this instanceof ThrownEnderpearl && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && this.level().paperConfig().misc.legacyEnderPearlBehavior) { this.owner = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit ++ if (this instanceof net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && this.level().paperConfig().misc.legacyEnderPearlBehavior) { this.owner = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit this.leftOwner = input.getBooleanOr("LeftOwner", false); this.hasBeenShot = input.getBooleanOr("HasBeenShot", false); } -@@ -157,7 +_,14 @@ +@@ -155,7 +_,14 @@ float f2 = Mth.cos(y * (float) (Math.PI / 180.0)) * Mth.cos(x * (float) (Math.PI / 180.0)); this.shoot(f, f1, f2, velocity, inaccuracy); Vec3 knownMovement = shooter.getKnownMovement(); @@ -57,7 +57,7 @@ } @Override -@@ -177,7 +_,12 @@ +@@ -175,7 +_,12 @@ public static T spawnProjectileFromRotation( Projectile.ProjectileFactory factory, ServerLevel level, ItemStack spawnedFrom, LivingEntity owner, float z, float velocity, float inaccuracy ) { @@ -71,7 +71,7 @@ factory.create(level, owner, spawnedFrom), level, spawnedFrom, -@@ -202,7 +_,13 @@ +@@ -200,7 +_,13 @@ public static T spawnProjectileUsingShoot( T projectile, ServerLevel level, ItemStack spawnedFrom, double x, double y, double z, float velocity, float inaccuracy ) { @@ -86,7 +86,7 @@ } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack spawnedFrom) { -@@ -210,11 +_,46 @@ +@@ -208,11 +_,46 @@ } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack stack, Consumer adapter) { @@ -137,7 +137,7 @@ public void applyOnProjectileSpawned(ServerLevel level, ItemStack spawnedFrom) { EnchantmentHelper.onProjectileSpawned(level, spawnedFrom, this, item -> {}); -@@ -226,6 +_,17 @@ +@@ -224,6 +_,17 @@ } } @@ -155,7 +155,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) { if (hitResult.getType() == HitResult.Type.ENTITY) { EntityHitResult entityHitResult = (EntityHitResult)hitResult; -@@ -293,15 +_,35 @@ +@@ -291,15 +_,35 @@ } protected void onHitBlock(BlockHitResult result) { @@ -191,7 +191,7 @@ return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(target); } } -@@ -314,13 +_,7 @@ +@@ -312,13 +_,7 @@ } protected static float lerpRotation(float currentRotation, float targetRotation) { 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 e6c8b8c4023e..c7c063146a24 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 -@@ -57,7 +_,21 @@ +@@ -55,7 +_,21 @@ this.finalTarget = EntityReference.of(finalTarget); this.currentMoveDirection = Direction.UP; this.selectNextMoveDirection(axis, finalTarget); @@ -23,7 +23,7 @@ @Override public SoundSource getSoundSource() { -@@ -179,7 +_,7 @@ +@@ -176,7 +_,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == Difficulty.PEACEFUL) { @@ -32,7 +32,7 @@ } } -@@ -223,7 +_,7 @@ +@@ -220,7 +_,7 @@ } if (hitResult != null && this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { @@ -41,7 +41,7 @@ } ProjectileUtil.rotateTowardsMovement(this, 0.5F); -@@ -296,7 +_,7 @@ +@@ -293,7 +_,7 @@ } if (entity instanceof LivingEntity livingEntity1) { @@ -50,7 +50,7 @@ } } } -@@ -309,14 +_,20 @@ +@@ -306,14 +_,20 @@ } private void destroy() { @@ -59,7 +59,7 @@ + this.destroy(null); + } + -+ private void destroy(@Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { ++ private void destroy(org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { + this.discard(cause); + // CraftBukkit end this.level().gameEvent(GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.Context.of(this)); @@ -73,7 +73,7 @@ } @Override -@@ -331,9 +_,14 @@ +@@ -328,9 +_,14 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java.patch index 1d4e63f3c04e..cee3560183ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/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/AbstractArrow.java -+++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -84,7 +_,14 @@ +--- a/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java +@@ -86,7 +_,14 @@ protected AbstractArrow( EntityType type, double x, double y, double z, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -15,7 +15,7 @@ this.pickupItemStack = pickupItemStack.copy(); this.applyComponentsFromItemStack(pickupItemStack); Unit unit = pickupItemStack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -109,8 +_,8 @@ +@@ -111,8 +_,8 @@ protected AbstractArrow( EntityType type, LivingEntity owner, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -26,7 +26,7 @@ } public void setSoundEvent(SoundEvent soundEvent) { -@@ -205,6 +_,7 @@ +@@ -207,6 +_,7 @@ this.setSharedFlagOnFire(this.getRemainingFireTicks() > 0); } } else { @@ -34,22 +34,25 @@ this.inGroundTime = 0; Vec3 vec31 = this.position(); if (this.isInWater()) { -@@ -272,12 +_,12 @@ +@@ -276,7 +_,7 @@ - if (entityHitResult == null) { + if (list.isEmpty()) { if (this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { - this.hitTargetOrDeflectSelf(hitResult); + this.preHitTargetOrDeflectSelf(hitResult); // CraftBukkit - projectile hit event - this.hasImpulse = true; + this.needsSync = true; } break; - } else if (this.isAlive() && !this.noPhysics) { -- ProjectileDeflection projectileDeflection = this.hitTargetOrDeflectSelf(entityHitResult); -+ ProjectileDeflection projectileDeflection = this.preHitTargetOrDeflectSelf(entityHitResult); // CraftBukkit - projectile hit event - this.hasImpulse = true; - if (this.getPierceLevel() > 0 && projectileDeflection == ProjectileDeflection.NONE) { - continue; -@@ -310,13 +_,26 @@ +@@ -293,7 +_,7 @@ + + private ProjectileDeflection hitTargetsOrDeflectSelf(Collection hitResults) { + for (EntityHitResult entityHitResult : hitResults) { +- ProjectileDeflection projectileDeflection = this.hitTargetOrDeflectSelf(entityHitResult); ++ ProjectileDeflection projectileDeflection = this.preHitTargetOrDeflectSelf(entityHitResult); // CraftBukkit - projectile hit event + if (!this.isAlive() || projectileDeflection != ProjectileDeflection.NONE) { + return projectileDeflection; + } +@@ -325,13 +_,26 @@ } } @@ -77,7 +80,7 @@ } private void startFalling() { -@@ -349,8 +_,8 @@ +@@ -364,8 +_,8 @@ protected void tickDespawn() { this.life++; @@ -88,7 +91,7 @@ } } -@@ -384,9 +_,9 @@ +@@ -399,9 +_,9 @@ } @Override @@ -100,7 +103,7 @@ } } -@@ -413,7 +_,7 @@ +@@ -428,7 +_,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -109,7 +112,7 @@ return; } -@@ -429,10 +_,16 @@ +@@ -444,10 +_,16 @@ livingEntity.setLastHurtMob(entity); } @@ -127,7 +130,7 @@ } if (entity.hurtOrSimulate(damageSource, ceil)) { -@@ -470,7 +_,7 @@ +@@ -485,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -136,7 +139,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -481,7 +_,7 @@ +@@ -496,7 +_,7 @@ this.spawnAtLocation(serverLevel2, this.getPickupItem(), 0.1F); } @@ -145,7 +148,7 @@ } } } -@@ -494,7 +_,7 @@ +@@ -509,7 +_,7 @@ double max = Math.max(0.0, 1.0 - entity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(d * 0.6 * max); if (vec3.lengthSqr() > 0.0) { @@ -154,7 +157,7 @@ } } } -@@ -601,7 +_,14 @@ +@@ -620,7 +_,14 @@ @Override public void setOwner(@Nullable Entity entity) { @@ -169,7 +172,7 @@ this.pickup = switch (entity) { case Player player when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -613,9 +_,22 @@ +@@ -632,9 +_,22 @@ @Override public void playerTouch(Player entity) { if (!this.level().isClientSide() && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch similarity index 82% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch index 706855d787e0..55d81a23186f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/Arrow.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/Arrow.java -+++ b/net/minecraft/world/entity/projectile/Arrow.java +--- a/net/minecraft/world/entity/projectile/arrow/Arrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/Arrow.java @@ -115,7 +_,7 @@ Entity effectSource = this.getEffectSource(); PotionContents potionContents = this.getPotionContents(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch similarity index 77% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch index 7932ff5dd462..a44b58670aa4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/SpectralArrow.java -+++ b/net/minecraft/world/entity/projectile/SpectralArrow.java +--- a/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java ++++ b/net/minecraft/world/entity/projectile/arrow/SpectralArrow.java @@ -41,7 +_,7 @@ protected void doPostHurtEffects(LivingEntity target) { super.doPostHurtEffects(target); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java.patch index 72a406d1af5c..0e745702adcb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/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/ThrownTrident.java -+++ b/net/minecraft/world/entity/projectile/ThrownTrident.java -@@ -48,6 +_,12 @@ +--- a/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java ++++ b/net/minecraft/world/entity/projectile/arrow/ThrownTrident.java +@@ -51,6 +_,12 @@ this.entityData.set(ID_FOIL, pickupItemStack.hasFoil()); } @@ -13,7 +13,7 @@ @Override protected void defineSynchedData(SynchedEntityData.Builder builder) { super.defineSynchedData(builder); -@@ -69,10 +_,10 @@ +@@ -72,10 +_,10 @@ this.spawnAtLocation(serverLevel, this.getPickupItem(), 0.1F); } @@ -26,7 +26,7 @@ return; } -@@ -101,6 +_,20 @@ +@@ -104,6 +_,20 @@ return this.entityData.get(ID_FOIL); } @@ -44,10 +44,10 @@ + } + // Paper end + - @Nullable @Override - protected EntityHitResult findHitEntity(Vec3 startVec, Vec3 endVec) { -@@ -110,7 +_,7 @@ + protected @Nullable EntityHitResult findHitEntity(Vec3 startVec, Vec3 endVec) { + return this.dealtDamage ? null : super.findHitEntity(startVec, endVec); +@@ -118,7 +_,7 @@ @Override protected void onHitEntity(EntityHitResult result) { Entity entity = result.getEntity(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch index 1b219a7e19c3..9eb8af597e53 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -+++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -20,6 +_,8 @@ +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/AbstractHurtingProjectile.java +@@ -22,6 +_,8 @@ public static final double INITAL_ACCELERATION_POWER = 0.1; public static final double DEFLECTION_SCALE = 0.5; public double accelerationPower = 0.1; @@ -9,7 +9,7 @@ protected AbstractHurtingProjectile(EntityType type, Level level) { super(type, level); -@@ -84,12 +_,12 @@ +@@ -86,12 +_,12 @@ } if (hitResultOnMoveVector.getType() != HitResult.Type.MISS && this.isAlive()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch index 9697917eaaf7..0f3dffb6cd05 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/DragonFireball.java -+++ b/net/minecraft/world/entity/projectile/DragonFireball.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/DragonFireball.java @@ -55,9 +_,11 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch similarity index 70% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch index 18c1ce5d89af..68379e517009 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java.patch @@ -1,25 +1,26 @@ ---- a/net/minecraft/world/entity/projectile/LargeFireball.java -+++ b/net/minecraft/world/entity/projectile/LargeFireball.java -@@ -20,11 +_,13 @@ +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java +@@ -20,20 +_,27 @@ public LargeFireball(EntityType type, Level level) { super(type, level); -+ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit ++ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); // CraftBukkit } public LargeFireball(Level level, LivingEntity owner, Vec3 movement, int explosionPower) { super(EntityType.FIREBALL, owner, movement, level); this.explosionPower = explosionPower; -+ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit ++ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); // CraftBukkit } @Override -@@ -32,8 +_,13 @@ + protected void onHit(HitResult result) { super.onHit(result); if (this.level() instanceof ServerLevel serverLevel) { - boolean _boolean = serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -- this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, _boolean, Level.ExplosionInteraction.MOB); +- boolean flag = serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); +- this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, flag, Level.ExplosionInteraction.MOB); - this.discard(); ++ // boolean flag = serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); // CraftBukkit - baked into fields (see constructor) + // CraftBukkit start - fire ExplosionPrimeEvent + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + if (event.callEvent()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch index 31dd848e92b6..59a16e4ae357 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java.patch @@ -1,12 +1,12 @@ ---- a/net/minecraft/world/entity/projectile/SmallFireball.java -+++ b/net/minecraft/world/entity/projectile/SmallFireball.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/SmallFireball.java @@ -23,6 +_,11 @@ public SmallFireball(Level level, LivingEntity owner, Vec3 movement) { super(EntityType.SMALL_FIREBALL, owner, movement, level); + // CraftBukkit start + if (this.getOwner() != null && this.getOwner() instanceof Mob) { -+ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ this.isIncendiary = (level instanceof ServerLevel serverLevel) && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING); + } + // CraftBukkit end } @@ -32,7 +32,7 @@ super.onHitBlock(result); if (this.level() instanceof ServerLevel serverLevel) { Entity owner = this.getOwner(); -- if (!(owner instanceof Mob) || serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!(owner instanceof Mob) || serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + if (this.isIncendiary) { // CraftBukkit BlockPos blockPos = result.getBlockPos().relative(result.getDirection()); - if (this.level().isEmptyBlock(blockPos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch index 14bb11e3177d..427e628f7980 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/WitherSkull.java -+++ b/net/minecraft/world/entity/projectile/WitherSkull.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java @@ -67,11 +_,11 @@ if (var8.isAlive()) { EnchantmentHelper.doPostAttackEffects(serverLevel, var8, damageSource); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch index 5c702b795c4b..503b3602f153 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java -+++ b/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/AbstractWindCharge.java @@ -85,7 +_,7 @@ } @@ -27,7 +27,7 @@ } } -@@ -140,7 +_,7 @@ +@@ -139,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/windcharge/BreezeWindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch similarity index 83% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch index bdc705872528..c2905d1cb136 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java -+++ b/net/minecraft/world/entity/projectile/windcharge/BreezeWindCharge.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/BreezeWindCharge.java @@ -21,6 +_,12 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/WindCharge.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/WindCharge.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch index c607b0fbaeac..a4a45fc9312a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/windcharge/WindCharge.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/windcharge/WindCharge.java -+++ b/net/minecraft/world/entity/projectile/windcharge/WindCharge.java +--- a/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java ++++ b/net/minecraft/world/entity/projectile/hurtingprojectile/windcharge/WindCharge.java @@ -54,6 +_,12 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java.patch similarity index 97% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java.patch index 719320435111..69d4e6502d60 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/AbstractThrownPotion.java -+++ b/net/minecraft/world/entity/projectile/AbstractThrownPotion.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/AbstractThrownPotion.java @@ -68,56 +_,97 @@ @Override protected void onHit(HitResult result) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch similarity index 67% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch index 440d63416474..5ce544f89f5f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Snowball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/Snowball.java -+++ b/net/minecraft/world/entity/projectile/Snowball.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java @@ -62,7 +_,7 @@ super.onHit(result); if (!this.level().isClientSide()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch similarity index 96% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch index 59fda363d32e..1c7b472ff8d8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/ThrownEgg.java -+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java @@ -62,31 +_,66 @@ protected void onHit(HitResult result) { super.onHit(result); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java.patch index be8ad6a68872..5baf743b58a9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/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/ThrownEnderpearl.java -+++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -104,11 +_,21 @@ +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java +@@ -102,11 +_,21 @@ Vec3 vec3 = this.oldPosition(); if (owner instanceof ServerPlayer serverPlayer) { if (serverPlayer.connection.isAcceptingMessages()) { @@ -24,7 +24,7 @@ } } -@@ -116,15 +_,17 @@ +@@ -114,15 +_,17 @@ owner.setPortalCooldown(); } @@ -48,7 +48,7 @@ } this.playSound(serverLevel, vec3); -@@ -140,9 +_,9 @@ +@@ -138,9 +_,9 @@ this.playSound(serverLevel, vec3); } @@ -60,17 +60,17 @@ } } } -@@ -165,7 +_,7 @@ +@@ -163,7 +_,7 @@ && !entity.isAlive() && !serverPlayer.wonGame - && serverPlayer.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { + && serverPlayer.level().getGameRules().get(GameRules.ENDER_PEARLS_VANISH_ON_DEATH)) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { super.tick(); } -@@ -195,7 +_,7 @@ - public Entity teleport(TeleportTransition teleportTransition) { +@@ -192,7 +_,7 @@ + public @Nullable Entity teleport(TeleportTransition teleportTransition) { Entity entity = super.teleport(teleportTransition); if (entity != null) { - entity.placePortalTicket(BlockPos.containing(entity.position())); @@ -78,7 +78,7 @@ } return entity; -@@ -203,7 +_,7 @@ +@@ -200,7 +_,7 @@ @Override public boolean canTeleport(Level fromLevel, Level toLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch similarity index 91% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch index 1cb59c72ff4e..74692dd6ce53 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java -+++ b/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownExperienceBottle.java @@ -40,16 +_,25 @@ protected void onHit(HitResult result) { super.onHit(result); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch index 8fc9c61e7f87..e41c58a29c49 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java -+++ b/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownLingeringPotion.java @@ -29,7 +_,7 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java.patch index 64d6f78a89ec..5a1801fc2f15 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/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/ThrownSplashPotion.java -+++ b/net/minecraft/world/entity/projectile/ThrownSplashPotion.java -@@ -36,13 +_,14 @@ +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownSplashPotion.java +@@ -37,13 +_,14 @@ } @Override @@ -16,7 +16,7 @@ float f = ProjectileUtil.computeMargin(this); if (!entitiesOfClass.isEmpty()) { Entity effectSource = this.getEffectSource(); -@@ -51,8 +_,25 @@ +@@ -52,8 +_,25 @@ if (livingEntity.isAffectedByPotions()) { double d = aabb.distanceToSqr(livingEntity.getBoundingBox().inflate(f)); if (d < 16.0) { @@ -44,7 +44,7 @@ for (MobEffectInstance mobEffectInstance : allEffects) { Holder effect = mobEffectInstance.getEffect(); if (effect.value().isInstantenous()) { -@@ -63,7 +_,7 @@ +@@ -64,7 +_,7 @@ effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible() ); if (!mobEffectInstance1.endsWithin(20)) { @@ -53,7 +53,7 @@ } } } -@@ -71,5 +_,6 @@ +@@ -72,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 955181e9c8e4..b5e70b6efac7 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,7 +1,7 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java @@ -61,6 +_,12 @@ - import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; public class Raid { + // Paper start @@ -22,7 +22,7 @@ ) .apply(instance, Raid::new) ); -@@ -128,6 +_,7 @@ +@@ -127,6 +_,7 @@ this.center = center; this.numGroups = this.getNumGroups(difficulty); this.status = Raid.RaidStatus.ONGOING; @@ -30,7 +30,7 @@ } private Raid( -@@ -143,6 +_,7 @@ +@@ -142,6 +_,7 @@ Raid.RaidStatus status, BlockPos center, Set heroesOfTheVillage @@ -38,7 +38,7 @@ ) { this.started = started; this.active = active; -@@ -156,6 +_,7 @@ +@@ -155,6 +_,7 @@ this.numGroups = numGroups; this.status = status; this.heroesOfTheVillage.addAll(heroesOfTheVillage); @@ -46,7 +46,7 @@ } public boolean isOver() { -@@ -182,6 +_,12 @@ +@@ -181,6 +_,12 @@ return this.status == Raid.RaidStatus.LOSS; } @@ -59,7 +59,7 @@ public float getTotalHealth() { return this.totalHealth; } -@@ -268,6 +_,7 @@ +@@ -267,6 +_,7 @@ boolean flag = this.active; this.active = level.hasChunkAt(this.center); if (level.getDifficulty() == Difficulty.PEACEFUL) { @@ -67,7 +67,7 @@ this.stop(); return; } -@@ -287,13 +_,16 @@ +@@ -286,13 +_,16 @@ if (!level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.RaidStatus.LOSS; @@ -84,7 +84,7 @@ this.stop(); return; } -@@ -382,6 +_,7 @@ +@@ -381,6 +_,7 @@ } if (i > 5) { @@ -92,7 +92,7 @@ this.stop(); break; } -@@ -393,6 +_,7 @@ +@@ -392,6 +_,7 @@ } else { this.status = Raid.RaidStatus.VICTORY; @@ -100,7 +100,7 @@ for (UUID uuid : this.heroesOfTheVillage) { Entity entity = level.getEntity(uuid); if (entity instanceof LivingEntity livingEntity && !entity.isSpectator()) { -@@ -400,9 +_,11 @@ +@@ -399,9 +_,11 @@ if (livingEntity instanceof ServerPlayer serverPlayer) { serverPlayer.awardStat(Stats.RAID_WIN); CriteriaTriggers.RAID_WIN.trigger(serverPlayer); @@ -112,7 +112,7 @@ } } -@@ -410,6 +_,7 @@ +@@ -409,6 +_,7 @@ } else if (this.isOver()) { this.celebrationTicks++; if (this.celebrationTicks >= 600) { @@ -120,7 +120,7 @@ this.stop(); return; } -@@ -514,7 +_,7 @@ +@@ -513,7 +_,7 @@ private void spawnGroup(ServerLevel level, BlockPos pos) { boolean flag = false; @@ -129,7 +129,7 @@ this.totalHealth = 0.0F; DifficultyInstance currentDifficultyAt = level.getCurrentDifficultyAt(pos); boolean shouldSpawnBonusGroup = this.shouldSpawnBonusGroup(); -@@ -563,6 +_,7 @@ +@@ -562,6 +_,7 @@ this.groupsSpawned++; this.updateBossbar(); this.setDirty(level); @@ -137,7 +137,7 @@ } public void joinRaid(ServerLevel level, int wave, Raider raider, @Nullable BlockPos pos, boolean isRecruited) { -@@ -577,7 +_,7 @@ +@@ -576,7 +_,7 @@ raider.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null); raider.applyRaidBuffs(level, wave, false); raider.setOnGround(true); @@ -146,7 +146,7 @@ } } } -@@ -796,6 +_,12 @@ +@@ -793,6 +_,12 @@ public void addHeroOfTheVillage(Entity player) { this.heroesOfTheVillage.add(player.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 584017abc9a1..1d98a008dec0 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 -@@ -214,17 +_,24 @@ +@@ -212,17 +_,24 @@ if (this.hasActiveRaid() && !flag && ItemStack.matches(item, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) { @@ -26,7 +26,7 @@ this.getCurrentRaid().setLeader(this.getWave(), this); this.setPatrolLeader(true); } else { -@@ -298,7 +_,7 @@ +@@ -295,7 +_,7 @@ for (Raider raider : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { @@ -35,7 +35,7 @@ } } -@@ -309,7 +_,7 @@ +@@ -306,7 +_,7 @@ if (target != null) { for (Raider raider : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { @@ -44,11 +44,11 @@ raider.setAggressive(true); } -@@ -394,6 +_,7 @@ +@@ -389,6 +_,7 @@ } private boolean cannotPickUpBanner() { -+ if (!getServerLevel(this.mob).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING)) return true; // Paper - respect game and entity rules for picking up items ++ if (!getServerLevel(this.mob).getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING)) return true; // Paper - respect game and entity rules for picking up items if (!this.mob.hasActiveRaid()) { return true; } else if (this.mob.getCurrentRaid().isOver()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch index ec707b410408..0efe66607e7e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raids.java +++ b/net/minecraft/world/entity/raid/Raids.java -@@ -58,6 +_,7 @@ +@@ -59,6 +_,7 @@ private Raids(List raids, int nextId, int tick) { for (Raids.RaidWithId raidWithId : raids) { this.raidMap.put(raidWithId.id, raidWithId.raid); @@ -8,32 +8,32 @@ } this.nextId = nextId; -@@ -140,11 +_,23 @@ - } +@@ -137,11 +_,23 @@ + } - Raid raid = this.getOrCreateRaid(serverLevel, blockPos); -- if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -- this.raidMap.put(this.getUniqueId(), raid); -- } + Raid raid = this.getOrCreateRaid(serverLevel, blockPos); +- if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { +- this.raidMap.put(this.getUniqueId(), raid); +- } - -- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { -+ // CraftBukkit - moved down -+ // if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -+ // this.raidMap.put(this.getUniqueId(), raid); -+ // } +- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { ++ // CraftBukkit - moved down ++ // if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ // this.raidMap.put(this.getUniqueId(), raid); ++ // } + -+ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(serverLevel, raid, player)) { -+ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); -+ return null; -+ } ++ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(serverLevel, raid, player)) { ++ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); ++ return null; ++ } + -+ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { -+ this.raidMap.put(this.getUniqueId(), raid); -+ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal -+ } -+ // CraftBukkit end - raid.absorbRaidOmen(player); - } ++ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ this.raidMap.put(this.getUniqueId(), raid); ++ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal ++ } ++ // CraftBukkit end + raid.absorbRaidOmen(player); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index 1c884027739d..ceb95d1af909 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -60,12 +_,12 @@ +@@ -59,12 +_,12 @@ default void addChestVehicleSaveData(ValueOutput output) { if (this.getContainerLootTable() != null) { - output.putString("LootTable", this.getContainerLootTable().location().toString()); + output.putString("LootTable", this.getContainerLootTable().identifier().toString()); + this.lootableData().saveNbt(output); // Paper if (this.getContainerLootTableSeed() != 0L) { output.putLong("LootTableSeed", this.getContainerLootTableSeed()); @@ -15,7 +15,7 @@ } default void readChestVehicleSaveData(ValueInput input) { -@@ -73,7 +_,12 @@ +@@ -72,7 +_,12 @@ ResourceKey resourceKey = input.read("LootTable", LootTable.KEY_CODEC).orElse(null); this.setContainerLootTable(resourceKey); this.setContainerLootTableSeed(input.getLongOr("LootTableSeed", 0L)); @@ -29,7 +29,7 @@ ContainerHelper.loadAllItems(input, this.getItemStacks()); } } -@@ -89,19 +_,27 @@ +@@ -88,19 +_,27 @@ } default InteractionResult interactWithContainerVehicle(Player player) { @@ -60,9 +60,9 @@ LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); if (player != null) { builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -171,4 +_,14 @@ +@@ -170,4 +_,14 @@ default boolean isChestVehicleStillValid(Player player) { - return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0); + return !this.isRemoved() && player.isWithinEntityInteractionRange(this.getBoundingBox(), 4.0); } + + // Paper start - LootTable API diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch deleted file mode 100644 index 16dc59fd85db..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -+++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -@@ -128,7 +_,7 @@ - MinecartCommandBlock.this.position(), - MinecartCommandBlock.this.getRotationVector(), - this.getLevel(), -- 2, -+ this.getLevel().paperConfig().commandBlocks.permissionsLevel, // Paper - configurable command block perm level - this.getName().getString(), - MinecartCommandBlock.this.getDisplayName(), - this.getLevel().getServer(), -@@ -140,5 +_,12 @@ - public boolean isValid() { - return !MinecartCommandBlock.this.isRemoved(); - } -+ -+ // CraftBukkit start -+ @Override -+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return net.minecraft.world.entity.vehicle.MinecartCommandBlock.this.getBukkitEntity(); -+ } -+ // CraftBukkit end - } - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch similarity index 90% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch index 6339c7e7f016..c26b465f5514 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch @@ -1,7 +1,7 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractBoat.java -+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -78,6 +_,15 @@ - private Leashable.LeashData leashData; +--- a/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java +@@ -79,6 +_,15 @@ + private Leashable.@Nullable LeashData leashData; private final Supplier dropItem; + // CraftBukkit start @@ -16,7 +16,7 @@ public AbstractBoat(EntityType type, Level level, Supplier dropItem) { super(type, level); this.dropItem = dropItem; -@@ -119,7 +_,7 @@ +@@ -120,7 +_,7 @@ } @Override @@ -25,7 +25,7 @@ return true; } -@@ -174,11 +_,30 @@ +@@ -175,11 +_,30 @@ @Override public void push(Entity entity) { @@ -56,7 +56,7 @@ super.push(entity); } } -@@ -245,6 +_,18 @@ +@@ -246,6 +_,18 @@ this.setDeltaMovement(Vec3.ZERO); } @@ -75,7 +75,7 @@ this.applyEffectsFromBlocks(); this.applyEffectsFromBlocks(); this.tickBubbleColumn(); -@@ -547,7 +_,7 @@ +@@ -545,7 +_,7 @@ this.waterLevel = this.getY(1.0); double d2 = this.getWaterLevelAbove() - this.getBbHeight() + 0.101; if (this.level().noCollision(this, this.getBoundingBox().move(0.0, d2 - this.getY(), 0.0))) { @@ -84,12 +84,12 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0)); this.lastYd = 0.0; } -@@ -710,12 +_,12 @@ +@@ -708,12 +_,12 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide() && reason.shouldDestroy() && this.isLeashed()) { this.dropLeash(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch similarity index 86% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch index c4e49c5976af..fe519a27e621 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java.patch @@ -1,11 +1,11 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java -+++ b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java +--- a/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java ++++ b/net/minecraft/world/entity/vehicle/boat/AbstractChestBoat.java @@ -67,12 +_,12 @@ } @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide() && reason.shouldDestroy()) { Containers.dropContents(this.level(), this, this); } @@ -26,16 +26,16 @@ this.gameEvent(GameEvent.CONTAINER_OPEN, player); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -149,7 +_,7 @@ - @Nullable +@@ -148,7 +_,7 @@ + @Override - public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { + public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { - if (this.lootTable != null && player.isSpectator()) { + if (this.lootTable != null && player.isSpectator()) { // Paper - LootTable API (TODO spectators can open chests that aren't ready to be re-generated but this doesn't support that) return null; } else { this.unpackLootTable(playerInventory.player); -@@ -196,4 +_,58 @@ +@@ -194,4 +_,58 @@ public void stopOpen(ContainerUser user) { this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(user.getLivingEntity())); } @@ -73,7 +73,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + org.bukkit.entity.Entity entity = this.getBukkitEntity(); + return entity instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch index 23323b9b5ebe..3e918e368e71 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -93,6 +_,17 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java +@@ -96,6 +_,17 @@ } ) ); @@ -18,7 +18,7 @@ protected AbstractMinecart(EntityType type, Level level) { super(type, level); -@@ -152,11 +_,19 @@ +@@ -154,11 +_,19 @@ @Override public boolean canCollideWith(Entity entity) { @@ -40,7 +40,7 @@ return true; } -@@ -257,6 +_,14 @@ +@@ -259,6 +_,14 @@ @Override public void tick() { @@ -55,10 +55,10 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -266,8 +_,20 @@ - } +@@ -269,8 +_,20 @@ this.checkBelowWorld(); + this.computeSpeed(); - this.handlePortal(); + // this.handlePortal(); // CraftBukkit - handled in postTick this.behavior.tick(); @@ -77,7 +77,7 @@ this.updateInWaterStateAndDoFluidPushing(); if (this.isInLava()) { this.lavaIgnite(); -@@ -355,12 +_,16 @@ +@@ -358,12 +_,16 @@ Vec3 deltaMovement = this.getDeltaMovement(); this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed)); if (this.onGround()) { @@ -96,7 +96,7 @@ } } -@@ -462,6 +_,15 @@ +@@ -465,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 -@@ -474,13 +_,26 @@ +@@ -477,13 +_,26 @@ output.putBoolean("FlippedRotation", this.flipped); output.putBoolean("HasTicked", this.firstTick); @@ -139,7 +139,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; -@@ -589,4 +_,26 @@ +@@ -592,4 +_,26 @@ public boolean isFurnace() { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch similarity index 84% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch index 2499cc67a92e..aef9f3d9e99e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java.patch @@ -1,13 +1,12 @@ ---- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -22,10 +_,11 @@ - import net.minecraft.world.phys.Vec3; +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java +@@ -23,9 +_,10 @@ + import org.jspecify.annotations.Nullable; 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 - @Nullable - public ResourceKey lootTable; + public @Nullable ResourceKey lootTable; public long lootTableSeed; + private final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(); // Paper - LootTable API @@ -18,7 +17,7 @@ @Override - public void remove(Entity.RemovalReason reason) { -+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide() && reason.shouldDestroy()) { Containers.dropContents(this.level(), this, this); } @@ -28,7 +27,7 @@ } @Override -@@ -165,4 +_,56 @@ +@@ -163,4 +_,56 @@ public void clearItemStacks() { this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); } @@ -65,7 +64,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + return this.getBukkitEntity() instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch new file mode 100644 index 000000000000..0eaa33118f97 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartCommandBlock.java +@@ -84,7 +_,7 @@ + + @Override + public InteractionResult interact(Player player, InteractionHand hand) { +- if (!player.canUseGameMasterBlocks()) { ++ if (!player.canUseGameMasterBlocks() && (!player.isCreative() || !player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission + return InteractionResult.PASS; + } else { + if (player.level().isClientSide()) { +@@ -122,7 +_,7 @@ + MinecartCommandBlock.this.position(), + MinecartCommandBlock.this.getRotationVector(), + level, +- LevelBasedPermissionSet.GAMEMASTER, ++ LevelBasedPermissionSet.forLevel(net.minecraft.server.permissions.PermissionLevel.byId(level.paperConfig().commandBlocks.permissionsLevel)), // Paper - configurable command block perm level + this.getName().getString(), + MinecartCommandBlock.this.getDisplayName(), + level.getServer(), +@@ -134,5 +_,17 @@ + public boolean isValid() { + return !MinecartCommandBlock.this.isRemoved(); + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { ++ return net.minecraft.world.entity.vehicle.minecart.MinecartCommandBlock.this.getBukkitEntity(); ++ } ++ ++ @Override ++ public net.minecraft.server.level.ServerLevel getLevel() { ++ return (net.minecraft.server.level.ServerLevel) MinecartCommandBlock.this.level(); ++ } ++ // CraftBukkit end + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch similarity index 89% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java.patch index da13294e34b0..a0cc24069497 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/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/MinecartTNT.java -+++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java -@@ -40,6 +_,7 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartTNT.java +@@ -39,6 +_,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; public float explosionSpeedFactor = 1.0F; @@ -8,7 +8,7 @@ public MinecartTNT(EntityType type, Level level) { super(type, level); -@@ -54,6 +_,12 @@ +@@ -53,6 +_,12 @@ public void tick() { super.tick(); if (this.fuse > 0) { @@ -21,9 +21,9 @@ 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) { -@@ -105,6 +_,17 @@ +@@ -104,6 +_,17 @@ if (this.level() instanceof ServerLevel serverLevel) { - if (serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + if (serverLevel.getGameRules().get(GameRules.TNT_EXPLODES)) { double min = Math.min(Math.sqrt(radiusModifier), 5.0); + // CraftBukkit start + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent( @@ -39,7 +39,7 @@ serverLevel.explode( this, damageSource, -@@ -112,13 +_,13 @@ +@@ -111,13 +_,13 @@ this.getX(), this.getY(), this.getZ(), diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch index 6e71e7a03766..d07d507f6177 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java.patch @@ -1,5 +1,5 @@ ---- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java -+++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +--- a/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/minecart/NewMinecartBehavior.java @@ -479,6 +_,12 @@ @Override @@ -10,7 +10,7 @@ + return this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed; + } + // CraftBukkit end - return level.getGameRules().getInt(GameRules.RULE_MINECART_MAX_SPEED) * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; + return level.getGameRules().get(GameRules.MAX_MINECART_SPEED).intValue() * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; } @@ -494,7 +_,8 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch similarity index 93% rename from paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch index 71c314ca361f..e4369eabbed7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java -+++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java -@@ -378,8 +_,22 @@ +--- a/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/minecart/OldMinecartBehavior.java +@@ -376,8 +_,22 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -23,7 +23,7 @@ entity.push(this.minecart); } } -@@ -387,6 +_,12 @@ +@@ -385,6 +_,12 @@ } else { for (Entity entity1 : this.level().getEntities(this.minecart, aabb)) { if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof AbstractMinecart) { @@ -36,7 +36,7 @@ entity1.push(this.minecart); } } -@@ -409,11 +_,18 @@ +@@ -407,11 +_,18 @@ @Override public double getMaxSpeed(ServerLevel 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 04aec9b9faa4..4b595cfd1806 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 @@ -47,8 +47,8 @@ } } - boolean _boolean = serverLevel.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); - if (_boolean && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { + boolean flag = serverLevel.getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION); + if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { this.tickTimer++; - if (this.tickTimer >= 10) { + if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit @@ -60,7 +60,7 @@ + player.causeFoodExhaustion(min, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent this.tickTimer = 0; } - } else if (_boolean && this.foodLevel >= 18 && player.isHurt()) { + } else if (flag && this.foodLevel >= 18 && player.isHurt()) { this.tickTimer++; - if (this.tickTimer >= 80) { - player.heal(1.0F); 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 66bf34a8d618..dbc59efe855d 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 @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -65,6 +_,36 @@ - @Nullable - private ContainerSynchronizer synchronizer; +@@ -63,6 +_,35 @@ + private final List containerListeners = Lists.newArrayList(); + private @Nullable ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; + // CraftBukkit start + public boolean checkReachable = true; @@ -16,8 +16,7 @@ + ((org.bukkit.craftbukkit.inventory.CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player); + } + -+ @Nullable -+ private net.minecraft.network.chat.Component title; ++ private net.minecraft.network.chat.@Nullable Component title; + public final net.minecraft.network.chat.Component getTitle() { + // Paper start - return chat component with empty text instead of throwing error + if (this.title == null) { @@ -37,7 +36,7 @@ protected AbstractContainerMenu(@Nullable MenuType menuType, int containerId) { this.menuType = menuType; -@@ -176,8 +_,43 @@ +@@ -174,8 +_,43 @@ if (this.synchronizer != null) { this.synchronizer.sendInitialData(this, list, carried.copy(), this.remoteDataSlots.toIntArray()); @@ -83,7 +82,7 @@ public void removeSlotListener(ContainerListener listener) { this.containerListeners.remove(listener); -@@ -243,7 +_,7 @@ +@@ -241,7 +_,7 @@ this.lastSlots.set(slotIndex, itemStack1); for (ContainerListener containerListener : this.containerListeners) { @@ -92,7 +91,7 @@ } } } -@@ -351,6 +_,7 @@ +@@ -349,6 +_,7 @@ this.resetQuickCraft(); } } else if (this.quickcraftStatus == 1) { @@ -100,7 +99,7 @@ Slot slot = this.slots.get(slotIndex); ItemStack carried = this.getCarried(); if (canItemQuickReplace(slot, carried, true) -@@ -375,6 +_,7 @@ +@@ -373,6 +_,7 @@ } int count = this.getCarried().getCount(); @@ -108,7 +107,7 @@ for (Slot slot1 : this.quickcraftSlots) { ItemStack carried1 = this.getCarried(); -@@ -387,12 +_,46 @@ +@@ -385,12 +_,46 @@ int min = Math.min(itemStack.getMaxStackSize(), slot1.getMaxStackSize(itemStack)); int min1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemStack) + i2, min); count -= min1 - i2; @@ -161,7 +160,7 @@ } this.resetQuickCraft(); -@@ -406,8 +_,11 @@ +@@ -404,8 +_,11 @@ if (slotIndex == SLOT_CLICKED_OUTSIDE) { if (!this.getCarried().isEmpty()) { if (clickAction == ClickAction.PRIMARY) { @@ -174,7 +173,7 @@ } else { player.drop(this.getCarried().split(1), true); } -@@ -469,8 +_,18 @@ +@@ -467,8 +_,18 @@ } slot.setChanged(); @@ -193,7 +192,7 @@ ItemStack item = inventory.getItem(button); Slot slot = this.slots.get(slotIndex); ItemStack carried = slot.getItem(); -@@ -590,8 +_,9 @@ +@@ -588,8 +_,9 @@ if (player instanceof ServerPlayer) { ItemStack carried = this.getCarried(); if (!carried.isEmpty()) { @@ -204,7 +203,7 @@ } } } -@@ -637,6 +_,14 @@ +@@ -635,6 +_,14 @@ public abstract boolean stillValid(Player player); protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) { @@ -219,7 +218,7 @@ boolean flag = false; int i = startIndex; if (reverseDirection) { -@@ -647,18 +_,27 @@ +@@ -645,18 +_,27 @@ while (!stack.isEmpty() && (reverseDirection ? i >= startIndex : i < endIndex)) { Slot slot = this.slots.get(i); ItemStack item = slot.getItem(); @@ -247,7 +246,7 @@ flag = true; } } -@@ -681,10 +_,21 @@ +@@ -679,10 +_,21 @@ while (reverseDirection ? i >= startIndex : i < endIndex) { Slot slotx = this.slots.get(i); ItemStack itemx = slotx.getItem(); @@ -269,7 +268,7 @@ flag = true; break; } -@@ -768,6 +_,11 @@ +@@ -766,6 +_,11 @@ } public ItemStack getCarried() { @@ -281,7 +280,7 @@ return this.carried; } -@@ -820,4 +_,15 @@ +@@ -818,4 +_,15 @@ this.stateId = this.stateId + 1 & 32767; return this.stateId; } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch new file mode 100644 index 000000000000..55a058461158 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractMountInventoryMenu.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/world/inventory/AbstractMountInventoryMenu.java ++++ b/net/minecraft/world/inventory/AbstractMountInventoryMenu.java +@@ -9,13 +_,28 @@ + public abstract class AbstractMountInventoryMenu extends AbstractContainerMenu { + protected final Container mountContainer; + public final LivingEntity mount; +- public final int SLOT_SADDLE = 0; +- public final int SLOT_BODY_ARMOR = 1; +- public final int SLOT_INVENTORY_START = 2; ++ public static final int SLOT_SADDLE = 0; // Paper - fix missing static ++ public static final int SLOT_BODY_ARMOR = 1; // Paper - fix missing static ++ public static final int SLOT_INVENTORY_START = 2; // Paper - fix missing static + protected static final int INVENTORY_ROWS = 3; + ++ // CraftBukkit start ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view; ++ private final Inventory inventory; ++ ++ @Override ++ public org.bukkit.inventory.InventoryView getBukkitView() { ++ if (this.view != null) { ++ return this.view; ++ } ++ ++ return this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), this.mountContainer.getOwner().getInventory(), this); ++ } ++ // CraftBukkit end ++ + protected AbstractMountInventoryMenu(int containerId, Inventory playerInventory, Container mountContainer, LivingEntity mount) { + super(null, containerId); ++ this.inventory = playerInventory; // CraftBukkit + this.mountContainer = mountContainer; + this.mount = mount; + mountContainer.startOpen(playerInventory.player); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch index 184b89d203bd..73337324a4bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AnvilMenu.java +++ b/net/minecraft/world/inventory/AnvilMenu.java -@@ -46,6 +_,12 @@ +@@ -45,6 +_,12 @@ private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76; private static final int RESULT_SLOT_X_PLACEMENT = 134; private static final int SLOT_Y_PLACEMENT = 47; @@ -13,7 +13,7 @@ public AnvilMenu(int containerId, Inventory playerInventory) { this(containerId, playerInventory, ContainerLevelAccess.NULL); -@@ -71,7 +_,7 @@ +@@ -70,7 +_,7 @@ @Override protected boolean mayPickup(Player player, boolean hasStack) { @@ -22,7 +22,7 @@ } @Override -@@ -92,7 +_,7 @@ +@@ -91,7 +_,7 @@ this.inputSlots.setItem(1, ItemStack.EMPTY); } @@ -31,7 +31,7 @@ if (player instanceof ServerPlayer serverPlayer && !StringUtil.isBlank(this.itemName) && !this.inputSlots.getItem(0).getHoverName().getString().equals(this.itemName)) { -@@ -104,6 +_,16 @@ +@@ -103,6 +_,16 @@ BlockState blockState = level.getBlockState(blockPos); if (!player.hasInfiniteMaterials() && blockState.is(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) { BlockState blockState1 = AnvilBlock.damage(blockState); @@ -48,7 +48,7 @@ if (blockState1 == null) { level.removeBlock(blockPos, false); level.levelEvent(LevelEvent.SOUND_ANVIL_BROKEN, blockPos, 0); -@@ -136,8 +_,8 @@ +@@ -135,8 +_,8 @@ if (itemStack.isDamageableItem() && item.isValidRepairItem(item1)) { int min = Math.min(itemStack.getDamageValue(), itemStack.getMaxDamage() / 4); if (min <= 0) { @@ -59,7 +59,7 @@ return; } -@@ -152,8 +_,8 @@ +@@ -151,8 +_,8 @@ this.repairItemCountCost = i2; } else { if (!hasStoredEnchantments && (!itemStack.is(item1.getItem()) || !itemStack.isDamageableItem())) { @@ -70,7 +70,7 @@ return; } -@@ -199,7 +_,7 @@ +@@ -198,7 +_,7 @@ flag1 = true; } else { flag = true; @@ -79,7 +79,7 @@ intValue = enchantment.getMaxLevel(); } -@@ -217,8 +_,8 @@ +@@ -216,8 +_,8 @@ } if (flag1 && !flag) { @@ -90,7 +90,7 @@ return; } } -@@ -243,14 +_,16 @@ +@@ -242,14 +_,16 @@ } if (i1 == i && i1 > 0) { @@ -110,7 +110,7 @@ itemStack = ItemStack.EMPTY; } -@@ -268,12 +_,13 @@ +@@ -267,12 +_,13 @@ EnchantmentHelper.setEnchantments(itemStack, mutable.toImmutable()); } @@ -127,7 +127,7 @@ } public static int calculateIncreasedRepairCost(int oldRepairCost) { -@@ -294,6 +_,7 @@ +@@ -293,6 +_,7 @@ } this.createResult(); @@ -135,7 +135,7 @@ return true; } else { return false; -@@ -309,4 +_,19 @@ +@@ -307,4 +_,19 @@ public int getCost() { return this.cost.get(); } 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 76af523d8930..65870483569e 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 @@ -21,7 +21,7 @@ private final ContainerLevelAccess access; private final ContainerData beaconData; + // CraftBukkit start -+ private @Nullable org.bukkit.craftbukkit.inventory.view.CraftBeaconView view = null; ++ private org.bukkit.craftbukkit.inventory.view.@Nullable CraftBeaconView view = null; + private final net.minecraft.world.entity.player.Inventory inventory; + // CraftBukkit end @@ -61,12 +61,12 @@ return stillValid(this.access, player, Blocks.BEACON); } -@@ -141,13 +_,30 @@ - public Holder getSecondaryEffect() { +@@ -138,13 +_,30 @@ + public @Nullable Holder getSecondaryEffect() { return decodeEffect(this.beaconData.get(2)); } + // Paper start - Add PlayerChangeBeaconEffectEvent -+ private static @Nullable org.bukkit.potion.PotionEffectType convert(Optional> optionalEffect) { ++ private static org.bukkit.potion.@Nullable PotionEffectType convert(Optional> optionalEffect) { + return optionalEffect.map(org.bukkit.craftbukkit.potion.CraftPotionEffectType::minecraftHolderToBukkit).orElse(null); + } + // Paper end - Add PlayerChangeBeaconEffectEvent @@ -94,7 +94,7 @@ } } -@@ -170,4 +_,17 @@ +@@ -167,4 +_,17 @@ return 1; } } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch index 50d426ca17ba..c2af45981276 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch @@ -4,7 +4,7 @@ public final ContainerLevelAccess access; private final Player player; private boolean placingRecipe; -+ private @Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; // CraftBukkit ++ private org.bukkit.craftbukkit.inventory.@Nullable CraftInventoryView view = null; // CraftBukkit public CraftingMenu(int containerId, Inventory playerInventory) { this(containerId, playerInventory, ContainerLevelAccess.NULL); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 239c786ecddb..0a8bd3647751 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -3,7 +3,7 @@ @@ -31,19 +_,17 @@ public class EnchantmentMenu extends AbstractContainerMenu { - static final ResourceLocation EMPTY_SLOT_LAPIS_LAZULI = ResourceLocation.withDefaultNamespace("container/slot/lapis_lazuli"); + static final Identifier EMPTY_SLOT_LAPIS_LAZULI = Identifier.withDefaultNamespace("container/slot/lapis_lazuli"); - private final Container enchantSlots = new SimpleContainer(2) { - @Override - public void setChanged() { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch deleted file mode 100644 index 1526896b913f..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/inventory/HorseInventoryMenu.java -+++ b/net/minecraft/world/inventory/HorseInventoryMenu.java -@@ -19,9 +_,23 @@ - public static final int SLOT_SADDLE = 0; - public static final int SLOT_BODY_ARMOR = 1; - public static final int SLOT_HORSE_INVENTORY_START = 2; -+ // CraftBukkit start -+ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view; -+ private final Inventory inventory; -+ -+ @Override -+ public org.bukkit.inventory.InventoryView getBukkitView() { -+ if (this.view != null) { -+ return this.view; -+ } -+ -+ return this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), this.horseContainer.getOwner().getInventory(), this); -+ } -+ // CraftBukkit end - - public HorseInventoryMenu(int containerId, Inventory inventory, Container horseContainer, final AbstractHorse horse, int columns) { - super(null, containerId); -+ this.inventory = inventory; // CraftBukkit - this.horseContainer = horseContainer; - this.horse = horse; - horseContainer.startOpen(inventory.player); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch index 313f84934b73..942a38db2986 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ItemCombinerMenu.java.patch @@ -51,6 +51,6 @@ @Override public boolean stillValid(Player player) { + if (!this.checkReachable) return true; // CraftBukkit - return this.access.evaluate((level, pos) -> !this.isValidBlock(level.getBlockState(pos)) ? false : player.canInteractWithBlock(pos, 4.0), true); + return this.access + .evaluate((level, pos) -> !this.isValidBlock(level.getBlockState(pos)) ? false : player.isWithinBlockInteractionRange(pos, 4.0), true); } - diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch index 31a0a81d1c5e..043e9ad15879 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/MerchantContainer.java +++ b/net/minecraft/world/inventory/MerchantContainer.java -@@ -17,6 +_,45 @@ - private MerchantOffer activeOffer; +@@ -16,6 +_,45 @@ + private @Nullable MerchantOffer activeOffer; public int selectionHint; private int futureXp; + // CraftBukkit start - add fields and methods @@ -35,12 +35,12 @@ + } + + public @javax.annotation.Nullable org.bukkit.inventory.InventoryHolder getOwner() { -+ return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? (org.bukkit.craftbukkit.entity.CraftAbstractVillager) abstractVillager.getBukkitEntity() : null; ++ return (this.merchant instanceof net.minecraft.world.entity.npc.villager.AbstractVillager abstractVillager) ? (org.bukkit.craftbukkit.entity.CraftAbstractVillager) abstractVillager.getBukkitEntity() : null; + } + + @Override + public @javax.annotation.Nullable org.bukkit.Location getLocation() { -+ return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? abstractVillager.getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations ++ return (this.merchant instanceof net.minecraft.world.entity.npc.villager.AbstractVillager abstractVillager) ? abstractVillager.getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch index 17cd510f9084..9b233499d30a 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch @@ -10,7 +10,7 @@ + // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent + io.papermc.paper.event.player.PlayerPurchaseEvent event = null; + if (activeOffer != null && player instanceof net.minecraft.server.level.ServerPlayer serverPlayer) { -+ if (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) { ++ if (this.merchant instanceof net.minecraft.world.entity.npc.villager.AbstractVillager abstractVillager) { + event = new io.papermc.paper.event.player.PlayerTradeEvent(serverPlayer.getBukkitEntity(), (org.bukkit.entity.AbstractVillager) abstractVillager.getBukkitEntity(), activeOffer.asBukkit(), true, true); + } else if (this.merchant instanceof org.bukkit.craftbukkit.inventory.CraftMerchantCustom.MinecraftMerchant) { + event = new io.papermc.paper.event.player.PlayerPurchaseEvent(serverPlayer.getBukkitEntity(), activeOffer.asBukkit(), false, true); @@ -19,7 +19,7 @@ + if (!event.callEvent()) { + stack.setCount(0); + player.containerMenu.sendAllDataToRemote(); -+ int level = merchant instanceof net.minecraft.world.entity.npc.Villager villager ? villager.getVillagerData().level() : 1; ++ int level = merchant instanceof net.minecraft.world.entity.npc.villager.Villager villager ? villager.getVillagerData().level() : 1; + serverPlayer.sendMerchantOffers(player.containerMenu.containerId, merchant.getOffers(), level, merchant.getVillagerXp(), merchant.showProgressBar(), merchant.canRestock()); + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch index 9db2a512bf94..e41f6d341dc6 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java +++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java -@@ -13,9 +_,23 @@ +@@ -12,9 +_,23 @@ + public class PlayerEnderChestContainer extends SimpleContainer { - @Nullable - private EnderChestBlockEntity activeChest; + private @Nullable EnderChestBlockEntity activeChest; - - public PlayerEnderChestContainer() { + // CraftBukkit start @@ -15,7 +15,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + return this.activeChest != null ? org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.activeChest.getBlockPos(), this.activeChest.getLevel()) : null; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch index b3efe5e40d7e..36e9f3a8cff2 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/inventory/ResultContainer.java +++ b/net/minecraft/world/inventory/ResultContainer.java -@@ -12,6 +_,55 @@ +@@ -11,6 +_,55 @@ + public class ResultContainer implements Container, RecipeCraftingHolder { private final NonNullList itemStacks = NonNullList.withSize(1, ItemStack.EMPTY); - @Nullable - private RecipeHolder recipeUsed; + private @Nullable RecipeHolder recipeUsed; + // CraftBukkit start + private int maxStack = MAX_STACK; + @@ -13,7 +13,7 @@ + } + + @Override -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + // Paper start - Add missing InventoryHolders + if (this.holder == null && this.holderCreator != null) { + this.holder = this.holderCreator.get(); @@ -39,13 +39,13 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + return null; + } + // CraftBukkit end + // Paper start - Add missing InventoryHolders -+ private @Nullable java.util.function.Supplier holderCreator; -+ private @Nullable org.bukkit.inventory.InventoryHolder holder; ++ private java.util.function.@Nullable Supplier holderCreator; ++ private org.bukkit.inventory.@Nullable InventoryHolder holder; + public ResultContainer(java.util.function.Supplier holderCreator) { + this.holderCreator = holderCreator; + } 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 185263b89d9c..f0262737cac7 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 @@ -101,10 +101,10 @@ + return false; + } + -+ net.minecraft.resources.ResourceLocation key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()); -+ if (!recipe.get().id().location().equals(key)) { // If the recipe did NOT stay the same ++ net.minecraft.resources.Identifier key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()); ++ if (!recipe.get().id().identifier().equals(key)) { // If the recipe did NOT stay the same + for (int newRecipeIndex = 0; newRecipeIndex < this.recipesForInput.entries().size(); newRecipeIndex++) { -+ if (this.recipesForInput.entries().get(newRecipeIndex).recipe().recipe().filter(r -> r.id().location().equals(key)).isPresent()) { ++ if (this.recipesForInput.entries().get(newRecipeIndex).recipe().recipe().filter(r -> r.id().identifier().equals(key)).isPresent()) { + recipeIndex = newRecipeIndex; + break; + } 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 d32f30a99646..52cf1527e917 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -56,6 +_,14 @@ +@@ -57,6 +_,14 @@ return InteractionResult.FAIL; } else { BlockState placementState = this.getPlacementState(blockPlaceContext); @@ -15,7 +15,7 @@ if (placementState == null) { return InteractionResult.FAIL; } else if (!this.placeBlock(blockPlaceContext, placementState)) { -@@ -68,15 +_,39 @@ +@@ -69,15 +_,39 @@ BlockState blockState = level.getBlockState(clickedPos); if (blockState.is(placementState.getBlock())) { blockState = this.updateBlockStateFromTag(clickedPos, level, itemInHand, blockState); @@ -55,7 +55,7 @@ level.playSound( player, clickedPos, -@@ -87,7 +_,7 @@ +@@ -88,7 +_,7 @@ ); level.gameEvent(GameEvent.BLOCK_PLACE, clickedPos, GameEvent.Context.of(player, blockState)); itemInHand.consume(1, player); @@ -64,7 +64,7 @@ } } } -@@ -136,8 +_,19 @@ +@@ -135,8 +_,19 @@ protected boolean canPlace(BlockPlaceContext context, BlockState state) { Player player = context.getPlayer(); @@ -86,7 +86,7 @@ } protected boolean mustSurvive() { -@@ -161,7 +_,7 @@ +@@ -160,7 +_,7 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch index a286e29b55e2..71411b0ac61e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BoneMealItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BoneMealItem.java +++ b/net/minecraft/world/item/BoneMealItem.java -@@ -35,12 +_,17 @@ +@@ -35,13 +_,18 @@ @Override public InteractionResult useOn(UseOnContext context) { @@ -12,19 +12,20 @@ Level level = context.getLevel(); BlockPos clickedPos = context.getClickedPos(); BlockPos blockPos = clickedPos.relative(context.getClickedFace()); - if (growCrop(context.getItemInHand(), level, clickedPos)) { + ItemStack itemInHand = context.getItemInHand(); + if (growCrop(itemInHand, level, clickedPos)) { if (!level.isClientSide()) { -- context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); -+ if (context.getPlayer() != null) context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 +- itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); ++ if (context.getPlayer() != null) itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, clickedPos, 15); } -@@ -50,7 +_,7 @@ +@@ -51,7 +_,7 @@ boolean isFaceSturdy = blockState.isFaceSturdy(level, clickedPos, context.getClickedFace()); - if (isFaceSturdy && growWaterPlant(context.getItemInHand(), level, blockPos, context.getClickedFace())) { + if (isFaceSturdy && growWaterPlant(itemInHand, level, blockPos, context.getClickedFace())) { if (!level.isClientSide()) { -- context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); -+ if (context.getPlayer() != null) context.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 +- itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); ++ if (context.getPlayer() != null) itemInHand.causeUseVibration(context.getPlayer(), GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, blockPos, 15); } 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 037a3a22ac8f..534428c9d894 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 @@ -1,14 +1,14 @@ --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java -@@ -30,6 +_,7 @@ - import net.minecraft.world.phys.HitResult; +@@ -31,6 +_,7 @@ + import org.jspecify.annotations.Nullable; public class BucketItem extends Item implements DispensibleContainerItem { + private static @Nullable ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper - Fix PlayerBucketEmptyEvent result itemstack public final Fluid content; public BucketItem(Fluid content, Item.Properties properties) { -@@ -56,12 +_,22 @@ +@@ -57,12 +_,22 @@ } else if (this.content == Fluids.EMPTY) { BlockState blockState = level.getBlockState(blockPos); if (blockState.getBlock() instanceof BucketPickup bucketPickup) { @@ -32,7 +32,7 @@ if (!level.isClientSide()) { CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, itemStack); } -@@ -74,7 +_,7 @@ +@@ -75,7 +_,7 @@ } else { BlockState blockState = level.getBlockState(blockPos); BlockPos blockPos2 = blockState.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockPos : blockPos1; @@ -41,7 +41,7 @@ this.checkExtraContent(player, level, itemInHand, blockPos2); if (player instanceof ServerPlayer) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, blockPos2, itemInHand); -@@ -91,6 +_,13 @@ +@@ -92,6 +_,13 @@ } public static ItemStack getEmptySuccessItem(ItemStack bucketStack, Player player) { @@ -55,7 +55,7 @@ return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : bucketStack; } -@@ -100,6 +_,12 @@ +@@ -101,6 +_,12 @@ @Override public boolean emptyContents(@Nullable LivingEntity entity, Level level, BlockPos pos, @Nullable BlockHitResult hitResult) { @@ -68,7 +68,7 @@ if (!(this.content instanceof FlowingFluid flowingFluid)) { return false; } else { -@@ -111,8 +_,18 @@ +@@ -112,8 +_,18 @@ || block instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(entity, level, pos, blockState, this.content); boolean flag2 = blockState.isAir() || flag1 && (!flag || hitResult == null); @@ -85,6 +85,6 @@ if (!flag2) { - return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null); + return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemstack, hand); // CraftBukkit - } else if (level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { + } else if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) && this.content.is(FluidTags.WATER)) { int x = pos.getX(); int y = pos.getY(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch index b797b0751900..b36d81a0e594 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch @@ -27,7 +27,7 @@ + double deltaZ = soundPos.getZ() - player.getZ(); + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; + final double soundRadiusSquared = serverLevel.getGlobalSoundRangeSquared(config -> config.endPortalSoundRadius); // Paper - respect global sound events gamerule -+ if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule ++ if (!serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule + if (distanceSquared > viewDistance * viewDistance) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch index 7d07004bad81..0ea5aed2bbc2 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FireChargeItem.java +++ b/net/minecraft/world/item/FireChargeItem.java -@@ -35,12 +_,28 @@ +@@ -36,12 +_,28 @@ if (!CampfireBlock.canLight(blockState) && !CandleBlock.canLight(blockState) && !CandleCakeBlock.canLight(blockState)) { clickedPos = clickedPos.relative(context.getClickedFace()); if (BaseFireBlock.canBePlacedAt(level, clickedPos, context.getHorizontalDirection())) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch index f767729f2db9..803d94ec2889 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FireworkRocketItem.java +++ b/net/minecraft/world/item/FireworkRocketItem.java -@@ -35,7 +_,7 @@ +@@ -36,7 +_,7 @@ ItemStack itemInHand = context.getItemInHand(); Vec3 clickLocation = context.getClickLocation(); Direction clickedFace = context.getClickedFace(); @@ -9,7 +9,7 @@ new FireworkRocketEntity( level, context.getPlayer(), -@@ -45,9 +_,14 @@ +@@ -46,9 +_,14 @@ itemInHand ), serverLevel, @@ -26,7 +26,7 @@ } return InteractionResult.SUCCESS; -@@ -59,13 +_,24 @@ +@@ -60,13 +_,24 @@ if (player.isFallFlying()) { ItemStack itemInHand = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch index 201431097b2a..16bc842d8e84 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch @@ -11,7 +11,7 @@ @@ -39,20 +_,31 @@ ); - player.gameEvent(GameEvent.ITEM_INTERACT_FINISH); + itemInHand.causeUseVibration(player, GameEvent.ITEM_INTERACT_FINISH); } else { - level.playSound( - null, 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 5c696fc98097..1710d50a1cac 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 -@@ -92,6 +_,14 @@ +@@ -146,6 +_,14 @@ return getWaxed(blockState).map(blockState1 -> { Player player = context.getPlayer(); ItemStack itemInHand = context.getItemInHand(); 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 4b0f5b28976f..902edf377e51 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 @@ -3,12 +3,12 @@ @@ -56,6 +_,13 @@ } - public void addCooldown(ResourceLocation group, int cooldown) { + public void addCooldown(Identifier group, int cooldown) { + // Paper start - Item cooldown events + this.addCooldown(group, cooldown, true); + } + -+ public void addCooldown(ResourceLocation group, int cooldown, boolean callEvent) { ++ public void addCooldown(Identifier group, int cooldown, boolean callEvent) { + // Event called in server override + // Paper end - Item cooldown events this.cooldowns.put(group, new ItemCooldowns.CooldownInstance(this.tickCount, this.tickCount + cooldown)); 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 a58ba461cc28..45bed600d1d6 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 -@@ -197,12 +_,20 @@ +@@ -202,12 +_,20 @@ @Override public void encode(RegistryFriendlyByteBuf buffer, ItemStack value) { @@ -23,7 +23,7 @@ } } }; -@@ -366,10 +_,166 @@ +@@ -371,10 +_,166 @@ return InteractionResult.PASS; } else { Item item = this.getItem(); @@ -192,7 +192,7 @@ return interactionResult; } -@@ -450,31 +_,67 @@ +@@ -455,31 +_,67 @@ return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -268,7 +268,7 @@ this.shrink(1); onBreak.accept(item); } -@@ -487,7 +_,26 @@ +@@ -492,7 +_,26 @@ return; } @@ -296,7 +296,7 @@ this.applyDamage(min, serverPlayer, item -> {}); } } -@@ -497,9 +_,14 @@ +@@ -502,9 +_,14 @@ } public void hurtAndBreak(int amount, LivingEntity entity, EquipmentSlot slot) { @@ -312,7 +312,7 @@ ); } } -@@ -713,6 +_,12 @@ +@@ -753,6 +_,12 @@ return this.getItem().useOnRelease(this); } @@ -322,10 +322,10 @@ + } + // CraftBukkit end + - @Nullable - public T set(DataComponentType component, @Nullable T value) { + public @Nullable T set(DataComponentType component, @Nullable T value) { return this.components.set(component, value); -@@ -761,6 +_,28 @@ + } +@@ -796,6 +_,28 @@ this.components.setAll(components); } @@ -342,7 +342,7 @@ + return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(itemstack); + } + -+ private @Nullable org.bukkit.craftbukkit.inventory.CraftItemStack bukkitStack; ++ private org.bukkit.craftbukkit.inventory.@Nullable CraftItemStack bukkitStack; + public org.bukkit.inventory.ItemStack getBukkitStack() { + if (this.bukkitStack == null || this.bukkitStack.handle != this) { + this.bukkitStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this); @@ -354,7 +354,7 @@ public Component getHoverName() { Component customName = this.getCustomName(); return customName != null ? customName : this.getItemName(); -@@ -990,6 +_,19 @@ +@@ -1026,6 +_,19 @@ EnchantmentHelper.forEachModifier(this, slot, action); } @@ -374,7 +374,7 @@ public Component getDisplayName() { MutableComponent mutableComponent = Component.empty().append(this.getHoverName()); if (this.has(DataComponents.CUSTOM_NAME)) { -@@ -1045,7 +_,7 @@ +@@ -1085,7 +_,7 @@ } public void consume(int amount, @Nullable LivingEntity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch index 1cdcd7b2ee57..5d1dddfbae69 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MaceItem.java +++ b/net/minecraft/world/item/MaceItem.java -@@ -53,7 +_,13 @@ +@@ -54,7 +_,13 @@ @Override public void hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) { @@ -15,7 +15,7 @@ ServerLevel serverLevel = (ServerLevel)attacker.level(); attacker.setDeltaMovement(attacker.getDeltaMovement().with(Direction.Axis.Y, 0.01F)); if (attacker instanceof ServerPlayer serverPlayer) { -@@ -128,7 +_,7 @@ +@@ -129,7 +_,7 @@ double knockbackPower = getKnockbackPower(attacker, livingEntity, vec3); Vec3 vec31 = vec3.normalize().scale(knockbackPower); if (knockbackPower > 0.0) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch index 0d250525f064..07a53be2f8aa 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MapItem.java +++ b/net/minecraft/world/item/MapItem.java -@@ -97,8 +_,8 @@ +@@ -95,8 +_,8 @@ int i9 = (i1 / i + i6 - 64) * i; int i10 = (i2 / i + i7 - 64) * i; Multiset multiset = LinkedHashMultiset.create(); @@ -11,7 +11,7 @@ int i11 = 0; double d1 = 0.0; if (level.dimensionType().hasCeiling()) { -@@ -205,7 +_,7 @@ +@@ -203,7 +_,7 @@ for (int i5 = 0; i5 < 128; i5++) { for (int i6 = 0; i6 < 128; i6++) { 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 bbc0b10653c8..3f975521c9f1 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 @@ -5,7 +5,7 @@ } + // Paper start - Add PlayerItemCooldownEvent -+ private int getCurrentCooldown(final ResourceLocation groupId) { ++ private int getCurrentCooldown(final Identifier groupId) { + final net.minecraft.world.item.ItemCooldowns.CooldownInstance cooldownInstance = this.cooldowns.get(groupId); + if (cooldownInstance == null) { + return 0; @@ -15,7 +15,7 @@ + + @Override + public void addCooldown(ItemStack item, int duration) { -+ final ResourceLocation cooldownGroup = this.getCooldownGroup(item); ++ final Identifier cooldownGroup = this.getCooldownGroup(item); + final io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent( + this.player.getBukkitEntity(), + org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(item.getItem()), @@ -30,7 +30,7 @@ + } + + @Override -+ public void addCooldown(ResourceLocation groupId, int duration, boolean callEvent) { ++ public void addCooldown(Identifier groupId, int duration, boolean callEvent) { + if (callEvent) { + final io.papermc.paper.event.player.PlayerItemGroupCooldownEvent event = new io.papermc.paper.event.player.PlayerItemGroupCooldownEvent( + this.player.getBukkitEntity(), @@ -49,5 +49,5 @@ + // Paper end - Add PlayerItemCooldownEvent + @Override - protected void onCooldownStarted(ResourceLocation group, int cooldown) { + protected void onCooldownStarted(Identifier group, int cooldown) { super.onCooldownStarted(group, cooldown); 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 fe3d4a6926e6..eb805f28709f 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,7 +1,7 @@ --- a/net/minecraft/world/item/SignItem.java +++ b/net/minecraft/world/item/SignItem.java @@ -11,6 +_,7 @@ - import net.minecraft.world.level.block.state.BlockState; + import org.jspecify.annotations.Nullable; public class SignItem extends StandingAndWallBlockItem { + public static BlockPos openSign; // CraftBukkit 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 386b72059b57..9ce8994289c2 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,6 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -68,6 +_,7 @@ +@@ -69,6 +_,7 @@ return InteractionResult.FAIL; } else { @@ -8,7 +8,7 @@ spawner.setEntityId(type, level.getRandom()); level.sendBlockUpdated(clickedPos, blockState, blockState, Block.UPDATE_ALL); level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, clickedPos); -@@ -95,7 +_,7 @@ +@@ -96,7 +_,7 @@ EntityType type = this.getType(stack); if (type == null) { return InteractionResult.FAIL; @@ -17,7 +17,7 @@ return InteractionResult.FAIL; } else { if (type.spawn((ServerLevel)level, stack, owner, pos, EntitySpawnReason.SPAWN_ITEM_USE, shouldOffsetY, shouldOffsetYMore) != null) { -@@ -179,7 +_,7 @@ +@@ -178,7 +_,7 @@ } else { breedOffspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); breedOffspring.applyComponentsFromItemStack(stack); diff --git a/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch index e99c04062a99..90f8211a9a80 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -42,7 +_,20 @@ +@@ -41,7 +_,20 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch index 0f46433c55fa..ad11eafc3829 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/WindChargeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/WindChargeItem.java +++ b/net/minecraft/world/item/WindChargeItem.java -@@ -27,7 +_,7 @@ +@@ -28,7 +_,7 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { @@ -9,7 +9,7 @@ (level1, owner, spawnedFrom) -> new WindCharge(player, level, player.position().x(), player.getEyePosition().y(), player.position().z()), serverLevel, itemInHand, -@@ -36,6 +_,22 @@ +@@ -37,6 +_,22 @@ PROJECTILE_SHOOT_POWER, 1.0F ); @@ -32,7 +32,7 @@ } level.playSound( -@@ -48,8 +_,7 @@ +@@ -49,8 +_,7 @@ 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) ); diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch index 164cb696762c..cf02814d415d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/TypedEntityData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/TypedEntityData.java +++ b/net/minecraft/world/item/component/TypedEntityData.java -@@ -78,6 +_,32 @@ +@@ -84,6 +_,32 @@ this.tag = stripId(tag); } @@ -33,7 +33,7 @@ public static TypedEntityData of(T type, CompoundTag tag) { return new TypedEntityData<>(type, tag); } -@@ -175,7 +_,7 @@ +@@ -181,7 +_,7 @@ public void addToTooltip(Item.TooltipContext context, Consumer tooltipAdder, TooltipFlag flag, DataComponentGetter componentGetter) { if (this.type.getClass() == EntityType.class) { EntityType entityType = (EntityType)this.type; diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch index 5b01096247ed..b8d4d0c85d0e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/WrittenBookContent.java +++ b/net/minecraft/world/item/component/WrittenBookContent.java -@@ -94,7 +_,7 @@ +@@ -93,7 +_,7 @@ public static boolean resolveForItem(ItemStack stack, CommandSourceStack source, @Nullable Player player) { WrittenBookContent writtenBookContent = stack.get(DataComponents.WRITTEN_BOOK_CONTENT); diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch index 538297e2aa92..a62881aad338 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch @@ -6,7 +6,7 @@ + // CraftBukkit start + public final org.bukkit.inventory.Recipe toBukkitRecipe() { -+ return this.value.toBukkitRecipe(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.id.location())); ++ return this.value.toBukkitRecipe(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.id.identifier())); + } + // CraftBukkit end + diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch index 723d1f665ff5..31ec46f411c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -39,7 +39,7 @@ } public Optional> byKey(ResourceKey> key) { -@@ -200,6 +_,22 @@ +@@ -198,6 +_,22 @@ Recipe recipe1 = Recipe.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json).getOrThrow(JsonParseException::new); return new RecipeHolder<>(recipe, recipe1); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch index 18e1fb071816..075f7f7cf2af 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -103,6 +_,68 @@ +@@ -102,6 +_,68 @@ ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index e13cbaac8ec6..be840f254289 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -31,6 +_,21 @@ +@@ -30,6 +_,21 @@ this.ingredients = ingredients; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch index 699390e1e937..4058cfeaa29d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -21,8 +_,15 @@ +@@ -20,8 +_,15 @@ + final Optional addition; final TransmuteResult result; - @Nullable - private PlacementInfo placementInfo; + private @Nullable PlacementInfo placementInfo; + final boolean copyDataComponents; // Paper - Option to prevent data components copy public SmithingTransformRecipe(Optional template, Ingredient base, Optional addition, TransmuteResult result) { @@ -16,7 +16,7 @@ this.template = template; this.base = base; this.addition = addition; -@@ -31,7 +_,7 @@ +@@ -30,7 +_,7 @@ @Override public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { @@ -25,7 +25,7 @@ } @Override -@@ -75,6 +_,17 @@ +@@ -74,6 +_,17 @@ ) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch index 7b1e17dcae44..b71e1693cffa 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -28,8 +_,15 @@ +@@ -27,8 +_,15 @@ + final Ingredient addition; final Holder pattern; - @Nullable - private PlacementInfo placementInfo; + private @Nullable PlacementInfo placementInfo; + final boolean copyDataComponents; // Paper - Option to prevent data components copy public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, Holder pattern) { @@ -16,7 +16,7 @@ this.template = template; this.base = base; this.addition = addition; -@@ -38,10 +_,15 @@ +@@ -37,10 +_,15 @@ @Override public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { @@ -33,7 +33,7 @@ Optional> fromIngredient = TrimMaterials.getFromIngredient(registries, addition); if (fromIngredient.isPresent()) { ArmorTrim armorTrim = base.get(DataComponents.TRIM); -@@ -49,7 +_,7 @@ +@@ -48,7 +_,7 @@ if (Objects.equals(armorTrim, armorTrim1)) { return ItemStack.EMPTY; } else { @@ -42,7 +42,7 @@ itemStack.set(DataComponents.TRIM, armorTrim1); return itemStack; } -@@ -102,6 +_,13 @@ +@@ -101,6 +_,13 @@ ) ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch index 53a594391013..742d7149df35 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/TransmuteRecipe.java +++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java -@@ -85,6 +_,13 @@ +@@ -84,6 +_,13 @@ ); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch index d0e55ad13b41..69112ac4b10c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/enchantment/ItemEnchantments.java +++ b/net/minecraft/world/item/enchantment/ItemEnchantments.java @@ -28,21 +_,24 @@ - import net.minecraft.world.item.component.TooltipProvider; + import org.jspecify.annotations.Nullable; public class ItemEnchantments implements TooltipProvider { - public static final ItemEnchantments EMPTY = new ItemEnchantments(new Object2IntOpenHashMap<>()); @@ -13,7 +13,7 @@ public static final Codec CODEC = Codec.unboundedMap(Enchantment.CODEC, LEVEL_CODEC) .xmap( - map -> new ItemEnchantments(new Object2IntOpenHashMap<>((Map, ? extends Integer>)map)), -+ map -> new net.minecraft.world.item.enchantment.ItemEnchantments(net.minecraft.Util.make(new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER), m -> m.putAll(map))), // Paper - sort enchantments ++ map -> new net.minecraft.world.item.enchantment.ItemEnchantments(net.minecraft.util.Util.make(new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER), m -> m.putAll(map))), // Paper - sort enchantments itemEnchantments -> itemEnchantments.enchantments ); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java.patch new file mode 100644 index 000000000000..6c7e2f12762e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java ++++ b/net/minecraft/world/item/enchantment/effects/ApplyExhaustion.java +@@ -17,7 +_,7 @@ + @Override + public void apply(ServerLevel level, int enchantmentLevel, EnchantedItemInUse item, Entity entity, Vec3 origin) { + if (entity instanceof Player player) { +- player.causeFoodExhaustion(this.amount.calculate(enchantmentLevel)); ++ player.causeFoodExhaustion(this.amount.calculate(enchantmentLevel), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ENCHANTMENT_EFFECT); // Paper - add ExhaustionReason + } + } + diff --git a/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch b/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch index 9a3b747befa4..4e3a8a135e4c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/trading/Merchant.java +++ b/net/minecraft/world/item/trading/Merchant.java -@@ -19,6 +_,8 @@ +@@ -18,6 +_,8 @@ void overrideOffers(MerchantOffers offers); -+ default void processTrade(MerchantOffer offer, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { this.notifyTrade(offer); } // Paper ++ default void processTrade(MerchantOffer offer, io.papermc.paper.event.player.@Nullable PlayerPurchaseEvent event) { this.notifyTrade(offer); } // Paper + void notifyTrade(MerchantOffer offer); void notifyTradeUpdated(ItemStack stack); -@@ -50,4 +_,6 @@ +@@ -49,4 +_,6 @@ boolean isClientSide(); boolean stillValid(Player player); diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch index 0950afd79f01..d8d9ad1a80df 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,75 +1,67 @@ --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java -@@ -35,6 +_,9 @@ +@@ -30,6 +_,10 @@ + @Nullable Component lastOutput; private String command = ""; - @Nullable - private Component customName; + private @Nullable Component customName; + // CraftBukkit start + protected abstract org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper); ++ public abstract ServerLevel getLevel(); + // CraftBukkit end public int getSuccessCount() { return this.successCount; -@@ -112,7 +_,13 @@ +@@ -106,7 +_,13 @@ this.successCount++; } }); -- server.getCommands().performPrefixedCommand(commandSourceStack, this.command); +- level.getServer().getCommands().performPrefixedCommand(commandSourceStack, this.command); + // Paper start - ServerCommandEvent + org.bukkit.event.server.ServerCommandEvent event = new org.bukkit.event.server.ServerCommandEvent(commandSourceStack.getBukkitSender(), net.minecraft.commands.Commands.trimOptionalPrefix(this.command)); + if (!event.callEvent()) { + return true; + } -+ server.getCommands().performPrefixedCommand(commandSourceStack, event.getCommand()); ++ level.getServer().getCommands().performPrefixedCommand(commandSourceStack, event.getCommand()); + // Paper end - ServerCommandEvent } - } catch (Throwable var8) { - CrashReport crashReport = CrashReport.forThrowable(var8, "Executing command block"); -@@ -133,9 +_,8 @@ + } catch (Throwable var7) { + CrashReport crashReport = CrashReport.forThrowable(var7, "Executing command block"); +@@ -127,8 +_,8 @@ } } -- @Nullable -- private BaseCommandBlock.CloseableCommandBlockSource createSource() { -- return this.trackOutput ? new BaseCommandBlock.CloseableCommandBlockSource() : null; -+ public BaseCommandBlock.CloseableCommandBlockSource createSource() { // Paper - public, remove nullable -+ return new BaseCommandBlock.CloseableCommandBlockSource(this.trackOutput); // Paper - add back source when output disabled +- private BaseCommandBlock.@Nullable CloseableCommandBlockSource createSource(ServerLevel level) { +- return this.trackOutput ? new BaseCommandBlock.CloseableCommandBlockSource(level) : null; ++ public BaseCommandBlock.CloseableCommandBlockSource createSource(ServerLevel level) { // Paper - public, remove nullable ++ return new BaseCommandBlock.CloseableCommandBlockSource(level, this.trackOutput); // Paper - add back source when output disabled } public Component getName() { -@@ -168,7 +_,7 @@ - } - - public InteractionResult usedBy(Player player) { -- if (!player.canUseGameMasterBlocks()) { -+ if (!player.canUseGameMasterBlocks() && (!player.isCreative() || !player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission - return InteractionResult.PASS; - } else { - if (player.level().isClientSide()) { -@@ -185,10 +_,21 @@ +@@ -161,13 +_,21 @@ public abstract boolean isValid(); - protected class CloseableCommandBlockSource implements CommandSource, AutoCloseable { + public class CloseableCommandBlockSource implements CommandSource, AutoCloseable { // Paper - public + private final ServerLevel level; private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss", Locale.ROOT); private boolean closed; +- protected CloseableCommandBlockSource(final ServerLevel level) { + // Paper start - add back source when output disabled + private final boolean trackOutput; -+ public CloseableCommandBlockSource(final boolean trackOutput) { ++ public CloseableCommandBlockSource(final ServerLevel level, final boolean trackOutput) { + this.level = level; + this.trackOutput = trackOutput; + } + @io.papermc.paper.annotation.DoNotUse @Deprecated -+ public CloseableCommandBlockSource() { -+ this(true); -+ } -+ // Paper end - add back source when output disabled -+ ++ public CloseableCommandBlockSource(final ServerLevel level) { // Paper - public ++ this(level, true); ++ // Paper end - add back source when output disabled + } + @Override - public boolean acceptsSuccess() { - return !this.closed && BaseCommandBlock.this.getLevel().getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK); -@@ -196,7 +_,7 @@ +@@ -177,7 +_,7 @@ @Override public boolean acceptsFailure() { @@ -78,7 +70,7 @@ } @Override -@@ -206,7 +_,8 @@ +@@ -187,7 +_,8 @@ @Override public void sendSystemMessage(Component message) { @@ -86,9 +78,9 @@ + if (this.trackOutput && !this.closed) { // Paper - add back source when output disabled + org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper - Don't broadcast messages to command blocks BaseCommandBlock.this.lastOutput = Component.literal("[" + TIME_FORMAT.format(ZonedDateTime.now()) + "] ").append(message); - BaseCommandBlock.this.onUpdated(); + BaseCommandBlock.this.onUpdated(this.level); } -@@ -216,5 +_,12 @@ +@@ -197,5 +_,12 @@ public void close() throws Exception { this.closed = true; } 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 c4ac267dbb92..e2911c4452ff 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 -@@ -54,13 +_,15 @@ +@@ -52,13 +_,15 @@ public int maxNearbyEntities = 6; public int requiredPlayerRange = 16; public int spawnRange = 4; @@ -17,7 +17,7 @@ } public void clientTick(Level level, BlockPos pos) { -@@ -83,13 +_,19 @@ +@@ -81,13 +_,19 @@ } public void serverTick(ServerLevel level, BlockPos pos) { @@ -27,7 +27,7 @@ + tickDelay = level.paperConfig().tickRates.mobSpawner; + if (tickDelay == -1) { return; } // If disabled + // Paper end - Configurable mob spawner tick rate - if (this.isNearPlayer(level, pos) && level.getServer().isSpawnerBlockEnabled()) { + if (this.isNearPlayer(level, pos) && level.isSpawnerBlockEnabled()) { - if (this.spawnDelay == -1) { + if (this.spawnDelay < -tickDelay) { // Paper - Configurable mob spawner tick rate this.delay(level, pos); @@ -39,7 +39,7 @@ } else { boolean flag = false; RandomSource random = level.getRandom(); -@@ -127,6 +_,21 @@ +@@ -125,6 +_,21 @@ continue; } @@ -61,7 +61,7 @@ Entity entity = EntityType.loadEntityRecursive(valueInput, level, EntitySpawnReason.SPAWNER, entity1 -> { entity1.snapTo(vec3.x, vec3.y, vec3.z, entity1.getYRot(), entity1.getXRot()); return entity1; -@@ -160,9 +_,22 @@ +@@ -158,9 +_,22 @@ } nextSpawnData.getEquipment().ifPresent(mob::equip); @@ -85,7 +85,7 @@ this.delay(level, pos); return; } -@@ -173,7 +_,7 @@ +@@ -171,7 +_,7 @@ ((Mob)entity).spawnAnim(); } @@ -94,7 +94,7 @@ } } } -@@ -200,12 +_,14 @@ +@@ -198,12 +_,14 @@ } public void load(@Nullable Level level, BlockPos pos, ValueInput input) { @@ -112,7 +112,7 @@ this.spawnCount = input.getIntOr("SpawnCount", 4); this.maxNearbyEntities = input.getIntOr("MaxNearbyEntities", 6); this.requiredPlayerRange = input.getIntOr("RequiredPlayerRange", 16); -@@ -214,9 +_,19 @@ +@@ -212,9 +_,19 @@ } public void save(ValueOutput output) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch index 54547655bb53..aedc95f317ab 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -32,6 +_,17 @@ +@@ -31,6 +_,17 @@ BlockState getBlockState(BlockPos pos); + // Paper start - if loaded util + @Nullable BlockState getBlockStateIfLoaded(BlockPos pos); + -+ default @Nullable net.minecraft.world.level.block.Block getBlockIfLoaded(BlockPos pos) { ++ default net.minecraft.world.level.block.@Nullable Block getBlockIfLoaded(BlockPos pos) { + BlockState type = this.getBlockStateIfLoaded(pos); + return type == null ? null : type.getBlock(); + } @@ -18,7 +18,7 @@ FluidState getFluidState(BlockPos pos); default int getLightEmission(BlockPos pos) { -@@ -65,10 +_,25 @@ +@@ -64,10 +_,25 @@ ); } @@ -32,7 +32,7 @@ + return clip(traverseContext, traversePos, null); + } + -+ default BlockHitResult clip(ClipContext traverseContext, BlockPos traversePos, @Nullable java.util.function.Predicate canCollide) { ++ default BlockHitResult clip(ClipContext traverseContext, BlockPos traversePos, java.util.function.@Nullable Predicate canCollide) { + // Paper end - Add predicate for blocks when raytracing + // Paper start - Prevent raytrace from loading chunks + BlockState blockState = this.getBlockStateIfLoaded(traversePos); @@ -48,7 +48,7 @@ Vec3 from = traverseContext.getFrom(); Vec3 to = traverseContext.getTo(); VoxelShape blockShape = traverseContext.getBlockShape(blockState, this, traversePos); -@@ -78,6 +_,18 @@ +@@ -77,6 +_,18 @@ double d = blockHitResult == null ? Double.MAX_VALUE : traverseContext.getFrom().distanceToSqr(blockHitResult.getLocation()); double d1 = blockHitResult1 == null ? Double.MAX_VALUE : traverseContext.getFrom().distanceToSqr(blockHitResult1.getLocation()); return d <= d1 ? blockHitResult : blockHitResult1; @@ -60,7 +60,7 @@ + return clip(context, (java.util.function.Predicate) null); + } + -+ default BlockHitResult clip(ClipContext context, @Nullable java.util.function.Predicate canCollide) { ++ default BlockHitResult clip(ClipContext context, java.util.function.@Nullable Predicate canCollide) { + // Paper end - Add predicate for blocks when raytracing + return (BlockHitResult) BlockGetter.traverseBlocks(context.getFrom(), context.getTo(), context, (raytrace1, blockposition) -> { + return this.clip(raytrace1, blockposition, canCollide); // CraftBukkit - moved into separate method // Paper - Add predicate for blocks when raytracing diff --git a/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch index fb5964b6390c..b5967d32843e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ClipContext.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/ClipContext.java +++ b/net/minecraft/world/level/ClipContext.java -@@ -25,7 +_,7 @@ +@@ -26,7 +_,7 @@ private final CollisionContext collisionContext; public ClipContext(Vec3 from, Vec3 to, ClipContext.Block block, ClipContext.Fluid fluid, Entity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch index f4f7f574b6bb..282491c93436 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/EmptyBlockAndTintGetter.java +++ b/net/minecraft/world/level/EmptyBlockAndTintGetter.java -@@ -39,6 +_,18 @@ +@@ -38,6 +_,18 @@ return Blocks.AIR.defaultBlockState(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch index d98e9785df76..690108e9358e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/EmptyBlockGetter.java +++ b/net/minecraft/world/level/EmptyBlockGetter.java -@@ -17,6 +_,18 @@ +@@ -16,6 +_,18 @@ return null; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch index edf6c3551026..3906f721e590 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EntityGetter.java.patch @@ -10,10 +10,10 @@ + } + // Paper end - Affects Spawning API + - @Nullable - default Player getNearestPlayer(double x, double y, double z, double distance, @Nullable Predicate predicate) { + default @Nullable Player getNearestPlayer(double x, double y, double z, double distance, @Nullable Predicate predicate) { double d = -1.0; -@@ -89,6 +_,28 @@ + Player player = null; +@@ -88,6 +_,28 @@ return player; } @@ -39,10 +39,10 @@ + } + // Paper end + - @Nullable - default Player getNearestPlayer(Entity entity, double distance) { + default @Nullable Player getNearestPlayer(Entity entity, double distance) { return this.getNearestPlayer(entity.getX(), entity.getY(), entity.getZ(), distance, false); -@@ -100,6 +_,20 @@ + } +@@ -97,6 +_,20 @@ return this.getNearestPlayer(x, y, z, distance, predicate); } @@ -63,7 +63,7 @@ default boolean hasNearbyAlivePlayer(double x, double y, double z, double distance) { for (Player player : this.players()) { if (EntitySelector.NO_SPECTATORS.test(player) && EntitySelector.LIVING_ENTITY_STILL_ALIVE.test(player)) { -@@ -124,4 +_,11 @@ +@@ -120,4 +_,11 @@ return null; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch deleted file mode 100644 index 919f1b35d85d..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch +++ /dev/null @@ -1,314 +0,0 @@ ---- a/net/minecraft/world/level/GameRules.java -+++ b/net/minecraft/world/level/GameRules.java -@@ -36,6 +_,14 @@ - import org.slf4j.Logger; - - public class GameRules { -+ // Paper start - allow disabling gamerule limits -+ private static final boolean DISABLE_LIMITS = Boolean.getBoolean("paper.disableGameRuleLimits"); -+ -+ private static int limit(final int limit, final int unlimited) { -+ return DISABLE_LIMITS ? unlimited : limit; -+ } -+ // Paper end - allow disabling gamerule limits -+ - public static final int DEFAULT_RANDOM_TICK_SPEED = 3; - static final Logger LOGGER = LogUtils.getLogger(); - public static final Map, GameRules.Type> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id)); -@@ -88,10 +_,10 @@ - "sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_REDUCEDDEBUGINFO = register( -- "reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (server, value) -> { -+ "reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes - byte b = value.get() ? EntityEvent.REDUCED_DEBUG_INFO : EntityEvent.FULL_DEBUG_INFO; - -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ for (ServerPlayer serverPlayer : level.players()) { - serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); - } - }) -@@ -115,8 +_,8 @@ - "doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(!SharedConstants.DEBUG_WORLD_RECREATE) - ); - public static final GameRules.Key RULE_LIMITED_CRAFTING = register( -- "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ "doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F)); - } - }) -@@ -140,8 +_,8 @@ - "doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_DO_IMMEDIATE_RESPAWN = register( -- "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (server, value) -> { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ "doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (level, value) -> { // Paper - rename param to match changes -+ for (ServerPlayer serverPlayer : level.players()) { // Paper - per world gamerules - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F)); - } - }) -@@ -212,13 +_,13 @@ - public static final GameRules.Key RULE_MINECART_MAX_SPEED = register( - "minecartMaxSpeed", - GameRules.Category.MISC, -- GameRules.IntegerValue.create(8, 1, 1000, FeatureFlagSet.of(FeatureFlags.MINECART_IMPROVEMENTS), (server, value) -> {}) -+ GameRules.IntegerValue.create(8, 1, limit(1000, Integer.MAX_VALUE), FeatureFlagSet.of(FeatureFlags.MINECART_IMPROVEMENTS), (server, value) -> {}) // Paper - allow disabling gamerule limits - ); - public static final GameRules.Key RULE_TNT_EXPLODES = register( - "tntExplodes", GameRules.Category.MISC, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_LOCATOR_BAR = register( -- "locatorBar", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true, (server, value) -> server.getAllLevels().forEach(level -> { -+ "locatorBar", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true, (minecraftServer, value) -> java.util.Optional.of(minecraftServer).ifPresent(level -> { // Paper - per world game rules - ServerWaypointManager waypointManager = level.getWaypointManager(); - if (value.get()) { - level.players().forEach(waypointManager::updatePlayer); -@@ -232,7 +_,11 @@ - "allowEnteringNetherUsingPortals", GameRules.Category.MISC, GameRules.BooleanValue.create(true) - ); - public static final GameRules.Key RULE_SPAWN_MONSTERS = register( -- "spawnMonsters", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true, (server, value) -> server.updateMobSpawningFlags()) -+ // Paper start - per world gamerules -+ "spawnMonsters", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true, (level, value) -> { -+ level.setSpawnSettings(level.serverLevelData.getDifficulty() != net.minecraft.world.Difficulty.PEACEFUL && level.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); -+ }) -+ // Paper end - per world gamerules - ); - public static final GameRules.Key RULE_COMMAND_BLOCKS_ENABLED = register( - "commandBlocksEnabled", GameRules.Category.MISC, GameRules.BooleanValue.create(true) -@@ -242,6 +_,7 @@ - ); - private final Map, GameRules.Value> rules; - private final FeatureFlagSet enabledFeatures; -+ private final GameRules.Value[] gameruleArray; // Paper - Perf: Use array for gamerule storage - - public static > GameRules.Type getType(GameRules.Key key) { - return (GameRules.Type)GAME_RULE_TYPES.get(key); -@@ -289,10 +_,21 @@ - private GameRules(Map, GameRules.Value> rules, FeatureFlagSet enabledFeatures) { - this.rules = rules; - this.enabledFeatures = enabledFeatures; -+ -+ // Paper start - Perf: Use array for gamerule storage -+ int arraySize = GameRules.Key.lastGameRuleIndex + 1; -+ GameRules.Value[] values = new GameRules.Value[arraySize]; -+ -+ for (Entry, GameRules.Value> entry : rules.entrySet()) { -+ values[entry.getKey().gameRuleIndex] = entry.getValue(); -+ } -+ -+ this.gameruleArray = values; -+ // Paper end - Perf: Use array for gamerule storage - } - - public > T getRule(GameRules.Key key) { -- T value = (T)this.rules.get(key); -+ T value = key == null ? null : (T) this.gameruleArray[key.gameRuleIndex]; // Paper - Perf: Use array for gamerule storage - if (value == null) { - throw new IllegalArgumentException("Tried to access invalid game rule"); - } else { -@@ -333,13 +_,13 @@ - } - } - -- public void assignFrom(GameRules rules, @Nullable MinecraftServer server) { -- rules.rules.keySet().forEach(key -> this.assignCap((GameRules.Key)key, rules, server)); -+ public void assignFrom(GameRules rules, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world -+ rules.rules.keySet().forEach(key -> this.assignCap((GameRules.Key)key, rules, level)); // CraftBukkit - per-world - } - -- private > void assignCap(GameRules.Key key, GameRules rules, @Nullable MinecraftServer server) { -+ private > void assignCap(GameRules.Key key, GameRules rules, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - T rule = rules.getRule(key); -- this.getRule(key).setFrom(rule, server); -+ this.getRule(key).setFrom(rule, level); // CraftBukkit - per-world - } - - public boolean getBoolean(GameRules.Key key) { -@@ -354,7 +_,7 @@ - private boolean value; - - private static GameRules.Type create( -- boolean defaultValue, BiConsumer changeListener, FeatureFlagSet requiredFeatures -+ boolean defaultValue, BiConsumer changeListener, FeatureFlagSet requiredFeatures // Paper - per world gamerules - ) { - return new GameRules.Type<>( - BoolArgumentType::bool, -@@ -366,7 +_,7 @@ - ); - } - -- static GameRules.Type create(boolean defaultValue, BiConsumer changeListener) { -+ static GameRules.Type create(boolean defaultValue, BiConsumer changeListener) { // Paper - per world gamerules - return new GameRules.Type<>( - BoolArgumentType::bool, - type -> new GameRules.BooleanValue(type, defaultValue), -@@ -387,17 +_,21 @@ - } - - @Override -- protected void updateFromArgument(CommandContext context, String paramName) { -- this.value = BoolArgumentType.getBool(context, paramName); -+ // Paper start - Add WorldGameRuleChangeEvent -+ protected void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { -+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(BoolArgumentType.getBool(context, paramName))); -+ if (!event.callEvent()) return; -+ this.value = Boolean.parseBoolean(event.getValue()); -+ // Paper end - Add WorldGameRuleChangeEvent - } - - public boolean get() { - return this.value; - } - -- public void set(boolean value, @Nullable MinecraftServer server) { -+ public void set(boolean value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - - @Override -@@ -426,9 +_,9 @@ - } - - @Override -- public void setFrom(GameRules.BooleanValue value, @Nullable MinecraftServer server) { -+ public void setFrom(GameRules.BooleanValue value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value.value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - } - -@@ -466,7 +_,7 @@ - public static class IntegerValue extends GameRules.Value { - private int value; - -- private static GameRules.Type create(int defaultValue, BiConsumer changeListener) { -+ private static GameRules.Type create(int defaultValue, BiConsumer changeListener) { // CraftBukkit - per-world - return new GameRules.Type<>( - IntegerArgumentType::integer, - type -> new GameRules.IntegerValue(type, defaultValue), -@@ -478,7 +_,7 @@ - } - - static GameRules.Type create( -- int defaultValue, int min, int max, FeatureFlagSet requiredFeatures, BiConsumer changeListener -+ int defaultValue, int min, int max, FeatureFlagSet requiredFeatures, BiConsumer changeListener // CraftBukkit - per-world - ) { - return new GameRules.Type<>( - () -> IntegerArgumentType.integer(min, max), -@@ -500,17 +_,21 @@ - } - - @Override -- protected void updateFromArgument(CommandContext context, String paramName) { -- this.value = IntegerArgumentType.getInteger(context, paramName); -+ // Paper start - Add WorldGameRuleChangeEvent -+ protected void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { -+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(IntegerArgumentType.getInteger(context, paramName))); -+ if (!event.callEvent()) return; -+ this.value = Integer.parseInt(event.getValue()); -+ // Paper end - Add WorldGameRuleChangeEvent - } - - public int get() { - return this.value; - } - -- public void set(int value, @Nullable MinecraftServer server) { -+ public void set(int value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - - @Override -@@ -561,13 +_,17 @@ - } - - @Override -- public void setFrom(GameRules.IntegerValue value, @Nullable MinecraftServer server) { -+ public void setFrom(GameRules.IntegerValue value, @Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world - this.value = value.value; -- this.onChanged(server); -+ this.onChanged(level); // CraftBukkit - per-world - } - } - - public static final class Key> { -+ // Paper start - Perf: Use array for gamerule storage -+ public static int lastGameRuleIndex = 0; -+ public final int gameRuleIndex = lastGameRuleIndex++; -+ // Paper end - Perf: Use array for gamerule storage - final String id; - private final GameRules.Category category; - -@@ -607,7 +_,7 @@ - public static class Type> { - final Supplier> argument; - private final Function, T> constructor; -- final BiConsumer callback; -+ final BiConsumer callback; // CraftBukkit - per-world - private final GameRules.VisitorCaller visitorCaller; - final Class valueClass; - final FeatureFlagSet requiredFeatures; -@@ -615,7 +_,7 @@ - Type( - Supplier> argument, - Function, T> constructor, -- BiConsumer callback, -+ BiConsumer callback, // CraftBukkit - per-world - GameRules.VisitorCaller visitorCaller, - Class valueClass, - FeatureFlagSet requiredFeatures -@@ -643,6 +_,12 @@ - public FeatureFlagSet requiredFeatures() { - return this.requiredFeatures; - } -+ // Paper start - expose FeatureElement wrapper for GameRules.Type. -+ // Chosen over simply adding this to the inheritance to avoid reobf issues with spigot... -+ public net.minecraft.world.flag.FeatureElement asFeatureElement() { -+ return GameRules.Type.this::requiredFeatures; -+ } -+ // Paper end - expose FeatureElement wrapper for GameRules.Type. - } - - public abstract static class Value> { -@@ -652,16 +_,16 @@ - this.type = type; - } - -- protected abstract void updateFromArgument(CommandContext context, String paramName); -+ protected abstract void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey); // Paper - Add WorldGameRuleChangeEvent - -- public void setFromArgument(CommandContext context, String paramName) { -- this.updateFromArgument(context, paramName); -- this.onChanged(context.getSource().getServer()); -+ public void setFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { // Paper - Add WorldGameRuleChangeEvent -+ this.updateFromArgument(context, paramName, gameRuleKey); // Paper - Add WorldGameRuleChangeEvent -+ this.onChanged(context.getSource().getLevel()); // CraftBukkit - per-world - } - -- public void onChanged(@Nullable MinecraftServer server) { -- if (server != null) { -- this.type.callback.accept(server, this.getSelf()); -+ public void onChanged(@Nullable net.minecraft.server.level.ServerLevel level) { // CraftBukkit - per-world -+ if (level != null) { // CraftBukkit - per-world -+ this.type.callback.accept(level, this.getSelf()); // CraftBukkit - per-world - } - } - -@@ -680,7 +_,7 @@ - - protected abstract T copy(); - -- public abstract void setFrom(T value, @Nullable MinecraftServer server); -+ public abstract void setFrom(T value, @Nullable net.minecraft.server.level.ServerLevel level); // CraftBukkit - per-world - } - - interface VisitorCaller> { 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 7c4687c4c956..b92398a3cda5 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 @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -85,6 +_,16 @@ - import net.minecraft.world.scores.Scoreboard; +@@ -86,6 +_,16 @@ import org.apache.commons.lang3.mutable.MutableBoolean; + import org.jspecify.annotations.Nullable; +// CraftBukkit start +import java.util.Map; @@ -16,7 +16,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, ResourceLocation.withDefaultNamespace("overworld")); + public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, Identifier.withDefaultNamespace("overworld")); @@ -127,6 +_,57 @@ private final PalettedContainerFactory palettedContainerFactory; private long subTickCount; @@ -24,7 +24,7 @@ + // CraftBukkit start + private final CraftWorld world; + public net.kyori.adventure.util.TriState pvpMode = net.kyori.adventure.util.TriState.NOT_SET; -+ public @Nullable org.bukkit.generator.ChunkGenerator generator; ++ public org.bukkit.generator.@Nullable ChunkGenerator generator; + + public boolean captureBlockStates = false; + public boolean captureTreeGeneration = false; @@ -81,8 +81,8 @@ long biomeZoomSeed, - int maxChainedNeighborUpdates + int maxChainedNeighborUpdates, -+ @Nullable org.bukkit.generator.ChunkGenerator generator, // Paper -+ @Nullable org.bukkit.generator.BiomeProvider biomeProvider, // Paper ++ org.bukkit.generator.@Nullable ChunkGenerator generator, // Paper ++ org.bukkit.generator.@Nullable BiomeProvider biomeProvider, // Paper + org.bukkit.World.Environment environment, // Paper + java.util.function.Function paperWorldConfigCreator // Paper - create paper world config @@ -100,8 +100,8 @@ + // CraftBukkit end this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; - DimensionType dimensionType = dimensionTypeRegistration.value(); -@@ -151,6 +_,46 @@ + this.dimension = dimension; +@@ -150,6 +_,46 @@ this.damageSources = new DamageSources(registryAccess); } @@ -148,7 +148,7 @@ @Override public boolean isClientSide() { return this.isClientSide; -@@ -162,8 +_,15 @@ +@@ -160,8 +_,15 @@ return null; } @@ -165,7 +165,7 @@ } public static boolean isInSpawnableBounds(BlockPos pos) { -@@ -171,21 +_,86 @@ +@@ -169,21 +_,86 @@ } private static boolean isInWorldBoundsHorizontal(BlockPos pos) { @@ -255,12 +255,12 @@ + } + // Paper end - @Nullable @Override -@@ -205,6 +_,22 @@ + public @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { +@@ -202,6 +_,22 @@ @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { + // Paper start - Protect Bedrock and End Portal/Frames from being destroyed @@ -280,7 +280,7 @@ if (this.isOutsideBuildHeight(pos)) { return false; } else if (!this.isClientSide() && this.isDebug()) { -@@ -212,11 +_,31 @@ +@@ -209,11 +_,31 @@ } else { LevelChunk chunkAt = this.getChunkAt(pos); Block block = state.getBlock(); @@ -312,7 +312,7 @@ if (blockState1 == state) { if (blockState != blockState1) { this.setBlocksDirty(pos, blockState, blockState1); -@@ -244,12 +_,68 @@ +@@ -241,12 +_,68 @@ this.updatePOIOnBlockStateChange(pos, blockState, blockState1); } @@ -381,7 +381,7 @@ public void updatePOIOnBlockStateChange(BlockPos pos, BlockState oldState, BlockState newState) { } -@@ -266,13 +_,31 @@ +@@ -263,13 +_,31 @@ return false; } else { FluidState fluidState = this.getFluidState(pos); @@ -416,7 +416,7 @@ } boolean flag = this.setBlock(pos, fluidState.createLegacyBlock(), Block.UPDATE_ALL, recursionLeft); -@@ -336,10 +_,18 @@ +@@ -335,10 +_,18 @@ @Override public BlockState getBlockState(BlockPos pos) { @@ -436,7 +436,7 @@ return chunk.getBlockState(pos); } } -@@ -452,31 +_,47 @@ +@@ -437,31 +_,47 @@ this.pendingBlockEntityTickers.clear(); } @@ -492,10 +492,10 @@ public boolean shouldTickDeath(Entity entity) { return true; -@@ -601,6 +_,12 @@ - @Nullable +@@ -585,6 +_,12 @@ + @Override - public BlockEntity getBlockEntity(BlockPos pos) { + public @Nullable BlockEntity getBlockEntity(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) { @@ -505,7 +505,7 @@ if (this.isOutsideBuildHeight(pos)) { return null; } else { -@@ -613,6 +_,12 @@ +@@ -597,6 +_,12 @@ public void setBlockEntity(BlockEntity blockEntity) { BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { @@ -518,7 +518,7 @@ this.getChunkAt(blockPos).addAndRegisterBlockEntity(blockEntity); } } -@@ -1039,7 +_,8 @@ +@@ -1001,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch index 1540db17ec5f..8f8e291a66b5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java -@@ -100,4 +_,6 @@ +@@ -97,4 +_,6 @@ default void gameEvent(ResourceKey gameEvent, BlockPos pos, GameEvent.Context context) { this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(gameEvent), pos, context); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch index c740a23a7f9f..cdaaa11078c6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelReader.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java @@ -26,6 +_,9 @@ - @Nullable - ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); + public interface LevelReader extends BlockAndTintGetter, CollisionGetter, SignalGetter, BiomeManager.NoiseBiomeSource { + @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); + @Nullable ChunkAccess getChunkIfLoadedImmediately(int x, int z); // Paper - ifLoaded api (we need this since current impl blocks if the chunk is loading) + @Nullable default ChunkAccess getChunkIfLoadedImmediately(BlockPos pos) { return this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4);} diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch index d752f6bafce3..a132dab9b9ad 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/LevelWriter.java +++ b/net/minecraft/world/level/LevelWriter.java -@@ -27,4 +_,10 @@ +@@ -28,4 +_,10 @@ default boolean addFreshEntity(Entity entity) { return false; } + + // CraftBukkit start -+ default boolean addFreshEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ default boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason reason) { + return false; + } + // CraftBukkit end 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 56385b437d02..fba73eea2467 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -75,6 +_,13 @@ +@@ -76,6 +_,13 @@ if (!(entity instanceof Mob mob && (mob.isPersistenceRequired() || mob.requiresCustomPersistence()))) { MobCategory category = entity.getType().getCategory(); if (category != MobCategory.MISC) { @@ -14,7 +14,7 @@ BlockPos blockPos = entity.blockPosition(); chunkGetter.query(ChunkPos.asLong(blockPos), chunk -> { MobSpawnSettings.MobSpawnCost mobSpawnCost = getRoughBiome(blockPos, chunk).getMobSettings().getMobSpawnCost(entity.getType()); -@@ -99,17 +_,34 @@ +@@ -100,17 +_,34 @@ return chunk.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ())).value(); } @@ -51,7 +51,7 @@ } } -@@ -129,6 +_,16 @@ +@@ -130,6 +_,16 @@ profilerFiller.pop(); } @@ -68,7 +68,7 @@ public static void spawnCategoryForChunk( MobCategory category, ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { -@@ -154,8 +_,8 @@ +@@ -155,8 +_,8 @@ StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int y = pos.getY(); @@ -79,7 +79,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); int i = 0; -@@ -177,7 +_,7 @@ +@@ -178,7 +_,7 @@ Player nearestPlayer = level.getNearestPlayer(d, y, d1, -1.0, false); if (nearestPlayer != null) { double d2 = nearestPlayer.distanceToSqr(d, y, d1); @@ -88,7 +88,7 @@ if (spawnerData == null) { Optional randomSpawnMobAt = getRandomSpawnMobAt( level, structureManager, generator, category, level.random, mutableBlockPos -@@ -190,7 +_,13 @@ +@@ -191,7 +_,13 @@ ceil = spawnerData.minCount() + level.random.nextInt(1 + spawnerData.maxCount() - spawnerData.minCount()); } @@ -103,7 +103,7 @@ && filter.test(spawnerData.type(), mutableBlockPos, chunk)) { Mob mobForSpawn = getMobForSpawn(level, spawnerData.type()); if (mobForSpawn == null) { -@@ -202,10 +_,15 @@ +@@ -203,10 +_,15 @@ spawnGroupData = mobForSpawn.finalizeSpawn( level, level.getCurrentDifficultyAt(mobForSpawn.blockPosition()), EntitySpawnReason.NATURAL, spawnGroupData ); @@ -113,7 +113,7 @@ - callback.run(mobForSpawn, chunk); + // CraftBukkit start + // SPIGOT-7045: Give ocelot babies back their special spawn reason. Note: This is the only modification required as ocelots count as monsters which means they only spawn during normal chunk ticking and do not spawn during chunk generation as starter mobs. -+ level.addFreshEntityWithPassengers(mobForSpawn, (mobForSpawn instanceof net.minecraft.world.entity.animal.Ocelot && !((org.bukkit.entity.Ageable) mobForSpawn.getBukkitEntity()).isAdult()) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); ++ level.addFreshEntityWithPassengers(mobForSpawn, (mobForSpawn instanceof net.minecraft.world.entity.animal.feline.Ocelot && !((org.bukkit.entity.Ageable) mobForSpawn.getBukkitEntity()).isAdult()) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); + if (!mobForSpawn.isRemoved()) { + ++i; + ++i3; @@ -123,7 +123,7 @@ if (i >= mobForSpawn.getMaxSpawnClusterSize()) { return; } -@@ -237,7 +_,15 @@ +@@ -238,7 +_,15 @@ } } @@ -140,7 +140,7 @@ ServerLevel level, MobCategory category, StructureManager structureManager, -@@ -247,7 +_,19 @@ +@@ -248,7 +_,19 @@ double distance ) { EntityType entityType = data.type(); @@ -161,14 +161,14 @@ && ( entityType.canSpawnFarFromPlayer() || !(distance > entityType.getCategory().getDespawnDistance() * entityType.getCategory().getDespawnDistance()) -@@ -257,6 +_,7 @@ +@@ -258,6 +_,7 @@ && SpawnPlacements.isSpawnPositionOk(entityType, level, pos) && SpawnPlacements.checkSpawnRules(entityType, level, EntitySpawnReason.NATURAL, pos, level.random) && level.noCollision(entityType.getSpawnAABB(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5)); + return success ? PreSpawnStatus.SUCCESS : PreSpawnStatus.FAIL; // Paper - PreCreatureSpawnEvent } - @Nullable + private static @Nullable Mob getMobForSpawn(ServerLevel level, EntityType entityType) { @@ -269,6 +_,7 @@ LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(entityType)); } catch (Exception var4) { @@ -194,7 +194,7 @@ flag = true; } } -@@ -509,8 +_,10 @@ +@@ -507,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 b58ac2ad2cdd..77a2f704aa99 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 @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -35,6 +_,14 @@ - import net.minecraft.world.phys.HitResult; +@@ -36,6 +_,14 @@ import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; +// CraftBukkit start -+import net.minecraft.world.entity.boss.EnderDragonPart; ++import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.util.CraftLocation; @@ -64,77 +64,79 @@ } d3 += d * 0.3F; -@@ -176,8 +_,8 @@ - int floor3 = Mth.floor(this.center.y + f + 1.0); - int floor4 = Mth.floor(this.center.z - f - 1.0); - int floor5 = Mth.floor(this.center.z + f + 1.0); +@@ -177,8 +_,8 @@ + int floor3 = Mth.floor(this.center.y + f + 1.0); + int floor4 = Mth.floor(this.center.z - f - 1.0); + int floor5 = Mth.floor(this.center.z + f + 1.0); - -- for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) { -+ List list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source -+ for (Entity entity : list) { // Paper - used in loop - if (!entity.ignoreExplosion(this)) { - double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; - if (!(d > 1.0)) { -@@ -185,18 +_,54 @@ - Vec3 vec31 = vec3.subtract(this.center).normalize(); - boolean shouldDamageEntity = this.damageCalculator.shouldDamageEntity(this, entity); - float knockbackMultiplier = this.damageCalculator.getKnockbackMultiplier(entity); -- float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : getSeenPercent(this.center, entity); -+ float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : this.getBlockDensity(this.center, entity); // Paper - Optimize explosions - if (shouldDamageEntity) { -- entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); -+ // CraftBukkit start +- for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) { ++ List list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source ++ for (Entity entity : list) { // Paper - used in loop + if (!entity.ignoreExplosion(this)) { + double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; + if (!(d > 1.0)) { +@@ -186,20 +_,56 @@ + Vec3 vec31 = vec3.subtract(this.center).normalize(); + boolean shouldDamageEntity = this.damageCalculator.shouldDamageEntity(this, entity); + float knockbackMultiplier = this.damageCalculator.getKnockbackMultiplier(entity); +- float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : getSeenPercent(this.center, entity); ++ float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : this.getBlockDensity(this.center, entity); // Paper - Optimize explosions + if (shouldDamageEntity) { +- entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); ++ // CraftBukkit start + -+ // Special case ender dragon only give knockback if no damage is cancelled -+ // Thinks to note: -+ // - Setting a velocity to a EnderDragonPart is ignored (and therefore not needed) -+ // - Damaging EnderDragonPart while forward the damage to EnderDragon -+ // - Damaging EnderDragon does nothing -+ // - EnderDragon hitbox always covers the other parts and is therefore always present -+ if (entity instanceof EnderDragonPart) { -+ continue; -+ } ++ // Special case ender dragon only give knockback if no damage is cancelled ++ // Thinks to note: ++ // - Setting a velocity to a EnderDragonPart is ignored (and therefore not needed) ++ // - Damaging EnderDragonPart while forward the damage to EnderDragon ++ // - Damaging EnderDragon does nothing ++ // - EnderDragon hitbox always covers the other parts and is therefore always present ++ if (entity instanceof EnderDragonPart) { ++ continue; ++ } + -+ entity.lastDamageCancelled = false; ++ entity.lastDamageCancelled = false; + -+ if (entity instanceof EnderDragon) { -+ for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) { -+ // Calculate damage separately for each EntityComplexPart -+ if (list.contains(dragonPart)) { -+ dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1)); ++ if (entity instanceof EnderDragon) { ++ for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) { ++ // Calculate damage separately for each EntityComplexPart ++ if (list.contains(dragonPart)) { ++ dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1)); ++ } + } ++ } else { ++ entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); + } -+ } else { -+ entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); -+ } + -+ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled -+ continue; ++ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled ++ continue; ++ } ++ // CraftBukkit end + } + + double d1 = entity instanceof LivingEntity livingEntity + ? livingEntity.getAttributeValue(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) + : 0.0; +- double d2 = (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); ++ double d2 = entity instanceof Player && this.level.paperConfig().environment.disableExplosionKnockback ? 0 : (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); // Paper + Vec3 vec32 = vec31.scale(d2); ++ // CraftBukkit start - Call EntityKnockbackEvent ++ if (entity instanceof LivingEntity) { ++ // Paper start - knockback events ++ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d2, vec32); ++ vec32 = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getKnockback()); ++ // Paper end - knockback events + } + // CraftBukkit end - } - - double d1 = entity instanceof LivingEntity livingEntity ? livingEntity.getAttributeValue(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) : 0.0; -- double d2 = (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); -+ double d2 = entity instanceof Player && this.level.paperConfig().environment.disableExplosionKnockback ? 0 : (1.0 - d) * f1 * knockbackMultiplier * (1.0 - d1); // Paper - Vec3 vec32 = vec31.scale(d2); -+ // CraftBukkit start - Call EntityKnockbackEvent -+ if (entity instanceof LivingEntity) { -+ // Paper start - knockback events -+ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d2, vec32); -+ vec32 = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getKnockback()); -+ // Paper end - knockback events -+ } -+ // CraftBukkit end - entity.push(vec32); - if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) { - projectile.setOwner(this.damageSource.getEntity()); -- } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) { -+ } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback - this.hitPlayers.put(player, vec32); - } + entity.push(vec32); + if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) { + projectile.setOwner(this.damageSource.getEntity()); +- } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) { ++ } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback + this.hitPlayers.put(player, vec32); + } -@@ -210,7 +_,56 @@ +@@ -214,7 +_,56 @@ List list = new ArrayList<>(); Util.shuffle(blocks, this.level.random); @@ -178,7 +180,7 @@ + // CraftBukkit start - TNTPrimeEvent + BlockState state = this.level.getBlockState(blockPos); + Block block = state.getBlock(); -+ if (level.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES) && block instanceof net.minecraft.world.level.block.TntBlock) { ++ if (level.getGameRules().get(GameRules.TNT_EXPLODES) && block instanceof net.minecraft.world.level.block.TntBlock) { + Entity sourceEntity = this.source == null ? null : this.source; + BlockPos sourceBlock = sourceEntity == null ? BlockPos.containing(this.center) : null; + if (!CraftEventFactory.callTNTPrimeEvent(this.level, blockPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.EXPLOSION, sourceEntity, sourceBlock)) { @@ -191,7 +193,7 @@ this.level .getBlockState(blockPos) .onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1)); -@@ -224,7 +_,11 @@ +@@ -228,7 +_,11 @@ private void createFire(List blocks) { for (BlockPos blockPos : blocks) { if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(blockPos).isAir() && this.level.getBlockState(blockPos.below()).isSolidRender()) { @@ -204,7 +206,7 @@ } } } -@@ -328,4 +_,86 @@ +@@ -326,4 +_,86 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch index 0d2900e6a1aa..0f1af218f263 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerLevelAccessor.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/ServerLevelAccessor.java +++ b/net/minecraft/world/level/ServerLevelAccessor.java -@@ -7,6 +_,17 @@ - ServerLevel getLevel(); +@@ -11,6 +_,17 @@ + DifficultyInstance getCurrentDifficultyAt(BlockPos pos); default void addFreshEntityWithPassengers(Entity entity) { - entity.getSelfAndPassengers().forEach(this::addFreshEntity); diff --git a/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch b/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch index a62cc178893f..690024da9c8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch @@ -15,7 +15,7 @@ Builder builder = ImmutableList.builder(); for (Entry entry : allReferences.entrySet()) { -@@ -114,14 +_,29 @@ +@@ -113,14 +_,29 @@ } public StructureStart getStructureWithPieceAt(BlockPos pos, HolderSet structures) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch index d04da8751dac..9d1bfb3fb2ca 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/TicketStorage.java +++ b/net/minecraft/world/level/TicketStorage.java -@@ -179,7 +_,7 @@ +@@ -177,7 +_,7 @@ } private static boolean isTicketSameTypeAndLevel(Ticket first, Ticket second) { @@ -9,7 +9,7 @@ } public int getTicketLevelAt(long chunkPos, boolean requireSimulation) { -@@ -301,7 +_,7 @@ +@@ -298,7 +_,7 @@ } public void deactivateTicketsOnClosing() { @@ -18,7 +18,7 @@ } public void removeTicketIf(TicketStorage.TicketPredicate predicate, @Nullable Long2ObjectOpenHashMap> tickets) { -@@ -411,4 +_,20 @@ +@@ -408,4 +_,20 @@ public interface TicketPredicate { boolean test(Ticket ticket, long chunkPos); } 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 8f76166ac20a..1c762eb3f28b 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 -@@ -70,9 +_,33 @@ +@@ -69,9 +_,33 @@ } public static class Builder { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch index ce188d7f0471..01c89a864918 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/net/minecraft/world/level/block/BambooStalkBlock.java -@@ -120,9 +_,9 @@ +@@ -119,9 +_,9 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (state.getValue(STAGE) == 0) { @@ -12,7 +12,7 @@ this.growBamboo(state, level, pos, random, i); } } -@@ -158,7 +_,7 @@ +@@ -157,7 +_,7 @@ public boolean isValidBonemealTarget(LevelReader level, BlockPos pos, BlockState state) { int heightAboveUpToMax = this.getHeightAboveUpToMax(level, pos); int heightBelowUpToMax = this.getHeightBelowUpToMax(level, pos); @@ -21,7 +21,7 @@ } @Override -@@ -176,7 +_,7 @@ +@@ -175,7 +_,7 @@ for (int i2 = 0; i2 < i1; i2++) { BlockPos blockPos = pos.above(heightAboveUpToMax); BlockState blockState = level.getBlockState(blockPos); @@ -30,7 +30,7 @@ return; } -@@ -191,27 +_,38 @@ +@@ -190,27 +_,38 @@ BlockPos blockPos = pos.below(2); BlockState blockState1 = level.getBlockState(blockPos); BambooLeaves bambooLeaves = BambooLeaves.NONE; @@ -74,7 +74,7 @@ i++; } -@@ -221,7 +_,7 @@ +@@ -220,7 +_,7 @@ protected int getHeightBelowUpToMax(BlockGetter level, BlockPos pos) { int i = 0; 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 060ec697d016..07ff52d43be4 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 -@@ -46,8 +_,7 @@ +@@ -45,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, 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 3aff396eca7e..9b9473adc698 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,19 +1,19 @@ --- a/net/minecraft/world/level/block/BedBlock.java +++ b/net/minecraft/world/level/block/BedBlock.java -@@ -90,7 +_,7 @@ - } +@@ -91,7 +_,7 @@ } -- if (!canSetSpawn(level)) { -+ if (false && !canSetSpawn(level)) { // CraftBukkit - moved world and biome check into Player + BedRule bedRule = level.environmentAttributes().getValue(EnvironmentAttributes.BED_RULE, pos); +- if (bedRule.explodes()) { ++ if (false && bedRule.explodes()) { // CraftBukkit - moved world and biome check into Player + bedRule.errorMessage().ifPresent(component -> player.displayClientMessage(component, true)); level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); - if (level.getBlockState(blockPos).is(this)) { -@@ -101,22 +_,56 @@ +@@ -103,22 +_,61 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { -+ if (!BedBlock.canSetSpawn(level)) return this.explodeBed(state, level, pos); // Paper - check explode first ++ if (bedRule.explodes()) return this.explodeBed(state, level, pos); // Paper - check explode first if (!this.kickVillagerOutOfBed(level, pos)) { player.displayClientMessage(Component.translatable("block.minecraft.bed.occupied"), true); } @@ -25,24 +25,29 @@ + final BlockPos finalBlockPos = pos; + // CraftBukkit end player.startSleepInBed(pos).ifLeft(bedSleepingProblem -> { +- if (bedSleepingProblem.message() != null) { + // Paper start - PlayerBedFailEnterEvent ++ if (false && bedSleepingProblem.message() != null) { // Moved down + player.displayClientMessage(bedSleepingProblem.message(), true); + } + if (bedSleepingProblem != null) { -+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.values()[bedSleepingProblem.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(level, finalBlockPos), !level.dimensionType().bedWorks(), io.papermc.paper.adventure.PaperAdventure.asAdventure(bedSleepingProblem.getMessage())); -+ if (!event.callEvent()) { ++ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedFailEnterEvent(player, finalBlockPos, bedSleepingProblem); ++ if (event.isCancelled()) { + return; + } + // Paper end - PlayerBedFailEnterEvent -+ // CraftBukkit start - handling bed explosion from below here -+ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent -+ this.explodeBed(finalBlockState, level, finalBlockPos); -+ } else -+ // CraftBukkit end - if (bedSleepingProblem.getMessage() != null) { -- player.displayClientMessage(bedSleepingProblem.getMessage(), true); -+ final net.kyori.adventure.text.Component message = event.getMessage(); // Paper - PlayerBedFailEnterEvent -+ if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper - PlayerBedFailEnterEvent - } -+ } // Paper - PlayerBedFailEnterEvent ++ // CraftBukkit start - handling bed explosion from below here ++ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent ++ this.explodeBed(finalBlockState, level, finalBlockPos); ++ } ++ // CraftBukkit end ++ // Paper start - PlayerBedFailEnterEvent ++ final net.kyori.adventure.text.Component message = event.getMessage(); ++ if (message != null) { ++ player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); ++ } ++ } ++ // Paper end - PlayerBedFailEnterEvent }); return InteractionResult.SUCCESS_SERVER; } @@ -61,13 +66,13 @@ + Vec3 center = pos.getCenter(); + level.explode(null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(blockState), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state + return InteractionResult.SUCCESS_SERVER; -+ } ++ } + // CraftBukkit end + - public static boolean canSetSpawn(Level level) { - return level.dimensionType().bedWorks(); - } -@@ -299,6 +_,11 @@ + private boolean kickVillagerOutOfBed(Level level, BlockPos pos) { + List entitiesOfClass = level.getEntitiesOfClass(Villager.class, new AABB(pos), LivingEntity::isSleeping); + if (entitiesOfClass.isEmpty()) { +@@ -296,6 +_,11 @@ if (!level.isClientSide()) { BlockPos blockPos = pos.relative(state.getValue(FACING)); level.setBlock(blockPos, state.setValue(PART, BedPart.HEAD), Block.UPDATE_ALL); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch index d3b3ba927b8a..c1d513fdc879 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -129,7 +_,7 @@ +@@ -126,7 +_,7 @@ @Override protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { @@ -9,7 +9,7 @@ } @Override -@@ -192,9 +_,23 @@ +@@ -189,9 +_,23 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { @@ -34,7 +34,7 @@ } } } -@@ -206,9 +_,9 @@ +@@ -203,9 +_,9 @@ } else { Tilt tilt = state.getValue(TILT); if (tilt == Tilt.UNSTABLE) { @@ -46,7 +46,7 @@ } else if (tilt == Tilt.FULL) { resetTilt(state, level, pos); } -@@ -231,8 +_,11 @@ +@@ -228,8 +_,11 @@ return entity.onGround() && entity.position().y > pos.getY() + 0.6875F; } @@ -60,7 +60,7 @@ if (sound != null) { playTiltSound(level, pos, sound); } -@@ -244,18 +_,26 @@ +@@ -241,18 +_,26 @@ } private static void resetTilt(BlockState state, Level level, BlockPos 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 11ef775f5eaf..26f43d832a90 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 -@@ -45,8 +_,7 @@ +@@ -44,8 +_,7 @@ @Override protected void openContainer(Level level, BlockPos pos, 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 ab894a1611e7..436493129718 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,35 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -103,6 +_,21 @@ +@@ -88,16 +_,18 @@ + return !Shapes.joinIsNotEmpty(Shapes.block(), shape, BooleanOp.NOT_SAME); + } + }); +- public static final int UPDATE_NEIGHBORS = 1; +- public static final int UPDATE_CLIENTS = 2; +- public static final int UPDATE_INVISIBLE = 4; +- public static final int UPDATE_IMMEDIATE = 8; +- public static final int UPDATE_KNOWN_SHAPE = 16; +- public static final int UPDATE_SUPPRESS_DROPS = 32; +- public static final int UPDATE_MOVE_BY_PISTON = 64; +- 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; ++ // 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 ++ public static final int UPDATE_INVISIBLE = 4; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_IMMEDIATE = 8; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_KNOWN_SHAPE = 16; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_SUPPRESS_DROPS = 32; // Paper - diff on change - all listed in UpdateFlags annotation ++ public static final int UPDATE_MOVE_BY_PISTON = 64; // Paper - diff on change - all listed in UpdateFlags annotation ++ 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 ++ // Paper end - diff on change - all listed in UpdateFlags annotation + @Block.UpdateFlags + public static final int UPDATE_NONE = 260; + @Block.UpdateFlags +@@ -111,6 +_,21 @@ public static final int UPDATE_LIMIT = 512; protected final StateDefinition stateDefinition; private BlockState defaultBlockState; @@ -19,10 +48,10 @@ + this != Blocks.JIGSAW; + } + // Paper end - Protect Bedrock and End Portal/Frames from being destroyed - @Nullable - private Item item; + private @Nullable Item item; private static final int CACHE_SIZE = 256; -@@ -357,6 +_,27 @@ + private static final ThreadLocal> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> { +@@ -366,6 +_,27 @@ return state.getDrops(builder); } @@ -50,7 +79,7 @@ public static void dropResources(BlockState state, Level level, BlockPos pos) { if (level instanceof ServerLevel) { getDrops(state, (ServerLevel)level, pos, null).forEach(stack -> popResource(level, pos, stack)); -@@ -372,9 +_,14 @@ +@@ -381,9 +_,14 @@ } public static void dropResources(BlockState state, Level level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) { @@ -66,8 +95,8 @@ } } -@@ -405,13 +_,25 @@ - if (level instanceof ServerLevel serverLevel && !stack.isEmpty() && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { +@@ -414,13 +_,25 @@ + if (level instanceof ServerLevel serverLevel && !stack.isEmpty() && serverLevel.getGameRules().get(GameRules.BLOCK_DROPS)) { ItemEntity itemEntity = itemEntitySupplier.get(); itemEntity.setDefaultPickUpDelay(); - level.addFreshEntity(itemEntity); @@ -86,15 +115,15 @@ + popExperience(level, pos, amount, null); + } + -+ public void popExperience(ServerLevel level, BlockPos pos, int amount, @Nullable net.minecraft.world.entity.Entity entity) { ++ public void popExperience(ServerLevel level, BlockPos pos, int amount, net.minecraft.world.entity.@Nullable Entity entity) { + // Paper end - add entity parameter - if (level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { + if (level.getGameRules().get(GameRules.BLOCK_DROPS)) { - ExperienceOrb.award(level, Vec3.atCenterOf(pos), amount); + ExperienceOrb.awardWithDirection(level, Vec3.atCenterOf(pos), net.minecraft.world.phys.Vec3.ZERO, amount, org.bukkit.entity.ExperienceOrb.SpawnReason.BLOCK_BREAK, entity, null); // Paper } } -@@ -430,10 +_,19 @@ +@@ -438,10 +_,19 @@ return this.defaultBlockState(); } @@ -116,7 +145,7 @@ } public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { -@@ -572,12 +_,20 @@ +@@ -580,12 +_,20 @@ return this.builtInRegistryHolder; } @@ -140,3 +169,11 @@ record ShapePairKey(VoxelShape first, VoxelShape second) { @Override +@@ -601,6 +_,7 @@ + + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.METHOD, 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 ad6d41474d16..f2dadd1ca3a2 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 -@@ -64,8 +_,7 @@ +@@ -63,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, 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 c5b619fdead2..ba3a3eb68533 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 @@ -11,7 +11,7 @@ } super.entityInside(state, level, pos, entity, effectApplier, pastEdges); -@@ -220,6 +_,11 @@ +@@ -219,6 +_,11 @@ && projectile.mayInteract(serverLevel, blockPos) && !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 08c14d335c6a..1536368b6288 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,6 +1,6 @@ --- a/net/minecraft/world/level/block/CarvedPumpkinBlock.java +++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java -@@ -94,6 +_,7 @@ +@@ -87,6 +_,7 @@ CopperGolem copperGolem = EntityType.COPPER_GOLEM.create(level, EntitySpawnReason.TRIGGERED); if (copperGolem != null) { spawnGolemInWorld(level, blockPatternMatch2, copperGolem, blockPatternMatch2.getBlock(0, 0, 0).getPos()); @@ -8,7 +8,7 @@ this.replaceCopperBlockWithChest(level, blockPatternMatch2); copperGolem.spawn(this.getWeatherStateFromPattern(blockPatternMatch2)); } -@@ -112,9 +_,22 @@ +@@ -105,9 +_,22 @@ } private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) { 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 3a77d4216c42..5acb1aad3f25 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,9 +1,9 @@ --- a/net/minecraft/world/level/block/CeilingHangingSignBlock.java +++ b/net/minecraft/world/level/block/CeilingHangingSignBlock.java -@@ -166,6 +_,6 @@ - @Nullable +@@ -165,6 +_,6 @@ + @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + public @Nullable BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, BlockEntityType.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 e7dc8cd5ffca..af84505e929e 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,15 +1,15 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -94,7 +_,7 @@ +@@ -96,7 +_,7 @@ @Override public Optional acceptDouble(final ChestBlockEntity first, final ChestBlockEntity second) { final Container container = new CompoundContainer(first, second); - return Optional.of(new MenuProvider() { + return Optional.of(DoubleInventory.wrap(new MenuProvider() { // CraftBukkit - wrap for identification - @Nullable @Override - public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { -@@ -112,10 +_,10 @@ + public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { + if (first.canOpen(player) && second.canOpen(player)) { +@@ -117,10 +_,10 @@ if (first.hasCustomName()) { return first.getDisplayName(); } else { @@ -22,7 +22,7 @@ } @Override -@@ -129,6 +_,34 @@ +@@ -134,6 +_,34 @@ } }; @@ -57,7 +57,7 @@ @Override public MapCodec codec() { return CODEC; -@@ -257,8 +_,7 @@ +@@ -261,8 +_,7 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (level instanceof ServerLevel serverLevel) { MenuProvider menuProvider = this.getMenuProvider(state, level, pos); @@ -67,10 +67,10 @@ player.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -297,7 +_,14 @@ - @Nullable +@@ -299,7 +_,14 @@ + @Override - public MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { + public @Nullable MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { - return this.combine(state, level, pos, false).apply(MENU_PROVIDER_COMBINER).orElse(null); + // CraftBukkit start + return this.getMenuProvider(state, level, pos, false); @@ -83,7 +83,7 @@ } public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity lid) { -@@ -340,6 +_,11 @@ +@@ -341,6 +_,11 @@ } private static boolean isCatSittingOnChest(LevelAccessor level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch index e48da683f8f1..f1fb477ea819 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch @@ -13,7 +13,7 @@ } } } -@@ -116,7 +_,7 @@ +@@ -115,7 +_,7 @@ @Override public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { 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 8e9d308cadec..c238837a1b3d 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,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -168,8 +_,18 @@ +@@ -167,8 +_,18 @@ boolean shouldTurnOn = this.shouldTurnOn(level, pos, state); boolean poweredValue = state.getValue(POWERED); if (poweredValue && !shouldTurnOn) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch index 6be7c6727b2f..70d5463e279a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -46,7 +46,7 @@ + } + // CraftBukkit end if (!level.isClientSide()) { - Vec3 vec3 = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandom(level.random, 0.7F); + Vec3 vec3 = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandomXZ(level.random, 0.7F); ItemEntity itemEntity = new ItemEntity(level, vec3.x(), vec3.y(), vec3.z(), new ItemStack(Items.BONE_MEAL)); @@ -305,14 +_,39 @@ return blockState; 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 909d34bee8a1..04e4b761cd90 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CopperGolemStatueBlock.java +++ b/net/minecraft/world/level/block/CopperGolemStatueBlock.java -@@ -113,15 +_,21 @@ +@@ -107,15 +_,21 @@ if (stack.is(ItemTags.AXES)) { return InteractionResult.PASS; } else { 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 532af18fbb92..853254707bcf 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 -@@ -152,6 +_,13 @@ +@@ -151,6 +_,13 @@ } else { RecipeHolder recipeHolder = potentialResults.get(); ItemStack itemStack = recipeHolder.value().assemble(var11, level.registryAccess()); @@ -14,7 +14,7 @@ if (itemStack.isEmpty()) { level.levelEvent(LevelEvent.SOUND_CRAFTER_FAIL, pos, 0); } else { -@@ -186,7 +_,25 @@ +@@ -185,7 +_,25 @@ Container containerAt = HopperBlockEntity.getContainerAt(level, pos.relative(direction)); ItemStack itemStack = stack.copy(); if (containerAt != null && (containerAt instanceof CrafterBlockEntity || stack.getCount() > containerAt.getMaxStackSize(stack))) { @@ -40,7 +40,7 @@ ItemStack itemStack1 = itemStack.copyWithCount(1); ItemStack itemStack2 = HopperBlockEntity.addItem(crafter, containerAt, itemStack1, direction.getOpposite()); if (!itemStack2.isEmpty()) { -@@ -196,7 +_,25 @@ +@@ -195,7 +_,25 @@ itemStack.shrink(1); } } else if (containerAt != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch index 587f3aac91c7..8f6e73e7d302 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch @@ -41,9 +41,9 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { -- if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { + 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 instanceof ServerLevel serverLevel && entity instanceof Ravager && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit ++ if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !serverLevel.getGameRules().get(GameRules.MOB_GRIEFING))) { // CraftBukkit serverLevel.destroyBlock(pos, true, entity); } 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 e0cfede41022..8e8a4959038e 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 @@ +@@ -71,6 +_,7 @@ i = Mth.clamp(i, 0, 15); if (state.getValue(POWER) != i) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch index 1c008e5b842c..260767c050ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DecoratedPotBlock.java +++ b/net/minecraft/world/level/block/DecoratedPotBlock.java -@@ -210,6 +_,11 @@ +@@ -209,6 +_,11 @@ protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { BlockPos blockPos = hit.getBlockPos(); if (level instanceof ServerLevel serverLevel && projectile.mayInteract(serverLevel, blockPos) && projectile.mayBreak(serverLevel)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch index 18fcad808192..77f0acfcdd6f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoorBlock.java +++ b/net/minecraft/world/level/block/DoorBlock.java -@@ -222,9 +_,22 @@ +@@ -221,9 +_,22 @@ @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch index bf674349fbd8..0d4725287a6d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -110,11 +_,16 @@ +@@ -109,11 +_,16 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch index b520d37a11d0..b0a0bea9ebad 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/EndGatewayBlock.java +++ b/net/minecraft/world/level/block/EndGatewayBlock.java -@@ -90,10 +_,15 @@ +@@ -89,10 +_,15 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { @@ -16,7 +16,7 @@ entity.setAsInsidePortal(this, pos); TheEndGatewayBlockEntity.triggerCooldown(level, pos, state, theEndGatewayBlockEntity); } -@@ -108,9 +_,9 @@ +@@ -106,9 +_,9 @@ return null; } else { return entity instanceof ThrownEnderpearl 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 95ae4bc01432..d9e3c4ce3361 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 @@ -16,8 +16,8 @@ serverPlayer.showEndCredits(); } else { entity.setAsInsidePortal(this, pos); -@@ -73,7 +_,7 @@ - public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { +@@ -72,7 +_,7 @@ + public @Nullable TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { LevelData.RespawnData respawnData = level.getRespawnData(); ResourceKey resourceKey = level.dimension(); - boolean flag = resourceKey == Level.END; @@ -25,7 +25,7 @@ ResourceKey resourceKey1 = flag ? respawnData.dimension() : Level.END; BlockPos blockPos = flag ? respawnData.pos() : ServerLevel.END_SPAWN_POINT; ServerLevel level1 = level.getServer().getLevel(resourceKey1); -@@ -85,7 +_,7 @@ +@@ -84,7 +_,7 @@ float f1; Set set; if (!flag) { @@ -34,7 +34,7 @@ f = Direction.WEST.toYRot(); f1 = 0.0F; set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); -@@ -97,15 +_,24 @@ +@@ -96,15 +_,24 @@ f1 = respawnData.pitch(); set = Relative.union(Relative.DELTA, Relative.ROTATION); if (entity instanceof ServerPlayer serverPlayer) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch index 0f801757a1dc..ba5457e83159 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch @@ -25,7 +25,7 @@ if (level instanceof ServerLevel serverLevel && level.random.nextFloat() < fallDistance - 0.5 && entity instanceof LivingEntity - && (entity instanceof Player || serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) + && (entity instanceof Player || serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { + // CraftBukkit start - Interact soil + org.bukkit.event.Cancellable cancellable; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch index 80ebc96251cd..eb63a4c8835e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -101,7 +_,25 @@ +@@ -99,7 +_,25 @@ BlockState neighborState, RandomSource random ) { @@ -27,83 +27,82 @@ } @Override -@@ -141,18 +_,18 @@ +@@ -139,17 +_,17 @@ @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - level.scheduleTick(pos, this, getFireTickDelay(level.random)); + level.scheduleTick(pos, this, getFireTickDelay(level)); // Paper - Add fire-tick-delay option - if (level.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { - if (level.getGameRules().getBoolean(GameRules.RULE_ALLOWFIRETICKAWAYFROMPLAYERS) || level.anyPlayerCloseEnoughForSpawning(pos)) { - if (!state.canSurvive(level, pos)) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - invalid place location - } - - BlockState blockState = level.getBlockState(pos.below()); - boolean isTag = blockState.is(level.dimensionType().infiniburn()); - int ageValue = state.getValue(AGE); - if (!isTag && level.isRaining() && this.isNearRain(level, pos) && random.nextFloat() < 0.2F + ageValue * 0.03F) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - extinguished by rain - } else { - int min = Math.min(15, ageValue + random.nextInt(3) / 2); - if (ageValue != min) { -@@ -164,26 +_,28 @@ - if (!this.isValidFireLocation(level, pos)) { - BlockPos blockPos = pos.below(); - if (!level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP) || ageValue > 3) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - } - - return; - } + if (level.canSpreadFireAround(pos)) { + if (!state.canSurvive(level, pos)) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit - invalid place location + } - if (ageValue == 15 && random.nextInt(4) == 0 && !this.canBurn(level.getBlockState(pos.below()))) { + BlockState blockState = level.getBlockState(pos.below()); + boolean isTag = blockState.is(level.dimensionType().infiniburn()); + int ageValue = state.getValue(AGE); + if (!isTag && level.isRaining() && this.isNearRain(level, pos) && random.nextFloat() < 0.2F + ageValue * 0.03F) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit - extinguished by rain + } else { + int min = Math.min(15, ageValue + random.nextInt(3) / 2); + if (ageValue != min) { +@@ -161,26 +_,28 @@ + if (!this.isValidFireLocation(level, pos)) { + BlockPos blockPos = pos.below(); + if (!level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP) || ageValue > 3) { - level.removeBlock(pos, false); + this.fireExtinguished(level, pos); // CraftBukkit - return; } + + return; + } + + if (ageValue == 15 && random.nextInt(4) == 0 && !this.canBurn(level.getBlockState(pos.below()))) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit + return; } + } - boolean isIncreasedFireBurnout = level.getBiome(pos).is(BiomeTags.INCREASED_FIRE_BURNOUT); - int i = isIncreasedFireBurnout ? -50 : 0; -- this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue); -- this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue); -- this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue); -+ // CraftBukkit start - add source blockPos to burn calls -+ this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); -+ // CraftBukkit end - BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + boolean value = level.environmentAttributes().getValue(EnvironmentAttributes.INCREASED_FIRE_BURNOUT, pos); + int i = value ? -50 : 0; +- this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue); +- this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue); +- this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue); ++ // CraftBukkit start - add source blockPos to burn calls ++ this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); ++ // CraftBukkit end - add source blockPos to burn calls + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for (int i1 = -1; i1 <= 1; i1++) { -@@ -205,7 +_,15 @@ + for (int i1 = -1; i1 <= 1; i1++) { +@@ -202,7 +_,15 @@ - if (i5 > 0 && random.nextInt(i4) <= i5 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { - int min1 = Math.min(15, ageValue + random.nextInt(5) / 4); -- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), Block.UPDATE_ALL); -+ // CraftBukkit start - Call to stop spread of fire -+ if (!level.getBlockState(mutableBlockPos).is(Blocks.FIRE)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, mutableBlockPos, pos).isCancelled()) { -+ continue; -+ } -+ -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); // CraftBukkit + if (i5 > 0 && random.nextInt(i4) <= i5 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { + int min1 = Math.min(15, ageValue + random.nextInt(5) / 4); +- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), Block.UPDATE_ALL); ++ // CraftBukkit start - Call to stop spread of fire ++ if (!level.getBlockState(mutableBlockPos).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, mutableBlockPos, pos).isCancelled()) { ++ continue; + } -+ // CraftBukkit end - } ++ ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), UPDATE_ALL); // CraftBukkit ++ } ++ // CraftBukkit end } } -@@ -237,19 +_,40 @@ + } +@@ -233,19 +_,40 @@ : this.igniteOdds.getInt(state.getBlock()); } @@ -146,7 +145,7 @@ TntBlock.prime(level, pos); } } -@@ -291,13 +_,14 @@ +@@ -287,13 +_,14 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch index 9d85e5f8b437..6bd8c0239747 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -66,6 +_,18 @@ +@@ -67,6 +_,18 @@ } else if (!this.isEmpty()) { return InteractionResult.CONSUME; } else { @@ -19,7 +19,7 @@ level.setBlock(pos, blockState, Block.UPDATE_ALL); level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); player.awardStat(Stats.POT_FLOWER); -@@ -80,6 +_,18 @@ +@@ -81,6 +_,18 @@ return InteractionResult.CONSUME; } else { ItemStack itemStack = new ItemStack(this.potted); 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 c383a4b8f2d8..7388ee1d652a 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 -@@ -45,8 +_,7 @@ +@@ -44,8 +_,7 @@ @Override protected void openContainer(Level level, BlockPos pos, 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 db77e5ffefa5..8e160a4c11cb 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 @@ +@@ -102,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { @@ -10,7 +10,7 @@ player.awardStat(Stats.INSPECT_HOPPER); } -@@ -158,6 +_,7 @@ +@@ -154,6 +_,7 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch index 4950d358fd5e..8f529c109ad5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/IceBlock.java +++ b/net/minecraft/world/level/block/IceBlock.java -@@ -32,8 +_,13 @@ +@@ -33,8 +_,13 @@ } @Override @@ -14,17 +14,20 @@ + public void afterDestroy(Level level, BlockPos pos, ItemStack stack) { + // Paper end - Improve Block#breakNaturally API if (!EnchantmentHelper.hasTag(stack, EnchantmentTags.PREVENTS_ICE_MELTING)) { - if (level.dimensionType().ultraWarm()) { + if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos)) { level.removeBlock(pos, false); -@@ -55,6 +_,11 @@ +@@ -56,7 +_,13 @@ } protected void melt(BlockState state, Level level, BlockPos pos) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, level.dimensionType().ultraWarm() ? Blocks.AIR.defaultBlockState() : Blocks.WATER.defaultBlockState()).isCancelled()) { +- if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos)) { ++ // Paper start - call BlockFadeEvent ++ final boolean waterEvaporates = level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, waterEvaporates ? Blocks.AIR.defaultBlockState() : Blocks.WATER.defaultBlockState()).isCancelled()) { + return; + } -+ // CraftBukkit end - if (level.dimensionType().ultraWarm()) { ++ if (waterEvaporates) { ++ // Paper end - call BlockFadeEvent level.removeBlock(pos, false); } else { + level.setBlockAndUpdate(pos, meltsInto()); 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 b477c022c3c0..8d6d7c1e5aaf 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, entity1 -> { - if (entity1.isOnFire() && entity1.mayInteract(serverLevel, blockPos)) { - this.handleEntityOnFireInside(state, level, blockPos); -+ if (entity1.isOnFire() && (entity instanceof net.minecraft.world.entity.player.Player || serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING)) && entity1.mayInteract(serverLevel, blockPos)) { // Paper - Fixes MC-248588 ++ if (entity1.isOnFire() && (entity instanceof net.minecraft.world.entity.player.Player || serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.MOB_GRIEFING)) && entity1.mayInteract(serverLevel, blockPos)) { // Paper - Fixes MC-248588 + // Paper start - cauldron level change event + if (this.handleEntityOnFireInside(state, level, blockPos, entity1)) { // Paper - track entity + InsideBlockEffectType.EXTINGUISH.effect().affect(entity1, blockPos); // apply extinguishing if event was not cancelled. diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch index 24d95a3621a1..8cb50108abfb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LeavesBlock.java +++ b/net/minecraft/world/level/block/LeavesBlock.java -@@ -56,6 +_,14 @@ +@@ -66,6 +_,14 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (this.decaying(state)) { 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 a2e5f2f1ce5d..e8377204ce2a 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 @@ -43,7 +43,7 @@ level.setBlock(pos, state.setValue(POWERED, powered), Block.UPDATE_ALL); updateBelow(level, pos, state); } -@@ -244,8 +_,7 @@ +@@ -243,8 +_,7 @@ private void openScreen(Level level, BlockPos pos, Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch index 89c9166ec4dc..9777099fd666 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LeverBlock.java +++ b/net/minecraft/world/level/block/LeverBlock.java -@@ -68,6 +_,19 @@ +@@ -67,6 +_,19 @@ makeParticle(blockState, level, pos, 1.0F); } } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch index 5bb146741cbb..713e011d6d6c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MangrovePropaguleBlock.java +++ b/net/minecraft/world/level/block/MangrovePropaguleBlock.java -@@ -103,7 +_,7 @@ +@@ -102,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!isHanging(state)) { 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 ea4a2323a87d..da474d26f0cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MultifaceSpreader.java +++ b/net/minecraft/world/level/block/MultifaceSpreader.java -@@ -154,14 +_,14 @@ +@@ -152,14 +_,14 @@ level.getChunk(pos.pos()).markPosForPostprocessing(pos.pos()); } @@ -17,7 +17,7 @@ } @FunctionalInterface -@@ -173,19 +_,19 @@ +@@ -171,19 +_,19 @@ SAME_POSITION { @Override public MultifaceSpreader.SpreadPos getSpreadPos(BlockPos pos, Direction face, Direction spreadDirection) { 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 9a769130ce04..30b239c9d2f8 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,15 +1,15 @@ --- a/net/minecraft/world/level/block/NetherPortalBlock.java +++ b/net/minecraft/world/level/block/NetherPortalBlock.java -@@ -65,7 +_,7 @@ +@@ -66,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { -- if (level.dimensionType().natural() -+ if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.dimensionType().natural() // Spigot - && level.isSpawningMonsters() +- if (level.isSpawningMonsters() ++ if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.isSpawningMonsters() // Spigot + && level.environmentAttributes().getValue(EnvironmentAttributes.NETHER_PORTAL_SPAWNS_PIGLINS, pos) && random.nextInt(2000) < level.getDifficulty().getId() && level.anyPlayerCloseEnoughForSpawning(pos)) { -@@ -74,9 +_,13 @@ +@@ -75,9 +_,13 @@ } if (level.getBlockState(pos).isValidSpawn(level, pos, EntityType.ZOMBIFIED_PIGLIN)) { @@ -24,7 +24,7 @@ Entity vehicle = entity.getVehicle(); if (vehicle != null) { vehicle.setPortalCooldown(); -@@ -107,7 +_,13 @@ +@@ -108,7 +_,13 @@ @Override protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { @@ -38,10 +38,10 @@ entity.setAsInsidePortal(this, pos); } } -@@ -130,22 +_,46 @@ - @Nullable +@@ -126,23 +_,47 @@ + @Override - public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { + public @Nullable TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { - ResourceKey resourceKey = level.dimension() == Level.NETHER ? Level.OVERWORLD : Level.NETHER; + // CraftBukkit start + ResourceKey resourceKey = level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER ? Level.OVERWORLD : Level.NETHER; @@ -82,15 +82,16 @@ } } - @Nullable -- private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder) { + private @Nullable TeleportTransition getExitPortal( +- ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder ++ ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result // CraftBukkit + ) { - Optional optional = level.getPortalForcer().findClosestPortalPosition(exitPos, isNether, worldBorder); -+ private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result) { // CraftBukkit + Optional optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, result.searchRadius()); // CraftBukkit BlockUtil.FoundRectangle largestRectangleAround; TeleportTransition.PostTeleportTransition postTeleportTransition; if (optional.isPresent()) { -@@ -160,17 +_,22 @@ +@@ -157,17 +_,22 @@ blockPos1 -> level.getBlockState(blockPos1) == blockState ); postTeleportTransition = TeleportTransition.PLAY_PORTAL_SOUND.then(entity1 -> entity1.placePortalTicket(blockPos)); @@ -116,7 +117,7 @@ return getDimensionTransitionFromExit(entity, pos, largestRectangleAround, level, postTeleportTransition); } -@@ -216,7 +_,7 @@ +@@ -213,7 +_,7 @@ boolean flag = axis1 == Direction.Axis.X; Vec3 vec3 = new Vec3(blockPos.getX() + (flag ? d2 : d4), blockPos.getY() + d3, blockPos.getZ() + (flag ? d4 : d2)); Vec3 vec31 = PortalShape.findCollisionFreePosition(vec3, level, entity, dimensions); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch index ec52a7b6e9f5..d1edc4d8998f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/PitcherCropBlock.java +++ b/net/minecraft/world/level/block/PitcherCropBlock.java -@@ -118,6 +_,7 @@ +@@ -117,6 +_,7 @@ @Override public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { + 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 instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) { serverLevel.destroyBlock(pos, true, entity); } -@@ -140,7 +_,7 @@ +@@ -139,7 +_,7 @@ @Override public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { float growthSpeed = CropBlock.getGrowthSpeed(this, level, pos); @@ -17,7 +17,7 @@ if (flag) { this.grow(level, state, pos, 1); } -@@ -150,7 +_,7 @@ +@@ -149,7 +_,7 @@ int min = Math.min(state.getValue(AGE) + ageIncrement, 4); if (this.canGrow(level, pos, state, min)) { BlockState blockState = state.setValue(AGE, min); 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 702e9730419d..ac731a2994d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -143,6 +_,11 @@ +@@ -144,6 +_,11 @@ && projectile.mayBreak(serverLevel) && projectile instanceof ThrownTrident && projectile.getDeltaMovement().length() > 0.6) { @@ -12,7 +12,7 @@ level.destroyBlock(blockPos, true); } } -@@ -151,7 +_,7 @@ +@@ -152,7 +_,7 @@ @Override public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, double fallDistance) { if (state.getValue(TIP_DIRECTION) == Direction.UP && state.getValue(THICKNESS) == DripstoneThickness.TIP) { @@ -21,7 +21,7 @@ } else { super.fallOn(level, state, pos, entity, fallDistance); } -@@ -209,10 +_,11 @@ +@@ -210,10 +_,11 @@ if (blockPos != null) { if (fluidAboveStalactite.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) { BlockState blockState = Blocks.CLAY.defaultBlockState(); @@ -34,7 +34,7 @@ } else { BlockPos blockPos1 = findFillableCauldronBelowStalactiteTip(level, blockPos, fluid); if (blockPos1 != null) { -@@ -364,17 +_,17 @@ +@@ -357,17 +_,17 @@ if (isUnmergedTipWithDirection(blockState, direction.getOpposite())) { createMergedTips(blockState, server, blockPos); } else if (blockState.isAir() || blockState.is(Blocks.WATER)) { @@ -55,7 +55,7 @@ } private static void createMergedTips(BlockState state, LevelAccessor level, BlockPos pos) { -@@ -388,8 +_,8 @@ +@@ -381,8 +_,8 @@ blockPos = pos.below(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch index b3063011ab02..fb6700ff7d0e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -19,11 +19,11 @@ entity1 -> { if (level instanceof ServerLevel serverLevel && entity1.isOnFire() -- && (serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof Player) +- && (serverLevel.getGameRules().get(GameRules.MOB_GRIEFING) || entity1 instanceof Player) + // CraftBukkit - move down && entity1.mayInteract(serverLevel, blockPos)) { + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity1, pos, Blocks.AIR.defaultBlockState(), !(serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof Player))) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity1, pos, Blocks.AIR.defaultBlockState(), !(serverLevel.getGameRules().get(GameRules.MOB_GRIEFING) || entity1 instanceof Player))) { + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch index 8b4e8f8001fd..ab0b98fd47f4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch @@ -13,7 +13,7 @@ public RailState(Level level, BlockPos pos, BlockState state) { this.level = level; this.pos = pos; -@@ -141,6 +_,11 @@ +@@ -140,6 +_,11 @@ } private void connectTo(RailState state) { @@ -25,7 +25,7 @@ this.connections.add(state.pos); BlockPos blockPos = this.pos.north(); BlockPos blockPos1 = this.pos.south(); -@@ -331,10 +_,15 @@ +@@ -330,10 +_,15 @@ this.state = this.state.setValue(this.block.getShapeProperty(), railShape); if (alwaysPlace || this.level.getBlockState(this.pos) != this.state) { this.level.setBlock(this.pos, this.state, Block.UPDATE_ALL); @@ -42,7 +42,7 @@ rail.removeSoftConnections(); if (rail.canConnectTo(this)) { rail.connectTo(this); -@@ -347,6 +_,6 @@ +@@ -346,6 +_,6 @@ } public BlockState getState() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch index 40638c1dbbf1..652ca91bea10 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneLampBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/RedstoneLampBlock.java +++ b/net/minecraft/world/level/block/RedstoneLampBlock.java -@@ -41,6 +_,11 @@ +@@ -40,6 +_,11 @@ if (litValue) { level.scheduleTick(pos, this, 4); } else { @@ -12,7 +12,7 @@ level.setBlock(pos, state.cycle(LIT), Block.UPDATE_CLIENTS); } } -@@ -50,6 +_,11 @@ +@@ -49,6 +_,11 @@ @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (state.getValue(LIT) && !level.hasNeighborSignal(pos)) { 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 cc868f6373da..392898ca5c6f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -104,11 +_,16 @@ - ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); - ServerPlayer.RespawnConfig respawnConfig1 = new ServerPlayer.RespawnConfig(LevelData.RespawnData.of(level.dimension(), pos, 0.0F, 0.0F), false); - if (respawnConfig == null || !respawnConfig.isSamePosition(respawnConfig1)) { -- serverPlayer.setRespawnPosition(respawnConfig1, true); -+ if (serverPlayer.setRespawnPosition(respawnConfig1, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent - level.playSound( - null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F +@@ -106,11 +_,16 @@ + LevelData.RespawnData.of(serverLevel.dimension(), pos, 0.0F, 0.0F), false ); - return InteractionResult.SUCCESS_SERVER; -+ // Paper start - Add PlayerSetSpawnEvent -+ } else { -+ return InteractionResult.FAIL; -+ } -+ // Paper end - Add PlayerSetSpawnEvent + if (respawnConfig == null || !respawnConfig.isSamePosition(respawnConfig1)) { +- serverPlayer.setRespawnPosition(respawnConfig1, true); ++ if (serverPlayer.setRespawnPosition(respawnConfig1, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent + serverLevel.playSound( + null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F + ); + return InteractionResult.SUCCESS_SERVER; ++ // Paper start - Add PlayerSetSpawnEvent ++ } else { ++ return InteractionResult.FAIL; ++ } ++ // Paper end - Add PlayerSetSpawnEvent + } } - } -@@ -142,6 +_,7 @@ +@@ -147,6 +_,7 @@ } - private void explode(BlockState state, Level level, final BlockPos pos2) { + private void explode(BlockState state, ServerLevel level, final BlockPos pos2) { + org.bukkit.block.BlockState blockState = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos2).getState(); // CraftBukkit - capture BlockState before remove block level.removeBlock(pos2, false); boolean flag = Direction.Plane.HORIZONTAL.stream().map(pos2::relative).anyMatch(blockPos -> isWaterThatWouldFlow(blockPos, level)); final boolean flag1 = flag || level.getFluidState(pos2.above()).is(FluidTags.WATER); -@@ -155,7 +_,7 @@ +@@ -160,7 +_,7 @@ }; Vec3 center = pos2.getCenter(); level.explode( 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 5ba297feff6c..b3c120dc3f1d 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 -@@ -61,8 +_,16 @@ +@@ -59,8 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, 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 20d1353b1c5c..167825ee44da 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 @@ +@@ -101,6 +_,18 @@ && level.getBlockEntity(pos) instanceof SculkSensorBlockEntity sculkSensorBlockEntity && level instanceof ServerLevel serverLevel && sculkSensorBlockEntity.getVibrationUser().canReceiveVibration(serverLevel, pos, GameEvent.STEP, GameEvent.Context.of(state))) { @@ -19,7 +19,7 @@ sculkSensorBlockEntity.getListener().forceScheduleVibration(serverLevel, GameEvent.STEP, GameEvent.Context.of(entity), entity.position()); } -@@ -191,10 +_,19 @@ +@@ -188,10 +_,19 @@ } public static boolean canActivate(BlockState state) { @@ -40,7 +40,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); -@@ -206,6 +_,15 @@ +@@ -203,6 +_,15 @@ } public void activate(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, int power, int frequency) { @@ -56,7 +56,7 @@ level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, power), Block.UPDATE_ALL); level.scheduleTick(pos, state.getBlock(), this.getActiveTicks()); updateNeighbours(level, pos, state); -@@ -283,8 +_,16 @@ +@@ -280,8 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, 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 1c5547e4529a..3bd01d8b8855 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 @@ -8,7 +8,7 @@ serverLevel.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent(sculkShrieker -> sculkShrieker.tryShriek(serverLevel, serverPlayer)); } } -@@ -128,9 +_,16 @@ +@@ -126,9 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); @@ -25,4 +25,4 @@ + // CraftBukkit end } - @Nullable + @Override 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 15ba87e8790d..f7dd0ba9f20a 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 -@@ -78,8 +_,8 @@ +@@ -76,8 +_,8 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { 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); } -@@ -117,7 +_,7 @@ +@@ -115,7 +_,7 @@ itemEntity.setDefaultPickUpDelay(); level.addFreshEntity(itemEntity); } else { @@ -20,33 +20,3 @@ } } -@@ -127,7 +_,15 @@ - @Override - protected List getDrops(BlockState state, LootParams.Builder params) { - BlockEntity blockEntity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); -+ Runnable reAdd = null; // Paper - if (blockEntity instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity) { -+ // Paper start - clear loot table if it was already used -+ if (shulkerBoxBlockEntity.lootableData().getLastFill() != -1 || !params.getLevel().paperConfig().lootables.retainUnlootedShulkerBoxLootTableOnNonPlayerBreak) { -+ net.minecraft.resources.ResourceKey lootTableResourceKey = shulkerBoxBlockEntity.getLootTable(); -+ reAdd = () -> shulkerBoxBlockEntity.setLootTable(lootTableResourceKey); -+ shulkerBoxBlockEntity.setLootTable(null); -+ } -+ // Paper end - params = params.withDynamicDrop(CONTENTS, output -> { - for (int i = 0; i < shulkerBoxBlockEntity.getContainerSize(); i++) { - output.accept(shulkerBoxBlockEntity.getItem(i)); -@@ -135,7 +_,13 @@ - }); - } - -+ // Paper start - re-set loot table if it was cleared -+ try { - return super.getDrops(state, params); -+ } finally { -+ if (reAdd != null) reAdd.run(); -+ } -+ // Paper end - re-set loot table if it was cleared - } - - @Override 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 eb1e38d31a91..3ea7cf679255 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 @@ -44,10 +44,10 @@ signEntity.setAllowedPlayerEditor(player.getUUID()); player.openTextEdit(signEntity, isFrontText); } -@@ -192,6 +_,6 @@ - @Nullable +@@ -191,6 +_,6 @@ + @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + public @Nullable BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, BlockEntityType.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 27b9bafcfd4e..dd2321c6f79c 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 -@@ -44,8 +_,7 @@ +@@ -43,8 +_,7 @@ @Override protected void openContainer(Level level, BlockPos pos, Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); 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 d2ce10af2f78..5dfdd1e2d92d 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 -@@ -41,9 +_,17 @@ +@@ -40,9 +_,17 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); 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 5661b3fd72df..478b2ae1b110 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 @@ -41,9 +41,9 @@ } - private static boolean prime(Level level, BlockPos pos, @Nullable LivingEntity entity) { -- if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { +- if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.TNT_EXPLODES)) { + private static boolean prime(Level level, BlockPos pos, @Nullable LivingEntity entity, java.util.function.BooleanSupplier event) { // Paper -+ if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES) && event.getAsBoolean()) { // Paper ++ if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().get(GameRules.TNT_EXPLODES) && event.getAsBoolean()) { // Paper PrimedTnt primedTnt = new PrimedTnt(level, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, entity); level.addFreshEntity(primedTnt); level.playSound(null, primedTnt.getX(), primedTnt.getY(), primedTnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch index bb0a61839340..690161f2fd68 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -113,10 +_,10 @@ +@@ -112,10 +_,10 @@ if (optionalValue.isPresent()) { Direction direction = optionalValue.get(); boolean flag = hookState.getOptionalValue(ATTACHED).orElse(false); @@ -13,7 +13,7 @@ int i = 0; BlockState[] blockStates = new BlockState[42]; -@@ -152,21 +_,48 @@ +@@ -151,21 +_,48 @@ flag2 &= i > 1; flag3 &= flag2; BlockState blockState1 = block.defaultBlockState().trySetValue(ATTACHED, flag2).trySetValue(POWERED, flag3); @@ -63,7 +63,7 @@ if (flag != flag2) { for (int i2 = 1; i2 < i; i2++) { -@@ -175,7 +_,7 @@ +@@ -174,7 +_,7 @@ if (blockState2 != null) { BlockState blockState3 = level.getBlockState(blockPos1); if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch index 636672b14e32..a10acf0be51c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -74,6 +_,19 @@ +@@ -75,6 +_,19 @@ && level instanceof ServerLevel serverLevel && this.canDestroyEgg(serverLevel, entity) && level.random.nextInt(chance) == 0) { @@ -20,8 +20,8 @@ this.decreaseEggs(serverLevel, pos, state); } } -@@ -95,10 +_,19 @@ - if (this.shouldUpdateHatchLevel(level) && onSand(level, pos)) { +@@ -96,10 +_,19 @@ + if (this.shouldUpdateHatchLevel(level, pos) && onSand(level, pos)) { int hatchValue = state.getValue(HATCH); if (hatchValue < 2) { + // CraftBukkit start - Call BlockGrowEvent @@ -41,7 +41,7 @@ level.playSound(null, pos, SoundEvents.TURTLE_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); level.removeBlock(pos, false); level.gameEvent(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(state)); -@@ -110,7 +_,7 @@ +@@ -111,7 +_,7 @@ turtle.setAge(-24000); turtle.setHomePos(pos); turtle.snapTo(pos.getX() + 0.3 + i * 0.2, pos.getY(), pos.getZ() + 0.3, 0.0F, 0.0F); @@ -50,7 +50,7 @@ } } } -@@ -138,8 +_,8 @@ +@@ -139,8 +_,8 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch index 705f3164b2fa..fc6f846c34cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch @@ -3,7 +3,7 @@ @@ -166,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - if (level.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) { + if (level.getGameRules().get(GameRules.SPREAD_VINES)) { - if (random.nextInt(4) == 0) { + if (random.nextFloat() < (level.spigotConfig.vineModifier / (100.0F * 4))) { // Spigot - SPIGOT-7159: Better modifier resolution Direction random1 = Direction.getRandom(random); 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 e00affc15925..b3a0e5ec97b3 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,9 +1,9 @@ --- a/net/minecraft/world/level/block/WallHangingSignBlock.java +++ b/net/minecraft/world/level/block/WallHangingSignBlock.java -@@ -176,6 +_,6 @@ - @Nullable +@@ -174,6 +_,6 @@ + @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + public @Nullable BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, BlockEntityType.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 7d61368e22b6..a1496c38cf0b 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,6 +1,6 @@ --- a/net/minecraft/world/level/block/WitherSkullBlock.java +++ b/net/minecraft/world/level/block/WitherSkullBlock.java -@@ -51,6 +_,7 @@ +@@ -49,6 +_,7 @@ } public static void checkSpawn(Level level, BlockPos pos, SkullBlockEntity blockEntity) { @@ -8,7 +8,7 @@ if (!level.isClientSide()) { BlockState blockState = blockEntity.getBlockState(); boolean flag = blockState.is(Blocks.WITHER_SKELETON_SKULL) || blockState.is(Blocks.WITHER_SKELETON_WALL_SKULL); -@@ -59,7 +_,7 @@ +@@ -57,7 +_,7 @@ if (blockPatternMatch != null) { WitherBoss witherBoss = EntityType.WITHER.create(level, EntitySpawnReason.TRIGGERED); if (witherBoss != null) { @@ -17,7 +17,7 @@ BlockPos pos1 = blockPatternMatch.getBlock(1, 2, 0).getPos(); witherBoss.snapTo( pos1.getX() + 0.5, -@@ -70,12 +_,18 @@ +@@ -68,12 +_,18 @@ ); witherBoss.yBodyRot = blockPatternMatch.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F; witherBoss.makeInvulnerable(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index add1fa3677cb..5b1e1d124407 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -205,7 +205,7 @@ this.cookingTimer = 0; this.setChanged(); } -@@ -343,8 +_,8 @@ +@@ -342,8 +_,8 @@ public void awardUsedRecipes(Player player, List items) { } @@ -216,7 +216,7 @@ player.awardRecipes(recipesToAwardAndPopExperience); for (RecipeHolder recipeHolder : recipesToAwardAndPopExperience) { -@@ -357,30 +_,60 @@ +@@ -354,30 +_,60 @@ } public List> getRecipesToAwardAndPopExperience(ServerLevel level, Vec3 popVec) { @@ -243,7 +243,7 @@ + private static void createExperience(ServerLevel level, Vec3 popVec, int recipeIndex, float experience, BlockPos blockPos, ServerPlayer serverPlayer, ItemStack itemStack, int amount) { // CraftBukkit int floor = Mth.floor(recipeIndex * experience); float fraction = Mth.frac(recipeIndex * experience); - if (fraction != 0.0F && Math.random() < fraction) { + if (fraction != 0.0F && level.random.nextFloat() < fraction) { floor++; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch index 237a3c34e038..6631c94aa4ed 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BannerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BannerBlockEntity.java -@@ -51,7 +_,7 @@ +@@ -49,7 +_,7 @@ @Override protected void saveAdditional(ValueOutput output) { super.saveAdditional(output); @@ -9,7 +9,7 @@ output.store("patterns", BannerPatternLayers.CODEC, this.patterns); } -@@ -62,7 +_,7 @@ +@@ -60,7 +_,7 @@ protected void loadAdditional(ValueInput input) { super.loadAdditional(input); this.name = parseCustomNameSafe(input, "CustomName"); @@ -18,7 +18,7 @@ } @Override -@@ -70,9 +_,18 @@ +@@ -68,9 +_,18 @@ return ClientboundBlockEntityDataPacket.create(this); } @@ -37,7 +37,7 @@ } public BannerPatternLayers getPatterns() { -@@ -92,7 +_,7 @@ +@@ -90,7 +_,7 @@ @Override protected void applyImplicitComponents(DataComponentGetter componentGetter) { super.applyImplicitComponents(componentGetter); @@ -46,7 +46,7 @@ this.name = componentGetter.get(DataComponents.CUSTOM_NAME); } -@@ -108,4 +_,13 @@ +@@ -106,4 +_,13 @@ output.discard("patterns"); output.discard("CustomName"); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index 2c832a19bb34..1c321829b731 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,61 +1,36 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -66,17 +_,45 @@ +@@ -66,14 +_,19 @@ protected abstract Component getDefaultName(); public boolean canOpen(Player player) { -- return canUnlock(player, this.lockKey, this.getDisplayName()); -+ return canUnlock(player, this.lockKey, this.getDisplayName(), this); // Paper - Add BlockLockCheckEvent +- return this.lockKey.canUnlock(player); ++ return org.bukkit.craftbukkit.event.CraftEventFactory.callBlockLockCheckEvent(this, this.lockKey, this.getDisplayName(), player); // Paper - Call BlockLockCheckEvent } -+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Add BlockLockCheckEvent - public static boolean canUnlock(Player player, LockCode code, Component displayName) { -+ // Paper start - Add BlockLockCheckEvent -+ return canUnlock(player, code, displayName, null); -+ } -+ -+ public static boolean canUnlock(Player player, LockCode code, Component displayName, @Nullable BlockEntity blockEntity) { -+ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer && blockEntity != null && blockEntity.getLevel() != null && blockEntity.getLevel().getBlockEntity(blockEntity.getBlockPos()) == blockEntity) { -+ final org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos()); -+ net.kyori.adventure.text.Component lockedMessage = net.kyori.adventure.text.Component.translatable("container.isLocked", io.papermc.paper.adventure.PaperAdventure.asAdventure(displayName)); -+ net.kyori.adventure.sound.Sound lockedSound = net.kyori.adventure.sound.Sound.sound(org.bukkit.Sound.BLOCK_CHEST_LOCKED, net.kyori.adventure.sound.Sound.Source.BLOCK, 1.0F, 1.0F); -+ final io.papermc.paper.event.block.BlockLockCheckEvent event = new io.papermc.paper.event.block.BlockLockCheckEvent(block, serverPlayer.getBukkitEntity(), lockedMessage, lockedSound); -+ event.callEvent(); -+ if (event.getResult() == org.bukkit.event.Event.Result.ALLOW) { -+ return true; -+ } else if (event.getResult() == org.bukkit.event.Event.Result.DENY || (!player.isSpectator() && !code.unlocksWith(event.isUsingCustomKeyItemStack() ? org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getKeyItem()) : player.getMainHandItem()))) { -+ if (event.getLockedMessage() != null) { -+ event.getPlayer().sendActionBar(event.getLockedMessage()); -+ } -+ if (event.getLockedSound() != null) { -+ event.getPlayer().playSound(event.getLockedSound()); -+ } -+ return false; -+ } else { -+ return true; -+ } -+ } else { // logic below is replaced by logic above -+ // Paper end - Add BlockLockCheckEvent - if (!player.isSpectator() && !code.unlocksWith(player.getMainHandItem())) { -- player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); -+ player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); // Paper - diff on change - player.playNotifySound(SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); - return false; - } else { - return true; + public static void sendChestLockedNotifications(Vec3 pos, Player player, Component displayName) { ++ // Paper start - BlockLockCheckEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.sendChestLockedNotifications(pos)) { ++ return; ++ } ++ // Paper end - BlockLockCheckEvent + Level level = player.level(); +- player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); ++ player.displayClientMessage(Component.translatable("container.isLocked", displayName), true); // Paper - diff on change + if (!level.isClientSide()) { +- level.playSound(null, pos.x(), pos.y(), pos.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.playSound(null, pos.x(), pos.y(), pos.z(), SoundEvents.CHEST_LOCKED, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper - diff on change } -+ } // Paper - Add BlockLockCheckEvent } - public boolean isLocked() { -@@ -168,4 +_,12 @@ +@@ -170,4 +_,12 @@ output.discard("lock"); output.discard("Items"); } + + // CraftBukkit start + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + if (this.level == null) return null; + return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } 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 06e7df1f2691..74e7cf991841 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,12 +1,11 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -110,6 +_,53 @@ +@@ -107,6 +_,51 @@ return 3; } }; + // CraftBukkit start - add fields and methods -+ @Nullable -+ public org.bukkit.potion.PotionEffect getPrimaryEffect() { ++ public org.bukkit.potion.@Nullable PotionEffect getPrimaryEffect() { + return (this.primaryPower != null) + ? org.bukkit.craftbukkit.potion.CraftPotionUtil.toBukkit(new MobEffectInstance( + this.primaryPower, @@ -18,8 +17,7 @@ + : null; + } + -+ @Nullable -+ public org.bukkit.potion.PotionEffect getSecondaryEffect() { ++ public org.bukkit.potion.@Nullable PotionEffect getSecondaryEffect() { + return (BeaconBlockEntity.hasSecondaryEffect(this.levels, this.primaryPower, this.secondaryPower)) + ? org.bukkit.craftbukkit.potion.CraftPotionUtil.toBukkit(new MobEffectInstance( + this.secondaryPower, @@ -52,9 +50,9 @@ + } + // Paper end - Custom beacon ranges - @Nullable - static Holder filterEffect(@Nullable Holder effect) { -@@ -167,17 +_,26 @@ + static @Nullable Holder filterEffect(@Nullable Holder effect) { + return VALID_EFFECTS.contains(effect) ? effect : null; +@@ -163,17 +_,26 @@ blockEntity.lastCheckY++; } @@ -83,7 +81,7 @@ if (blockEntity.lastCheckY >= height) { blockEntity.lastCheckY = level.getMinY() - 1; -@@ -228,35 +_,100 @@ +@@ -224,35 +_,100 @@ @Override public void setRemoved() { @@ -202,16 +200,16 @@ public static void playSound(Level level, BlockPos pos, SoundEvent sound) { level.playSound(null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F); -@@ -285,7 +_,7 @@ +@@ -280,7 +_,7 @@ + } - @Nullable - private static Holder loadEffect(ValueInput input, String key) { + private static @Nullable Holder loadEffect(ValueInput input, String key) { - return input.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).filter(VALID_EFFECTS::contains).orElse(null); + return input.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) } @Override -@@ -293,8 +_,10 @@ +@@ -288,8 +_,10 @@ super.loadAdditional(input); this.primaryPower = loadEffect(input, "primary_effect"); this.secondaryPower = loadEffect(input, "secondary_effect"); @@ -222,7 +220,7 @@ } @Override -@@ -305,6 +_,7 @@ +@@ -300,6 +_,7 @@ output.putInt("Levels", this.levels); output.storeNullable("CustomName", ComponentSerialization.CODEC, this.name); this.lockKey.addToTag(output); @@ -230,12 +228,12 @@ } public void setCustomName(@Nullable Component name) { -@@ -320,7 +_,7 @@ - @Nullable +@@ -313,7 +_,7 @@ + @Override - public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { -- return BaseContainerBlockEntity.canUnlock(player, this.lockKey, this.getDisplayName()) -+ return BaseContainerBlockEntity.canUnlock(player, this.lockKey, this.getDisplayName(), this) // Paper - Add BlockLockCheckEvent - ? new BeaconMenu(containerId, playerInventory, this.dataAccess, ContainerLevelAccess.create(this.level, this.getBlockPos())) - : null; - } + public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { +- if (this.lockKey.canUnlock(player)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockLockCheckEvent(this, this.lockKey, this.getDisplayName(), player)) { // Paper - Call BlockLockCheckEvent + return new BeaconMenu(containerId, playerInventory, this.dataAccess, ContainerLevelAccess.create(this.level, this.getBlockPos())); + } else { + BaseContainerBlockEntity.sendChestLockedNotifications(this.getBlockPos().getCenter(), player, this.getDisplayName()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index ada76af48298..0ee4679347a5 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 @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -84,6 +_,7 @@ +@@ -85,6 +_,7 @@ + public static final int MIN_OCCUPATION_TICKS_NECTARLESS = 600; private List stored = Lists.newArrayList(); - @Nullable - public BlockPos savedFlowerPos; + public @Nullable BlockPos savedFlowerPos; + public int maxBees = MAX_OCCUPANTS; // CraftBukkit - allow setting max amount of bees a hive can hold public BeehiveBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.BEEHIVE, pos, blockState); -@@ -117,7 +_,7 @@ +@@ -118,7 +_,7 @@ } public boolean isFull() { @@ -17,7 +17,7 @@ } public void emptyAllLivingFromHive(@Nullable Player player, BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { -@@ -126,7 +_,7 @@ +@@ -127,7 +_,7 @@ for (Entity entity : list) { if (entity instanceof Bee bee && player.position().distanceToSqr(entity.position()) <= 16.0) { if (!this.isSedated()) { @@ -26,7 +26,7 @@ } else { bee.setStayOutOfHiveCountdown(400); } -@@ -136,8 +_,14 @@ +@@ -137,8 +_,14 @@ } private List releaseAllOccupants(BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { @@ -42,7 +42,7 @@ if (!list.isEmpty()) { super.setChanged(); } -@@ -150,6 +_,11 @@ +@@ -151,6 +_,11 @@ return this.stored.size(); } @@ -54,7 +54,7 @@ public static int getHoneyLevel(BlockState state) { return state.getValue(BeehiveBlock.HONEY_LEVEL); } -@@ -160,7 +_,16 @@ +@@ -161,7 +_,16 @@ } public void addOccupant(Bee bee) { @@ -72,7 +72,7 @@ bee.stopRiding(); bee.ejectPassengers(); bee.dropLeash(); -@@ -185,7 +_,7 @@ +@@ -186,7 +_,7 @@ this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(bee, this.getBlockState())); } @@ -81,11 +81,12 @@ super.setChanged(); } } -@@ -203,7 +_,21 @@ +@@ -204,8 +_,21 @@ BeehiveBlockEntity.BeeReleaseStatus releaseStatus, @Nullable BlockPos storedFlowerPos ) { -- if (Bee.isNightOrRaining(level) && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { +- if (level.environmentAttributes().getValue(EnvironmentAttributes.BEES_STAY_IN_HIVE, pos) +- && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { + // CraftBukkit start + return releaseOccupant(level, pos, state, occupant, storedInHives, releaseStatus, storedFlowerPos, false); + } @@ -99,12 +100,12 @@ + @Nullable BlockPos storedFlowerPos, + boolean force + ) { -+ if (!force && Bee.isNightOrRaining(level) && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { ++ if (!force && level.environmentAttributes().getValue(EnvironmentAttributes.BEES_STAY_IN_HIVE, pos) && releaseStatus != BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY) { + // CraftBukkit end return false; } else { Direction direction = state.getValue(BeehiveBlock.FACING); -@@ -214,6 +_,17 @@ +@@ -216,6 +_,17 @@ } else { Entity entity = occupant.createEntity(level, pos); if (entity != null) { @@ -122,7 +123,7 @@ if (entity instanceof Bee bee) { if (storedFlowerPos != null && !bee.hasSavedFlowerPos() && level.random.nextFloat() < 0.9F) { bee.setSavedFlowerPos(storedFlowerPos); -@@ -229,7 +_,13 @@ +@@ -231,7 +_,13 @@ i--; } @@ -137,7 +138,7 @@ } } } -@@ -238,17 +_,19 @@ +@@ -240,17 +_,19 @@ storedInHives.add(bee); } @@ -158,7 +159,7 @@ } else { return false; } -@@ -274,6 +_,11 @@ +@@ -276,6 +_,11 @@ flag = true; iterator.remove(); } @@ -170,7 +171,7 @@ } } -@@ -295,9 +_,10 @@ +@@ -297,9 +_,10 @@ @Override protected void loadAdditional(ValueInput input) { super.loadAdditional(input); @@ -182,7 +183,7 @@ } @Override -@@ -305,12 +_,13 @@ +@@ -307,12 +_,13 @@ super.saveAdditional(output); output.store("bees", BeehiveBlockEntity.Occupant.LIST_CODEC, this.getBees()); output.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos); @@ -197,7 +198,7 @@ List list = componentGetter.getOrDefault(DataComponents.BEES, Bees.EMPTY).bees(); list.forEach(this::storeBee); } -@@ -338,15 +_,18 @@ +@@ -340,15 +_,18 @@ static class BeeData { private final BeehiveBlockEntity.Occupant occupant; @@ -217,7 +218,7 @@ } public BeehiveBlockEntity.Occupant toOccupant() { -@@ -421,6 +_,7 @@ +@@ -422,6 +_,7 @@ } private static void setBeeReleaseData(int ticksInHive, Bee bee) { @@ -225,7 +226,7 @@ int age = bee.getAge(); if (age < 0) { bee.setAge(Math.min(0, age + ticksInHive)); -@@ -429,6 +_,7 @@ +@@ -430,6 +_,7 @@ } bee.setInLoveTime(Math.max(0, bee.getInLoveTime() - ticksInHive)); 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 7915f91c6b17..4767a1f8501f 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 @@ -11,7 +11,7 @@ private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final BlockEntityType type; -@@ -52,6 +_,7 @@ +@@ -51,6 +_,7 @@ this.worldPosition = pos.immutable(); this.validateBlockState(blockState); this.blockState = blockState; @@ -19,7 +19,7 @@ } private void validateBlockState(BlockState state) { -@@ -68,6 +_,7 @@ +@@ -67,6 +_,7 @@ int intOr = tag.getIntOr("x", 0); int intOr1 = tag.getIntOr("y", 0); int intOr2 = tag.getIntOr("z", 0); @@ -27,7 +27,7 @@ int sectionPosCoord = SectionPos.blockToSectionCoord(intOr); int sectionPosCoord1 = SectionPos.blockToSectionCoord(intOr2); if (sectionPosCoord != chunkPos.x || sectionPosCoord1 != chunkPos.z) { -@@ -75,6 +_,7 @@ +@@ -74,6 +_,7 @@ intOr = chunkPos.getBlockX(SectionPos.sectionRelative(intOr)); intOr2 = chunkPos.getBlockZ(SectionPos.sectionRelative(intOr2)); } @@ -35,7 +35,7 @@ return new BlockPos(intOr, intOr1, intOr2); } -@@ -93,6 +_,12 @@ +@@ -91,6 +_,12 @@ } protected void loadAdditional(ValueInput input) { @@ -48,7 +48,7 @@ } public final void loadWithComponents(ValueInput input) { -@@ -142,6 +_,11 @@ +@@ -140,6 +_,11 @@ public void saveWithoutMetadata(ValueOutput output) { this.saveAdditional(output); output.store("components", DataComponentMap.CODEC, this.components); @@ -60,7 +60,7 @@ } public final CompoundTag saveCustomOnly(HolderLookup.Provider registries) { -@@ -157,6 +_,11 @@ +@@ -155,6 +_,11 @@ public void saveCustomOnly(ValueOutput output) { this.saveAdditional(output); @@ -72,7 +72,7 @@ } public void saveId(ValueOutput output) { -@@ -289,6 +_,12 @@ +@@ -285,6 +_,12 @@ } public final void applyComponents(DataComponentMap components, DataComponentPatch patch) { @@ -85,7 +85,7 @@ final Set> set = new HashSet<>(); set.add(DataComponents.BLOCK_ENTITY_DATA); set.add(DataComponents.BLOCK_STATE); -@@ -309,6 +_,10 @@ +@@ -304,6 +_,10 @@ }); DataComponentPatch dataComponentPatch = patch.forget(set::contains); this.components = dataComponentPatch.split().added(); @@ -96,17 +96,17 @@ } protected void collectImplicitComponents(DataComponentMap.Builder components) { -@@ -345,6 +_,27 @@ +@@ -339,6 +_,27 @@ @Override public void registerDebugValues(ServerLevel level, DebugValueSource.Registration registrar) { } + + // CraftBukkit start - add method -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner() { + return getOwner(true); + } + -+ public @Nullable org.bukkit.inventory.InventoryHolder getOwner(boolean useSnapshot) { ++ public org.bukkit.inventory.@Nullable InventoryHolder getOwner(boolean useSnapshot) { + if (this.level == null) return null; + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition); + org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch index d84df75e0ba4..9121a4882188 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -@@ -68,9 +_,26 @@ +@@ -66,9 +_,26 @@ return false; } else { this.coolDownEndsAtTick = startTick + 10L; @@ -29,7 +29,7 @@ this.brushingCompleted(level, brusher, stack); return true; } else { -@@ -78,7 +_,7 @@ +@@ -76,7 +_,7 @@ int completionState1 = this.getCompletionState(); if (completionState != completionState1) { BlockState blockState = this.getBlockState(); @@ -38,7 +38,7 @@ level.setBlock(this.getBlockPos(), blockState1, Block.UPDATE_ALL); } -@@ -119,6 +_,11 @@ +@@ -117,6 +_,11 @@ this.dropContent(level, brusher, stack); BlockState blockState = this.getBlockState(); level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_BRUSH_BLOCK_COMPLETE, this.getBlockPos(), Block.getId(blockState)); @@ -50,7 +50,7 @@ Block turnsInto; if (this.getBlockState().getBlock() instanceof BrushableBlock brushableBlock) { turnsInto = brushableBlock.getTurnsInto(); -@@ -126,6 +_,11 @@ +@@ -124,6 +_,11 @@ turnsInto = Blocks.AIR; } @@ -62,7 +62,7 @@ level.setBlock(this.worldPosition, turnsInto.defaultBlockState(), Block.UPDATE_ALL); } -@@ -142,7 +_,12 @@ +@@ -140,7 +_,12 @@ double d5 = blockPos.getZ() + 0.5 * d1 + d2; ItemEntity itemEntity = new ItemEntity(level, d3, d4, d5, this.item.split(level.random.nextInt(21) + 10)); itemEntity.setDeltaMovement(Vec3.ZERO); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch index a6e5091f7471..aaa4eb961a99 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java -@@ -26,6 +_,13 @@ +@@ -27,6 +_,18 @@ private boolean auto = false; private boolean conditionMet = false; private final BaseCommandBlock commandBlock = new BaseCommandBlock() { @@ -9,17 +9,22 @@ + public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { + return new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, CommandBlockEntity.this); + } ++ ++ @Override ++ public net.minecraft.server.level.ServerLevel getLevel() { ++ return (net.minecraft.server.level.ServerLevel) CommandBlockEntity.this.getLevel(); ++ } + // CraftBukkit end + @Override public void setCommand(String command) { super.setCommand(command); -@@ -56,7 +_,7 @@ +@@ -47,7 +_,7 @@ Vec3.atCenterOf(CommandBlockEntity.this.worldPosition), new Vec2(0.0F, direction.toYRot()), - this.getLevel(), -- 2, -+ this.getLevel().paperConfig().commandBlocks.permissionsLevel, // Paper - configurable command block perm level + level, +- LevelBasedPermissionSet.GAMEMASTER, ++ LevelBasedPermissionSet.forLevel(net.minecraft.server.permissions.PermissionLevel.byId(level.paperConfig().commandBlocks.permissionsLevel)), // Paper - configurable command block perm level this.getName().getString(), this.getName(), - this.getLevel().getServer(), + level.getServer(), diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index 5730d843586a..da783a5a8b1d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -165,8 +_,20 @@ +@@ -164,8 +_,20 @@ } private static void applyEffects(Level level, BlockPos pos, List positions) { @@ -21,7 +21,7 @@ int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -175,20 +_,25 @@ +@@ -174,20 +_,25 @@ if (!entitiesOfClass.isEmpty()) { for (Player player : entitiesOfClass) { if (pos.closerThan(player.blockPosition(), i) && player.isInWaterOrRain()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch index 0401a584fd95..6e186effe97c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java @@ -23,6 +_,48 @@ - import net.minecraft.world.ticks.ContainerSingleItem; + import org.jspecify.annotations.Nullable; public class DecoratedPotBlockEntity extends BlockEntity implements RandomizableContainer, ContainerSingleItem.BlockContainerSingleItem { + @@ -40,7 +40,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + if (this.level == null) return null; + return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } @@ -49,7 +49,7 @@ public static final String TAG_SHERDS = "sherds"; public static final String TAG_ITEM = "item"; public static final int EVENT_POT_WOBBLES = 1; -@@ -47,8 +_,8 @@ +@@ -45,8 +_,8 @@ output.store("sherds", PotDecorations.CODEC, this.decorations); } @@ -60,7 +60,7 @@ } } -@@ -70,7 +_,14 @@ +@@ -68,7 +_,14 @@ @Override public CompoundTag getUpdateTag(HolderLookup.Provider registries) { 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 4dde6baac79e..b6f64612fd73 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 @@ -237,13 +237,12 @@ } destination.setChanged(); -@@ -337,14 +_,59 @@ +@@ -337,12 +_,56 @@ return stack; } + // CraftBukkit start -+ @Nullable -+ private static Container runHopperInventorySearchEvent( ++ private static @Nullable Container runHopperInventorySearchEvent( + Container container, + org.bukkit.craftbukkit.block.CraftBlock hopper, + org.bukkit.craftbukkit.block.CraftBlock searchLocation, @@ -260,8 +259,7 @@ + } + // CraftBukkit end + - @Nullable - private static Container getAttachedContainer(Level level, BlockPos pos, HopperBlockEntity blockEntity) { + private static @Nullable Container getAttachedContainer(Level level, BlockPos pos, HopperBlockEntity blockEntity) { - return getContainerAt(level, pos.relative(blockEntity.facing)); + // Paper start + BlockPos searchPosition = pos.relative(blockEntity.facing); @@ -279,8 +277,7 @@ + // Paper end } - @Nullable - private static Container getSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) { + private static @Nullable Container getSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) { - return getContainerAt(level, pos, state, hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ()); + // Paper start + final Container inventory = HopperBlockEntity.getContainerAt(level, pos, state, hopper.getLevelX(), hopper.getLevelY() + 1.0D, hopper.getLevelZ()); @@ -299,10 +296,10 @@ } public static List getItemsAtAndAbove(Level level, Hopper hopper) { -@@ -369,6 +_,7 @@ +@@ -364,6 +_,7 @@ + } - @Nullable - private static Container getBlockContainer(Level level, BlockPos pos, BlockState state) { + private static @Nullable Container getBlockContainer(Level level, BlockPos pos, BlockState state) { + if (!level.spigotConfig.hopperCanLoadChunks && !level.hasChunkAt(pos)) return null; // Spigot Block block = state.getBlock(); if (block instanceof WorldlyContainerHolder) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch index 471f03ffb264..004ae297513a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch @@ -45,7 +45,7 @@ public static final String SONG_ITEM_TAG_ID = "RecordItem"; public static final String TICKS_SINCE_SONG_STARTED_TAG_ID = "ticks_since_song_started"; private ItemStack item = ItemStack.EMPTY; -@@ -132,7 +_,7 @@ +@@ -133,7 +_,7 @@ @Override public int getMaxStackSize() { @@ -54,7 +54,7 @@ } @Override -@@ -156,11 +_,16 @@ +@@ -157,11 +_,16 @@ } @VisibleForTesting diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index aaa6977fcd07..ed5cfb0cd0e0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/LecternBlockEntity.java +++ b/net/minecraft/world/level/block/entity/LecternBlockEntity.java -@@ -33,7 +_,53 @@ +@@ -34,7 +_,53 @@ public static final int NUM_DATA = 1; public static final int SLOT_BOOK = 0; public static final int NUM_SLOTS = 1; @@ -37,7 +37,7 @@ + } + + @Override -+ public @Nullable org.bukkit.Location getLocation() { ++ public org.bukkit.@Nullable Location getLocation() { + if (LecternBlockEntity.this.level == null) return null; + return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(LecternBlockEntity.this.worldPosition, LecternBlockEntity.this.level); + } @@ -55,7 +55,7 @@ @Override public int getContainerSize() { return 1; -@@ -77,11 +_,19 @@ +@@ -78,11 +_,19 @@ @Override public void setItem(int slot, ItemStack stack) { @@ -76,7 +76,7 @@ } @Override -@@ -159,7 +_,7 @@ +@@ -160,7 +_,7 @@ if (i != this.page) { this.page = i; this.setChanged(); @@ -85,7 +85,7 @@ } } -@@ -180,6 +_,36 @@ +@@ -181,6 +_,36 @@ return stack; } @@ -122,16 +122,18 @@ private CommandSourceStack createCommandSourceStack(@Nullable Player player, ServerLevel level) { String string; Component component; -@@ -192,7 +_,7 @@ - } +@@ -194,8 +_,8 @@ Vec3 vec3 = Vec3.atCenterOf(this.worldPosition); -- return new CommandSourceStack(CommandSource.NULL, vec3, Vec2.ZERO, level, 2, string, component, level.getServer(), player); -+ return new CommandSourceStack(this.commandSource, vec3, Vec2.ZERO, level, 2, string, component, level.getServer(), player); // CraftBukkit - commandSource + return new CommandSourceStack( +- CommandSource.NULL, vec3, Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player +- ); ++ this.commandSource, vec3, Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player ++ ); // CraftBukkit - commandSource } @Override -@@ -232,7 +_,7 @@ +@@ -235,7 +_,7 @@ @Override public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { 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 83a42ad68e36..587d8177a4e8 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 -@@ -116,4 +_,13 @@ +@@ -114,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 320946a1b736..1079d36b8d11 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -@@ -88,6 +_,13 @@ +@@ -87,6 +_,13 @@ + } - @Nullable - public static ServerPlayer tryGetPlayer(@Nullable Entity entity) { + public static @Nullable ServerPlayer tryGetPlayer(@Nullable Entity entity) { + // Paper start - check global player list where appropriate; ensure level is the same for sculk events + final ServerPlayer player = tryGetPlayer0(entity); + return player != null && player.level() == entity.level() ? player : null; @@ -14,7 +14,7 @@ if (entity instanceof ServerPlayer serverPlayer) { return serverPlayer; } else if (entity != null && entity.getControllingPassenger() instanceof ServerPlayer serverPlayer) { -@@ -163,7 +_,7 @@ +@@ -162,7 +_,7 @@ private boolean trySummonWarden(ServerLevel level) { return this.warningLevel >= 4 && SpawnUtil.trySpawnMob( 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 cce435d19b5a..ca4946a67577 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShelfBlockEntity.java -@@ -35,6 +_,47 @@ +@@ -36,6 +_,47 @@ private final NonNullList items = NonNullList.withSize(3, ItemStack.EMPTY); private boolean alignItemsToBottom; 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 4bce3675d4b3..28174a42b059 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 @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -50,6 +_,42 @@ - @Nullable - private final DyeColor color; +@@ -49,6 +_,42 @@ + private float progressOld; + private final @Nullable DyeColor color; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList<>(); @@ -43,7 +43,7 @@ public ShulkerBoxBlockEntity(@Nullable DyeColor color, BlockPos pos, BlockState blockState) { super(BlockEntityType.SHULKER_BOX, pos, blockState); this.color = color; -@@ -172,6 +_,7 @@ +@@ -171,6 +_,7 @@ } this.openCount++; @@ -51,7 +51,7 @@ this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount == 1) { this.level.gameEvent(user.getLivingEntity(), GameEvent.CONTAINER_OPEN, this.worldPosition); -@@ -185,6 +_,7 @@ +@@ -184,6 +_,7 @@ public void stopOpen(ContainerUser user) { if (!this.remove && !user.getLivingEntity().isSpectator()) { this.openCount--; 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 7e6f64604a00..5e3de0e9dedc 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 @@ -103,7 +103,7 @@ flag = true; break; case ClickEvent.ShowDialog showDialog: -@@ -212,10 +_,55 @@ +@@ -212,12 +_,56 @@ return flag; } @@ -139,7 +139,9 @@ + // CraftBukkit end String string = player == null ? "Sign" : player.getPlainTextName(); Component component = (Component)(player == null ? Component.literal("Sign") : player.getDisplayName()); -- return new CommandSourceStack(CommandSource.NULL, Vec3.atCenterOf(pos), Vec2.ZERO, level, 2, string, component, level.getServer(), player); +- return new CommandSourceStack( +- CommandSource.NULL, Vec3.atCenterOf(pos), Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player +- ); + + // Paper start - Fix commands from signs not firing command events + CommandSource commandSource = level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this.commandSource) { @@ -157,14 +159,15 @@ + } : this.commandSource; + // Paper end - Fix commands from signs not firing command events + // CraftBukkit - this -+ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, level, 2, string, component, level.getServer(), player); // Paper - Fix commands from signs not firing command events ++ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, level, LevelBasedPermissionSet.GAMEMASTER, string, component, level.getServer(), player ++ ); // Paper - Fix commands from signs not firing command events } @Override -@@ -234,12 +_,17 @@ +@@ -235,12 +_,17 @@ + } - @Nullable - public UUID getPlayerWhoMayEdit() { + public @Nullable UUID getPlayerWhoMayEdit() { + // CraftBukkit start - unnecessary sign ticking removed, so do this lazily + if (this.level != null && this.playerWhoMayEdit != null) { + this.clearInvalidPlayerWhoMayEdit(this, this.level, this.playerWhoMayEdit); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch index 09f5bd372611..c9cd6f58f8f0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -@@ -131,7 +_,7 @@ +@@ -129,7 +_,7 @@ + } - @Nullable - public Vec3 getPortalPosition(ServerLevel level, BlockPos pos) { + public @Nullable Vec3 getPortalPosition(ServerLevel level, BlockPos pos) { - if (this.exitPortal == null && level.dimension() == Level.END) { + if (this.exitPortal == null && level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit - work in alternate worlds BlockPos blockPos = findOrCreateValidTeleportPos(level, pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch index bcf8b430a4d4..97db3c8b6051 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java -@@ -219,7 +_,14 @@ +@@ -216,7 +_,14 @@ nextSpawnData.getEquipment().ifPresent(mob::equip); } @@ -16,7 +16,7 @@ return Optional.empty(); } -@@ -234,10 +_,24 @@ +@@ -231,10 +_,24 @@ } public void ejectReward(ServerLevel level, BlockPos pos, ResourceKey lootTable) { @@ -42,7 +42,7 @@ for (ItemStack itemStack : randomItems) { DefaultDispenseItemBehavior.spawnItem(level, itemStack, 2, Direction.UP, Vec3.atBottomCenterOf(pos).relative(Direction.UP, 1.2)); } -@@ -407,6 +_,35 @@ +@@ -400,6 +_,35 @@ this.requiredPlayerRange ); } 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 702a9a8f1cff..f06bd4ea7c52 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 -@@ -188,7 +_,7 @@ +@@ -186,7 +_,7 @@ mob.dropPreservedEquipment(level); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch index 8c272f01a761..3af49bdb93d6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java +++ b/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java -@@ -258,7 +_,13 @@ +@@ -256,7 +_,13 @@ if (!list.isEmpty()) { player.awardStat(Stats.ITEM_USED.get(stack.getItem())); stack.consume(config.keyItem().getCount(), player); @@ -15,7 +15,7 @@ serverData.addToRewardedPlayers(player); sharedData.updateConnectedPlayersWithinRange(level, pos, serverData, config, config.deactivationRange()); } -@@ -267,8 +_,30 @@ +@@ -265,8 +_,30 @@ } static void setVaultState(ServerLevel level, BlockPos pos, BlockState oldState, BlockState newState, VaultConfig config, VaultSharedData sharedData) { @@ -48,7 +48,7 @@ level.setBlock(pos, newState, Block.UPDATE_ALL); vaultState.onTransition(level, pos, vaultState1, config, sharedData, newState.getValue(VaultBlock.OMINOUS)); } -@@ -280,6 +_,11 @@ +@@ -278,6 +_,11 @@ ItemStack randomDisplayItemFromLootTable = getRandomDisplayItemFromLootTable( level, pos, config.overrideLootTableToDisplay().orElse(config.lootTable()) ); @@ -60,7 +60,7 @@ sharedData.setDisplayItem(randomDisplayItemFromLootTable); } } -@@ -302,10 +_,24 @@ +@@ -300,10 +_,24 @@ VaultSharedData sharedData, List itemsToEject ) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 1ad9aa9a7d14..40be0c223f58 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -132,6 +_,7 @@ +@@ -130,6 +_,7 @@ .get(configuredMegaFeature) .orElse(null); if (holder != null) { @@ -8,7 +8,7 @@ for (int i = 0; i >= -1; i--) { for (int i1 = 0; i1 >= -1; i1--) { if (isTwoByTwoSapling(state, level, pos, i, i1)) { -@@ -164,6 +_,7 @@ +@@ -162,6 +_,7 @@ if (holder1 == null) { return false; } else { @@ -16,7 +16,7 @@ ConfiguredFeature configuredFeature2 = holder1.value(); BlockState blockState1 = level.getFluidState(pos).createLegacyBlock(); level.setBlock(pos, blockState1, Block.UPDATE_NONE); -@@ -198,4 +_,58 @@ +@@ -196,4 +_,58 @@ return false; } 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 1b5e5c96d717..bde64a653281 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 @@ -11,7 +11,7 @@ } + // CraftBukkit start -+ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, @Nullable net.minecraft.world.item.context.UseOnContext context) { ++ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, net.minecraft.world.item.context.@Nullable UseOnContext context) { + this.onPlace(state, level, pos, oldState, movedByPiston); + } + // CraftBukkit end @@ -44,13 +44,12 @@ } protected boolean canBeReplaced(BlockState state, Fluid fluid) { -@@ -469,6 +_,16 @@ +@@ -466,6 +_,15 @@ this.instrument = properties.instrument; this.replaceable = properties.replaceable; } + // Paper start - Perf: impl cached craft block data, lazy load to fix issue with loading at the wrong time -+ @Nullable -+ private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData; ++ private org.bukkit.craftbukkit.block.data.@Nullable CraftBlockData cachedCraftBlockData; + + public org.bukkit.craftbukkit.block.data.CraftBlockData createCraftBlockData() { + if (this.cachedCraftBlockData == null) this.cachedCraftBlockData = org.bukkit.craftbukkit.block.data.CraftBlockData.createData(this.asState()); @@ -61,7 +60,7 @@ private boolean calculateSolid() { if (this.owner.properties.forceSolidOn) { -@@ -488,12 +_,14 @@ +@@ -485,12 +_,14 @@ } } @@ -76,7 +75,7 @@ this.legacySolid = this.calculateSolid(); this.occlusionShape = this.canOcclude ? this.owner.getOcclusionShape(this.asState()) : Shapes.empty(); -@@ -532,6 +_,11 @@ +@@ -529,6 +_,11 @@ public boolean isSolid() { return this.legacySolid; } @@ -88,7 +87,7 @@ public boolean isValidSpawn(BlockGetter level, BlockPos pos, EntityType entityType) { return this.getBlock().properties.isValidSpawn.test(this.asState(), level, pos, entityType); -@@ -553,19 +_,19 @@ +@@ -550,19 +_,19 @@ return this.occlusionShape; } @@ -113,7 +112,7 @@ return this.isAir; } -@@ -635,14 +_,14 @@ +@@ -632,14 +_,14 @@ } public PushReaction getPistonPushReaction() { @@ -130,7 +129,7 @@ return this.canOcclude; } -@@ -729,7 +_,13 @@ +@@ -726,7 +_,13 @@ } public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { @@ -139,13 +138,13 @@ + this.onPlace(level, pos, oldState, movedByPiston, null); + } + -+ public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, @Nullable net.minecraft.world.item.context.UseOnContext context) { ++ public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, net.minecraft.world.item.context.@Nullable UseOnContext context) { + this.getBlock().onPlace(this.asState(), level, pos, oldState, movedByPiston, context); + // CraftBukkit end } public void affectNeighborsAfterRemoval(ServerLevel level, BlockPos pos, boolean movedByPiston) { -@@ -754,6 +_,7 @@ +@@ -751,6 +_,7 @@ public void spawnAfterBreak(ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { this.getBlock().spawnAfterBreak(this.asState(), level, pos, stack, dropExperience); @@ -153,7 +152,7 @@ } public List getDrops(LootParams.Builder lootParams) { -@@ -862,11 +_,11 @@ +@@ -857,11 +_,11 @@ return this.getBlock().builtInRegistryHolder().is(block); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch index 78b6de8b7ee6..9087bd5e8570 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/properties/Property.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/properties/Property.java +++ b/net/minecraft/world/level/block/state/properties/Property.java -@@ -72,7 +_,7 @@ +@@ -71,7 +_,7 @@ @Override public boolean equals(Object other) { 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 72cab22c3dda..649fae49b6eb 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 @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -34,6 +_,7 @@ +@@ -33,6 +_,7 @@ double centerZ; int absoluteMaxSize = 29999984; WorldBorder.BorderExtent extent = new WorldBorder.StaticBorderExtent(5.999997E7F); -+ public net.minecraft.server.level.ServerLevel world; // CraftBukkit ++ public net.minecraft.server.level.@org.jspecify.annotations.Nullable ServerLevel world; // CraftBukkit - public boolean isWithinBounds(BlockPos pos) { - return this.isWithinBounds(pos.getX(), pos.getZ()); -@@ -47,6 +_,20 @@ + public WorldBorder() { + this(WorldBorder.Settings.DEFAULT); +@@ -54,6 +_,20 @@ return this.isWithinBounds(chunkPos.getMinBlockX(), chunkPos.getMinBlockZ()) && this.isWithinBounds(chunkPos.getMaxBlockX(), chunkPos.getMaxBlockZ()); } @@ -29,7 +29,7 @@ public boolean isWithinBounds(AABB box) { return this.isWithinBounds(box.minX, box.minZ, box.maxX - 1.0E-5F, box.maxZ - 1.0E-5F); } -@@ -135,6 +_,14 @@ +@@ -158,6 +_,14 @@ } public void setCenter(double x, double z) { @@ -44,7 +44,7 @@ this.centerX = x; this.centerZ = z; this.extent.onCenterChange(); -@@ -158,6 +_,17 @@ +@@ -181,6 +_,17 @@ } public void setSize(double size) { @@ -52,8 +52,8 @@ + if (this.world != null) { + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE, getSize(), size, 0); + if (!event.callEvent()) return; -+ if (event.getType() == io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDuration() > 0) { // If changed to a timed transition -+ lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDuration()); ++ if (event.getType() == io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDurationTicks() > 0) { // If changed to a timed transition ++ lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDurationTicks(), this.world.getGameTime()); + return; + } + size = event.getNewSize(); @@ -62,10 +62,10 @@ this.extent = new WorldBorder.StaticBorderExtent(size); this.setDirty(); -@@ -167,6 +_,20 @@ +@@ -190,6 +_,20 @@ } - public void lerpSizeBetween(double oldSize, double newSize, long time) { + public void lerpSizeBetween(double oldSize, double newSize, long time, long startTime) { + // Paper start - Add worldborder events + if (this.world != null) { + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type type; @@ -77,13 +77,13 @@ + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), type, oldSize, newSize, time); + if (!event.callEvent()) return; + newSize = event.getNewSize(); -+ time = event.getDuration(); ++ time = event.getDurationTicks(); + } + // Paper end - Add worldborder events this.extent = (WorldBorder.BorderExtent)(oldSize == newSize ? new WorldBorder.StaticBorderExtent(newSize) - : new WorldBorder.MovingBorderExtent(oldSize, newSize, time)); -@@ -182,6 +_,7 @@ + : new WorldBorder.MovingBorderExtent(oldSize, newSize, time, startTime)); +@@ -205,6 +_,7 @@ } public void addListener(BorderChangeListener listener) { @@ -91,10 +91,33 @@ this.listeners.add(listener); } -@@ -379,6 +_,7 @@ - @Override - public WorldBorder.BorderExtent update() { - if (this.getLerpTime() <= 0L) { +@@ -298,6 +_,22 @@ + } + } + ++ // Paper start - add back applySettings ++ public void applySettings(net.minecraft.world.level.border.WorldBorder.Settings settings) { ++ this.setCenter(settings.centerX(), settings.centerZ()); ++ this.setDamagePerBlock(settings.damagePerBlock()); ++ this.setSafeZone(settings.safeZone()); ++ this.setWarningBlocks(settings.warningBlocks()); ++ this.setWarningTime(settings.warningTime()); ++ if (settings.lerpTime() > 0L) { ++ final long startTime = (this.world != null) ? this.world.getGameTime() : 0; // Virtual Borders don't have a World ++ this.lerpSizeBetween(settings.size(), settings.lerpTarget(), settings.lerpTime(), startTime); ++ } else { ++ this.setSize(settings.size()); ++ } ++ } ++ // Paper end - add back applySettings ++ + interface BorderExtent { + double getMinX(float partialTick); + +@@ -432,6 +_,7 @@ + this.previousSize = this.size; + this.size = this.calculateSize(); + if (this.lerpProgress <= 0L) { + if (world != null) new io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent(world.getWorld(), world.getWorld().getWorldBorder(), this.from, this.to, this.lerpDuration).callEvent(); // Paper - Add worldborder events WorldBorder.this.setDirty(); return WorldBorder.this.new StaticBorderExtent(this.to); 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 8028eaa10955..05cc529bf4e7 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 @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java @@ -64,7 +_,7 @@ - protected final ShortList[] postProcessing; + protected final @Nullable ShortList[] postProcessing; private volatile boolean unsaved; private volatile boolean isLightCorrect; - protected final ChunkPos chunkPos; + protected final ChunkPos chunkPos; public final long coordinateKey; public final int locX; public final int locZ; // Paper - cache coordinate key private long inhabitedTime; - @Nullable @Deprecated -@@ -82,6 +_,10 @@ + private @Nullable BiomeGenerationSettings carverBiomeSettings; +@@ -79,6 +_,10 @@ public final Map blockEntities = new Object2ObjectOpenHashMap<>(); protected final LevelHeightAccessor levelHeightAccessor; protected final LevelChunkSection[] sections; @@ -20,8 +20,8 @@ public ChunkAccess( ChunkPos chunkPos, -@@ -92,7 +_,8 @@ - @Nullable LevelChunkSection[] sections, +@@ -89,7 +_,8 @@ + LevelChunkSection @Nullable [] sections, @Nullable BlendingData blendingData ) { - this.chunkPos = chunkPos; @@ -30,16 +30,16 @@ this.upgradeData = upgradeData; this.levelHeightAccessor = levelHeightAccessor; this.sections = new LevelChunkSection[levelHeightAccessor.getSectionsCount()]; -@@ -123,6 +_,8 @@ +@@ -120,6 +_,8 @@ return GameEventListenerRegistry.NOOP; } + public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper + - @Nullable - public BlockState setBlockState(BlockPos pos, BlockState state) { + public @Nullable BlockState setBlockState(BlockPos pos, BlockState state) { return this.setBlockState(pos, state, Block.UPDATE_ALL); -@@ -274,6 +_,7 @@ + } +@@ -266,6 +_,7 @@ public boolean tryMarkSaved() { if (this.unsaved) { this.unsaved = false; @@ -47,7 +47,7 @@ return true; } else { return false; -@@ -281,7 +_,7 @@ +@@ -273,7 +_,7 @@ } public boolean isUnsaved() { @@ -56,7 +56,7 @@ } public abstract ChunkStatus getPersistedStatus(); -@@ -447,6 +_,22 @@ +@@ -438,6 +_,22 @@ throw new ReportedException(crashReport); } } 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 ea796e005fc8..468cd148d15c 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,14 +11,14 @@ } public Optional>> getTypeNameForDataFixer() { -@@ -130,6 +_,24 @@ +@@ -129,6 +_,24 @@ if (SharedConstants.DEBUG_DISABLE_FEATURES) { return null; } else { + // Paper start - StructuresLocateEvent + final org.bukkit.World bukkitWorld = level.getWorld(); + final org.bukkit.Location origin = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); -+ final List apiStructures = structure.stream().map(Holder::value).map(nms -> org.bukkit.craftbukkit.generator.structure.CraftStructure.minecraftToBukkit(nms)).toList(); ++ final List apiStructures = structure.stream().map(org.bukkit.craftbukkit.generator.structure.CraftStructure::minecraftHolderToBukkit).toList(); + if (!apiStructures.isEmpty()) { + final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, apiStructures, radius, skipKnownStructures); + if (!event.callEvent()) { @@ -36,7 +36,7 @@ ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); Map>> map = new Object2ObjectArrayMap<>(); -@@ -225,6 +_,7 @@ +@@ -223,6 +_,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); for (ChunkPos chunkPos : ringPositionsFor) { @@ -44,7 +44,7 @@ mutableBlockPos.set(SectionPos.sectionToBlockCoord(chunkPos.x, 8), 32, SectionPos.sectionToBlockCoord(chunkPos.z, 8)); double d1 = mutableBlockPos.distSqr(pos); boolean flag = pair == null || d1 < d; -@@ -258,11 +_,15 @@ +@@ -255,11 +_,15 @@ int spacing = spreadPlacement.spacing(); for (int i = -z; i <= z; i++) { @@ -64,7 +64,7 @@ int i2 = x + spacing * i; int i3 = y + spacing * i1; ChunkPos potentialStructureChunk = spreadPlacement.getPotentialStructureChunk(seed, i2, i3); -@@ -315,7 +_,7 @@ +@@ -311,7 +_,7 @@ } } @@ -73,7 +73,7 @@ ChunkPos pos = chunk.getPos(); if (!SharedConstants.debugVoidTerrain(pos)) { SectionPos sectionPos = SectionPos.of(pos, level.getMinSectionY()); -@@ -386,7 +_,14 @@ +@@ -382,7 +_,14 @@ int i3 = ints[i2]; PlacedFeature placedFeature = stepFeatureData1.features().get(i3); Supplier supplier1 = () -> registry1.getResourceKey(placedFeature).map(Object::toString).orElseGet(placedFeature::toString); @@ -89,7 +89,7 @@ try { level.setCurrentlyGenerating(supplier1); -@@ -411,6 +_,32 @@ +@@ -407,6 +_,32 @@ } } } @@ -122,7 +122,7 @@ private static BoundingBox getWritableArea(ChunkAccess chunk) { ChunkPos pos = chunk.getPos(); -@@ -488,7 +_,7 @@ +@@ -484,7 +_,7 @@ } } @@ -131,7 +131,7 @@ if (list.size() == 1) { this.tryGenerateStructure( list.get(0), -@@ -583,6 +_,14 @@ +@@ -579,6 +_,14 @@ predicate ); if (structureStart.isValid()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch index 922eaedc8558..30d517aba8b1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch @@ -41,8 +41,8 @@ + return list.stream().map((holder) -> { + StructureSet structureset = holder.value(); + final Holder newHolder; // Paper - Add missing structure set seed configs -+ if (structureset.placement() instanceof net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement randomConfig && holder.unwrapKey().orElseThrow().location().getNamespace().equals(net.minecraft.resources.ResourceLocation.DEFAULT_NAMESPACE)) { // Paper - Add missing structure set seed configs; check namespace cause datapacks could add structure sets with the same path -+ String name = holder.unwrapKey().orElseThrow().location().getPath(); ++ if (structureset.placement() instanceof net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement randomConfig && holder.unwrapKey().orElseThrow().identifier().getNamespace().equals(net.minecraft.resources.Identifier.DEFAULT_NAMESPACE)) { // Paper - Add missing structure set seed configs; check namespace cause datapacks could add structure sets with the same path ++ String name = holder.unwrapKey().orElseThrow().identifier().getPath(); + int seed = randomConfig.salt; + + switch (name) { @@ -145,7 +145,7 @@ double d = randomSource.nextDouble() * Math.PI * 2.0; int i = 0; int i1 = 0; -@@ -197,7 +_,7 @@ +@@ -196,7 +_,7 @@ for (int i = x - range; i <= x + range; i++) { for (int i1 = z - range; i1 <= z + range; i1++) { 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 44b507e43b7b..bf030502e8ce 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 @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -@@ -26,6 +_,13 @@ +@@ -27,6 +_,13 @@ return Blocks.VOID_AIR.defaultBlockState(); } @@ -11,6 +11,6 @@ + } + // Paper end + - @Nullable @Override - public BlockState setBlockState(BlockPos pos, BlockState state, int flags) { + public @Nullable BlockState setBlockState(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { + return null; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch index 7346ceb90101..332679661db4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -50,6 +_,13 @@ +@@ -49,6 +_,13 @@ return this.wrapped.getBlockState(pos); } 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 c6fcf3b3d1df..0afd6ef03354 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 @@ -1,15 +1,14 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -86,7 +_,7 @@ +@@ -87,13 +_,21 @@ }; private final Map tickersInLevel = Maps.newHashMap(); public boolean loaded; - public final Level level; + public final ServerLevel level; // CraftBukkit - type - @Nullable - private Supplier fullStatus; - @Nullable -@@ -95,6 +_,14 @@ + private @Nullable Supplier fullStatus; + private LevelChunk.@Nullable PostLoadProcessor postLoad; + private final Int2ObjectMap gameEventListenerRegistrySections; private final LevelChunkTicks blockTicks; private final LevelChunkTicks fluidTicks; private LevelChunk.UnsavedListener unsavedListener = chunkPos -> {}; @@ -24,7 +23,7 @@ public LevelChunk(Level level, ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -112,7 +_,7 @@ +@@ -111,7 +_,7 @@ @Nullable BlendingData blendingData ) { super(pos, data, level, level.palettedContainerFactory(), inhabitedTime, sections, blendingData); @@ -33,7 +32,7 @@ this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); for (Heightmap.Types types : Heightmap.Types.values()) { -@@ -164,6 +_,10 @@ +@@ -163,6 +_,10 @@ this.skyLightSources = chunk.skyLightSources; this.setLightCorrect(chunk.isLightCorrect()); this.markUnsaved(); @@ -44,7 +43,7 @@ } public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) { -@@ -172,6 +_,12 @@ +@@ -171,6 +_,12 @@ unsavedListener.setUnsaved(this.chunkPos); } } @@ -57,7 +56,7 @@ @Override public void markUnsaved() { -@@ -205,8 +_,28 @@ +@@ -204,8 +_,28 @@ : super.getListenerRegistry(sectionY); } @@ -86,7 +85,7 @@ int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -241,28 +_,42 @@ +@@ -240,28 +_,42 @@ } } @@ -130,8 +129,8 @@ + */ // Paper - Perf: Optimise Chunk#getFluid } - @Nullable -@@ -324,7 +_,7 @@ + @Override +@@ -322,7 +_,7 @@ if (!section.getBlockState(i, i1, i2).is(block)) { return null; } else { @@ -140,10 +139,10 @@ state.onPlace(this.level, pos, blockState, flag1); } -@@ -378,7 +_,12 @@ +@@ -373,7 +_,12 @@ + } - @Nullable - public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) { + public @Nullable BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) { - BlockEntity blockEntity = this.blockEntities.get(pos); + // CraftBukkit start + BlockEntity blockEntity = this.level.capturedTileEntities.get(pos); @@ -154,7 +153,7 @@ if (blockEntity == null) { CompoundTag compoundTag = this.pendingBlockEntities.remove(pos); if (compoundTag != null) { -@@ -433,7 +_,13 @@ +@@ -428,7 +_,13 @@ BlockPos blockPos = blockEntity.getBlockPos(); BlockState blockState = this.getBlockState(blockPos); if (!blockState.hasBlockEntity()) { @@ -169,7 +168,7 @@ } else { BlockState blockState1 = blockEntity.getBlockState(); if (blockState != blockState1) { -@@ -481,6 +_,11 @@ +@@ -475,6 +_,11 @@ public void removeBlockEntity(BlockPos pos) { if (this.isInLevel()) { BlockEntity blockEntity = this.blockEntities.remove(pos); @@ -181,7 +180,7 @@ if (blockEntity != null) { if (this.level instanceof ServerLevel serverLevel) { this.removeGameEventListener(blockEntity, serverLevel); -@@ -524,6 +_,65 @@ +@@ -518,6 +_,65 @@ } } @@ -247,7 +246,7 @@ public boolean isEmpty() { return false; } -@@ -762,23 +_,24 @@ +@@ -756,23 +_,24 @@ if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch index 4024c49f2911..f0f46aee2a6d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -93,14 +_,31 @@ +@@ -90,14 +_,31 @@ return new ChunkAccess.PackedTicks(this.blockTicks.pack(gameTime), this.fluidTicks.pack(gameTime)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch deleted file mode 100644 index 38bdc3df492c..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch +++ /dev/null @@ -1,97 +0,0 @@ ---- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -@@ -38,17 +_,30 @@ - return this.worker.isOldChunkAround(pos, radius); - } - -+ // CraftBukkit start - public CompoundTag upgradeChunkTag( -- ResourceKey levelKey, -+ ResourceKey levelKey, - Supplier storage, - CompoundTag chunkData, -- Optional>> chunkGeneratorKey -+ Optional>> chunkGeneratorKey, -+ ChunkPos pos, -+ @Nullable net.minecraft.world.level.LevelAccessor levelAccessor -+ // CraftBukkit end - ) { - int version = getVersion(chunkData); - if (version == SharedConstants.getCurrentVersion().dataVersion().version()) { - return chunkData; - } else { - try { -+ // CraftBukkit start -+ if (version < 1466) { -+ CompoundTag level = chunkData.getCompoundOrEmpty("Level"); -+ if (level.getBooleanOr("TerrainPopulated", false) && !level.getBooleanOr("LightPopulated", false)) { -+ // Light is purged updating to 1.14+. We need to set light populated to true so the converter recognizes the chunk as being "full" -+ level.putBoolean("LightPopulated", true); -+ } -+ } -+ // CraftBukkit end - if (version < 1493) { - chunkData = DataFixTypes.CHUNK.update(this.fixerUpper, chunkData, version, 1493); - if (chunkData.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { -@@ -57,8 +_,22 @@ - } - } - -+ // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty -+ boolean stopBelowZero = false; -+ boolean belowZeroGenerationInExistingChunks = (levelAccessor != null) ? ((net.minecraft.server.level.ServerLevel) levelAccessor).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; -+ -+ if (version <= 2730 && !belowZeroGenerationInExistingChunks) { -+ stopBelowZero = "full".equals(chunkData.getCompound("Level").flatMap(l -> l.getString("Status")).orElse(null)); -+ } -+ // Spigot end -+ - injectDatafixingContext(chunkData, levelKey, chunkGeneratorKey); - chunkData = DataFixTypes.CHUNK.updateToCurrentVersion(this.fixerUpper, chunkData, Math.max(1493, version)); -+ // Spigot start -+ if (stopBelowZero) { -+ chunkData.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); -+ } -+ // Spigot end - removeDatafixingContext(chunkData); - NbtUtils.addCurrentDataVersion(chunkData); - return chunkData; -@@ -71,7 +_,7 @@ - } - } - -- private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, Supplier storage) { -+ private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, Supplier storage) { // CraftBukkit - LegacyStructureDataHandler legacyStructureDataHandler = this.legacyStructureHandler; - if (legacyStructureDataHandler == null) { - synchronized (this) { -@@ -86,7 +_,7 @@ - } - - public static void injectDatafixingContext( -- CompoundTag chunkData, ResourceKey levelKey, Optional>> chunkGeneratorKey -+ CompoundTag chunkData, ResourceKey levelKey, Optional>> chunkGeneratorKey // CraftBukkit - ) { - CompoundTag compoundTag = new CompoundTag(); - compoundTag.putString("dimension", levelKey.location().toString()); -@@ -107,8 +_,19 @@ - } - - public CompletableFuture write(ChunkPos pos, Supplier tagSupplier) { -+ // Paper start - guard against possible chunk pos desync -+ final Supplier guardedPosCheck = () -> { -+ CompoundTag nbt = tagSupplier.get(); -+ if (nbt != null && !pos.equals(SerializableChunkData.getChunkCoordinate(nbt))) { -+ final String world = (ChunkStorage.this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) ChunkStorage.this).level.getWorld().getName() : null; -+ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + pos -+ + " but compound says coordinate is " + SerializableChunkData.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world))); -+ } -+ return nbt; -+ }; -+ // Paper end - guard against possible chunk pos desync - this.handleLegacyStructureIndex(pos); -- return this.worker.store(pos, tagSupplier); -+ return this.worker.store(pos, guardedPosCheck); // Paper - guard against possible chunk pos desync - } - - protected void handleLegacyStructureIndex(ChunkPos chunkPos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch index adc8aaa96866..b04f2e617633 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFile.java.patch @@ -24,7 +24,7 @@ if (sectorNumber < 2) { LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", path, i1, sectorNumber); this.offsets.put(i1, 0); -@@ -117,6 +_,13 @@ +@@ -116,6 +_,13 @@ } else { int sectorNumber = getSectorNumber(offset); int numSectors = getNumSectors(offset); @@ -38,7 +38,7 @@ int i = numSectors * 4096; ByteBuffer byteBuffer = ByteBuffer.allocate(i); this.file.read(byteBuffer, sectorNumber * 4096); -@@ -260,6 +_,7 @@ +@@ -257,6 +_,7 @@ return true; } } catch (IOException var9) { @@ -46,7 +46,7 @@ return false; } } -@@ -331,6 +_,11 @@ +@@ -328,6 +_,11 @@ try (FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) { chunkData.position(5); fileChannel.write(chunkData); 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 9af4f5c09254..3d3404cdedc8 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 @@ -22,10 +22,10 @@ RegionFile regionFile1 = new RegionFile(this.info, path, this.folder, this.sync); this.regionCache.putAndMoveToFirst(packedChunkPos, regionFile1); return regionFile1; -@@ -49,7 +_,12 @@ +@@ -48,7 +_,12 @@ + } - @Nullable - public CompoundTag read(ChunkPos chunkPos) throws IOException { + public @Nullable CompoundTag read(ChunkPos chunkPos) throws IOException { - RegionFile regionFile = this.getRegionFile(chunkPos); + // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing + RegionFile regionFile = this.getRegionFile(chunkPos, true); @@ -36,7 +36,7 @@ CompoundTag var4; try (DataInputStream chunkDataInputStream = regionFile.getChunkDataInputStream(chunkPos)) { -@@ -64,7 +_,12 @@ +@@ -63,7 +_,12 @@ } public void scanChunk(ChunkPos chunkPos, StreamTagVisitor visitor) throws IOException { @@ -50,7 +50,7 @@ try (DataInputStream chunkDataInputStream = regionFile.getChunkDataInputStream(chunkPos)) { if (chunkDataInputStream != null) { -@@ -75,7 +_,7 @@ +@@ -74,7 +_,7 @@ protected void write(ChunkPos chunkPos, @Nullable CompoundTag chunkData) throws IOException { if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch index 86785dab5a50..26636eb668ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/RegionFileVersion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -@@ -61,6 +_,16 @@ +@@ -60,6 +_,16 @@ private final RegionFileVersion.StreamWrapper inputWrapper; private final RegionFileVersion.StreamWrapper outputWrapper; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch index cb9fbc094cf6..29cbf85f57fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -4,18 +4,18 @@ List entities, List blockEntities, CompoundTag structureData -+ , @Nullable net.minecraft.nbt.Tag persistentDataContainer // CraftBukkit - persistentDataContainer ++ , net.minecraft.nbt.@Nullable Tag persistentDataContainer // CraftBukkit - persistentDataContainer ) { private static final Codec>> BLOCK_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.BLOCK.byNameCodec()).listOf(); private static final Codec>> FLUID_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.FLUID.byNameCodec()).listOf(); -@@ -107,12 +_,38 @@ +@@ -107,11 +_,37 @@ public static final String BLOCK_LIGHT_TAG = "BlockLight"; public static final String SKY_LIGHT_TAG = "SkyLight"; + // Paper start - guard against serializing mismatching coordinates + // TODO Note: This needs to be re-checked each update + public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) { -+ final int dataVersion = ChunkStorage.getVersion(chunkData); ++ final int dataVersion = NbtUtils.getDataVersion(chunkData); + if (dataVersion < 2842) { // Level tag is removed after this version + final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); + return new ChunkPos(levelData.getIntOr("xPos", 0), levelData.getIntOr("zPos", 0)); @@ -30,7 +30,6 @@ + private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion"); + // Paper end - Do not let the server load chunks from newer versions + - @Nullable public static SerializableChunkData parse(LevelHeightAccessor level, PalettedContainerFactory containerFactory, CompoundTag tag) { if (tag.getString("Status").isEmpty()) { return null; @@ -48,16 +47,16 @@ long longOr = tag.getLongOr("LastUpdate", 0L); long longOr1 = tag.getLongOr("InhabitedTime", 0L); ChunkStatus chunkStatus = tag.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); -@@ -149,7 +_,7 @@ +@@ -150,7 +_,7 @@ CompoundTag compoundOrEmpty = tag.getCompoundOrEmpty("structures"); - ListTag listOrEmpty2 = tag.getListOrEmpty("sections"); - List list5 = new ArrayList<>(listOrEmpty2.size()); + ListTag listOrEmpty1 = tag.getListOrEmpty("sections"); + List list5 = new ArrayList<>(listOrEmpty1.size()); - Codec>> codec = containerFactory.biomeContainerCodec(); + Codec>> codec = containerFactory.biomeContainerRWCodec(); // CraftBukkit - read/write Codec> codec1 = containerFactory.blockStatesContainerCodec(); - for (int i2 = 0; i2 < listOrEmpty2.size(); i2++) { -@@ -166,7 +_,7 @@ + for (int i2 = 0; i2 < listOrEmpty1.size(); i2++) { +@@ -167,7 +_,7 @@ .getOrThrow(SerializableChunkData.ChunkReadException::new) ) .orElseGet(containerFactory::createForBlockStates); @@ -66,7 +65,7 @@ .map( compoundTag1 -> codec.parse(NbtOps.INSTANCE, compoundTag1) .promotePartial(string -> logErrors(chunkPos, byteOr, string)) -@@ -203,6 +_,7 @@ +@@ -204,6 +_,7 @@ list3, list4, compoundOrEmpty @@ -74,7 +73,7 @@ ); } } -@@ -287,6 +_,12 @@ +@@ -288,6 +_,12 @@ } } @@ -87,7 +86,7 @@ chunkAccess.setLightCorrect(this.lightCorrect); EnumSet set = EnumSet.noneOf(Heightmap.Types.class); -@@ -390,6 +_,12 @@ +@@ -394,6 +_,12 @@ CompoundTag compoundTag = packStructureData( StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences() ); @@ -100,7 +99,7 @@ return new SerializableChunkData( level.palettedContainerFactory(), pos, -@@ -409,6 +_,7 @@ +@@ -413,6 +_,7 @@ list2, list1, compoundTag @@ -108,7 +107,7 @@ ); } } -@@ -476,6 +_,11 @@ +@@ -480,6 +_,11 @@ this.heightmaps.forEach((types, longs) -> compoundTag2.put(types.getSerializationKey(), new LongArrayTag(longs))); compoundTag.put("Heightmaps", compoundTag2); compoundTag.put("structures", this.structureData); @@ -120,7 +119,7 @@ return compoundTag; } -@@ -557,6 +_,12 @@ +@@ -560,6 +_,12 @@ } else { StructureStart structureStart = StructureStart.loadStaticStart(context, compoundOrEmpty.getCompoundOrEmpty(string), seed); if (structureStart != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch new file mode 100644 index 000000000000..e9b4c4a5a21e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java ++++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +@@ -51,19 +_,47 @@ + } + + public CompletableFuture write(ChunkPos chunkPos, Supplier data) { ++ // Paper start - guard against possible chunk pos desync ++ final Supplier guardedPosCheck = () -> { ++ CompoundTag nbt = data.get(); ++ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; ++ if (chunkStorage && nbt != null && !chunkPos.equals(SerializableChunkData.getChunkCoordinate(nbt))) { ++ final String world = (SimpleRegionStorage.this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) SimpleRegionStorage.this).level.getWorld().getName() : null; ++ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos ++ + " but compound says coordinate is " + SerializableChunkData.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world))); ++ } ++ return nbt; ++ }; ++ // Paper end - guard against possible chunk pos desync + this.markChunkDone(chunkPos); +- return this.worker.store(chunkPos, data); ++ return this.worker.store(chunkPos, guardedPosCheck); // Paper - guard against possible chunk pos desync + } + +- public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag) { ++ public CompoundTag upgradeChunkTag(CompoundTag tag, int fallbackVersion, @Nullable CompoundTag contextTag, net.minecraft.world.level.@Nullable LevelAccessor levelAccessor) { // CraftBukkit + int dataVersion = NbtUtils.getDataVersion(tag, fallbackVersion); + if (dataVersion == SharedConstants.getCurrentVersion().dataVersion().version()) { + return tag; + } else { + try { + tag = this.legacyFixer.get().applyFix(tag); ++ // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty ++ boolean stopBelowZero = false; ++ final boolean chunkStorage = this.dataFixType == net.minecraft.util.datafix.DataFixTypes.CHUNK; ++ if (chunkStorage) { ++ boolean belowZeroGenerationInExistingChunks = (levelAccessor != null) ? ((net.minecraft.server.level.ServerLevel) levelAccessor).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; ++ ++ if (dataVersion <= 2730 && !belowZeroGenerationInExistingChunks) { ++ stopBelowZero = "full".equals(tag.getCompound("Level").flatMap(l -> l.getString("Status")).orElse(null)); ++ } ++ } ++ // Spigot end + injectDatafixingContext(tag, contextTag); + tag = this.dataFixType.updateToCurrentVersion(this.fixerUpper, tag, Math.max(this.legacyFixer.get().targetDataVersion(), dataVersion)); ++ // Spigot start ++ if (stopBelowZero) { ++ tag.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); ++ } ++ // Spigot end + removeDatafixingContext(tag); + NbtUtils.addCurrentDataVersion(tag); + return tag; +@@ -77,11 +_,11 @@ + } + + public CompoundTag upgradeChunkTag(CompoundTag tag, int version) { +- return this.upgradeChunkTag(tag, version, null); ++ return this.upgradeChunkTag(tag, version, null, null); // CraftBukkit + } + + public Dynamic upgradeChunkTag(Dynamic tag, int version) { +- return new Dynamic<>(tag.getOps(), this.upgradeChunkTag((CompoundTag)tag.getValue(), version, null)); ++ return new Dynamic<>(tag.getOps(), this.upgradeChunkTag((CompoundTag)tag.getValue(), version, null, null)); // CraftBukkit + } + + public static void injectDatafixingContext(CompoundTag tag, @Nullable CompoundTag contextTag) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index 201c35f63b13..81e8c3b40392 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -11,7 +11,7 @@ ) .setPlayBossMusic(true) .setCreateWorldFog(true); -@@ -112,7 +_,12 @@ +@@ -108,7 +_,12 @@ if (data.isRespawning) { this.respawnStage = DragonRespawnAnimation.START; } @@ -25,7 +25,7 @@ this.portalLocation = data.exitPortalLocation.orElse(null); this.gateways.addAll(data.gateways.orElseGet(() -> { ObjectArrayList list = new ObjectArrayList<>(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers())); -@@ -209,9 +_,9 @@ +@@ -205,9 +_,9 @@ this.dragonUUID = enderDragon.getUUID(); LOGGER.info("Found that there's a dragon still alive ({})", enderDragon); this.dragonKilled = false; @@ -37,7 +37,7 @@ this.dragonUUID = null; } } -@@ -366,12 +_,22 @@ +@@ -361,12 +_,22 @@ this.dragonEvent.setVisible(false); this.spawnExitPortal(true); this.spawnNewGateway(); @@ -66,7 +66,7 @@ } this.previouslyKilled = true; -@@ -385,6 +_,24 @@ +@@ -380,6 +_,24 @@ this.gateways.clear(); } @@ -91,7 +91,7 @@ private void spawnNewGateway() { if (!this.gateways.isEmpty()) { int i = this.gateways.remove(this.gateways.size() - 1); -@@ -415,6 +_,11 @@ +@@ -410,6 +_,11 @@ this.portalLocation = this.portalLocation.atY(Math.max(this.level.getMinY() + 1, this.portalLocation.getY())); } @@ -103,7 +103,7 @@ if (endPodiumFeature.place( FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation )) { -@@ -434,6 +_,7 @@ +@@ -428,6 +_,7 @@ enderDragon.snapTo(this.origin.getX(), 128 + this.origin.getY(), this.origin.getZ(), this.level.random.nextFloat() * 360.0F, 0.0F); this.level.addFreshEntity(enderDragon); this.dragonUUID = enderDragon.getUUID(); @@ -111,7 +111,7 @@ } return enderDragon; -@@ -445,6 +_,10 @@ +@@ -439,6 +_,10 @@ this.ticksSinceDragonSeen = 0; if (dragon.hasCustomName()) { this.dragonEvent.setName(dragon.getDisplayName()); @@ -122,7 +122,7 @@ } } } -@@ -472,7 +_,13 @@ +@@ -466,7 +_,13 @@ return this.previouslyKilled; } @@ -137,7 +137,7 @@ if (this.dragonKilled && this.respawnStage == null) { BlockPos blockPos = this.portalLocation; if (blockPos == null) { -@@ -487,6 +_,22 @@ +@@ -481,6 +_,22 @@ blockPos = this.portalLocation; } @@ -160,7 +160,7 @@ List list = Lists.newArrayList(); BlockPos blockPos1 = blockPos.above(1); -@@ -494,18 +_,19 @@ +@@ -488,18 +_,19 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { List entitiesOfClass = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(blockPos1.relative(direction, 2))); if (entitiesOfClass.isEmpty()) { @@ -183,7 +183,7 @@ if (this.dragonKilled && this.respawnStage == null) { for (BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); blockPatternMatch != null; blockPatternMatch = this.findExitPortal()) { for (int i = 0; i < this.exitPortalPattern.getWidth(); i++) { -@@ -524,7 +_,9 @@ +@@ -518,7 +_,9 @@ this.respawnTime = 0; this.spawnExitPortal(false); this.respawnCrystals = crystals; diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch index c0246df6bb4b..a920d35331d0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/DynamicGameEventListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java +++ b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -@@ -41,7 +_,7 @@ +@@ -40,7 +_,7 @@ private static void ifChunkExists(LevelReader level, @Nullable SectionPos sectionPos, Consumer dispatcherConsumer) { if (sectionPos != null) { 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 be2290d7c916..efcac86d58ce 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 @@ -4,8 +4,8 @@ } private static Holder.Reference register(String name, int notificationRadius) { -- return Registry.registerForHolder(BuiltInRegistries.GAME_EVENT, ResourceLocation.withDefaultNamespace(name), new GameEvent(notificationRadius)); -+ return io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerForHolderWithListeners(BuiltInRegistries.GAME_EVENT, ResourceLocation.withDefaultNamespace(name), new GameEvent(notificationRadius)); // Paper - run with listeners +- return Registry.registerForHolder(BuiltInRegistries.GAME_EVENT, Identifier.withDefaultNamespace(name), new GameEvent(notificationRadius)); ++ return io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerForHolderWithListeners(BuiltInRegistries.GAME_EVENT, Identifier.withDefaultNamespace(name), new GameEvent(notificationRadius)); // Paper - run with listeners } public record Context(@Nullable Entity sourceEntity, @Nullable BlockState affectedState) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch index 48fcd72e8e62..043949fc6716 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch @@ -6,7 +6,7 @@ BlockPos blockPos = BlockPos.containing(pos); + // CraftBukkit start + org.bukkit.event.world.GenericGameEvent apiEvent = new org.bukkit.event.world.GenericGameEvent( -+ org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameEvent.value()), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, this.level), ++ org.bukkit.craftbukkit.CraftGameEvent.minecraftHolderToBukkit(gameEvent), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, this.level), + (context.sourceEntity() == null) ? null : context.sourceEntity().getBukkitEntity(), notificationRadius, !org.bukkit.Bukkit.isPrimaryThread()); + if (!apiEvent.callEvent()) { + return; 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 a69e5d7e9436..c56f5cbcf66d 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 @@ -9,7 +9,7 @@ ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.Data::getTravelTimeInTicks) ) .apply( -@@ -214,7 +_,14 @@ +@@ -212,7 +_,14 @@ return false; } else { Vec3 vec3 = position.get(); @@ -17,7 +17,7 @@ + // CraftBukkit start + boolean defaultCancel = !vibrationUser.canReceiveVibration(level, BlockPos.containing(pos), gameEvent, context); + Entity entity = context.sourceEntity(); -+ org.bukkit.event.block.BlockReceiveGameEvent event1 = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameEvent.value()), org.bukkit.craftbukkit.block.CraftBlock.at(level, BlockPos.containing(vec3)), (entity == null) ? null : entity.getBukkitEntity()); ++ org.bukkit.event.block.BlockReceiveGameEvent event1 = new org.bukkit.event.block.BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftHolderToBukkit(gameEvent), org.bukkit.craftbukkit.block.CraftBlock.at(level, BlockPos.containing(vec3)), (entity == null) ? null : entity.getBukkitEntity()); + event1.setCancelled(defaultCancel); + level.getCraftServer().getPluginManager().callEvent(event1); + if (event1.isCancelled()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch new file mode 100644 index 000000000000..afb8178f0114 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/gamerules/GameRules.java.patch @@ -0,0 +1,69 @@ +--- a/net/minecraft/world/level/gamerules/GameRules.java ++++ b/net/minecraft/world/level/gamerules/GameRules.java +@@ -17,6 +_,14 @@ + import org.jspecify.annotations.Nullable; + + public class GameRules { ++ // Paper start - allow disabling gamerule limits ++ private static final boolean DISABLE_LIMITS = Boolean.getBoolean("paper.disableGameRuleLimits"); ++ ++ private static int limit(final int limit, final int unlimited) { ++ return DISABLE_LIMITS ? unlimited : limit; ++ } ++ // Paper end - allow disabling gamerule limits ++ + public static final GameRule ADVANCE_TIME = registerBoolean("advance_time", GameRuleCategory.UPDATES, !SharedConstants.DEBUG_WORLD_RECREATE); + public static final GameRule ADVANCE_WEATHER = registerBoolean("advance_weather", GameRuleCategory.UPDATES, !SharedConstants.DEBUG_WORLD_RECREATE); + public static final GameRule ALLOW_ENTERING_NETHER_USING_PORTALS = registerBoolean( +@@ -114,13 +_,15 @@ + } + } + +- public void set(GameRule rule, T value, @Nullable MinecraftServer server) { ++ public void set(GameRule rule, T value, net.minecraft.server.level.@Nullable ServerLevel level) { // Paper - per-world game rules + if (!this.rules.has(rule)) { + throw new IllegalArgumentException("Tried to set invalid game rule"); + } else { + this.rules.set(rule, value); +- if (server != null) { +- server.onGameRuleChanged(rule, value); ++ // Paper start - per-world game rules ++ if (level != null) { ++ level.getServer().onGameRuleChanged(level, rule, value); ++ // Paper end - per-world game rules + } + } + } +@@ -129,16 +_,22 @@ + return new GameRules(enabledFeatures, this.rules); + } + +- public void setAll(GameRules gameRules, @Nullable MinecraftServer server) { +- this.setAll(gameRules.rules, server); +- } +- +- public void setAll(GameRuleMap rules, @Nullable MinecraftServer server) { +- rules.keySet().forEach(rule -> this.setFromOther(rules, (GameRule)rule, server)); +- } +- +- private void setFromOther(GameRuleMap rules, GameRule rule, @Nullable MinecraftServer server) { +- this.set(rule, Objects.requireNonNull(rules.get(rule)), server); ++ // Paper start - per-world game rules ++ public void setAll(GameRules gameRules, net.minecraft.server.level.@Nullable ServerLevel level) { ++ this.setAll(gameRules.rules, level); ++ // Paper end - per-world game rules ++ } ++ ++ // Paper start - per-world game rules ++ public void setAll(GameRuleMap rules, net.minecraft.server.level.@Nullable ServerLevel level) { ++ rules.keySet().forEach(rule -> this.setFromOther(rules, (GameRule)rule, level)); ++ // Paper end - per-world game rules ++ } ++ ++ // Paper start - per-world game rules ++ private void setFromOther(GameRuleMap rules, GameRule rule, net.minecraft.server.level.@Nullable ServerLevel level) { ++ this.set(rule, Objects.requireNonNull(rules.get(rule)), level); ++ // Paper end - per-world game rules + } + + public void visitGameRuleTypes(GameRuleTypeVisitor visitor) { 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 5216f0dba60a..0b411864f6da 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,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -224,7 +_,7 @@ +@@ -226,7 +_,7 @@ @Override public void buildSurface(WorldGenRegion region, StructureManager structureManager, RandomState random, ChunkAccess chunk) { if (!SharedConstants.debugVoidTerrain(chunk.getPos()) && !SharedConstants.DEBUG_DISABLE_SURFACE) { @@ -9,7 +9,7 @@ this.buildSurface( chunk, worldGenerationContext, -@@ -267,7 +_,7 @@ +@@ -269,7 +_,7 @@ NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk(chunkAccess -> this.createNoiseChunk(chunkAccess, structureManager, Blender.of(region), random)); Aquifer aquifer = noiseChunk.aquifer(); CarvingContext carvingContext = new CarvingContext( diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index 911686196d51..76603adde963 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java -@@ -20,18 +_,47 @@ +@@ -18,17 +_,47 @@ @Override public void tick(ServerLevel level, boolean spawnEnemies) { + if (level.paperConfig().entities.behavior.pillagerPatrols.disable || level.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return; // Paper - Add option to disable pillager patrols & Pillager patrol spawn settings and per player options if (spawnEnemies) { - if (level.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { + if (level.getGameRules().get(GameRules.SPAWN_PATROLS)) { RandomSource randomSource = level.random; - this.nextTick--; - if (this.nextTick <= 0) { - this.nextTick = this.nextTick + 12000 + randomSource.nextInt(1200); -- long l = level.getDayTime() / 24000L; -- if (l >= 5L && level.isBrightOutside()) { +- if (level.isBrightOutside()) { - if (randomSource.nextInt(5) == 0) { - int size = level.players().size(); + // this.nextTick--; @@ -36,11 +35,11 @@ + patrolSpawnDelay = this.nextTick; + } + if (patrolSpawnDelay <= 0) { -+ long days; ++ long dayCount; + if (level.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) { -+ days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks ++ dayCount = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks + } else { -+ days = level.getDayTime() / 24000L; ++ dayCount = level.getDayCount(); + } + if (level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) { + player.patrolSpawnDelay += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); @@ -48,7 +47,7 @@ + this.nextTick += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); + } + -+ if (days >= level.paperConfig().entities.behavior.pillagerPatrols.start.day && level.isBrightOutside()) { ++ if (dayCount >= level.paperConfig().entities.behavior.pillagerPatrols.start.day && level.isBrightOutside()) { + if (randomSource.nextDouble() < level.paperConfig().entities.behavior.pillagerPatrols.spawnChance) { + // Paper end - Pillager patrol spawn settings and per player options if (size >= 1) { @@ -56,7 +55,7 @@ if (!player.isSpectator()) { if (!level.isCloseToVillage(player.blockPosition(), 2)) { int i = (24 + randomSource.nextInt(24)) * (randomSource.nextBoolean() ? -1 : 1); -@@ -88,7 +_,7 @@ +@@ -84,7 +_,7 @@ patrollingMonster.setPos(pos.getX(), pos.getY(), pos.getZ()); patrollingMonster.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.PATROL, null); 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 5101a29d2e7c..602489891fc3 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 @@ -3,7 +3,7 @@ @@ -25,13 +_,22 @@ public void tick(ServerLevel level, boolean spawnEnemies) { if (spawnEnemies) { - if (level.getGameRules().getBoolean(GameRules.RULE_DOINSOMNIA)) { + if (level.getGameRules().get(GameRules.SPAWN_PHANTOMS)) { + // Paper start - Ability to control player's insomnia and phantoms + if (level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds <= 0) { + return; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch index ae7f643e1962..50db0210b37d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch @@ -1,24 +1,40 @@ --- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -221,17 +_,17 @@ +@@ -116,6 +_,15 @@ } + + int dataVersion = NbtUtils.getDataVersion(tag); ++ // CraftBukkit start ++ if (dataVersion < 1466) { ++ CompoundTag level = tag.getCompoundOrEmpty("Level"); ++ if (level.getBooleanOr("TerrainPopulated", false) && !level.getBooleanOr("LightPopulated", false)) { ++ // Light is purged updating to 1.14+. We need to set light populated to true so the converter recognizes the chunk as being "full" ++ level.putBoolean("LightPopulated", true); ++ } ++ } ++ // CraftBukkit end + if (dataVersion < 1493) { + tag = DataFixTypes.CHUNK.update(this.dataFixer, tag, dataVersion, 1493); + if (tag.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { +@@ -260,17 +_,18 @@ } -- public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage) { + public static Supplier getLegacyTagFixer(ResourceKey level, Supplier<@Nullable DimensionDataStorage> storage, DataFixer dataFixer) { - if (level == Level.OVERWORLD) { -+ public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage) { // CraftBukkit -+ if (level == net.minecraft.world.level.dimension.LevelStem.OVERWORLD) { // CraftBukkit - return new LegacyStructureDataHandler( - storage, ++ ResourceKey stemKey = net.minecraft.core.registries.Registries.levelToLevelStem(level); // CraftBukkit ++ if (stemKey == net.minecraft.world.level.dimension.LevelStem.OVERWORLD) { // CraftBukkit + return () -> new LegacyStructureDataHandler( + storage.get(), ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), - ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument") + ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument"), + dataFixer ); - } else if (level == Level.NETHER) { -+ } else if (level == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit ++ } else if (stemKey == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit List list = ImmutableList.of("Fortress"); - return new LegacyStructureDataHandler(storage, list, list); + return () -> new LegacyStructureDataHandler(storage.get(), list, list, dataFixer); - } else if (level == Level.END) { -+ } else if (level == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit ++ } else if (stemKey == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit List list = ImmutableList.of("EndCity"); - return new LegacyStructureDataHandler(storage, list, list); + return () -> new LegacyStructureDataHandler(storage.get(), list, list, dataFixer); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch index 30e8373a4848..89126f2147fe 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -41,7 +_,7 @@ +@@ -43,7 +_,7 @@ private final ChunkScanAccess storageAccess; private final RegistryAccess registryAccess; private final StructureTemplateManager structureTemplateManager; @@ -9,7 +9,7 @@ private final ChunkGenerator chunkGenerator; private final RandomState randomState; private final LevelHeightAccessor heightAccessor; -@@ -55,7 +_,7 @@ +@@ -57,7 +_,7 @@ ChunkScanAccess storageAccess, RegistryAccess registryAccess, StructureTemplateManager structureTemplateManager, @@ -18,7 +18,7 @@ ChunkGenerator chunkGenerator, RandomState randomState, LevelHeightAccessor heightAccessor, -@@ -75,6 +_,20 @@ +@@ -77,6 +_,20 @@ this.fixerUpper = fixerUpper; } @@ -39,7 +39,7 @@ public StructureCheckResult checkStart(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) { long packedChunkPos = chunkPos.toLong(); Object2IntMap map = this.loadedChunks.get(packedChunkPos); -@@ -84,7 +_,7 @@ +@@ -86,7 +_,7 @@ StructureCheckResult structureCheckResult = this.tryLoadFromStorage(chunkPos, structure, skipKnownStructures, packedChunkPos); if (structureCheckResult != null) { return structureCheckResult; 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 c08d93948b83..d358e0362acb 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 -@@ -181,6 +_,11 @@ +@@ -180,6 +_,11 @@ } level.setBlock(worldPos, state, Block.UPDATE_CLIENTS); @@ -12,7 +12,7 @@ FluidState fluidState = level.getFluidState(worldPos); if (!fluidState.isEmpty()) { level.scheduleTick(worldPos, fluidState.getType(), 0); -@@ -193,6 +_,48 @@ +@@ -192,6 +_,48 @@ } } @@ -61,7 +61,7 @@ protected boolean canBeReplaced(LevelReader level, int x, int y, int z, BoundingBox box) { return true; } -@@ -421,11 +_,17 @@ +@@ -420,11 +_,17 @@ state = reorient(level, pos, Blocks.CHEST.defaultBlockState()); } @@ -84,7 +84,7 @@ return true; } else { -@@ -438,11 +_,28 @@ +@@ -437,11 +_,28 @@ ) { BlockPos worldPos = this.getWorldPos(x, y, z); if (box.isInside(worldPos) && !level.getBlockState(worldPos).is(Blocks.DISPENSER)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 2f1367496772..c42ee6b4f724 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java -@@ -30,6 +_,12 @@ - @Nullable - private volatile BoundingBox cachedBoundingBox; +@@ -29,6 +_,12 @@ + private int references; + private volatile @Nullable BoundingBox cachedBoundingBox; + // CraftBukkit start + private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); @@ -13,7 +13,7 @@ public StructureStart(Structure structure, ChunkPos chunkPos, int references, PiecesContainer pieceContainer) { this.structure = structure; this.chunkPos = chunkPos; -@@ -87,11 +_,23 @@ +@@ -85,11 +_,23 @@ BlockPos center = boundingBox.getCenter(); BlockPos blockPos = new BlockPos(center.getX(), boundingBox.minY(), center.getZ()); @@ -40,7 +40,7 @@ this.structure.afterPlace(level, structureManager, generator, random, box, chunkPos, this.pieceContainer); } -@@ -99,6 +_,11 @@ +@@ -97,6 +_,11 @@ public CompoundTag createTag(StructurePieceSerializationContext context, ChunkPos chunkPos) { CompoundTag compoundTag = new CompoundTag(); 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 1794d24018d5..b76a0f994cf1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java -@@ -397,10 +_,13 @@ +@@ -396,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(1, 0, i8); if (box.isInside(worldPos) && this.isInterior(level, 1, 0, i8, box)) { this.hasPlacedSpider = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch index abb610b37793..dd3faae71de3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java -@@ -1077,10 +_,13 @@ +@@ -1084,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(3, 5, 5); if (box.isInside(worldPos)) { this.hasPlacedSpawner = true; 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 b1642fdef4c5..75dc3003e1a4 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 -@@ -314,14 +_,20 @@ +@@ -308,14 +_,20 @@ @Override protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { if ("chest".equals(name)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch index dc109e132743..9ce178ba9c73 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java -@@ -21,7 +_,7 @@ +@@ -19,7 +_,7 @@ + private @Nullable BoundingBox boundingBox; private LiquidSettings liquidSettings = LiquidSettings.APPLY_WATERLOGGING; - @Nullable - private RandomSource random; + private @Nullable RandomSource random; - private int palette; + public int palette = -1; // CraftBukkit - Set initial value so we know if the palette has been set forcefully private final List processors = Lists.newArrayList(); private boolean knownShape; private boolean finalizeEntities; -@@ -142,6 +_,13 @@ +@@ -139,6 +_,13 @@ int size = palettes.size(); if (size == 0) { throw new IllegalStateException("No palettes"); 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 96ba5c45bad1..0bffaf4763df 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 @@ -11,7 +11,7 @@ public Vec3i getSize() { return this.size; -@@ -256,6 +_,19 @@ +@@ -258,6 +_,19 @@ if (this.palettes.isEmpty()) { return false; } else { @@ -31,7 +31,7 @@ List list = settings.getRandomPalette(this.palettes, offset).blocks(); if ((!list.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 -@@ -283,6 +_,21 @@ +@@ -285,6 +_,21 @@ level.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), Block.UPDATE_SKIP_ALL_SIDEEFFECTS | Block.UPDATE_NONE); } @@ -53,7 +53,7 @@ if (level.setBlock(blockPos, blockState, flags)) { i = Math.min(i, blockPos.getX()); i1 = Math.min(i1, blockPos.getY()); -@@ -294,7 +_,7 @@ +@@ -296,7 +_,7 @@ if (structureBlockInfo.nbt != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos); if (blockEntity != null) { @@ -62,7 +62,7 @@ structureBlockInfo.nbt.putLong("LootTableSeed", random.nextLong()); } -@@ -381,7 +_,11 @@ +@@ -383,7 +_,11 @@ if (pair1.getSecond() != null) { BlockEntity blockEntity = level.getBlockEntity(blockPos4); if (blockEntity != null) { @@ -75,7 +75,7 @@ } } } -@@ -389,7 +_,7 @@ +@@ -391,7 +_,7 @@ if (!settings.isIgnoreEntities()) { this.placeEntities( @@ -84,7 +84,7 @@ offset, settings.getMirror(), settings.getRotation(), -@@ -502,14 +_,17 @@ +@@ -504,14 +_,17 @@ }); } } @@ -107,7 +107,7 @@ } public Vec3i getSize(Rotation rotation) { -@@ -702,6 +_,11 @@ +@@ -704,6 +_,11 @@ tag.put("entities", listTag3); tag.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); @@ -119,7 +119,7 @@ return NbtUtils.addCurrentDataVersion(tag); } -@@ -732,6 +_,11 @@ +@@ -734,6 +_,11 @@ .ifPresent(compoundTag1 -> this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(vec3, blockPos, compoundTag1))); } ); @@ -131,12 +131,12 @@ } private void loadPalette(HolderGetter blockGetter, ListTag paletteTag, ListTag blocksTag) { -@@ -831,7 +_,7 @@ +@@ -833,7 +_,7 @@ public static final class Palette { private final List blocks; - private final Map> cache = Maps.newHashMap(); + private final Map> cache = Maps.newConcurrentMap(); // Paper - Fix CME due to this collection being shared across threads - @Nullable - private List cachedJigsaws; + private @Nullable List cachedJigsaws; + Palette(List blocks) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch index e705834d44aa..8b385e7dbad5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java @@ -94,6 +_,13 @@ - BlockState blockState = level.getBlockState(blockPos); - if (blockState.isAir()) { - if (this.hasFlammableNeighbours(level, blockPos)) { -+ // CraftBukkit start - Prevent lava putting something on fire -+ if (!level.getBlockState(blockPos).is(Blocks.FIRE)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockPos, pos).isCancelled()) { -+ continue; -+ } -+ } -+ // CraftBukkit end - level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); - return; - } -@@ -109,6 +_,14 @@ - } - - if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { + BlockState blockState = level.getBlockState(blockPos); + if (blockState.isAir()) { + if (this.hasFlammableNeighbours(level, blockPos)) { + // CraftBukkit start - Prevent lava putting something on fire -+ BlockPos up = blockPos1.above(); -+ if (!level.getBlockState(up).is(Blocks.FIRE)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, up, pos).isCancelled()) { ++ if (!level.getBlockState(blockPos).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockPos, pos).isCancelled()) { + continue; + } + } -+ // CraftBukkit end - Prevent lava putting something on fire - level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); ++ // CraftBukkit end + level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); + return; } +@@ -109,6 +_,14 @@ } -@@ -119,9 +_,10 @@ + + if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { ++ // CraftBukkit start - Prevent lava putting something on fire ++ BlockPos up = blockPos1.above(); ++ if (!level.getBlockState(up).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, up, pos).isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end - Prevent lava putting something on fire + level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); + } + } +@@ -118,9 +_,10 @@ @Override protected void entityInside(Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { @@ -41,7 +41,7 @@ } private boolean hasFlammableNeighbours(LevelReader level, BlockPos pos) { -@@ -209,7 +_,11 @@ +@@ -207,7 +_,11 @@ FluidState fluidState1 = level.getFluidState(pos); if (this.is(FluidTags.LAVA) && fluidState1.is(FluidTags.WATER)) { if (state.getBlock() instanceof LiquidBlock) { @@ -54,7 +54,7 @@ } this.fizz(level, pos); -@@ -227,7 +_,7 @@ +@@ -225,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch index 2d7aee20e32b..0accdf667c84 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/material/WaterFluid.java +++ b/net/minecraft/world/level/material/WaterFluid.java -@@ -78,6 +_,14 @@ - return level.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION); +@@ -77,6 +_,14 @@ + return level.getGameRules().get(GameRules.WATER_SOURCE_CONVERSION); } + // Paper start - Add BlockBreakBlockEvent @@ -15,7 +15,7 @@ @Override protected void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state) { BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; -@@ -121,7 +_,7 @@ +@@ -120,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index 94a7ed2e86b6..cacf29e39716 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -480,7 +_,12 @@ +@@ -477,7 +_,12 @@ } protected static PathType getPathTypeFromState(BlockGetter level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch index 6d690ba52d9a..3cbbdd7538ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch @@ -14,7 +14,7 @@ this.axis = axis; this.numPortalBlocks = numPortalBlocks; this.rightDir = rightDir; -@@ -63,24 +_,25 @@ +@@ -63,23 +_,24 @@ } public static PortalShape findAnyShape(BlockGetter level, BlockPos bottomLeft, Direction.Axis axis) { @@ -34,20 +34,19 @@ } else { MutableInt mutableInt = new MutableInt(); - int i1 = calculateHeight(level, blockPos, direction, i, mutableInt); -- return new PortalShape(axis, mutableInt.getValue(), direction, blockPos, i, i1); +- return new PortalShape(axis, mutableInt.intValue(), direction, blockPos, i, i1); + int i1 = calculateHeight(level, blockPos, direction, i, mutableInt, blocks); // CraftBukkit -+ return new PortalShape(axis, mutableInt.getValue(), direction, blockPos, i, i1, blocks); // CraftBukkit ++ return new PortalShape(axis, mutableInt.intValue(), direction, blockPos, i, i1, blocks); // CraftBukkit } } } - @Nullable -- private static BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos) { -+ private static BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit +- private static @Nullable BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos) { ++ private static @Nullable BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit int max = Math.max(level.getMinY(), pos.getY() - 21); while (pos.getY() > max && isEmpty(level.getBlockState(pos.below()))) { -@@ -88,16 +_,16 @@ +@@ -87,16 +_,16 @@ } Direction opposite = direction.getOpposite(); @@ -68,7 +67,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); for (int i = 0; i <= 21; i++) { -@@ -105,6 +_,7 @@ +@@ -104,6 +_,7 @@ BlockState blockState = level.getBlockState(mutableBlockPos); if (!isEmpty(blockState)) { if (FRAME.test(blockState, level, mutableBlockPos)) { @@ -76,7 +75,7 @@ return i; } break; -@@ -114,32 +_,34 @@ +@@ -113,32 +_,34 @@ if (!FRAME.test(blockState1, level, mutableBlockPos)) { break; } @@ -116,7 +115,7 @@ ) { for (int i = 0; i < 21; i++) { checkPos.set(pos).move(Direction.UP, i).move(direction, -1); -@@ -163,6 +_,10 @@ +@@ -162,6 +_,10 @@ portalBlocks.increment(); } } @@ -127,7 +126,7 @@ } return 21; -@@ -176,10 +_,23 @@ +@@ -175,10 +_,23 @@ return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } 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 c95d2dfa4d1a..bdae25a276df 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 -@@ -148,7 +_,7 @@ +@@ -145,7 +_,7 @@ orientation = this.orientation.withFront(direction); } 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 1b10c37a4fe6..2ac346fb508f 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 @@ -96,7 +96,7 @@ } public static void addTargetDecoration(ItemStack stack, BlockPos pos, String type, Holder mapDecorationType) { -@@ -356,7 +_,12 @@ +@@ -352,7 +_,12 @@ } public void setColorsDirty(int x, int z) { @@ -110,7 +110,7 @@ for (MapItemSavedData.HoldingPlayer holdingPlayer : this.carriedBy) { holdingPlayer.markColorsDirty(x, z); -@@ -397,7 +_,7 @@ +@@ -393,7 +_,7 @@ return true; } @@ -119,7 +119,7 @@ this.bannerMarkers.put(mapBanner.getId(), mapBanner); this.addDecoration(mapBanner.getDecoration(), level, mapBanner.getId(), d, d1, 180.0, mapBanner.name().orElse(null)); this.setDirty(); -@@ -499,7 +_,7 @@ +@@ -495,7 +_,7 @@ this.player = player; } @@ -128,7 +128,7 @@ int i = this.minDirtyX; int i1 = this.minDirtyY; int i2 = this.maxDirtyX + 1 - this.minDirtyX; -@@ -508,7 +_,7 @@ +@@ -504,7 +_,7 @@ for (int i4 = 0; i4 < i2; i4++) { for (int i5 = 0; i5 < i3; i5++) { @@ -137,9 +137,9 @@ } } -@@ -518,17 +_,38 @@ - @Nullable - Packet nextUpdatePacket(MapId mapId) { +@@ -513,17 +_,38 @@ + + @Nullable Packet nextUpdatePacket(MapId mapId) { MapItemSavedData.MapPatch mapPatch; + // Paper start + if (!this.dirtyData && this.tick % 5 != 0) { @@ -179,7 +179,7 @@ } else { collection = null; } -@@ -556,6 +_,23 @@ +@@ -551,6 +_,23 @@ private void markDecorationsDirty() { this.dirtyDecorations = true; } @@ -203,7 +203,7 @@ } record MapDecorationLocation(Holder type, byte x, byte y, byte rot) { -@@ -600,4 +_,71 @@ +@@ -595,4 +_,71 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index 7fb3ede9cd79..81c5212d5251 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -150,7 +_,7 @@ +@@ -145,7 +_,7 @@ } else { int i = Util.maxAllowedExecutorThreads(); int size = map.size(); @@ -9,7 +9,7 @@ this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(object -> { List> list = new ArrayList<>(i); int i1 = Mth.positiveCeilDiv(size, i); -@@ -171,7 +_,7 @@ +@@ -166,7 +_,7 @@ object -> CompletableFuture.allOf( map.entrySet() .stream() diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch index 06fe93b17e45..41797a9d2508 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelData.java +++ b/net/minecraft/world/level/storage/LevelData.java -@@ -71,5 +_,25 @@ +@@ -72,5 +_,25 @@ public BlockPos pos() { return this.globalPos.pos(); } 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 9ddec50747a5..af68b818219b 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 -@@ -145,6 +_,7 @@ +@@ -142,6 +_,7 @@ PrimaryLevelData primaryLevelData = PrimaryLevelData.parse( dynamic, levelSettings, complete.specialWorldProperty(), worldGenSettings.options(), lifecycle ); @@ -8,7 +8,7 @@ return new LevelDataAndDimensions(primaryLevelData, complete); } -@@ -341,25 +_,39 @@ +@@ -336,25 +_,39 @@ return this.backupDir; } @@ -45,7 +45,7 @@ + } else if (dimensionType == LevelStem.END) { + return path.resolve("DIM1"); + } else { -+ return path.resolve("dimensions").resolve(dimensionType.location().getNamespace()).resolve(dimensionType.location().getPath()); ++ return path.resolve("dimensions").resolve(dimensionType.identifier().getNamespace()).resolve(dimensionType.identifier().getPath()); + } + } + // CraftBukkit end @@ -53,7 +53,7 @@ public record LevelCandidates(List levels) implements Iterable { public boolean isEmpty() { return this.levels.isEmpty(); -@@ -410,8 +_,12 @@ +@@ -405,8 +_,12 @@ public final LevelStorageSource.LevelDirectory levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -67,7 +67,7 @@ this.levelId = levelId; this.levelDirectory = new LevelStorageSource.LevelDirectory(levelDir); this.lock = DirectoryLock.create(levelDir); -@@ -454,7 +_,7 @@ +@@ -449,7 +_,7 @@ } public Path getDimensionPath(ResourceKey dimensionPath) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index 4cd5a8519012..ec0dfb0392aa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -33,6 +_,7 @@ +@@ -31,6 +_,7 @@ } public void save(Player player) { @@ -8,7 +8,7 @@ try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(player.problemPath(), LOGGER)) { TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, player.registryAccess()); player.saveWithoutId(tagValueOutput); -@@ -44,7 +_,7 @@ +@@ -42,7 +_,7 @@ Path path3 = path.resolve(player.getStringUUID() + ".dat_old"); Util.safeReplaceFile(path2, path1, path3); } catch (Exception var11) { @@ -17,10 +17,10 @@ } } -@@ -64,9 +_,25 @@ +@@ -62,9 +_,25 @@ private Optional load(NameAndId nameAndId, String suffix) { - File file = new File(this.playerDir, nameAndId.id().toString() + suffix); + File file = new File(this.playerDir, nameAndId.id() + suffix); + // Spigot start + boolean usingWrongFile = false; + if (org.bukkit.Bukkit.getOnlineMode() && !file.exists()) { // Paper - Check online mode first @@ -44,7 +44,7 @@ } catch (Exception var5) { LOGGER.warn("Failed to load player data for {}", nameAndId.name()); } -@@ -86,4 +_,10 @@ +@@ -84,4 +_,10 @@ return DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, compoundTag, dataVersion); }); } 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 5ebc8a8f21cb..75ca0c09e94b 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 @@ -8,8 +8,8 @@ + public net.minecraft.resources.ResourceKey respawnDimension = net.minecraft.world.level.Level.OVERWORLD; // Paper private long gameTime; private long dayTime; - @Nullable -@@ -74,6 +_,21 @@ + private final @Nullable CompoundTag loadedPlayerTag; +@@ -71,6 +_,21 @@ private final Set removedFeatureFlags; private final TimerQueue scheduledEvents; @@ -31,7 +31,7 @@ private PrimaryLevelData( @Nullable CompoundTag loadedPlayerTag, boolean wasModded, -@@ -171,7 +_,7 @@ +@@ -168,7 +_,7 @@ Lifecycle worldGenSettingsLifecycle ) { long _long = tag.get("Time").asLong(0L); @@ -40,7 +40,7 @@ tag.get("Player").flatMap(CompoundTag.CODEC::parse).result().orElse(null), tag.get("WasModded").asBoolean(false), tag.get("spawn").read(LevelData.RespawnData.CODEC).result().orElse(LevelData.RespawnData.DEFAULT), -@@ -205,6 +_,13 @@ +@@ -202,6 +_,13 @@ specialWorldProperty, worldGenSettingsLifecycle ); @@ -54,7 +54,7 @@ } @Override -@@ -233,11 +_,12 @@ +@@ -230,11 +_,12 @@ tag.put("Version", compoundTag); NbtUtils.addCurrentDataVersion(tag); DynamicOps dynamicOps = registry.createSerializationContext(NbtOps.INSTANCE); @@ -68,7 +68,7 @@ tag.putLong("Time", this.gameTime); tag.putLong("DayTime", this.dayTime); tag.putLong("LastPlayed", Util.getEpochMillis()); -@@ -269,6 +_,8 @@ +@@ -266,6 +_,8 @@ tag.putInt("WanderingTraderSpawnDelay", this.wanderingTraderSpawnDelay); tag.putInt("WanderingTraderSpawnChance", this.wanderingTraderSpawnChance); tag.storeNullable("WanderingTraderId", UUIDUtil.CODEC, this.wanderingTraderId); @@ -77,7 +77,7 @@ } private static ListTag stringCollectionToTag(Set stringCollection) { -@@ -340,6 +_,25 @@ +@@ -336,6 +_,25 @@ @Override public void setThundering(boolean thundering) { @@ -103,7 +103,7 @@ this.thundering = thundering; } -@@ -360,6 +_,26 @@ +@@ -356,6 +_,26 @@ @Override public void setRaining(boolean isRaining) { @@ -130,7 +130,7 @@ this.raining = isRaining; } -@@ -426,6 +_,12 @@ +@@ -422,6 +_,12 @@ @Override public void setDifficulty(Difficulty difficulty) { this.settings = this.settings.withDifficulty(difficulty); @@ -143,7 +143,7 @@ } @Override -@@ -561,6 +_,14 @@ +@@ -555,6 +_,14 @@ public LevelSettings getLevelSettings() { return this.settings.copy(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch index 521ff0103e15..0b8df8cc19cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootDataType.java.patch @@ -12,7 +12,7 @@ + value.validate( + context.setContextKeySet(value.getParamSet()).enterElement(new ProblemReporter.RootElementPathElement(key), key) + ); -+ value.craftLootTable = new org.bukkit.craftbukkit.CraftLootTable(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.location()), value); ++ value.craftLootTable = new org.bukkit.craftbukkit.CraftLootTable(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.identifier()), value); + // CraftBukkit end + }; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch index e94a2298f50f..3e2647744fbb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -6,7 +6,7 @@ private final BiFunction compositeFunction; + public org.bukkit.craftbukkit.CraftLootTable craftLootTable; // CraftBukkit - LootTable(ContextKeySet paramSet, Optional randomSequence, List pools, List functions) { + LootTable(ContextKeySet paramSet, Optional randomSequence, List pools, List functions) { this.paramSet = paramSet; @@ -63,9 +_,10 @@ } diff --git a/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch new file mode 100644 index 000000000000..24a2d294325d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/scores/Scoreboard.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/scores/Scoreboard.java ++++ b/net/minecraft/world/scores/Scoreboard.java +@@ -375,7 +_,7 @@ + } + + protected List packPlayerTeams() { +- return this.getPlayerTeams().stream().map(PlayerTeam::pack).toList(); ++ return this.getPlayerTeams().stream().filter(p -> io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams || !p.getPlayers().isEmpty()).map(PlayerTeam::pack).toList(); // Paper - Don't save empty scoreboard teams to scoreboard.dat + } + + protected void loadPlayerTeam(PlayerTeam.Packed packed) { diff --git a/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch deleted file mode 100644 index 35907f4c14ed..000000000000 --- a/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/scores/ScoreboardSaveData.java -+++ b/net/minecraft/world/scores/ScoreboardSaveData.java -@@ -39,7 +_,7 @@ - this.scoreboard.getObjectives().stream().map(Objective::pack).toList(), - this.scoreboard.packPlayerScores(), - map, -- this.scoreboard.getPlayerTeams().stream().map(PlayerTeam::pack).toList() -+ this.scoreboard.getPlayerTeams().stream().filter(p -> io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams || !p.getPlayers().isEmpty()).map(PlayerTeam::pack).toList() // Paper - Don't save empty scoreboard teams to scoreboard.dat - ); - } - 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 771c6b266b91..c8583cb0bc5a 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 @@ -14,7 +14,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.monster.RangedAttackMob; import org.apache.commons.lang3.math.NumberUtils; @@ -32,94 +32,94 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class); map.put(net.minecraft.world.entity.animal.Animal.class, Animals.class); map.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class); - map.put(net.minecraft.world.entity.animal.Bee.class, Bee.class); + map.put(net.minecraft.world.entity.animal.bee.Bee.class, Bee.class); map.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class); - map.put(net.minecraft.world.entity.animal.Cat.class, Cat.class); - map.put(net.minecraft.world.entity.monster.CaveSpider.class, CaveSpider.class); - map.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class); - map.put(net.minecraft.world.entity.animal.Cod.class, Cod.class); - map.put(net.minecraft.world.entity.animal.Cow.class, Cow.class); + map.put(net.minecraft.world.entity.animal.feline.Cat.class, Cat.class); + map.put(net.minecraft.world.entity.monster.spider.CaveSpider.class, CaveSpider.class); + map.put(net.minecraft.world.entity.animal.chicken.Chicken.class, Chicken.class); + map.put(net.minecraft.world.entity.animal.fish.Cod.class, Cod.class); + map.put(net.minecraft.world.entity.animal.cow.Cow.class, Cow.class); map.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class); map.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class); - map.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class); - map.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class); + map.put(net.minecraft.world.entity.animal.dolphin.Dolphin.class, Dolphin.class); + map.put(net.minecraft.world.entity.monster.zombie.Drowned.class, Drowned.class); map.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class); map.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class); map.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class); - map.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class); - map.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class); - map.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class); - map.put(net.minecraft.world.entity.animal.Fox.class, Fox.class); + map.put(net.minecraft.world.entity.monster.illager.Evoker.class, Evoker.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractFish.class, Fish.class); + map.put(net.minecraft.world.entity.animal.fish.AbstractSchoolingFish.class, SchoolableFish.class); + map.put(net.minecraft.world.entity.animal.fox.Fox.class, Fox.class); map.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class); map.put(net.minecraft.world.entity.monster.Giant.class, Giant.class); - map.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class); + map.put(net.minecraft.world.entity.animal.golem.AbstractGolem.class, Golem.class); map.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class); map.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class); - map.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class); - map.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class); - map.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class); - map.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class); - map.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class); - map.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Horse.class, Horse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractHorse.class, AbstractHorse.class); + map.put(net.minecraft.world.entity.animal.equine.AbstractChestedHorse.class, ChestedHorse.class); + map.put(net.minecraft.world.entity.animal.equine.Donkey.class, Donkey.class); + map.put(net.minecraft.world.entity.animal.equine.Mule.class, Mule.class); + map.put(net.minecraft.world.entity.animal.equine.SkeletonHorse.class, SkeletonHorse.class); + map.put(net.minecraft.world.entity.animal.equine.ZombieHorse.class, ZombieHorse.class); map.put(net.minecraft.world.entity.animal.camel.Camel.class, Camel.class); - map.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class); - map.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class); - map.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class); - map.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class); - map.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class); - map.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class); + map.put(net.minecraft.world.entity.monster.illager.AbstractIllager.class, Illager.class); + map.put(net.minecraft.world.entity.monster.illager.Illusioner.class, Illusioner.class); + map.put(net.minecraft.world.entity.monster.illager.SpellcasterIllager.class, Spellcaster.class); + 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.Monster.class, Monster.class); map.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); - map.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class); - map.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class); - map.put(net.minecraft.world.entity.animal.Panda.class, Panda.class); - map.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class); - map.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class); + map.put(net.minecraft.world.entity.animal.cow.MushroomCow.class, MushroomCow.class); + map.put(net.minecraft.world.entity.animal.feline.Ocelot.class, Ocelot.class); + map.put(net.minecraft.world.entity.animal.panda.Panda.class, Panda.class); + map.put(net.minecraft.world.entity.animal.parrot.Parrot.class, Parrot.class); + map.put(net.minecraft.world.entity.animal.parrot.ShoulderRidingEntity.class, Parrot.class); map.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class); - map.put(net.minecraft.world.entity.animal.Pig.class, Pig.class); - map.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class); - map.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class); - map.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class); - map.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class); - map.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class); + map.put(net.minecraft.world.entity.animal.pig.Pig.class, Pig.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombifiedPiglin.class, PigZombie.class); + map.put(net.minecraft.world.entity.monster.illager.Pillager.class, Pillager.class); + map.put(net.minecraft.world.entity.animal.polarbear.PolarBear.class, PolarBear.class); + map.put(net.minecraft.world.entity.animal.fish.Pufferfish.class, PufferFish.class); + map.put(net.minecraft.world.entity.animal.rabbit.Rabbit.class, Rabbit.class); map.put(net.minecraft.world.entity.raid.Raider.class, Raider.class); map.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class); - map.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class); + map.put(net.minecraft.world.entity.animal.fish.Salmon.class, Salmon.class); map.put(net.minecraft.world.entity.animal.sheep.Sheep.class, Sheep.class); map.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class); map.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class); - map.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class); - map.put(net.minecraft.world.entity.monster.AbstractSkeleton.class, AbstractSkeleton.class); - map.put(net.minecraft.world.entity.monster.Stray.class, Stray.class); - map.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class); + map.put(net.minecraft.world.entity.monster.skeleton.Skeleton.class, Skeleton.class); + 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.animal.SnowGolem.class, Snowman.class); - map.put(net.minecraft.world.entity.monster.Spider.class, Spider.class); - map.put(net.minecraft.world.entity.animal.Squid.class, Squid.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); map.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class); - map.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class); - map.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class); + map.put(net.minecraft.world.entity.animal.fish.TropicalFish.class, TropicalFish.class); + map.put(net.minecraft.world.entity.animal.turtle.Turtle.class, Turtle.class); map.put(net.minecraft.world.entity.monster.Vex.class, Vex.class); - map.put(net.minecraft.world.entity.npc.Villager.class, Villager.class); - map.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class); - map.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class); - map.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class); - map.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class); + map.put(net.minecraft.world.entity.npc.villager.Villager.class, Villager.class); + map.put(net.minecraft.world.entity.npc.villager.AbstractVillager.class, AbstractVillager.class); + map.put(net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader.class, WanderingTrader.class); + map.put(net.minecraft.world.entity.monster.illager.Vindicator.class, Vindicator.class); + map.put(net.minecraft.world.entity.animal.fish.WaterAnimal.class, WaterMob.class); map.put(net.minecraft.world.entity.monster.Witch.class, Witch.class); map.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class); map.put(net.minecraft.world.entity.animal.wolf.Wolf.class, Wolf.class); - map.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class); - map.put(net.minecraft.world.entity.monster.Husk.class, Husk.class); - map.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class); + map.put(net.minecraft.world.entity.monster.zombie.Zombie.class, Zombie.class); + map.put(net.minecraft.world.entity.monster.zombie.Husk.class, Husk.class); + map.put(net.minecraft.world.entity.monster.zombie.ZombieVillager.class, ZombieVillager.class); map.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class); map.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class); map.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class); map.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class); map.put(net.minecraft.world.entity.monster.Strider.class, Strider.class); map.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class); - map.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class); + map.put(net.minecraft.world.entity.animal.squid.GlowSquid.class, GlowSquid.class); map.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class); map.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class); map.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class); @@ -129,12 +129,17 @@ public class MobGoalHelper { map.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class); map.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class); map.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class); - map.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class); + map.put(net.minecraft.world.entity.monster.skeleton.Bogged.class, Bogged.class); map.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class); map.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class); - map.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); - map.put(net.minecraft.world.entity.animal.HappyGhast.class, HappyGhast.class); - map.put(net.minecraft.world.entity.animal.coppergolem.CopperGolem.class, CopperGolem.class); + map.put(net.minecraft.world.entity.animal.cow.AbstractCow.class, AbstractCow.class); + map.put(net.minecraft.world.entity.animal.happyghast.HappyGhast.class, HappyGhast.class); + map.put(net.minecraft.world.entity.animal.golem.CopperGolem.class, CopperGolem.class); + map.put(net.minecraft.world.entity.animal.nautilus.AbstractNautilus.class, AbstractNautilus.class); + map.put(net.minecraft.world.entity.animal.nautilus.Nautilus.class, Nautilus.class); + 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); // End generate - MobGoalHelper#BUKKIT_BRIDGE // }); 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 581e988bd7dc..9863aed2417e 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 @@ -1,6 +1,6 @@ package com.destroystokyo.paper.gui; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.server.MinecraftServer; import net.minecraft.util.TimeUtil; 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 f8fa27f99ac6..b4ce727bd292 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 @@ -9,7 +9,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import io.papermc.paper.profile.MutablePropertyMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.UUIDUtil; import net.minecraft.server.MinecraftServer; import net.minecraft.server.players.NameAndId; diff --git a/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java b/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java index cc65129c868a..fcd94bb0b7d2 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java @@ -15,7 +15,7 @@ import javax.crypto.spec.SecretKeySpec; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.login.custom.CustomQueryPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.player.ProfilePublicKey; /** @@ -35,7 +35,7 @@ public class VelocityProxy { public static final int MODERN_FORWARDING_WITH_KEY_V2 = 3; public static final int MODERN_LAZY_SESSION = 4; public static final byte MAX_SUPPORTED_FORWARDING_VERSION = MODERN_LAZY_SESSION; - public static final ResourceLocation PLAYER_INFO_CHANNEL = ResourceLocation.fromNamespaceAndPath("velocity", "player_info"); + public static final Identifier PLAYER_INFO_CHANNEL = Identifier.fromNamespaceAndPath("velocity", "player_info"); public static boolean checkIntegrity(final FriendlyByteBuf buf) { final byte[] signature = new byte[32]; 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 677b72f56db1..f7979f188c3d 100644 --- a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java +++ b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java @@ -10,12 +10,16 @@ import io.papermc.paper.world.damagesource.FallLocationType; import io.papermc.paper.world.damagesource.PaperCombatEntryWrapper; import io.papermc.paper.world.damagesource.PaperCombatTrackerWrapper; +import java.util.function.Function; +import java.util.function.Predicate; import net.kyori.adventure.text.Component; import net.minecraft.Optionull; -import net.minecraft.commands.PermissionSource; +import net.minecraft.commands.Commands; import net.minecraft.world.damagesource.FallLocation; import net.minecraft.world.entity.decoration.Mannequin; +import org.bukkit.GameRule; import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.block.CraftBiome; import org.bukkit.craftbukkit.damage.CraftDamageEffect; import org.bukkit.craftbukkit.damage.CraftDamageSource; @@ -25,7 +29,6 @@ import org.bukkit.entity.LivingEntity; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.function.Predicate; @NullMarked public class PaperServerInternalAPIBridge implements InternalAPIBridge { @@ -84,7 +87,7 @@ private CombatEntry createCombatEntry( @Override public Predicate restricted(final Predicate predicate) { - record RestrictedPredicate(Predicate predicate) implements Predicate, PermissionSource.RestrictedMarker { + record RestrictedPredicate(Predicate predicate) implements Predicate, Commands.RestrictedMarker { @Override public boolean test(final CommandSourceStack commandSourceStack) { return this.predicate.test(commandSourceStack); @@ -108,4 +111,9 @@ public SkinParts.Mutable allSkinParts() { public Component defaultMannequinDescription() { return PaperAdventure.asAdventure(Mannequin.DEFAULT_DESCRIPTION); } + + @Override + public GameRule legacyGameRuleBridge(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass) { + return CraftGameRule.wrap(rule, fromLegacyToModern, toLegacyFromModern, legacyClass); + } } 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 34dc37f83538..fad4840d2c11 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 @@ -195,7 +195,7 @@ public String getSerializedName() { ).apply(instance, (key, uuid, component) -> HoverEvent.showEntity(key, uuid, component.orElse(null)))); static final MapCodec> SHOW_ITEM_CODEC = net.minecraft.network.chat.HoverEvent.ShowItem.CODEC.xmap(internal -> { - @Subst("key") final String typeKey = internal.item().getItemHolder().unwrapKey().orElseThrow().location().toString(); + @Subst("key") final String typeKey = internal.item().getItemHolder().unwrapKey().orElseThrow().identifier().toString(); return HoverEvent.showItem(Key.key(typeKey), internal.item().getCount(), PaperAdventure.asAdventure(internal.item().getComponentsPatch())); }, adventure -> { final Item itemType = BuiltInRegistries.ITEM.getValue(PaperAdventure.asVanilla(adventure.value().item())); diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java index f6266b3ca9c0..965ddeb8f575 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/ChatProcessor.java @@ -22,13 +22,13 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minecraft.ChatFormatting; import net.minecraft.Optionull; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.OutgoingChatMessage; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import org.bukkit.command.ConsoleCommandSender; @@ -50,7 +50,7 @@ @DefaultQualifier(NonNull.class) public final class ChatProcessor { - static final ResourceKey PAPER_RAW = ResourceKey.create(Registries.CHAT_TYPE, ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "raw")); + static final ResourceKey PAPER_RAW = ResourceKey.create(Registries.CHAT_TYPE, Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "raw")); static final String DEFAULT_LEGACY_FORMAT = "<%1$s> %2$s"; // copied from PlayerChatEvent/AsyncPlayerChatEvent final MinecraftServer server; final ServerPlayer player; @@ -280,7 +280,7 @@ private void broadcastToViewers(Collection viewers, final ChatType.Bou private net.kyori.adventure.chat.ChatType.Bound adventure(ChatType.Bound chatType) { @Subst("key:value") final String stringKey = Objects.requireNonNull( - chatType.chatType().unwrapKey().orElseThrow().location(), + chatType.chatType().unwrapKey().orElseThrow().identifier(), () -> "No key for '%s' in CHAT_TYPE registry.".formatted(chatType) ).toString(); net.kyori.adventure.chat.@Nullable ChatType adventure = BUILT_IN_CHAT_TYPES.get(stringKey); 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 efcf79712be2..8cd1ea370dd4 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 @@ -52,7 +52,7 @@ import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.world.BossEvent; @@ -141,12 +141,12 @@ private PaperAdventure() { // Key - public static Key asAdventure(final ResourceLocation key) { + public static Key asAdventure(final Identifier key) { return Key.key(key.getNamespace(), key.getPath()); } - public static ResourceLocation asVanilla(final Key key) { - return ResourceLocation.fromNamespaceAndPath(key.namespace(), key.value()); + public static Identifier asVanilla(final Key key) { + return Identifier.fromNamespaceAndPath(key.namespace(), key.value()); } public static ResourceKey asVanilla( @@ -157,10 +157,10 @@ public static ResourceKey asVanilla( } public static Key asAdventureKey(final ResourceKey key) { - return asAdventure(key.location()); + return asAdventure(key.identifier()); } - public static @Nullable ResourceLocation asVanillaNullable(final Key key) { + public static @Nullable Identifier asVanillaNullable(final Key key) { if (key == null) { return null; } @@ -168,7 +168,7 @@ public static Key asAdventureKey(final ResourceKey key) { } public static Holder resolveSound(final Key key) { - ResourceLocation id = asVanilla(key); + Identifier id = asVanilla(key); Optional> vanilla = BuiltInRegistries.SOUND_EVENT.get(id); if (vanilla.isPresent()) { return vanilla.get(); @@ -180,7 +180,7 @@ public static Holder resolveSound(final Key key) { // Component - public static @NotNull Component asAdventure(@Nullable final net.minecraft.network.chat.Component component) { + public static @NotNull Component asAdventure(final net.minecraft.network.chat.@Nullable Component component) { return component == null ? Component.empty() : WRAPPER_AWARE_SERIALIZER.deserialize(component); } @@ -256,7 +256,7 @@ private static Component translated(final Component component, final Locale loca ); } - public static Component resolveWithContext(final @NotNull Component component, final @Nullable CommandSender context, final @Nullable org.bukkit.entity.Entity scoreboardSubject, final boolean bypassPermissions) throws IOException { + 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) { @@ -354,7 +354,7 @@ public static SoundSource asVanilla(final Sound.Source source) { } public static Packet asSoundPacket(final Sound sound, final double x, final double y, final double z, final long seed, @Nullable BiConsumer, Float> packetConsumer) { - final ResourceLocation name = asVanilla(sound.name()); + final Identifier name = asVanilla(sound.name()); final Optional soundEvent = BuiltInRegistries.SOUND_EVENT.getOptional(name); final SoundSource source = asVanilla(sound.source()); @@ -367,7 +367,7 @@ public static Packet asSoundPacket(final Sound sound, final double x, final d } public static Packet asSoundPacket(final Sound sound, final Entity emitter, final long seed, @Nullable BiConsumer, Float> packetConsumer) { - final ResourceLocation name = asVanilla(sound.name()); + final Identifier name = asVanilla(sound.name()); final Optional soundEvent = BuiltInRegistries.SOUND_EVENT.getOptional(name); final SoundSource source = asVanilla(sound.source()); diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java index e62cfa5f47f5..85b8c1dcc5f9 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java @@ -19,7 +19,7 @@ import net.minecraft.core.UUIDUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; @SuppressWarnings("UnstableApiUsage") // permitted provider @@ -85,11 +85,11 @@ void doRunCallback(final @NotNull Audience audience, final Key key, final Tag ta abstract static class CallbackManager { - private final Predicate locationPredicate; + private final Predicate locationPredicate; protected final Map> callbacks = new HashMap<>(); private final Queue> queue = new ConcurrentLinkedQueue<>(); - protected CallbackManager(final Predicate locationPredicate) { + protected CallbackManager(final Predicate locationPredicate) { this.locationPredicate = locationPredicate; } @@ -125,7 +125,7 @@ final void tryConsumeCallback(final I key, final Consumer callbackCon abstract void doRunCallback(final @NotNull Audience audience, final Key key, final Tag tag); - public final void tryRunCallback(final @NotNull Audience audience, final ResourceLocation key, final Optional tag) { + public final void tryRunCallback(final @NotNull Audience audience, final Identifier key, final Optional tag) { if (!this.locationPredicate.test(key) || tag.isEmpty()) return; this.doRunCallback(audience, PaperAdventure.asAdventure(key), tag.get()); } 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 69b553747b33..568d12d00699 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 @@ -8,6 +8,7 @@ import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.LevelChunk; @@ -35,7 +36,7 @@ public void modifyBlocks(ClientboundLevelChunkWithLightPacket chunkPacket, Chunk chunkPacket.setReady(true); } - public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, int flags, int maxUpdateDepth) { + public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, @Block.UpdateFlags int flags, int maxUpdateDepth) { } 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 3f21d3f49098..b03b2d098c20 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 @@ -608,7 +608,7 @@ private boolean[] readPalette(Palette palette, boolean[] temp, boole } @Override - public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, int flags, int maxUpdateDepth) { + public void onBlockChange(Level level, BlockPos blockPos, BlockState newBlockState, BlockState oldBlockState, @Block.UpdateFlags int flags, int maxUpdateDepth) { if (oldBlockState != null && solidGlobal[GLOBAL_BLOCKSTATE_PALETTE.idFor(oldBlockState, PaletteResize.noResizeExpected())] && !solidGlobal[GLOBAL_BLOCKSTATE_PALETTE.idFor(newBlockState, PaletteResize.noResizeExpected())] && blockPos.getY() <= maxBlockHeightUpdatePosition) { updateNearbyBlocks(level, blockPos); } diff --git a/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridgeImpl.java b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridgeImpl.java new file mode 100644 index 000000000000..8527db6c2b4a --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionBridgeImpl.java @@ -0,0 +1,33 @@ +package io.papermc.paper.block.bed; + +import net.minecraft.world.entity.player.Player; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class BedEnterActionBridgeImpl implements BedEnterActionBridge { + + @Override + public BedEnterProblem createTooFarAwayProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.TOO_FAR_AWAY); + } + + @Override + public BedEnterProblem createObstructedProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.OBSTRUCTED); + } + + @Override + public BedEnterProblem createNotSafeProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.NOT_SAFE); + } + + @Override + public BedEnterProblem createExplosionProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.EXPLOSION); + } + + @Override + public BedEnterProblem createOtherProblem() { + return new BedEnterProblemImpl(Player.BedSleepingProblem.OTHER_PROBLEM); + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionImpl.java b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionImpl.java new file mode 100644 index 000000000000..b1a2eb96601f --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterActionImpl.java @@ -0,0 +1,12 @@ +package io.papermc.paper.block.bed; + +import net.kyori.adventure.text.Component; +import org.jspecify.annotations.Nullable; + +public record BedEnterActionImpl( + BedRuleResult canSleep, + BedRuleResult canSetSpawn, + @Nullable BedEnterProblem problem, + @Nullable Component errorMessage +) implements BedEnterAction { +} diff --git a/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterProblemImpl.java b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterProblemImpl.java new file mode 100644 index 000000000000..9782a9e05e33 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/block/bed/BedEnterProblemImpl.java @@ -0,0 +1,21 @@ +package io.papermc.paper.block.bed; + +import io.papermc.paper.adventure.PaperAdventure; +import net.kyori.adventure.text.Component; +import net.minecraft.world.entity.player.Player; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +record BedEnterProblemImpl( + Player.BedSleepingProblem vanillaProblem, + @Nullable Component errorMessage +) implements BedEnterProblem { + + BedEnterProblemImpl(Player.BedSleepingProblem vanillaProblem) { + this( + vanillaProblem, + vanillaProblem.message() == null ? null : PaperAdventure.asAdventure(vanillaProblem.message()) + ); + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java b/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java index 953c30500892..a9443f24971f 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java +++ b/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java @@ -8,7 +8,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.command.CommandSender; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.framework.qual.DefaultQualifier; @@ -56,7 +56,7 @@ public static List getListMatchingLast( while (iterator.hasNext()) { Object object = iterator.next(); - if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath())) { + if (object instanceof Identifier && matches(last, ((Identifier) object).getPath())) { results.add(String.valueOf(object)); } } diff --git a/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java b/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java index 33b10d4eb634..b629a9a37ce7 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/PaperCommand.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.Command; diff --git a/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java b/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java index 2d1de331ae0e..c40dc26e7da4 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java +++ b/paper-server/src/main/java/io/papermc/paper/command/brigadier/PaperBrigadier.java @@ -9,6 +9,7 @@ import net.minecraft.commands.CommandSource; import net.minecraft.commands.Commands; import net.minecraft.network.chat.CommonComponents; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import org.bukkit.command.Command; @@ -22,7 +23,7 @@ public final class PaperBrigadier { Vec3.ZERO, Vec2.ZERO, null, - 4, + LevelBasedPermissionSet.OWNER, "", CommonComponents.EMPTY, null, 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 d1309cc51f8e..bff395667f69 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 @@ -49,7 +49,7 @@ 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.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.AngleArgument; import net.minecraft.commands.arguments.ColorArgument; @@ -66,7 +66,7 @@ import net.minecraft.commands.arguments.RangeArgument; import net.minecraft.commands.arguments.ResourceArgument; import net.minecraft.commands.arguments.ResourceKeyArgument; -import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.commands.arguments.IdentifierArgument; import net.minecraft.commands.arguments.ScoreboardSlotArgument; import net.minecraft.commands.arguments.StyleArgument; import net.minecraft.commands.arguments.TemplateMirrorArgument; @@ -318,12 +318,12 @@ public ArgumentType scoreboardDisplaySlot() { @Override public ArgumentType namespacedKey() { - return this.wrap(ResourceLocationArgument.id(), CraftNamespacedKey::fromMinecraft); + return this.wrap(IdentifierArgument.id(), CraftNamespacedKey::fromMinecraft); } @Override public ArgumentType key() { - return this.wrap(ResourceLocationArgument.id(), CraftNamespacedKey::fromMinecraft); + return this.wrap(IdentifierArgument.id(), CraftNamespacedKey::fromMinecraft); } @Override @@ -407,7 +407,7 @@ public ArgumentType templateRotation() { public ArgumentType> resourceKey(final RegistryKey registryKey) { return this.wrap( ResourceKeyArgument.key(PaperRegistries.registryToNms(registryKey)), - nmsRegistryKey -> TypedKey.create(registryKey, CraftNamespacedKey.fromMinecraft(nmsRegistryKey.location())) + nmsRegistryKey -> TypedKey.create(registryKey, CraftNamespacedKey.fromMinecraft(nmsRegistryKey.identifier())) ); } @@ -424,7 +424,7 @@ private ArgumentType resourceRaw(final RegistryKey regis resource -> requireNonNull( RegistryAccess.registryAccess() .getRegistry(registryKey) - .get(CraftNamespacedKey.fromMinecraft(resource.key().location())) + .get(CraftNamespacedKey.fromMinecraft(resource.key().identifier())) ) ); } diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java index b4b90c1bda72..4c3d5712c677 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java @@ -65,7 +65,7 @@ private void doDumpItem(final CommandSender sender, final boolean includeAllComp final ItemStack itemStack = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand()); final TextComponent.Builder visualOutput = Component.text(); final StringBuilder itemCommandBuilder = new StringBuilder(); - final String itemName = itemStack.getItemHolder().unwrapKey().orElseThrow().location().toString(); + final String itemName = itemStack.getItemHolder().unwrapKey().orElseThrow().identifier().toString(); itemCommandBuilder.append(itemName); visualOutput.append(text(itemName, YELLOW)); // item type final Set> referencedComponentTypes = Collections.newSetFromMap(new IdentityHashMap<>()); @@ -82,7 +82,7 @@ private void doDumpItem(final CommandSender sender, final boolean includeAllComp final List componentComponents = new ArrayList<>(); final List commandComponents = new ArrayList<>(); for (final DataComponentType type : referencedComponentTypes) { - final String path = registry.getResourceKey(type).orElseThrow().location().getPath(); + final String path = registry.getResourceKey(type).orElseThrow().identifier().getPath(); final @Nullable Optional patchedValue = patch.get(type); final @Nullable TypedDataComponent prototypeValue = prototype.getTyped(type); if (patchedValue != null) { diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java index e3ddc201b328..e3e21acb82b5 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java @@ -14,7 +14,7 @@ import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; @@ -73,7 +73,7 @@ private void listEntities(final CommandSender sender, final String[] args) { filter = args[1]; } final String cleanfilter = filter.replace("?", ".?").replace("*", ".*?"); - Set names = BuiltInRegistries.ENTITY_TYPE.keySet().stream() + Set names = BuiltInRegistries.ENTITY_TYPE.keySet().stream() .filter(n -> n.toString().matches(cleanfilter)) .collect(Collectors.toSet()); if (names.isEmpty()) { @@ -92,7 +92,7 @@ private void listEntities(final CommandSender sender, final String[] args) { sender.sendMessage(text("Usage: /paper entity list [filter] [worldName]", RED)); return; } - Map>> list = Maps.newHashMap(); + Map>> list = Maps.newHashMap(); @Nullable World bukkitWorld = Bukkit.getWorld(worldName); if (bukkitWorld == null) { sender.sendMessage(text("Could not load world for " + worldName + ". Please select a valid world.", RED)); @@ -100,10 +100,10 @@ private void listEntities(final CommandSender sender, final String[] args) { return; } ServerLevel world = ((CraftWorld) bukkitWorld).getHandle(); - Map nonEntityTicking = Maps.newHashMap(); + Map nonEntityTicking = Maps.newHashMap(); ServerChunkCache chunkProviderServer = world.getChunkSource(); FeatureHooks.getAllEntities(world).forEach(e -> { - ResourceLocation key = EntityType.getKey(e.getType()); + Identifier key = EntityType.getKey(e.getType()); MutablePair> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); ChunkPos chunk = e.chunkPosition(); @@ -114,7 +114,7 @@ private void listEntities(final CommandSender sender, final String[] args) { } }); if (names.size() == 1) { - ResourceLocation name = names.iterator().next(); + Identifier name = names.iterator().next(); Pair> info = list.get(name); int nonTicking = nonEntityTicking.getOrDefault(name, 0); if (info == null) { @@ -133,7 +133,7 @@ private void listEntities(final CommandSender sender, final String[] args) { sender.sendMessage(message); }); } else { - List> info = list.entrySet().stream() + List> info = list.entrySet().stream() .filter(e -> names.contains(e.getKey())) .map(e -> Pair.of(e.getKey(), e.getValue().left)) .sorted((a, b) -> !a.getRight().equals(b.getRight()) ? b.getRight() - a.getRight() : a.getKey().toString().compareTo(b.getKey().toString())) 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 7aa78cc98de8..b84c2c663e9b 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 @@ -1,7 +1,6 @@ package io.papermc.paper.commands; import io.papermc.paper.adventure.PaperAdventure; -import java.util.UUID; import java.util.function.Consumer; import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.identity.Identity; @@ -10,6 +9,7 @@ import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import org.bukkit.command.CommandSender; @@ -74,7 +74,7 @@ public CommandSourceStack asVanilla() { respawnDimension == null ? Vec3.ZERO : Vec3.atLowerCornerOf(respawnDimension.getRespawnData().pos()), Vec2.ZERO, respawnDimension, - 4, + LevelBasedPermissionSet.OWNER, this.getName(), net.minecraft.network.chat.Component.literal(this.getName()), this.server.getServer(), diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java b/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java index d0c4037c3cc6..889051d2d6e6 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/Configurations.java @@ -16,9 +16,9 @@ import java.util.Objects; import java.util.function.UnaryOperator; import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import org.jetbrains.annotations.MustBeInvokedByOverriders; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -35,7 +35,7 @@ public abstract class Configurations { private static final Logger LOGGER = LogUtils.getClassLogger(); public static final String WORLD_DEFAULTS = "__world_defaults__"; - public static final ResourceLocation WORLD_DEFAULTS_KEY = ResourceLocation.fromNamespaceAndPath("configurations", WORLD_DEFAULTS); + public static final Identifier WORLD_DEFAULTS_KEY = Identifier.fromNamespaceAndPath("configurations", WORLD_DEFAULTS); protected final Path globalFolder; protected final Class globalConfigClass; protected final Class worldConfigClass; @@ -341,7 +341,7 @@ public ContextMap build() { public static final ContextKey WORLD_DIRECTORY = new ContextKey<>(Path.class, "world directory"); public static final ContextKey WORLD_NAME = new ContextKey<>(String.class, "world name"); // TODO remove when we deprecate level names - public static final ContextKey WORLD_KEY = new ContextKey<>(ResourceLocation.class, "world key"); + public static final ContextKey WORLD_KEY = new ContextKey<>(Identifier.class, "world key"); public static final ContextKey FIRST_DEFAULT = new ContextKey<>(Void.class, "first default"); public static final ContextKey REGISTRY_ACCESS = new ContextKey<>(RegistryAccess.class, "registry access"); public static final ContextKey GAME_RULES = new ContextKey<>(GameRules.class, "game rules"); diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java index 81553c3f08bf..1ae8f8587fc9 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -12,7 +12,7 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.spongepowered.configurate.objectmapping.ConfigSerializable; @@ -374,7 +374,7 @@ public class Items extends ConfigurationPart { Set.of() ); - public Map modelOverrides = Map.of( + public Map modelOverrides = Map.of( Objects.requireNonNull(net.minecraft.world.item.Items.ELYTRA.components().get(DataComponents.ITEM_MODEL)), new ItemObfuscationBinding.AssetObfuscationConfiguration( true, diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java index 940f60cd8461..e0491ef5cfc0 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java @@ -13,7 +13,7 @@ import io.papermc.paper.configuration.serializer.EnumValueSerializer; import io.papermc.paper.configuration.serializer.NbtPathSerializer; import io.papermc.paper.configuration.serializer.ServerboundPacketClassSerializer; -import io.papermc.paper.configuration.serializer.ResourceLocationSerializer; +import io.papermc.paper.configuration.serializer.IdentifierSerializer; import io.papermc.paper.configuration.serializer.StringRepresentableSerializer; import io.papermc.paper.configuration.serializer.collection.TableSerializer; import io.papermc.paper.configuration.serializer.collection.map.FastutilMapSerializer; @@ -56,12 +56,12 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.apache.commons.lang3.RandomStringUtils; @@ -191,7 +191,7 @@ private static ConfigurationOptions defaultOptions(ConfigurationOptions options) .register(Duration.SERIALIZER) .register(DurationOrDisabled.SERIALIZER) .register(NbtPathSerializer.SERIALIZER) - .register(ResourceLocationSerializer.INSTANCE) + .register(IdentifierSerializer.INSTANCE) ); } @@ -347,10 +347,10 @@ public void reloadConfigs(MinecraftServer server) { } private static ContextMap createWorldContextMap(ServerLevel level) { - return createWorldContextMap(level.levelStorageAccess.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig, level.registryAccess(), level.getGameRules()); + return createWorldContextMap(level.levelStorageAccess.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().identifier(), level.spigotConfig, level.registryAccess(), level.getGameRules()); } - public static ContextMap createWorldContextMap(final Path dir, final String levelName, final ResourceLocation worldKey, final SpigotWorldConfig spigotConfig, final RegistryAccess registryAccess, final GameRules gameRules) { + public static ContextMap createWorldContextMap(final Path dir, final String levelName, final Identifier worldKey, final SpigotWorldConfig spigotConfig, final RegistryAccess registryAccess, final GameRules gameRules) { return ContextMap.builder() .put(WORLD_DIRECTORY, dir) .put(WORLD_NAME, levelName) 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 6877056ddfe5..237abcf06ebf 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 @@ -34,11 +34,11 @@ import java.util.OptionalInt; import java.util.function.Function; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.commands.arguments.NbtPathArgument; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.Difficulty; import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Entity; @@ -48,8 +48,8 @@ import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.decoration.HangingEntity; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.monster.Vindicator; -import net.minecraft.world.entity.monster.Zombie; +import net.minecraft.world.entity.monster.illager.Vindicator; +import net.minecraft.world.entity.monster.zombie.Zombie; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -73,9 +73,9 @@ public class WorldConfiguration extends ConfigurationPart { static final int CURRENT_VERSION = 31; // (when you change the version, change the comment, so it conflicts on rebases): migrate spawn loaded configs to gamerule private final transient SpigotWorldConfig spigotConfig; - private final transient ResourceLocation worldKey; + private final transient Identifier worldKey; - WorldConfiguration(final SpigotWorldConfig spigotConfig, final ResourceLocation worldKey) { + WorldConfiguration(final SpigotWorldConfig spigotConfig, final Identifier worldKey) { this.spigotConfig = spigotConfig; this.worldKey = worldKey; } @@ -238,7 +238,7 @@ public class SlimeChunk extends ConfigurationPart { public class WanderingTrader extends ConfigurationPart { public int spawnMinuteLength = 1200; - public int spawnDayLength = net.minecraft.world.entity.npc.WanderingTraderSpawner.DEFAULT_SPAWN_DELAY; + public int spawnDayLength = net.minecraft.world.entity.npc.wanderingtrader.WanderingTraderSpawner.DEFAULT_SPAWN_DELAY; public int spawnChanceFailureIncrement = 25; public int spawnChanceMin = 25; public int spawnChanceMax = 75; diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/IdentifierSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/IdentifierSerializer.java new file mode 100644 index 000000000000..8ff097d1b7c5 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/IdentifierSerializer.java @@ -0,0 +1,27 @@ +package io.papermc.paper.configuration.serializer; + +import java.lang.reflect.AnnotatedType; +import java.lang.reflect.Type; +import java.util.function.Predicate; +import net.minecraft.resources.Identifier; +import org.spongepowered.configurate.serialize.ScalarSerializer; +import org.spongepowered.configurate.serialize.SerializationException; + +public class IdentifierSerializer extends ScalarSerializer.Annotated { + + public static final ScalarSerializer INSTANCE = new IdentifierSerializer(); + + private IdentifierSerializer() { + super(Identifier.class); + } + + @Override + public Identifier deserialize(final AnnotatedType annotatedType, final Object obj) throws SerializationException { + return Identifier.read(obj.toString()).getOrThrow(s -> new SerializationException(Identifier.class, s)); + } + + @Override + protected Object serialize(final AnnotatedType annotatedType, final Identifier item, final Predicate> typeSupported) { + return item.toString(); + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ResourceLocationSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ResourceLocationSerializer.java deleted file mode 100644 index 9a6c278d6264..000000000000 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ResourceLocationSerializer.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.papermc.paper.configuration.serializer; - -import java.lang.reflect.AnnotatedType; -import java.lang.reflect.Type; -import java.util.function.Predicate; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.configurate.serialize.ScalarSerializer; -import org.spongepowered.configurate.serialize.SerializationException; - -public class ResourceLocationSerializer extends ScalarSerializer.Annotated { - - public static final ScalarSerializer INSTANCE = new ResourceLocationSerializer(); - - private ResourceLocationSerializer() { - super(ResourceLocation.class); - } - - @Override - public ResourceLocation deserialize(final AnnotatedType annotatedType, final Object obj) throws SerializationException { - return ResourceLocation.read(obj.toString()).getOrThrow(s -> new SerializationException(ResourceLocation.class, s)); - } - - @Override - protected Object serialize(final AnnotatedType annotatedType, final ResourceLocation item, final Predicate> typeSupported) { - return item.toString(); - } -} diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java index 6d4df95336c2..3dd96af2ffea 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/ServerboundPacketClassSerializer.java @@ -23,7 +23,7 @@ import net.minecraft.network.protocol.login.LoginPacketTypes; import net.minecraft.network.protocol.ping.PingPacketTypes; import net.minecraft.network.protocol.status.StatusPacketTypes; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.spongepowered.configurate.serialize.ScalarSerializer; @@ -44,12 +44,12 @@ public final class ServerboundPacketClassSerializer extends ScalarSerializer ID_TO_INFO; + private static final Map ID_TO_INFO; private static final Map, PacketInfo> CLASS_TO_INFO; static { try { - final ImmutableMap.Builder idBuilder = ImmutableMap.builder(); + final ImmutableMap.Builder idBuilder = ImmutableMap.builder(); final ImmutableMap.Builder, PacketInfo> classBuilder = ImmutableMap.builder(); for (final Class holder : PACKET_CLASS_HOLDERS) { for (final Field field : holder.getDeclaredFields()) { @@ -85,9 +85,9 @@ public ServerboundPacketClassSerializer() { @Override public Class> deserialize(final Type type, final Object obj) throws SerializationException { - final ResourceLocation location = ResourceLocation.tryParse(obj.toString()); + final Identifier location = Identifier.tryParse(obj.toString()); if (location == null) { - throw new SerializationException(ResourceLocation.class, "Could not deserialize a packet from " + obj); + throw new SerializationException(Identifier.class, "Could not deserialize a packet from " + obj); } final PacketInfo info = ID_TO_INFO.get(location); if (info == null) { diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java index 5ca61cb1e543..cabd06b9842a 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryEntrySerializer.java @@ -7,7 +7,7 @@ import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.spongepowered.configurate.serialize.ScalarSerializer; import org.spongepowered.configurate.serialize.SerializationException; @@ -57,15 +57,15 @@ public final T deserialize(final AnnotatedType type, final Object obj) throws Se @Override protected final Object serialize(final AnnotatedType type, final T item, final Predicate> typeSupported) { final ResourceKey key = this.convertToResourceKey(item); - if (this.omitMinecraftNamespace && key.location().getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) { - return key.location().getPath(); + if (this.omitMinecraftNamespace && key.identifier().getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) { + return key.identifier().getPath(); } else { - return key.location().toString(); + return key.identifier().toString(); } } private ResourceKey deserializeKey(final Object input) throws SerializationException { - final ResourceLocation key = ResourceLocation.tryParse(input.toString()); + final Identifier key = Identifier.tryParse(input.toString()); if (key == null) { throw new SerializationException("Could not create a key from " + input); } diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java index ad08f242cd19..6d39c5ee997f 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/serializer/registry/RegistryValueSerializer.java @@ -33,7 +33,7 @@ public RegistryValueSerializer( protected T convertFromResourceKey(final ResourceKey key) throws SerializationException { final T value = this.registry().getValue(key); if (value == null) { - throw new SerializationException("Missing value in " + this.registry() + " with key " + key.location()); + throw new SerializationException("Missing value in " + this.registry() + " with key " + key.identifier()); } return value; } diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java index 9838438ef7d6..36895faebc19 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V30_PacketIds.java @@ -12,7 +12,7 @@ import java.io.Reader; import java.util.Map; import java.util.Objects; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jspecify.annotations.Nullable; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.NodePath; @@ -28,10 +28,10 @@ public class V30_PacketIds implements TransformAction { private static final int VERSION = 30; private static final Gson GSON = new Gson(); - private static final Map MOJANG_TO_ID; + private static final Map MOJANG_TO_ID; static { - final ImmutableMap.Builder builder2 = ImmutableMap.builder(); + final ImmutableMap.Builder builder2 = ImmutableMap.builder(); final InputStream input = V30_PacketIds.class.getResourceAsStream("/config-data/packet-limiter-upgrade-data.json"); if (input == null) { throw new RuntimeException("Failed to load packet limiter upgrade data"); @@ -40,7 +40,7 @@ public class V30_PacketIds implements TransformAction { final JsonArray array = GSON.fromJson(reader, JsonArray.class); for (final JsonElement element : array) { final JsonObject obj = element.getAsJsonObject(); - builder2.put(obj.get("simple_class_name").getAsString(), ResourceLocation.parse(obj.get("id").getAsString())); + builder2.put(obj.get("simple_class_name").getAsString(), Identifier.parse(obj.get("id").getAsString())); } } catch (final IOException e) { throw new RuntimeException("Failed to load packet limiter upgrade data", e); diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java index d670865dc9bf..7345db4342ea 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java @@ -7,7 +7,7 @@ import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.jspecify.annotations.Nullable; @@ -33,9 +33,9 @@ public final class FeatureSeedsGeneration implements TransformAction { private static final Logger LOGGER = LogUtils.getClassLogger(); - private final ResourceLocation worldKey; + private final Identifier worldKey; - private FeatureSeedsGeneration(ResourceLocation worldKey) { + private FeatureSeedsGeneration(Identifier worldKey) { this.worldKey = worldKey; } diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java index 7af8f613ac63..f64cc8381d94 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java @@ -11,7 +11,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.item.Item; import org.bukkit.Material; @@ -103,7 +103,7 @@ private static ConfigurationTransformation.Versioned versioned() { ) .addVersion(26, ConfigurationTransformation.builder().addAction(path("alt-item-despawn-rate", "items", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> { String itemName = path.get(path.size() - 1).toString(); - final Optional> item = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); + final Optional> item = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, Identifier.parse(itemName.toLowerCase(Locale.ROOT)))); if (item.isEmpty()) { itemName = Material.valueOf(itemName).getKey().getKey(); } @@ -135,13 +135,13 @@ private static ConfigurationTransformation notVersioned() { Map rebuild = new HashMap<>(); value.childrenMap().forEach((key, node) -> { String itemName = key.toString(); - final Optional> itemHolder = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); + final Optional> itemHolder = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, Identifier.parse(itemName.toLowerCase(Locale.ROOT)))); final String item; if (itemHolder.isEmpty()) { final Material bukkitMat = Material.matchMaterial(itemName); item = bukkitMat != null ? bukkitMat.getKey().getKey() : null; } else { - item = itemHolder.get().unwrapKey().orElseThrow().location().getPath(); + item = itemHolder.get().unwrapKey().orElseThrow().identifier().getPath(); } if (item != null) { rebuild.put(item, node.getInt()); diff --git a/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java b/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java index 38b5fd22de8f..416a94d6a53e 100644 --- a/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java +++ b/paper-server/src/main/java/io/papermc/paper/connection/PaperPlayerConfigurationConnection.java @@ -26,7 +26,7 @@ import net.minecraft.network.protocol.common.ClientboundShowDialogPacket; import net.minecraft.network.protocol.common.custom.DiscardedPayload; import net.minecraft.network.protocol.configuration.ClientboundResetChatPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ClientInformation; import net.minecraft.server.network.ConfigurationTask; import net.minecraft.server.network.ServerConfigurationPacketListenerImpl; @@ -134,7 +134,7 @@ public void sendPluginMessage(final Plugin source, final String channel, final b if (this.channels().contains(channel)) { @SuppressWarnings("deprecation") // "not an API method" does not apply to us - ResourceLocation id = ResourceLocation.parse(StandardMessenger.validateAndCorrectChannel(channel)); + Identifier id = Identifier.parse(StandardMessenger.validateAndCorrectChannel(channel)); ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(new DiscardedPayload(id, message)); this.handle.send(packet); } diff --git a/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java b/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java index a537efef8ac6..226e63bd7749 100644 --- a/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java @@ -7,7 +7,7 @@ import net.minecraft.network.Connection; import net.minecraft.network.protocol.cookie.ClientboundCookieRequestPacket; import net.minecraft.network.protocol.cookie.ServerboundCookieResponsePacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.jspecify.annotations.NullMarked; @@ -16,7 +16,7 @@ public abstract class ReadablePlayerCookieConnectionImpl implements ReadablePlayerCookieConnection { // Because we support async cookies, order is not promised. - private final Map requestedCookies = new ConcurrentHashMap<>(); + private final Map requestedCookies = new ConcurrentHashMap<>(); private final Connection connection; public ReadablePlayerCookieConnectionImpl(final Connection connection) { @@ -28,7 +28,7 @@ public CompletableFuture retrieveCookie(final NamespacedKey key) { Preconditions.checkArgument(key != null, "Cookie key cannot be null"); CompletableFuture future = new CompletableFuture<>(); - ResourceLocation resourceLocation = CraftNamespacedKey.toMinecraft(key); + Identifier resourceLocation = CraftNamespacedKey.toMinecraft(key); this.requestedCookies.put(resourceLocation, new CookieFuture(resourceLocation, future)); this.connection.send(new ClientboundCookieRequestPacket(resourceLocation)); @@ -55,6 +55,6 @@ public boolean isAwaitingCookies() { return !this.requestedCookies.isEmpty(); } - public record CookieFuture(ResourceLocation key, CompletableFuture future) { + public record CookieFuture(Identifier key, CompletableFuture future) { } } 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 1249be9e9062..f6783d5f9279 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 @@ -1,6 +1,7 @@ package io.papermc.paper.datacomponent; import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.datacomponent.item.PaperAttackRange; import io.papermc.paper.datacomponent.item.PaperBannerPatternLayers; import io.papermc.paper.datacomponent.item.PaperBlockItemDataProperties; import io.papermc.paper.datacomponent.item.PaperBlocksAttacks; @@ -23,19 +24,23 @@ import io.papermc.paper.datacomponent.item.PaperItemLore; import io.papermc.paper.datacomponent.item.PaperItemTool; import io.papermc.paper.datacomponent.item.PaperJukeboxPlayable; +import io.papermc.paper.datacomponent.item.PaperKineticWeapon; import io.papermc.paper.datacomponent.item.PaperLodestoneTracker; import io.papermc.paper.datacomponent.item.PaperMapDecorations; import io.papermc.paper.datacomponent.item.PaperMapId; import io.papermc.paper.datacomponent.item.PaperMapItemColor; import io.papermc.paper.datacomponent.item.PaperOminousBottleAmplifier; +import io.papermc.paper.datacomponent.item.PaperPiercingWeapon; import io.papermc.paper.datacomponent.item.PaperPotDecorations; import io.papermc.paper.datacomponent.item.PaperPotionContents; 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.PaperSuspiciousStewEffects; +import io.papermc.paper.datacomponent.item.PaperSwingAnimation; import io.papermc.paper.datacomponent.item.PaperTooltipDisplay; import io.papermc.paper.datacomponent.item.PaperUseCooldown; +import io.papermc.paper.datacomponent.item.PaperUseEffects; import io.papermc.paper.datacomponent.item.PaperUseRemainder; import io.papermc.paper.datacomponent.item.PaperWeapon; import io.papermc.paper.datacomponent.item.PaperWritableBookContent; @@ -59,6 +64,7 @@ import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.damage.CraftDamageType; import org.bukkit.craftbukkit.entity.CraftCat; import org.bukkit.craftbukkit.entity.CraftChicken; import org.bukkit.craftbukkit.entity.CraftCow; @@ -66,6 +72,7 @@ import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; +import org.bukkit.craftbukkit.entity.CraftZombieNautilus; import org.bukkit.craftbukkit.inventory.CraftMetaFirework; import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial; import org.bukkit.craftbukkit.util.Handleable; @@ -98,8 +105,11 @@ public static void bootstrap() { registerIdentity(DataComponents.MAX_DAMAGE); registerIdentity(DataComponents.DAMAGE); registerUntyped(DataComponents.UNBREAKABLE); + register(DataComponents.USE_EFFECTS, PaperUseEffects::new); registerIdentity(DataComponents.POTION_DURATION_SCALE); register(DataComponents.CUSTOM_NAME, PaperAdventure::asAdventure, PaperAdventure::asVanilla); + registerIdentity(DataComponents.MINIMUM_ATTACK_CHARGE); + register(DataComponents.DAMAGE_TYPE, nms -> CraftDamageType.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftDamageType.bukkitToMinecraftHolder(api))); register(DataComponents.ITEM_NAME, PaperAdventure::asAdventure, PaperAdventure::asVanilla); register(DataComponents.ITEM_MODEL, PaperAdventure::asAdventure, PaperAdventure::asVanilla); register(DataComponents.LORE, PaperItemLore::new); @@ -169,26 +179,30 @@ public static void bootstrap() { register(DataComponents.TOOLTIP_DISPLAY, PaperTooltipDisplay::new); register(DataComponents.WEAPON, PaperWeapon::new); register(DataComponents.BLOCKS_ATTACKS, PaperBlocksAttacks::new); - + register(DataComponents.PIERCING_WEAPON, PaperPiercingWeapon::new); + register(DataComponents.KINETIC_WEAPON, PaperKineticWeapon::new); + register(DataComponents.ATTACK_RANGE, PaperAttackRange::new); + register(DataComponents.SWING_ANIMATION, PaperSwingAnimation::new); register(DataComponents.VILLAGER_VARIANT, CraftVillager.CraftType::minecraftHolderToBukkit, CraftVillager.CraftType::bukkitToMinecraftHolder); register(DataComponents.WOLF_VARIANT, CraftWolf.CraftVariant::minecraftHolderToBukkit, CraftWolf.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.WOLF_COLLAR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); register(DataComponents.WOLF_SOUND_VARIANT, CraftWolf.CraftSoundVariant::minecraftHolderToBukkit, CraftWolf.CraftSoundVariant::bukkitToMinecraftHolder); - register(DataComponents.FOX_VARIANT, nms -> org.bukkit.entity.Fox.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Fox.Variant.byId(api.ordinal())); - register(DataComponents.SALMON_SIZE, nms -> Salmon.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Salmon.Variant.values()[api.ordinal()]); - register(DataComponents.PARROT_VARIANT, nms -> Parrot.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Parrot.Variant.byId(api.ordinal())); - register(DataComponents.TROPICAL_FISH_PATTERN, nms -> TropicalFish.Pattern.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.TropicalFish.Pattern.values()[api.ordinal()]); + register(DataComponents.FOX_VARIANT, nms -> org.bukkit.entity.Fox.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.fox.Fox.Variant.byId(api.ordinal())); + register(DataComponents.SALMON_SIZE, nms -> Salmon.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.fish.Salmon.Variant.values()[api.ordinal()]); + register(DataComponents.PARROT_VARIANT, nms -> Parrot.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.parrot.Parrot.Variant.byId(api.ordinal())); + register(DataComponents.TROPICAL_FISH_PATTERN, nms -> TropicalFish.Pattern.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.fish.TropicalFish.Pattern.values()[api.ordinal()]); register(DataComponents.TROPICAL_FISH_BASE_COLOR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); register(DataComponents.TROPICAL_FISH_PATTERN_COLOR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); - register(DataComponents.MOOSHROOM_VARIANT, nms -> MushroomCow.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.MushroomCow.Variant.values()[api.ordinal()]); - register(DataComponents.RABBIT_VARIANT, nms -> Rabbit.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.Rabbit.Variant.byId(api.ordinal())); + register(DataComponents.MOOSHROOM_VARIANT, nms -> MushroomCow.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.cow.MushroomCow.Variant.values()[api.ordinal()]); + register(DataComponents.RABBIT_VARIANT, nms -> Rabbit.Type.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.rabbit.Rabbit.Variant.byId(api.ordinal())); register(DataComponents.PIG_VARIANT, CraftPig.CraftVariant::minecraftHolderToBukkit, CraftPig.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.COW_VARIANT, CraftCow.CraftVariant::minecraftHolderToBukkit, CraftCow.CraftVariant::bukkitToMinecraftHolder); register(DataComponents.CHICKEN_VARIANT, nms -> CraftChicken.CraftVariant.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftChicken.CraftVariant.bukkitToMinecraftHolder(api))); register(DataComponents.FROG_VARIANT, CraftFrog.CraftVariant::minecraftHolderToBukkit, CraftFrog.CraftVariant::bukkitToMinecraftHolder); - register(DataComponents.HORSE_VARIANT, nms -> Horse.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.horse.Variant.byId(api.ordinal())); + register(DataComponents.ZOMBIE_NAUTILUS_VARIANT, nms -> CraftZombieNautilus.CraftVariant.minecraftHolderToBukkit(nms.unwrap(CraftRegistry.getMinecraftRegistry()).orElseThrow()), api -> new EitherHolder<>(CraftZombieNautilus.CraftVariant.bukkitToMinecraftHolder(api))); + register(DataComponents.HORSE_VARIANT, nms -> Horse.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.equine.Variant.byId(api.ordinal())); register(DataComponents.PAINTING_VARIANT, CraftArt::minecraftHolderToBukkit, CraftArt::bukkitToMinecraftHolder); - register(DataComponents.LLAMA_VARIANT, nms -> Llama.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.horse.Llama.Variant.byId(api.ordinal())); + register(DataComponents.LLAMA_VARIANT, nms -> Llama.Color.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.equine.Llama.Variant.byId(api.ordinal())); register(DataComponents.AXOLOTL_VARIANT, nms -> Axolotl.Variant.values()[nms.ordinal()], api -> net.minecraft.world.entity.animal.axolotl.Axolotl.Variant.byId(api.ordinal())); register(DataComponents.CAT_VARIANT, CraftCat.CraftType::minecraftHolderToBukkit, CraftCat.CraftType::bukkitToMinecraftHolder); register(DataComponents.CAT_COLLAR, nms -> DyeColor.getByWoolData((byte) nms.getId()), api -> net.minecraft.world.item.DyeColor.byId(api.getWoolData())); 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 a415cf6ca7cf..f8ba50404d24 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 @@ -256,4 +256,37 @@ public TooltipDisplay.Builder tooltipDisplay() { public Weapon.Builder weapon() { return new PaperWeapon.BuilderImpl(); } + + @Override + public KineticWeapon.Builder kineticWeapon() { + return new PaperKineticWeapon.BuilderImpl(); + } + + @Override + public UseEffects.Builder useEffects() { + return new PaperUseEffects.BuilderImpl(); + } + + @Override + public PiercingWeapon.Builder piercingWeapon() { + return new PaperPiercingWeapon.BuilderImpl(); + } + + @Override + public AttackRange.Builder attackRange() { + return new PaperAttackRange.BuilderImpl(); + } + + @Override + public SwingAnimation.Builder swingAnimation() { + return new PaperSwingAnimation.BuilderImpl(); + } + + @Override + public KineticWeapon.Condition kineticWeaponCondition(int maxDurationTicks, float minSpeed, float minRelativeSpeed) { + Preconditions.checkArgument(maxDurationTicks >= 0, "maxDurationTicks must be non-negative"); + return new PaperKineticWeapon.PaperKineticWeaponCondition(new net.minecraft.world.item.component.KineticWeapon.Condition( + maxDurationTicks, minSpeed, minRelativeSpeed + )); + } } diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperAttackRange.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperAttackRange.java new file mode 100644 index 000000000000..6ff60151b548 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperAttackRange.java @@ -0,0 +1,82 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; +import org.bukkit.craftbukkit.util.Handleable; + +public record PaperAttackRange( + net.minecraft.world.item.component.AttackRange impl +) implements AttackRange, Handleable { + + @Override + public net.minecraft.world.item.component.AttackRange getHandle() { + return this.impl; + } + + @Override + public float minReach() { + return this.impl.minRange(); + } + + @Override + public float maxReach() { + return this.impl.maxRange(); + } + + @Override + public float hitboxMargin() { + return this.impl.hitboxMargin(); + } + + @Override + public float mobFactor() { + return this.impl.mobFactor(); + } + + static final class BuilderImpl implements AttackRange.Builder { + + private float minReach = net.minecraft.world.item.component.AttackRange.DEFAULT.minRange(); + private float maxReach = net.minecraft.world.item.component.AttackRange.DEFAULT.maxRange(); + private float hitboxMargin = net.minecraft.world.item.component.AttackRange.DEFAULT.hitboxMargin(); + private float mobFactor = net.minecraft.world.item.component.AttackRange.DEFAULT.mobFactor(); + + @Override + public AttackRange.Builder minReach(final float minReach) { + Preconditions.checkArgument(minReach >= 0.0F && minReach <= 64.0F, "minReach must be in range [0,64] was %s", minReach); + this.minReach = minReach; + return this; + } + + @Override + public AttackRange.Builder maxReach(final float maxReach) { + Preconditions.checkArgument(maxReach >= 0.0F && maxReach <= 64.0F, "maxReach must be in range [0,64] was %s", maxReach); + this.maxReach = maxReach; + return this; + } + + @Override + public AttackRange.Builder hitboxMargin(final float hitboxMargin) { + Preconditions.checkArgument(hitboxMargin >= 0.0F && hitboxMargin <= 1.0F, "hitboxMargin must be in range [0,1] was %s", hitboxMargin); + this.hitboxMargin = hitboxMargin; + return this; + } + + @Override + public AttackRange.Builder mobFactor(final float mobFactor) { + Preconditions.checkArgument(mobFactor >= 0.0F && mobFactor <= 2.0F, "mobFactor must be in range [0,2] was %s", mobFactor); + this.mobFactor = mobFactor; + return this; + } + + @Override + public AttackRange build() { + return new PaperAttackRange( + new net.minecraft.world.item.component.AttackRange( + this.minReach, + this.maxReach, + this.hitboxMargin, + this.mobFactor + ) + ); + } + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java index 4e78722f80d4..71c927abdebc 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java @@ -8,9 +8,9 @@ import io.papermc.paper.datacomponent.item.blocksattacks.PaperItemDamageFunction; import io.papermc.paper.registry.PaperRegistries; import io.papermc.paper.registry.tag.TagKey; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; import java.util.Optional; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.kyori.adventure.key.Key; import org.bukkit.craftbukkit.util.Handleable; import org.bukkit.damage.DamageType; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java index e2f2d435b97a..9b36a53930ae 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java @@ -1,6 +1,7 @@ package io.papermc.paper.datacomponent.item; import com.google.common.base.Preconditions; +import io.papermc.paper.util.MCUtil; import it.unimi.dsi.fastutil.booleans.BooleanArrayList; import it.unimi.dsi.fastutil.booleans.BooleanList; import it.unimi.dsi.fastutil.floats.FloatArrayList; @@ -10,7 +11,6 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.Collections; import java.util.List; -import io.papermc.paper.util.MCUtil; import org.bukkit.Color; import org.bukkit.craftbukkit.util.Handleable; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java index 3ead3fbaf9cd..aa10ee49b810 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java @@ -12,7 +12,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.item.equipment.EquipmentAsset; @@ -114,7 +114,7 @@ static final class BuilderImpl implements Builder { private final net.minecraft.world.entity.EquipmentSlot equipmentSlot; private Holder equipSound = SoundEvents.ARMOR_EQUIP_GENERIC; private Optional> assetId = Optional.empty(); - private Optional cameraOverlay = Optional.empty(); + private Optional cameraOverlay = Optional.empty(); private Optional>> allowedEntities = Optional.empty(); private boolean dispensable = true; private boolean swappable = true; 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 705f5a4f1d18..c2e2ff3a8c1b 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.critereon.DataComponentMatchers; +import net.minecraft.advancements.criterion.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.critereon.BlockPredicate(Optional.ofNullable(predicate.blocks()).map( + this.predicates.add(new net.minecraft.advancements.criterion.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/PaperKineticWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java new file mode 100644 index 000000000000..acbe7842cffa --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperKineticWeapon.java @@ -0,0 +1,200 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; +import io.papermc.paper.adventure.PaperAdventure; +import java.util.Optional; +import net.kyori.adventure.key.Key; +import net.minecraft.core.Holder; +import net.minecraft.sounds.SoundEvent; +import org.bukkit.craftbukkit.util.Handleable; +import org.jspecify.annotations.Nullable; + +public record PaperKineticWeapon( + net.minecraft.world.item.component.KineticWeapon impl +) implements KineticWeapon, Handleable { + + private static net.minecraft.world.item.component.KineticWeapon.Condition toNms(final KineticWeapon.Condition api) { + if (api instanceof PaperKineticWeaponCondition( + net.minecraft.world.item.component.KineticWeapon.Condition cond + )) { + return cond; + } else { + throw new UnsupportedOperationException("Could not decode " + api); + } + } + + @Override + public net.minecraft.world.item.component.KineticWeapon getHandle() { + return this.impl; + } + + @Override + public int contactCooldownTicks() { + return this.impl.contactCooldownTicks(); + } + + @Override + public int delayTicks() { + return this.impl.delayTicks(); + } + + @Override + public KineticWeapon.@Nullable Condition dismountConditions() { + return this.impl.dismountConditions().map(PaperKineticWeaponCondition::new) + .orElse(null); + } + + @Override + public KineticWeapon.@Nullable Condition knockbackConditions() { + return this.impl.knockbackConditions().map(PaperKineticWeaponCondition::new) + .orElse(null); + } + + @Override + public KineticWeapon.@Nullable Condition damageConditions() { + return this.impl.damageConditions().map(PaperKineticWeaponCondition::new) + .orElse(null); + } + + @Override + public float forwardMovement() { + return this.impl.forwardMovement(); + } + + @Override + public float damageMultiplier() { + return this.impl.damageMultiplier(); + } + + @Override + public @Nullable Key sound() { + return this.impl.sound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + @Override + public @Nullable Key hitSound() { + return this.impl.hitSound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + public record PaperKineticWeaponCondition( + net.minecraft.world.item.component.KineticWeapon.Condition impl + ) implements KineticWeapon.Condition, Handleable { + + @Override + public net.minecraft.world.item.component.KineticWeapon.Condition getHandle() { + return this.impl; + } + + @Override + public int maxDurationTicks() { + return this.impl.maxDurationTicks(); + } + + @Override + public float minSpeed() { + return this.impl.minSpeed(); + } + + @Override + public float minRelativeSpeed() { + return this.impl.minRelativeSpeed(); + } + } + + static final class BuilderImpl implements KineticWeapon.Builder { + + private int contactCooldownTicks = 10; + private int delayTicks = 0; + + private net.minecraft.world.item.component.KineticWeapon.@Nullable Condition dismountConditions; + private net.minecraft.world.item.component.KineticWeapon.@Nullable Condition knockbackConditions; + private net.minecraft.world.item.component.KineticWeapon.@Nullable Condition damageConditions; + + private @Nullable Key sound = null; + private @Nullable Key hitSound = null; + + private float damageMultiplier = 1; + private float forwardMovement = 0.0F; + + @Override + public KineticWeapon.Builder contactCooldownTicks(final int ticks) { + Preconditions.checkArgument(ticks >= 0, "contactCooldownTicks must be non-negative"); + this.contactCooldownTicks = ticks; + return this; + } + + @Override + public KineticWeapon.Builder delayTicks(final int ticks) { + Preconditions.checkArgument(ticks >= 0, "delayTicks must be non-negative"); + this.delayTicks = ticks; + return this; + } + + @Override + public KineticWeapon.Builder dismountConditions(final KineticWeapon.@Nullable Condition condition) { + this.dismountConditions = condition == null ? null : toNms(condition); + return this; + } + + @Override + public KineticWeapon.Builder knockbackConditions(final KineticWeapon.@Nullable Condition condition) { + this.knockbackConditions = condition == null ? null : toNms(condition); + return this; + } + + @Override + public KineticWeapon.Builder damageConditions(final KineticWeapon.@Nullable Condition condition) { + this.damageConditions = condition == null ? null : toNms(condition); + return this; + } + + @Override + public Builder damageMultiplier(float damageMultiplier) { + this.damageMultiplier = damageMultiplier; + return this; + } + + @Override + public Builder forwardMovement(float forwardMovement) { + this.forwardMovement = forwardMovement; + return this; + } + + @Override + public KineticWeapon.Builder sound(final @Nullable Key sound) { + this.sound = sound; + return this; + } + + @Override + public KineticWeapon.Builder hitSound(final @Nullable Key sound) { + this.hitSound = sound; + return this; + } + + @Override + public KineticWeapon build() { + return new PaperKineticWeapon( + new net.minecraft.world.item.component.KineticWeapon( + this.contactCooldownTicks, + this.delayTicks, + Optional.ofNullable(this.dismountConditions), + Optional.ofNullable(this.knockbackConditions), + Optional.ofNullable(this.damageConditions), + this.forwardMovement, + this.damageMultiplier, + Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), + Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) + ) + ); + } + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java new file mode 100644 index 000000000000..7843e88b2c5a --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperPiercingWeapon.java @@ -0,0 +1,92 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.adventure.PaperAdventure; +import java.util.Optional; +import net.kyori.adventure.key.Key; +import net.minecraft.core.Holder; +import net.minecraft.sounds.SoundEvent; +import org.bukkit.craftbukkit.util.Handleable; +import org.jspecify.annotations.Nullable; + +public record PaperPiercingWeapon( + net.minecraft.world.item.component.PiercingWeapon impl +) implements PiercingWeapon, Handleable { + + @Override + public net.minecraft.world.item.component.PiercingWeapon getHandle() { + return this.impl; + } + + @Override + public boolean dealsKnockback() { + return this.impl.dealsKnockback(); + } + + @Override + public boolean dismounts() { + return this.impl.dismounts(); + } + + @Override + public @Nullable Key sound() { + return this.impl.sound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + @Override + public @Nullable Key hitSound() { + return this.impl.hitSound() + .map(Holder::value) + .map(SoundEvent::location) + .map(PaperAdventure::asAdventure) + .orElse(null); + } + + static final class BuilderImpl implements PiercingWeapon.Builder { + + private boolean dealsKnockback = true; + private boolean dismounts = false; + + private @Nullable Key sound = null; + private @Nullable Key hitSound = null; + + @Override + public PiercingWeapon.Builder dealsKnockback(final boolean dealsKnockback) { + this.dealsKnockback = dealsKnockback; + return this; + } + + @Override + public PiercingWeapon.Builder dismounts(final boolean dismounts) { + this.dismounts = dismounts; + return this; + } + + @Override + public PiercingWeapon.Builder sound(final @Nullable Key sound) { + this.sound = sound; + return this; + } + + @Override + public PiercingWeapon.Builder hitSound(final @Nullable Key sound) { + this.hitSound = sound; + return this; + } + + @Override + public PiercingWeapon build() { + return new PaperPiercingWeapon( + new net.minecraft.world.item.component.PiercingWeapon( + this.dealsKnockback, + this.dismounts, + Optional.ofNullable(this.sound).map(PaperAdventure::resolveSound), + Optional.ofNullable(this.hitSound).map(PaperAdventure::resolveSound) + ) + ); + } + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java index 1ee469b3b690..c5a9bafdaaec 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSeededContainerLoot.java @@ -19,7 +19,7 @@ public net.minecraft.world.item.component.SeededContainerLoot getHandle() { @Override public Key lootTable() { - return CraftNamespacedKey.fromMinecraft(this.impl.lootTable().location()); + return CraftNamespacedKey.fromMinecraft(this.impl.lootTable().identifier()); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java new file mode 100644 index 000000000000..cdc315158d62 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperSwingAnimation.java @@ -0,0 +1,54 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; +import net.minecraft.world.item.SwingAnimationType; +import org.bukkit.craftbukkit.util.Handleable; + +public record PaperSwingAnimation( + net.minecraft.world.item.component.SwingAnimation impl +) implements SwingAnimation, Handleable { + + @Override + public net.minecraft.world.item.component.SwingAnimation getHandle() { + return this.impl; + } + + @Override + public Animation type() { + return Animation.valueOf(this.impl.type().name()); + } + + @Override + public int duration() { + return this.impl.duration(); + } + + static final class BuilderImpl implements SwingAnimation.Builder { + + private SwingAnimationType type = net.minecraft.world.item.component.SwingAnimation.DEFAULT.type(); + private int duration = net.minecraft.world.item.component.SwingAnimation.DEFAULT.duration(); + + @Override + public SwingAnimation.Builder type(final SwingAnimation.Animation type) { + this.type = SwingAnimationType.valueOf(type.name()); + return this; + } + + @Override + public SwingAnimation.Builder duration(final int duration) { + Preconditions.checkArgument(duration > 0, "duration must be positive"); + this.duration = duration; + return this; + } + + @Override + public SwingAnimation build() { + return new PaperSwingAnimation( + new net.minecraft.world.item.component.SwingAnimation( + this.type, + this.duration + ) + ); + } + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java index b5e2e7387431..ad6c99782a6e 100644 --- a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseCooldown.java @@ -3,7 +3,7 @@ import io.papermc.paper.adventure.PaperAdventure; import java.util.Optional; import net.kyori.adventure.key.Key; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.craftbukkit.util.Handleable; import org.jspecify.annotations.Nullable; @@ -31,7 +31,7 @@ public float seconds() { static final class BuilderImpl implements Builder { private final float seconds; - private Optional cooldownGroup = Optional.empty(); + private Optional cooldownGroup = Optional.empty(); BuilderImpl(final float seconds) { this.seconds = seconds; diff --git a/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java new file mode 100644 index 000000000000..8b3ad2095296 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUseEffects.java @@ -0,0 +1,66 @@ +package io.papermc.paper.datacomponent.item; + +import com.google.common.base.Preconditions; +import org.bukkit.craftbukkit.util.Handleable; + +public record PaperUseEffects( + net.minecraft.world.item.component.UseEffects impl +) implements UseEffects, Handleable { + + @Override + public net.minecraft.world.item.component.UseEffects getHandle() { + return this.impl; + } + + @Override + public boolean canSprint() { + return this.impl.canSprint(); + } + + @Override + public boolean interactVibrations() { + return this.impl.interactVibrations(); + } + + @Override + public float speedMultiplier() { + return this.impl.speedMultiplier(); + } + + static final class BuilderImpl implements UseEffects.Builder { + + private boolean canSprint = net.minecraft.world.item.component.UseEffects.DEFAULT.canSprint(); + private boolean interactVibrations = net.minecraft.world.item.component.UseEffects.DEFAULT.interactVibrations(); + private float speedMultiplier = net.minecraft.world.item.component.UseEffects.DEFAULT.speedMultiplier(); + + @Override + public UseEffects.Builder canSprint(final boolean canSprint) { + this.canSprint = canSprint; + return this; + } + + @Override + public UseEffects.Builder interactVibrations(final boolean interactVibrations) { + this.interactVibrations = interactVibrations; + return this; + } + + @Override + public UseEffects.Builder speedMultiplier(final float speedMultiplier) { + Preconditions.checkArgument(speedMultiplier >= 0.0F && speedMultiplier <= 1.0F, "speedMultiplier must be between 0.0 and 1.0 (inclusive)"); + this.speedMultiplier = speedMultiplier; + return this; + } + + @Override + public UseEffects build() { + return new PaperUseEffects( + new net.minecraft.world.item.component.UseEffects( + this.canSprint, + this.interactVibrations, + this.speedMultiplier + ) + ); + } + } +} diff --git a/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java b/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java index 7857853c5280..ef42f1b74366 100644 --- a/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java +++ b/paper-server/src/main/java/io/papermc/paper/dialog/PaperDialog.java @@ -7,18 +7,10 @@ public final class PaperDialog extends HolderableBase implements Dialog { - public static net.minecraft.server.dialog.Dialog bukkitToMinecraft(final Dialog bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(final Dialog bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } - public static Dialog minecraftToBukkit(final net.minecraft.server.dialog.Dialog minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.DIALOG); - } - public static Dialog minecraftHolderToBukkit(final Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.DIALOG); } diff --git a/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java b/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java index 04c8213ae6f3..661e0c324cac 100644 --- a/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java +++ b/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java @@ -1,6 +1,6 @@ package io.papermc.paper.entity; -import net.minecraft.world.entity.animal.AbstractSchoolingFish; +import net.minecraft.world.entity.animal.fish.AbstractSchoolingFish; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftFish; import org.jetbrains.annotations.NotNull; diff --git a/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java b/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java index 493914c8d14a..b6fccd37c76d 100644 --- a/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java +++ b/paper-server/src/main/java/io/papermc/paper/entity/activation/ActivationType.java @@ -4,11 +4,11 @@ import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.ambient.AmbientCreature; import net.minecraft.world.entity.animal.AgeableWaterCreature; -import net.minecraft.world.entity.animal.WaterAnimal; +import net.minecraft.world.entity.animal.fish.WaterAnimal; import net.minecraft.world.entity.monster.Enemy; import net.minecraft.world.entity.monster.Ghast; import net.minecraft.world.entity.monster.Phantom; -import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.npc.villager.Villager; import net.minecraft.world.entity.raid.Raider; import net.minecraft.world.phys.AABB; diff --git a/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java b/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java new file mode 100644 index 000000000000..917ebc6c9083 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/event/world/PaperWorldGameRuleChangeEvent.java @@ -0,0 +1,24 @@ +package io.papermc.paper.event.world; + +import org.bukkit.GameRule; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.CraftGameRule; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public class PaperWorldGameRuleChangeEvent extends WorldGameRuleChangeEvent { + + public PaperWorldGameRuleChangeEvent(final World world, final @Nullable CommandSender commandSender, final GameRule gameRule, final String value) { + super(world, commandSender, gameRule, value); + } + + @Override + public void setValue(final String value) { + ((CraftGameRule) this.gameRule).getHandle().deserialize(value).ifError(error -> { + throw CraftGameRule.INVALID_VALUE.apply(value, error); + }); + super.setValue(value); + } +} 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 844c2b8fd46d..121babcfdda5 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 @@ -20,6 +20,7 @@ import io.papermc.paper.registry.data.PaperPigVariantRegistryEntry; import io.papermc.paper.registry.data.PaperSoundEventRegistryEntry; import io.papermc.paper.registry.data.PaperWolfVariantRegistryEntry; +import io.papermc.paper.registry.data.PaperZombieNautilusVariantRegistryEntry; import io.papermc.paper.registry.data.dialog.PaperDialogRegistryEntry; import io.papermc.paper.registry.entry.RegistryEntry; import io.papermc.paper.registry.entry.RegistryEntryMeta; @@ -35,6 +36,7 @@ import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; import org.bukkit.JukeboxSong; import org.bukkit.Keyed; import org.bukkit.MusicInstrument; @@ -46,6 +48,7 @@ import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftFluid; import org.bukkit.craftbukkit.CraftGameEvent; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.CraftJukeboxSong; import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.CraftSound; @@ -62,6 +65,7 @@ import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; +import org.bukkit.craftbukkit.entity.CraftZombieNautilus; import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructureType; import org.bukkit.craftbukkit.inventory.CraftItemType; @@ -81,6 +85,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; import org.bukkit.inventory.ItemType; @@ -115,6 +120,7 @@ public final class PaperRegistries { start(Registries.FLUID, RegistryKey.FLUID).craft(Fluid.class, CraftFluid::new).build(), start(Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT).craft(Sound.class, CraftSound::new, true).create(PaperSoundEventRegistryEntry.PaperBuilder::new, RegistryEntryMeta.RegistryModificationApiSupport.NONE), start(Registries.DATA_COMPONENT_TYPE, RegistryKey.DATA_COMPONENT_TYPE).craft(DataComponentTypes.class, PaperDataComponentType::of).build(), + start(Registries.GAME_RULE, RegistryKey.GAME_RULE).craft(GameRule.class, CraftGameRule::new).build(), // data-driven start(Registries.BIOME, RegistryKey.BIOME).craft(Biome.class, CraftBiome::new).build().delayed(), @@ -134,6 +140,7 @@ public final class PaperRegistries { start(Registries.CHICKEN_VARIANT, RegistryKey.CHICKEN_VARIANT).craft(Chicken.Variant.class, CraftChicken.CraftVariant::new).writable(PaperChickenVariantRegistryEntry.PaperBuilder::new), start(Registries.COW_VARIANT, RegistryKey.COW_VARIANT).craft(Cow.Variant.class, CraftCow.CraftVariant::new).writable(PaperCowVariantRegistryEntry.PaperBuilder::new), start(Registries.PIG_VARIANT, RegistryKey.PIG_VARIANT).craft(Pig.Variant.class, CraftPig.CraftVariant::new).writable(PaperPigVariantRegistryEntry.PaperBuilder::new), + start(Registries.ZOMBIE_NAUTILUS_VARIANT, RegistryKey.ZOMBIE_NAUTILUS_VARIANT).craft(ZombieNautilus.Variant.class, CraftZombieNautilus.CraftVariant::new).writable(PaperZombieNautilusVariantRegistryEntry.PaperBuilder::new), start(Registries.DIALOG, RegistryKey.DIALOG).craft(Dialog.class, PaperDialog::new, true).writable(PaperDialogRegistryEntry.PaperBuilder::new), // api-only @@ -186,7 +193,7 @@ public static ResourceKey> registryToNms(final Regi } public static TypedKey fromNms(final ResourceKey resourceKey) { - return TypedKey.create(registryFromNms(resourceKey.registryKey()), CraftNamespacedKey.fromMinecraft(resourceKey.location())); + return TypedKey.create(registryFromNms(resourceKey.registryKey()), CraftNamespacedKey.fromMinecraft(resourceKey.identifier())); } @SuppressWarnings({"unchecked", "RedundantCast"}) diff --git a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java index 65339315be6b..24cd0d16ccc4 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/PaperRegistryListenerManager.java @@ -28,7 +28,7 @@ import net.minecraft.core.WritableRegistry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.Keyed; import org.intellij.lang.annotations.Subst; import org.jspecify.annotations.Nullable; @@ -47,13 +47,13 @@ private PaperRegistryListenerManager() { * For {@link Registry#register(Registry, String, Object)} */ public M registerWithListeners(final Registry registry, final String id, final M nms) { - return this.registerWithListeners(registry, ResourceLocation.withDefaultNamespace(id), nms); + return this.registerWithListeners(registry, Identifier.withDefaultNamespace(id), nms); } /** - * For {@link Registry#register(Registry, ResourceLocation, Object)} + * For {@link Registry#register(Registry, Identifier, Object)} */ - public M registerWithListeners(final Registry registry, final ResourceLocation loc, final M nms) { + public M registerWithListeners(final Registry registry, final Identifier loc, final M nms) { return this.registerWithListeners(registry, ResourceKey.create(registry.key(), loc), nms); } @@ -65,9 +65,9 @@ public M registerWithListeners(final Registry registry, final ResourceKey } /** - * For {@link Registry#registerForHolder(Registry, ResourceLocation, Object)} + * For {@link Registry#registerForHolder(Registry, Identifier, Object)} */ - public Holder.Reference registerForHolderWithListeners(final Registry registry, final ResourceLocation loc, final M nms) { + public Holder.Reference registerForHolderWithListeners(final Registry registry, final Identifier loc, final M nms) { return this.registerForHolderWithListeners(registry, ResourceKey.create(registry.key(), loc), nms); } @@ -131,7 +131,7 @@ public , R> R registerW final RegisterMethod registerMethod, final Conversions conversions ) { - @Subst("namespace:key") final ResourceLocation beingAdded = key.location(); + @Subst("namespace:key") final Identifier beingAdded = key.identifier(); @SuppressWarnings("PatternValidation") final TypedKey typedKey = TypedKey.create(entry.apiKey(), Key.key(beingAdded.getNamespace(), beingAdded.getPath())); final RegistryEntryAddEventImpl event = entry.createEntryAddEvent(typedKey, builder, conversions); LifecycleEventRunner.INSTANCE.callEvent(this.valueAddEventTypes.getEventType(entry.apiKey()), event); diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java index 70d226a14a8d..93f1aa9a8816 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperBannerPatternRegistryEntry.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.PaperRegistryBuilder; import io.papermc.paper.registry.data.util.Conversions; import net.kyori.adventure.key.Key; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.entity.BannerPattern; import org.bukkit.block.banner.PatternType; import org.jspecify.annotations.Nullable; @@ -13,7 +13,7 @@ public class PaperBannerPatternRegistryEntry implements BannerPatternRegistryEntry { - protected @Nullable ResourceLocation assetId; + protected @Nullable Identifier assetId; protected @Nullable String translationKey; public PaperBannerPatternRegistryEntry( 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 68fadaf8aa98..7b73a4a8e549 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 @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.CatVariant; +import net.minecraft.world.entity.animal.feline.CatVariant; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Cat; import org.jspecify.annotations.Nullable; 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 000127f3b6b4..31b931326467 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 @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.ChickenVariant; +import net.minecraft.world.entity.animal.chicken.ChickenVariant; import net.minecraft.world.entity.variant.ModelAndTexture; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Chicken; 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 c168150e2c75..cd3249196b26 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 @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.CowVariant; +import net.minecraft.world.entity.animal.cow.CowVariant; import net.minecraft.world.entity.variant.ModelAndTexture; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Cow; 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 31430bfbec5b..2fd8ece677df 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 @@ -7,8 +7,8 @@ import java.util.OptionalInt; import net.kyori.adventure.key.Key; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.resources.Identifier; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import org.bukkit.Art; import org.jetbrains.annotations.Range; import org.jspecify.annotations.Nullable; @@ -23,7 +23,7 @@ public class PaperPaintingVariantRegistryEntry implements PaintingVariantRegistr protected OptionalInt height = OptionalInt.empty(); protected @Nullable Component title; protected @Nullable Component author; - protected @Nullable ResourceLocation assetId; + protected @Nullable Identifier assetId; protected final Conversions conversions; 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 b43dcd08180d..3f8af47de16b 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 @@ -4,7 +4,7 @@ import io.papermc.paper.registry.data.client.ClientTextureAsset; import io.papermc.paper.registry.data.util.Conversions; import net.minecraft.core.ClientAsset; -import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.entity.animal.pig.PigVariant; import net.minecraft.world.entity.variant.ModelAndTexture; import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import org.bukkit.entity.Pig; diff --git a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java index 9590faa0c6c1..d60bd7867e92 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperSoundEventRegistryEntry.java @@ -5,7 +5,7 @@ import io.papermc.paper.registry.data.util.Conversions; import java.util.Optional; import net.kyori.adventure.key.Key; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvent; import org.bukkit.Sound; import org.jspecify.annotations.Nullable; @@ -20,7 +20,7 @@ public class PaperSoundEventRegistryEntry implements SoundEventRegistryEntry { protected final Conversions conversions; - protected @Nullable ResourceLocation location; + protected @Nullable Identifier location; protected @Nullable Float fixedRange; public PaperSoundEventRegistryEntry(final Conversions conversions, final @Nullable SoundEvent soundEvent) { 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 new file mode 100644 index 000000000000..c9938e7772e0 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/registry/data/PaperZombieNautilusVariantRegistryEntry.java @@ -0,0 +1,81 @@ +package io.papermc.paper.registry.data; + +import io.papermc.paper.registry.PaperRegistryBuilder; +import io.papermc.paper.registry.data.client.ClientTextureAsset; +import io.papermc.paper.registry.data.util.Conversions; +import net.minecraft.core.ClientAsset; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant; +import net.minecraft.world.entity.variant.ModelAndTexture; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import org.bukkit.entity.ZombieNautilus; +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 PaperZombieNautilusVariantRegistryEntry implements ZombieNautilusVariantRegistryEntry { + + protected ZombieNautilusVariant.@Nullable ModelType model; + protected ClientAsset.@Nullable ResourceTexture clientTextureAsset; + protected SpawnPrioritySelectors spawnConditions; + + protected final Conversions conversions; + + public PaperZombieNautilusVariantRegistryEntry( + final Conversions conversions, + final @Nullable ZombieNautilusVariant internal + ) { + this.conversions = conversions; + if (internal == null) { + this.spawnConditions = SpawnPrioritySelectors.EMPTY; + return; + } + + this.clientTextureAsset = internal.modelAndTexture().asset(); + this.model = internal.modelAndTexture().model(); + this.spawnConditions = internal.spawnConditions(); + } + + @Override + public ClientTextureAsset clientTextureAsset() { + return this.conversions.asBukkit(asConfigured(this.clientTextureAsset, "clientTextureAsset")); + } + + @Override + public ZombieNautilusVariantRegistryEntry.Model model() { + return switch (asConfigured(this.model, "model")) { + case NORMAL -> ZombieNautilusVariantRegistryEntry.Model.NORMAL; + case WARM -> ZombieNautilusVariantRegistryEntry.Model.WARM; + }; + } + + public static final class PaperBuilder extends PaperZombieNautilusVariantRegistryEntry implements Builder, PaperRegistryBuilder { + + public PaperBuilder(final Conversions conversions, final @Nullable ZombieNautilusVariant internal) { + super(conversions, internal); + } + + @Override + public ZombieNautilusVariantRegistryEntry.Builder clientTextureAsset(final ClientTextureAsset clientTextureAsset) { + this.clientTextureAsset = this.conversions.asVanilla(asArgument(clientTextureAsset, "clientTextureAsset")); + return this; + } + + @Override + public ZombieNautilusVariantRegistryEntry.Builder model(final ZombieNautilusVariantRegistryEntry.Model model) { + this.model = switch (asArgument(model, "model")) { + case NORMAL -> ZombieNautilusVariant.ModelType.NORMAL; + case WARM -> ZombieNautilusVariant.ModelType.WARM; + }; + return this; + } + + @Override + public ZombieNautilusVariant build() { + return new ZombieNautilusVariant( + new ModelAndTexture<>(asConfigured(this.model, "model"), asConfigured(this.clientTextureAsset, "clientTextureAsset")), + asConfigured(this.spawnConditions, "spawnConditions") + ); + } + } +} 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 9e2a26aeb21b..209ea05ade06 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,11 +22,11 @@ import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.dialog.CommonButtonData; import net.minecraft.server.dialog.Dialog; import net.minecraft.server.dialog.action.ParsedTemplate; @@ -54,7 +54,7 @@ private PaperDialogCodecs() { ); private static final Map> STATIC_ACTION_CODECS = Arrays.stream(AdventureCodecs.CLICK_EVENT_TYPES.get()).collect(Collectors.toMap(Function.identity(), type -> type.codec().xmap(DialogAction::staticAction, DialogAction.StaticAction::value))); private static final Registry> DIALOG_ACTION_TYPES = Util.make(() -> { - final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "dialog_action_type")), Lifecycle.experimental()); + final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "dialog_action_type")), Lifecycle.experimental()); STATIC_ACTION_CODECS.forEach((clickType, actionCodec) -> { Registry.register(registry, clickType.getSerializedName(), actionCodec); }); @@ -94,7 +94,7 @@ private PaperDialogCodecs() { ).apply(instance, (itemStack, plainMessageBody, showDecorations, showTooltip, width, height) -> DialogBody.item(itemStack, plainMessageBody.orElse(null), showDecorations, showTooltip, width, height)) ); private static final Registry> DIALOG_BODY_TYPES = Util.make(() -> { - final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "dialog_body_type")), Lifecycle.experimental()); + final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "dialog_body_type")), Lifecycle.experimental()); Registry.register(registry, "item", ITEM_BODY_CODEC); Registry.register(registry, "plain_message", PLAIN_MESSAGE_BODY_CODEC); return registry.freeze(); @@ -155,7 +155,7 @@ private PaperDialogCodecs() { DialogInput.text(key, width, label, labelVisible, initial, maxLength, multilineOptions.orElse(null)) )); private static final Registry> DIALOG_INPUT_TYPES = Util.make(() -> { - final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "dialog_input_type")), Lifecycle.experimental()); + final MappedRegistry> registry = new MappedRegistry<>(ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "dialog_input_type")), Lifecycle.experimental()); Registry.register(registry, "boolean", BOOLEAN_DIALOG_INPUT_TYPE_MAP_CODEC); Registry.register(registry, "number_range", NUMBER_RANGE_INPUT_MAP_CODEC); Registry.register(registry, "single_option", SINGLE_OPTION_DIALOG_INPUT_TYPE_MAP_CODEC); diff --git a/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java b/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java index 87c0f502afb5..b34d415d70e1 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/entry/RegistryTypeMapper.java @@ -6,6 +6,7 @@ import java.util.function.Function; import net.minecraft.core.Holder; import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; public final class RegistryTypeMapper { @@ -14,7 +15,7 @@ public final class RegistryTypeMapper { if (!(holder instanceof final Holder.Reference reference)) { throw new IllegalArgumentException("This type does not support direct holders: " + holder); } - return byValueCreator.apply(MCUtil.fromResourceKey(reference.key()), reference.value()); + return byValueCreator.apply(CraftNamespacedKey.fromResourceKey(reference.key()), reference.value()); }; } diff --git a/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java b/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java index 7fbde6cd6817..10f86a16ef74 100644 --- a/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/registry/set/NamedRegistryKeySetImpl.java @@ -32,7 +32,7 @@ public NamedRegistryKeySetImpl(final HolderSet.Named namedSet) { public @Unmodifiable Collection> values() { final ImmutableList.Builder> builder = ImmutableList.builder(); for (final Holder holder : this.namedSet) { - builder.add(TypedKey.create(this.tagKey.registryKey(), CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().location()))); + builder.add(TypedKey.create(this.tagKey.registryKey(), CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().identifier()))); } return builder.build(); } @@ -53,7 +53,7 @@ public boolean contains(final TypedKey valueKey) { public @Unmodifiable Collection resolve(final Registry registry) { final ImmutableList.Builder builder = ImmutableList.builder(); for (final Holder holder : this.namedSet) { - builder.add(registry.getOrThrow(CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().location()))); + builder.add(registry.getOrThrow(CraftNamespacedKey.fromMinecraft(((Holder.Reference) holder).key().identifier()))); } return builder.build(); } diff --git a/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java b/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java index 2596586fd7e2..53e2b0d20d0a 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java @@ -17,7 +17,7 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.function.Function; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -27,13 +27,13 @@ @DefaultQualifier(NonNull.class) public class PaperPostFlattenTagRegistrar implements PaperRegistrar, PostFlattenTagRegistrar { - public final Map> tags; - private final Function> fromIdConverter; - private final Function toIdConverter; + public final Map> tags; + private final Function> fromIdConverter; + private final Function toIdConverter; private final RegistryKey registryKey; public PaperPostFlattenTagRegistrar( - final Map> tags, + final Map> tags, final TagEventConfig config ) { this.tags = tags; @@ -54,7 +54,7 @@ public RegistryKey registryKey() { @Override public Map, Collection>> getAllTags() { final ImmutableMap.Builder, Collection>> tags = ImmutableMap.builderWithExpectedSize(this.tags.size()); - for (final Map.Entry> entry : this.tags.entrySet()) { + for (final Map.Entry> entry : this.tags.entrySet()) { final TagKey key = TagKey.create(this.registryKey, CraftNamespacedKey.fromMinecraft(entry.getKey())); tags.put(key, this.convert(entry.getValue())); } @@ -67,7 +67,7 @@ private List> convert(final List nms) { ); } - private TypedKey convert(final ResourceLocation location) { + private TypedKey convert(final Identifier location) { return TypedKey.create(this.registryKey, CraftNamespacedKey.fromMinecraft(location)); } @@ -85,7 +85,7 @@ public boolean hasTag(final TagKey tagKey) { } private List getNmsTag(final TagKey tagKey, final boolean create) { - final ResourceLocation vanillaKey = PaperAdventure.asVanilla(tagKey.key()); + final Identifier vanillaKey = PaperAdventure.asVanilla(tagKey.key()); List tag = this.tags.get(vanillaKey); if (tag == null) { if (create) { 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 44111b55eaa6..229543e88182 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 @@ -16,7 +16,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagLoader; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.checkerframework.checker.nullness.qual.NonNull; @@ -27,13 +27,13 @@ @DefaultQualifier(NonNull.class) public class PaperPreFlattenTagRegistrar implements PaperRegistrar, PreFlattenTagRegistrar { - public final Map> tags; + public final Map> tags; private final RegistryKey registryKey; private @Nullable BootstrapContext owner; public PaperPreFlattenTagRegistrar( - final Map> tags, + final Map> tags, final TagEventConfig config ) { this.tags = new HashMap<>(tags); @@ -53,7 +53,7 @@ public RegistryKey registryKey() { @Override public Map, Collection>> getAllTags() { final ImmutableMap.Builder, Collection>> builder = ImmutableMap.builderWithExpectedSize(this.tags.size()); - for (final Map.Entry> entry : this.tags.entrySet()) { + for (final Map.Entry> entry : this.tags.entrySet()) { final TagKey key = TagKey.create(this.registryKey, CraftNamespacedKey.fromMinecraft(entry.getKey())); builder.put(key, convert(entry.getValue())); } @@ -70,7 +70,7 @@ private static io.papermc.paper.tag.TagEntry convert(final TagLoader.Entr private TagLoader.EntryWithSource convert(final TagEntry entry) { Preconditions.checkState(this.owner != null, "Owner is not set"); - final ResourceLocation vanilla = PaperAdventure.asVanilla(entry.key()); + final Identifier vanilla = PaperAdventure.asVanilla(entry.key()); final net.minecraft.tags.TagEntry nmsEntry; if (entry.isTag()) { if (entry.isRequired()) { @@ -94,7 +94,7 @@ public boolean hasTag(final TagKey tagKey) { } private List getNmsTag(final TagKey tagKey, boolean create) { - final ResourceLocation vanillaKey = PaperAdventure.asVanilla(tagKey.key()); + final Identifier vanillaKey = PaperAdventure.asVanilla(tagKey.key()); List tag = this.tags.get(vanillaKey); if (tag == null) { if (create) { diff --git a/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java b/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java index e1ffb7f1df66..05e88076cf84 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/PaperTagListenerManager.java @@ -13,7 +13,7 @@ import java.util.Map; import net.minecraft.core.Holder; import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagLoader; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -33,8 +33,8 @@ public class PaperTagListenerManager { private PaperTagListenerManager() { } - public Map> firePreFlattenEvent( - final Map> initial, + public Map> firePreFlattenEvent( + final Map> initial, final @Nullable TagEventConfig config ) { if (config == null || config.preFlatten() == null || !config.preFlatten().hasHandlers()) { @@ -50,8 +50,8 @@ public Map> firePreFlatten return Map.copyOf(registrar.tags); } - public Map> firePostFlattenEvent( - final Map> initial, + public Map> firePostFlattenEvent( + final Map> initial, final @Nullable TagEventConfig config ) { if (config == null || config.postFlatten() == null || !config.postFlatten().hasHandlers()) { @@ -86,7 +86,7 @@ public Map> firePostFlattenEvent( postFlatten, cause, registry::get, - h -> ((Holder.Reference) h).key().location(), + h -> ((Holder.Reference) h).key().identifier(), PaperRegistries.registryFromNms(registry.key()) ); } diff --git a/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java b/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java index d6d4bfc6f45d..497f2e3dc4c6 100644 --- a/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java +++ b/paper-server/src/main/java/io/papermc/paper/tag/TagEventConfig.java @@ -6,7 +6,7 @@ import io.papermc.paper.registry.RegistryKey; import java.util.Optional; import java.util.function.Function; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.framework.qual.DefaultQualifier; @@ -16,8 +16,8 @@ public record TagEventConfig( @Nullable AbstractLifecycleEventType>, ?> preFlatten, @Nullable AbstractLifecycleEventType>, ?> postFlatten, ReloadableRegistrarEvent.Cause cause, - Function> fromIdConverter, - Function toIdConverter, + Function> fromIdConverter, + Function toIdConverter, RegistryKey apiRegistryKey ) { } diff --git a/paper-server/src/main/java/io/papermc/paper/util/Holderable.java b/paper-server/src/main/java/io/papermc/paper/util/Holderable.java index 746c14b1792d..a1927b6bcea6 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/Holderable.java +++ b/paper-server/src/main/java/io/papermc/paper/util/Holderable.java @@ -12,6 +12,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.Handleable; import org.intellij.lang.annotations.Subst; import org.jspecify.annotations.NullMarked; @@ -54,7 +55,7 @@ default Object toBukkitSerializationObject(final Codec directCodec) { final RegistryOps ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JsonOps.INSTANCE); yield new JsonObjectWrapper(directCodec.encodeStart(ops, direct.value()).getOrThrow().getAsJsonObject()); } - case final Holder.Reference reference -> reference.key().location().toString(); + case final Holder.Reference reference -> reference.key().identifier().toString(); default -> throw new IllegalArgumentException("Cannot serialize " + this.getHolder()); }; } @@ -80,10 +81,10 @@ default String implToString() { } default @Nullable NamespacedKey getKeyOrNull() { - return this.getHolder().unwrapKey().map(MCUtil::fromResourceKey).orElse(null); + return this.getHolder().unwrapKey().map(CraftNamespacedKey::fromResourceKey).orElse(null); } default NamespacedKey getKey() { - return MCUtil.fromResourceKey(this.getHolder().unwrapKey().orElseThrow(() -> new IllegalStateException("Cannot get key for this registry item, because it is not registered."))); + return CraftNamespacedKey.fromResourceKey(this.getHolder().unwrapKey().orElseThrow(() -> new IllegalStateException("Cannot get key for this registry item, because it is not registered."))); } } 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 e3138cd67378..46f6750b1eae 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 @@ -199,17 +199,6 @@ public static void scheduleAsyncTask(Runnable run) { ASYNC_EXECUTOR.execute(run); } - public static ResourceKey toResourceKey( - final ResourceKey> registry, - final NamespacedKey namespacedKey - ) { - return ResourceKey.create(registry, CraftNamespacedKey.toMinecraft(namespacedKey)); - } - - public static NamespacedKey fromResourceKey(final ResourceKey key) { - return CraftNamespacedKey.fromMinecraft(key.location()); - } - public static List transformUnmodifiable(final List nms, final Function converter) { return Collections.unmodifiableList(Lists.transform(nms, converter::apply)); } diff --git a/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java b/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java index 6734280b9205..5b1fa5bd5495 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java +++ b/paper-server/src/main/java/io/papermc/paper/util/OldEnumHolderable.java @@ -26,10 +26,10 @@ protected OldEnumHolderable(final Holder holder, final int ordinal) { // in case plugins use for example the name as key in a config file to receive registry item specific values. // Custom registry items will return the key with namespace. For a plugin this should look than like a new registry item // (which can always be added in new minecraft versions and the plugin should therefore handle it accordingly). - if (NamespacedKey.MINECRAFT.equals(reference.key().location().getNamespace())) { - this.name = reference.key().location().getPath().toUpperCase(Locale.ROOT); + if (NamespacedKey.MINECRAFT.equals(reference.key().identifier().getNamespace())) { + this.name = reference.key().identifier().getPath().toUpperCase(Locale.ROOT); } else { - this.name = reference.key().location().toString(); + this.name = reference.key().identifier().toString(); } } else { this.name = null; diff --git a/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java b/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java index 6064086cc76e..9b1ae8f191a6 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java +++ b/paper-server/src/main/java/io/papermc/paper/util/PaperScoreboardFormat.java @@ -26,9 +26,9 @@ public static net.minecraft.network.chat.numbers.NumberFormat asVanilla(final Nu public static NumberFormat asPaper(final net.minecraft.network.chat.numbers.NumberFormat vanilla) { if (vanilla instanceof final net.minecraft.network.chat.numbers.StyledFormat styled) { - return NumberFormat.styled(PaperAdventure.asAdventure(styled.style)); + return NumberFormat.styled(PaperAdventure.asAdventure(styled.style())); } else if (vanilla instanceof final net.minecraft.network.chat.numbers.FixedFormat fixed) { - return NumberFormat.fixed(io.papermc.paper.adventure.PaperAdventure.asAdventure(fixed.value)); + return NumberFormat.fixed(io.papermc.paper.adventure.PaperAdventure.asAdventure(fixed.value())); } else if (vanilla instanceof net.minecraft.network.chat.numbers.BlankFormat) { return NumberFormat.blank(); } diff --git a/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java b/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java index ee76a9c488ef..b09f79d22fdd 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java +++ b/paper-server/src/main/java/io/papermc/paper/util/ServerWorkerThread.java @@ -1,7 +1,7 @@ package io.papermc.paper.util; import java.util.concurrent.atomic.AtomicInteger; -import net.minecraft.Util; +import net.minecraft.util.Util; public class ServerWorkerThread extends Thread { private static final AtomicInteger threadId = new AtomicInteger(1); diff --git a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java index aabbf7b18479..47810cb33204 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java +++ b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java @@ -6,7 +6,7 @@ import java.util.Map; import java.util.Optional; import java.util.function.UnaryOperator; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; diff --git a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java index 95d510a704f2..c0f68462d9bb 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java +++ b/paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java @@ -9,7 +9,7 @@ import java.util.function.UnaryOperator; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.component.DataComponents; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import org.jspecify.annotations.NullMarked; import org.spongepowered.configurate.objectmapping.ConfigSerializable; @@ -24,13 +24,13 @@ public final class ItemObfuscationBinding { public final ItemObfuscationSession.ObfuscationLevel level; private final BoundObfuscationConfiguration base; - private final Map overrides; + private final Map overrides; public ItemObfuscationBinding(final GlobalConfiguration.Anticheat.Obfuscation.Items items) { this.level = items.enableItemObfuscation ? ItemObfuscationSession.ObfuscationLevel.ALL : ItemObfuscationSession.ObfuscationLevel.OVERSIZED; this.base = bind(items.allModels); - final Map overrides = new HashMap<>(); - for (final Map.Entry entry : items.modelOverrides.entrySet()) { + final Map overrides = new HashMap<>(); + for (final Map.Entry entry : items.modelOverrides.entrySet()) { overrides.put(entry.getKey(), bind(entry.getValue())); } this.overrides = Collections.unmodifiableMap(overrides); 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 f5e9dd588068..51a01f86fee5 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 @@ -57,7 +57,7 @@ private WorldLoadingInfo getWorldInfo( dimension = -999; } String worldType = dimension == -999 - ? stemKey.location().getNamespace() + "_" + stemKey.location().getPath() + ? stemKey.identifier().getNamespace() + "_" + stemKey.identifier().getPath() : World.Environment.getEnvironment(dimension).toString().toLowerCase(Locale.ROOT); String name = stemKey == LevelStem.OVERWORLD ? levelId diff --git a/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java b/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java index 43afa79e9834..f5ce9f4b8df8 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java +++ b/paper-server/src/main/java/io/papermc/paper/world/damagesource/PaperCombatTrackerWrapper.java @@ -7,7 +7,7 @@ import java.util.List; import net.kyori.adventure.text.Component; import net.minecraft.Optionull; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.damagesource.FallLocation; import org.bukkit.entity.LivingEntity; import org.jspecify.annotations.NullMarked; diff --git a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java index e0a595324a7b..c0953bb67dcf 100644 --- a/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/world/flag/PaperFeatureFlagProviderImpl.java @@ -4,14 +4,13 @@ import com.google.common.collect.ImmutableBiMap; import java.util.Collections; import java.util.HashSet; -import java.util.Map; import java.util.Set; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.GameRules; import org.bukkit.FeatureFlag; import org.bukkit.GameRule; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.entity.CraftEntityType; import org.bukkit.craftbukkit.potion.CraftPotionType; import org.bukkit.entity.EntityType; @@ -51,18 +50,10 @@ static FeatureElement getFeatureElement(final FeatureDependant dependant) { } else if (dependant instanceof final PotionType potionType) { return CraftPotionType.bukkitToMinecraft(potionType); } else if (dependant instanceof final GameRule gameRule) { - return getGameRuleType(gameRule.getName()).asFeatureElement(); + return () -> CraftGameRule.bukkitToMinecraft(gameRule).requiredFeatures(); } else { throw new IllegalArgumentException(dependant + " is not a valid feature dependant"); } } - private static GameRules.Type getGameRuleType(final String name) { - for (final Map.Entry, GameRules.Type> gameRules : GameRules.GAME_RULE_TYPES.entrySet()) { - if (gameRules.getKey().getId().equals(name)) { - return gameRules.getValue(); - } - } - return null; - } } 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 60b6e040df57..8fa41e9d4210 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 @@ -7,7 +7,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.KeyDispatchDataCodec; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; @@ -20,15 +20,15 @@ // Modelled off of SurfaceRules$VerticalGradientConditionSource // Flat bedrock generator settings @DefaultQualifier(NonNull.class) -public record OptionallyFlatBedrockConditionSource(ResourceLocation randomName, VerticalAnchor trueAtAndBelow, VerticalAnchor falseAtAndAbove, boolean isRoof) implements SurfaceRules.ConditionSource { +public record OptionallyFlatBedrockConditionSource(Identifier randomName, VerticalAnchor trueAtAndBelow, VerticalAnchor falseAtAndAbove, boolean isRoof) implements SurfaceRules.ConditionSource { private static final ResourceKey> CODEC_RESOURCE_KEY = ResourceKey.create( Registries.MATERIAL_CONDITION, - ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "optionally_flat_bedrock_condition_source") + Identifier.fromNamespaceAndPath(Identifier.PAPER_NAMESPACE, "optionally_flat_bedrock_condition_source") ); private static final KeyDispatchDataCodec CODEC = KeyDispatchDataCodec.of(RecordCodecBuilder.mapCodec((instance) -> { return instance.group( - ResourceLocation.CODEC.fieldOf("random_name").forGetter(OptionallyFlatBedrockConditionSource::randomName), + 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) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java index d837b95337c3..95995694fbb5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -5,25 +5,17 @@ import net.kyori.adventure.text.Component; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import org.bukkit.Art; public class CraftArt extends OldEnumHolderable implements Art { private static int count = 0; - public static Art minecraftToBukkit(PaintingVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.PAINTING_VARIANT); - } - public static Art minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.PAINTING_VARIANT); } - public static PaintingVariant bukkitToMinecraft(Art bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Art bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java index a21bf2c5bc7c..8607b31c9c4d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java @@ -3,7 +3,7 @@ import java.util.Locale; import com.google.common.collect.BiMap; import com.google.common.collect.EnumBiMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlotGroup; import org.bukkit.inventory.EquipmentSlot; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java index 636c46b61293..4a05855086bb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java @@ -8,12 +8,12 @@ public class CraftGameEvent extends GameEvent implements Holderable { - public static GameEvent minecraftToBukkit(net.minecraft.world.level.gameevent.GameEvent minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.GAME_EVENT); + public static GameEvent minecraftHolderToBukkit(Holder minecraft) { + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.GAME_EVENT); } - public static net.minecraft.world.level.gameevent.GameEvent bukkitToMinecraft(GameEvent bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); + public static Holder bukkitToMinecraftHolder(GameEvent bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); } private final Holder holder; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java new file mode 100644 index 000000000000..5d42203a9079 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftGameRule.java @@ -0,0 +1,110 @@ +package org.bukkit.craftbukkit; + +import com.mojang.serialization.DataResult; +import io.papermc.paper.util.Holderable; +import java.util.function.BiFunction; +import java.util.function.Function; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import org.bukkit.GameRule; +import org.bukkit.NamespacedKey; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class CraftGameRule extends GameRule implements Holderable> { + + public static final BiFunction, IllegalArgumentException> INVALID_VALUE = (value, error) -> { + return new IllegalArgumentException("Invalid value: %s (%s)".formatted(value, error.message())); + }; + + public static GameRule minecraftToBukkit(net.minecraft.world.level.gamerules.GameRule minecraft) { + return CraftRegistry.minecraftToBukkit(minecraft, Registries.GAME_RULE); + } + + public static net.minecraft.world.level.gamerules.GameRule bukkitToMinecraft(GameRule bukkit) { + return CraftRegistry.bukkitToMinecraft(bukkit); + } + + private final Holder> holder; + + @SuppressWarnings("unchecked") + public CraftGameRule(Holder> holder) { + this.holder = (Holder) holder; + } + + @SuppressWarnings("unchecked") + public static GameRule wrap(GameRule rule, Function fromLegacyToModern, Function toLegacyFromModern, Class legacyClass) { + return new LegacyGameRuleWrapper<>(((CraftGameRule) rule).getHolder(), fromLegacyToModern, toLegacyFromModern, legacyClass); + } + + @Override + public Holder> getHolder() { + return this.holder; + } + + @Override + public NamespacedKey getKey() { + return Holderable.super.getKey(); + } + + @Override + public int hashCode() { + return Holderable.super.implHashCode(); + } + + @Override + public boolean equals(final Object obj) { + return Holderable.super.implEquals(obj); + } + + @Override + public String toString() { + return Holderable.super.implToString(); + } + + @Override + public String getName() { + return this.holder.getRegisteredName(); + } + + @SuppressWarnings("unchecked") + @Override + public Class getType() { + return (Class) switch (this.getHandle().gameRuleType()) { + case INT -> Integer.class; + case BOOL -> Boolean.class; + }; + } + + @Override + public String translationKey() { + return this.getHandle().getDescriptionId(); + } + + public static class LegacyGameRuleWrapper extends CraftGameRule { + + private final Class typeOverride; + private final Function fromLegacyToModern; + private final Function toLegacyFromModern; + + public LegacyGameRuleWrapper(Holder> holder, Function fromLegacyToModern, Function toLegacyFromModern, Class typeOverride) { + super(holder); + this.fromLegacyToModern = fromLegacyToModern; + this.toLegacyFromModern = toLegacyFromModern; + this.typeOverride = typeOverride; + } + + public Function getFromLegacyToModern() { + return this.fromLegacyToModern; + } + + public Function getToLegacyFromModern() { + return this.toLegacyFromModern; + } + + @Override + public Class getType() { + return this.typeOverride; + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftInventoryArmoredSaddledMount.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftInventoryArmoredSaddledMount.java new file mode 100644 index 000000000000..c86f9255f21e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftInventoryArmoredSaddledMount.java @@ -0,0 +1,12 @@ +package org.bukkit.craftbukkit; + +import net.minecraft.world.Container; +import org.bukkit.craftbukkit.inventory.CraftInventorySaddledMount; +import org.bukkit.inventory.ArmoredSaddledMountInventory; + +public class CraftInventoryArmoredSaddledMount extends CraftInventorySaddledMount implements ArmoredSaddledMountInventory { + + public CraftInventoryArmoredSaddledMount(final Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { + super(inventory, bodyArmorInventory, saddleInventory); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java index d601352135ff..5f8868b2350e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java @@ -13,18 +13,10 @@ @NullMarked public class CraftJukeboxSong extends HolderableBase implements JukeboxSong { - public static JukeboxSong minecraftToBukkit(net.minecraft.world.item.JukeboxSong minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.JUKEBOX_SONG); - } - public static JukeboxSong minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.JUKEBOX_SONG); } - public static net.minecraft.world.item.JukeboxSong bukkitToMinecraft(JukeboxSong bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(JukeboxSong bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 7a67d38af41b..f1a616432ea7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -7,7 +7,7 @@ import java.util.Random; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.context.ContextKey; import net.minecraft.util.context.ContextKeySet; @@ -34,7 +34,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { - public static org.bukkit.loot.LootTable minecraftToBukkit(ResourceLocation minecraft) { + public static org.bukkit.loot.LootTable minecraftToBukkit(Identifier minecraft) { return (minecraft == null) ? null : Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(minecraft)); } @@ -43,7 +43,7 @@ public static org.bukkit.loot.LootTable minecraftToBukkit(ResourceKey } public static NamespacedKey minecraftToBukkitKey(ResourceKey minecraft) { - return (minecraft == null) ? null : CraftNamespacedKey.fromMinecraft(minecraft.location()); + return (minecraft == null) ? null : CraftNamespacedKey.fromMinecraft(minecraft.identifier()); } public static ResourceKey bukkitToMinecraft(org.bukkit.loot.LootTable table) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java index ba1bc2ff7072..610bebdf860a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java @@ -15,18 +15,10 @@ public class CraftMusicInstrument extends MusicInstrument implements io.papermc.paper.util.Holderable { - public static MusicInstrument minecraftToBukkit(Instrument minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.INSTRUMENT); - } - public static MusicInstrument minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.INSTRUMENT); // Paper - switch to Holder } - public static Instrument bukkitToMinecraft(MusicInstrument bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(MusicInstrument bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } 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 872552864cd3..97b097eca4f1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -385,7 +385,7 @@ public Location getRespawnLocation(final boolean loadLocationAndValidate) { } private ServerStatsCounter getStatisticManager() { - return this.server.getHandle().getPlayerStats(this.getUniqueId(), this.getName()); + return this.server.getHandle().getPlayerStats(this.nameAndId.toUncompletedGameProfile()); } @Override 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 b8c0b05f589d..3f940a89a336 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -48,7 +48,7 @@ public static Particle minecraftToBukkit(net.minecraft.core.particles.ParticleTy Preconditions.checkArgument(minecraft != null); net.minecraft.core.Registry> registry = CraftRegistry.getMinecraftRegistry(Registries.PARTICLE_TYPE); - Particle bukkit = Registry.PARTICLE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); + Particle bukkit = Registry.PARTICLE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); Preconditions.checkArgument(bukkit != null); 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 119f4c23e351..21d594a39d09 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -7,6 +7,7 @@ import java.util.Random; import java.util.function.Consumer; import java.util.function.Predicate; +import net.minecraft.SharedConstants; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; @@ -465,12 +466,12 @@ public net.minecraft.world.entity.Entity createEntity(Location location, Class B minecraftToBukkit(M minecraft, ResourceKey< } else if (resourceKey.isEmpty()) { throw new IllegalStateException(String.format("Cannot convert '%s' to bukkit representation, since it is not registered.", minecraft)); } - final B bukkit = bukkitRegistry.get(CraftNamespacedKey.fromMinecraft(resourceKey.get().location())); + final B bukkit = bukkitRegistry.get(CraftNamespacedKey.fromMinecraft(resourceKey.get().identifier())); Preconditions.checkArgument(bukkit != null); @@ -84,7 +84,7 @@ public static B minecraftHolderToBukkit(final Holder min } yield ((CraftRegistry) bukkitRegistry).createBukkit(direct); } - case final Holder.Reference reference -> bukkitRegistry.get(MCUtil.fromResourceKey(reference.key())); + case final Holder.Reference reference -> bukkitRegistry.get(CraftNamespacedKey.fromResourceKey(reference.key())); default -> throw new IllegalArgumentException("Unknown holder: " + minecraft); }; Preconditions.checkArgument(bukkit != null); @@ -119,7 +119,7 @@ public static Optional unwrapAndConvertHolder(final Regi if (registry instanceof final CraftRegistry craftRegistry && craftRegistry.supportsDirectHolders() && value.kind() == Holder.Kind.DIRECT) { return Optional.of(((CraftRegistry) registry).createBukkit(value)); } - return value.unwrapKey().map(key -> registry.get(CraftNamespacedKey.fromMinecraft(key.location()))); + return value.unwrapKey().map(key -> registry.get(CraftNamespacedKey.fromMinecraft(key.identifier()))); } // Paper end - fixup upstream being dum @@ -196,7 +196,7 @@ public B get(NamespacedKey namespacedKey) { } // Important to use the ResourceKey "get" method below because it will work before registry is frozen - final Optional> holderOptional = this.minecraftRegistry.get(MCUtil.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); + final Optional> holderOptional = this.minecraftRegistry.get(CraftNamespacedKey.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); final Holder.Reference holder; if (holderOptional.isPresent()) { holder = holderOptional.get(); @@ -204,7 +204,7 @@ public B get(NamespacedKey namespacedKey) { // we lock the reference holders after the preload class has been initialized // this is to support the vanilla mechanic of preventing vanilla registry entries being loaded. We need // to create something to fill the API constant fields, so we create a dummy reference holder. - holder = Holder.Reference.createStandAlone(this.invalidHolderOwner, MCUtil.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); + holder = Holder.Reference.createStandAlone(this.invalidHolderOwner, CraftNamespacedKey.toResourceKey(this.minecraftRegistry.key(), namespacedKey)); } else { return null; } 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 34d74014fd04..b2961752b50e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -54,7 +54,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ReloadableServerRegistries; import net.minecraft.server.WorldLoader; @@ -81,7 +81,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ai.village.VillageSiege; import net.minecraft.world.entity.npc.CatSpawner; -import net.minecraft.world.entity.npc.WanderingTraderSpawner; +import net.minecraft.world.entity.npc.wanderingtrader.WanderingTraderSpawner; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.inventory.CraftingMenu; @@ -95,7 +95,7 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RepairItemRecipe; import net.minecraft.world.level.CustomSpawner; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.GameType; import net.minecraft.world.level.LevelSettings; import net.minecraft.world.level.biome.BiomeManager; @@ -994,7 +994,7 @@ public void reload() { this.console.paperConfigurations.reloadConfigs(this.console); for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty - world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && world.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) + world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && world.getGameRules().get(GameRules.SPAWN_MONSTERS)); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) for (SpawnCategory spawnCategory : SpawnCategory.values()) { if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { @@ -1282,7 +1282,7 @@ public World createWorld(WorldCreator creator) { } else if (name.equals(levelName + "_the_end")) { dimensionKey = net.minecraft.world.level.Level.END; } else { - dimensionKey = ResourceKey.create(Registries.DIMENSION, ResourceLocation.fromNamespaceAndPath(creator.key().namespace(), creator.key().value())); + dimensionKey = ResourceKey.create(Registries.DIMENSION, Identifier.fromNamespaceAndPath(creator.key().namespace(), creator.key().value())); } ServerLevel serverLevel = new ServerLevel( @@ -1416,7 +1416,9 @@ public void addWorld(World world) { @Override public WorldBorder createWorldBorder() { - return new CraftWorldBorder(new net.minecraft.world.level.border.WorldBorder()); + net.minecraft.world.level.border.WorldBorder border = new net.minecraft.world.level.border.WorldBorder(); + border.setWarningTime(net.minecraft.world.level.border.WorldBorder.Settings.DEFAULT.warningTime()); // TODO remove once MC-304061 is truly fixed + return new CraftWorldBorder(border); } @Override @@ -2554,7 +2556,7 @@ public org.bukkit.Tag getTag(String registry, NamespacedKey Preconditions.checkArgument(registry != null, "registry cannot be null"); Preconditions.checkArgument(tag != null, "NamespacedKey tag cannot be null"); Preconditions.checkArgument(clazz != null, "Class clazz cannot be null"); - ResourceLocation key = CraftNamespacedKey.toMinecraft(tag); + Identifier key = CraftNamespacedKey.toMinecraft(tag); switch (registry) { case org.bukkit.Tag.REGISTRY_BLOCKS -> { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index f79833051f31..e786c0cce9ce 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -5,7 +5,7 @@ import com.google.common.collect.ImmutableBiMap; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.ServerStatsCounter; import net.minecraft.stats.Stats; @@ -70,6 +70,7 @@ public enum CraftStatistic { LEAVE_GAME(Stats.LEAVE_GAME), MINECART_ONE_CM(Stats.MINECART_ONE_CM), MOB_KILLS(Stats.MOB_KILLS), + NAUTILUS_ONE_CM(Stats.NAUTILUS_ONE_CM), OPEN_BARREL(Stats.OPEN_BARREL), CHEST_OPENED(Stats.OPEN_CHEST), ENDERCHEST_OPENED(Stats.OPEN_ENDERCHEST), @@ -101,21 +102,21 @@ public enum CraftStatistic { WALK_UNDER_WATER_ONE_CM(Stats.WALK_UNDER_WATER_ONE_CM), // End generate - CraftStatisticCustom // Start generate - CraftStatisticType - BREAK_ITEM(ResourceLocation.withDefaultNamespace("broken")), - CRAFT_ITEM(ResourceLocation.withDefaultNamespace("crafted")), - DROP(ResourceLocation.withDefaultNamespace("dropped")), - KILL_ENTITY(ResourceLocation.withDefaultNamespace("killed")), - ENTITY_KILLED_BY(ResourceLocation.withDefaultNamespace("killed_by")), - MINE_BLOCK(ResourceLocation.withDefaultNamespace("mined")), - PICKUP(ResourceLocation.withDefaultNamespace("picked_up")), - USE_ITEM(ResourceLocation.withDefaultNamespace("used")); + BREAK_ITEM(Identifier.withDefaultNamespace("broken")), + CRAFT_ITEM(Identifier.withDefaultNamespace("crafted")), + DROP(Identifier.withDefaultNamespace("dropped")), + KILL_ENTITY(Identifier.withDefaultNamespace("killed")), + ENTITY_KILLED_BY(Identifier.withDefaultNamespace("killed_by")), + MINE_BLOCK(Identifier.withDefaultNamespace("mined")), + PICKUP(Identifier.withDefaultNamespace("picked_up")), + USE_ITEM(Identifier.withDefaultNamespace("used")); // End generate - CraftStatisticType - private final ResourceLocation minecraftKey; + private final Identifier minecraftKey; private final org.bukkit.Statistic bukkit; - private static final BiMap statistics; + private static final BiMap statistics; static { - ImmutableBiMap.Builder statisticBuilder = ImmutableBiMap.builder(); + ImmutableBiMap.Builder statisticBuilder = ImmutableBiMap.builder(); for (CraftStatistic statistic : CraftStatistic.values()) { statisticBuilder.put(statistic.minecraftKey, statistic.bukkit); } @@ -123,7 +124,7 @@ public enum CraftStatistic { statistics = statisticBuilder.build(); } - private CraftStatistic(ResourceLocation minecraftKey) { + private CraftStatistic(Identifier minecraftKey) { this.minecraftKey = minecraftKey; this.bukkit = org.bukkit.Statistic.valueOf(this.name()); @@ -133,10 +134,10 @@ private CraftStatistic(ResourceLocation minecraftKey) { public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Stat statistic) { Preconditions.checkArgument(statistic != null, "NMS Statistic cannot be null"); Registry statRegistry = statistic.getType().getRegistry(); - ResourceLocation nmsKey = BuiltInRegistries.STAT_TYPE.getKey(statistic.getType()); + Identifier nmsKey = BuiltInRegistries.STAT_TYPE.getKey(statistic.getType()); if (statRegistry == BuiltInRegistries.CUSTOM_STAT) { - nmsKey = (ResourceLocation) statistic.getValue(); + nmsKey = (Identifier) statistic.getValue(); } return statistics.get(nmsKey); @@ -145,7 +146,7 @@ public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Stat nms = Stats.CUSTOM.get(statistics.inverse().get(bukkit)); + net.minecraft.stats.Stat nms = Stats.CUSTOM.get(statistics.inverse().get(bukkit)); Preconditions.checkArgument(nms != null, "NMS Statistic %s does not exist", bukkit); return nms; 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 e92827b83d2c..5d1afba644e0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -7,18 +7,17 @@ import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; import io.papermc.paper.FeatureHooks; +import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilder; +import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilderImpl; import io.papermc.paper.raytracing.RayTraceTarget; import io.papermc.paper.registry.RegistryAccess; import io.papermc.paper.registry.RegistryKey; -import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilder; -import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilderImpl; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -32,6 +31,7 @@ import java.util.stream.Collectors; import net.kyori.adventure.pointer.PointersSupplier; import net.kyori.adventure.util.TriState; +import net.minecraft.SharedConstants; import net.minecraft.core.BlockPos; import net.minecraft.core.GlobalPos; import net.minecraft.core.Holder; @@ -44,8 +44,8 @@ import net.minecraft.network.protocol.game.ClientboundSetTimePacket; import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket; import net.minecraft.network.protocol.game.ClientboundSoundPacket; +import net.minecraft.resources.Identifier; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.DistanceManager; @@ -57,6 +57,9 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; +import net.minecraft.world.attribute.BedRule; +import net.minecraft.util.NullOps; +import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LightningBolt; @@ -66,13 +69,14 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.GameRules; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ImposterProtoChunk; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.status.ChunkStatus; +import net.minecraft.world.level.gamerules.GameRule; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.LevelResource; @@ -87,7 +91,6 @@ import org.bukkit.Difficulty; import org.bukkit.Effect; import org.bukkit.FluidCollisionMode; -import org.bukkit.GameRule; import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.bukkit.Particle; @@ -109,6 +112,7 @@ import org.bukkit.craftbukkit.boss.CraftDragonBattle; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.generator.structure.CraftGeneratedStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -345,7 +349,7 @@ private boolean setSpawnLocation(int x, int y, int z, float yaw, float pitch) { this.world.serverLevelData.setSpawn( new LevelData.RespawnData( GlobalPos.of( - ResourceKey.create(Registries.DIMENSION, this.world.dimension().location()), + ResourceKey.create(Registries.DIMENSION, this.world.dimension().identifier()), new BlockPos(x, y, z) ), Mth.wrapDegrees(yaw), @@ -690,7 +694,7 @@ public T spawnArrow(Location location, Vector directio Preconditions.checkArgument(direction != null, "Vector cannot be null"); Preconditions.checkArgument(clazz != null, "clazz Entity for the arrow cannot be null"); - net.minecraft.world.entity.projectile.AbstractArrow arrow; + net.minecraft.world.entity.projectile.arrow.AbstractArrow arrow; if (TippedArrow.class.isAssignableFrom(clazz)) { arrow = EntityType.ARROW.create(this.world, EntitySpawnReason.COMMAND); ((Arrow) arrow.getBukkitEntity()).setBasePotionType(PotionType.WATER); @@ -786,7 +790,7 @@ public UUID getUID() { @Override public NamespacedKey getKey() { - return CraftNamespacedKey.fromMinecraft(this.world.dimension().location()); + return CraftNamespacedKey.fromMinecraft(this.world.dimension().identifier()); } @Override @@ -796,15 +800,15 @@ public String toString() { @Override public long getTime() { - long time = this.getFullTime() % Level.TICKS_PER_DAY; - if (time < 0) time += Level.TICKS_PER_DAY; + long time = this.getFullTime() % SharedConstants.TICKS_PER_GAME_DAY; + if (time < 0) time += SharedConstants.TICKS_PER_GAME_DAY; return time; } @Override public void setTime(long time) { - long margin = (time - this.getFullTime()) % Level.TICKS_PER_DAY; - if (margin < 0) margin += Level.TICKS_PER_DAY; + long margin = (time - this.getFullTime()) % SharedConstants.TICKS_PER_GAME_DAY; + if (margin < 0) margin += SharedConstants.TICKS_PER_GAME_DAY; this.setFullTime(this.getFullTime() + margin); } @@ -829,7 +833,7 @@ public void setFullTime(long time) { CraftPlayer cp = (CraftPlayer) p; if (cp.getHandle().connection == null) continue; - cp.getHandle().connection.send(new ClientboundSetTimePacket(cp.getHandle().level().getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().relativeTime && cp.getHandle().level().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); + cp.getHandle().connection.send(new ClientboundSetTimePacket(cp.getHandle().level().getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().relativeTime && cp.getHandle().level().getGameRules().get(GameRules.ADVANCE_TIME))); } } @@ -1245,12 +1249,12 @@ public long getSeed() { @Override public boolean getPVP() { - return this.world.pvpMode.toBooleanOrElseGet(() -> this.world.getGameRules().getBoolean(GameRules.RULE_PVP)); + return this.world.pvpMode.toBooleanOrElseGet(() -> this.world.getGameRules().get(GameRules.PVP)); } @Override public void setPVP(boolean pvp) { - if (this.world.getGameRules().getBoolean(GameRules.RULE_PVP) == pvp) { + if (this.world.getGameRules().get(GameRules.PVP) == pvp) { return; } this.world.pvpMode = TriState.byBoolean(pvp); @@ -1367,12 +1371,13 @@ public int getLogicalHeight() { @Override public boolean isNatural() { - return this.world.dimensionType().natural(); + throw new UnsupportedOperationException("// TODO - snapshot"); } @Override public boolean isBedWorks() { - return this.world.dimensionType().bedWorks(); + BedRule bedRule = this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE); + return !bedRule.explodes() && bedRule.canSleep().test(this.world); } @Override @@ -1387,22 +1392,24 @@ public boolean hasCeiling() { @Override public boolean isPiglinSafe() { - return this.world.dimensionType().piglinSafe(); + return !this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.PIGLINS_ZOMBIFY); } @Override public boolean isRespawnAnchorWorks() { - return this.world.dimensionType().respawnAnchorWorks(); + return this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.RESPAWN_ANCHOR_WORKS); } @Override public boolean hasRaids() { - return this.world.dimensionType().hasRaids(); + return this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.CAN_START_RAID); } @Override public boolean isUltraWarm() { - return this.world.dimensionType().ultraWarm(); + return this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.WATER_EVAPORATES) + && this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.FAST_LAVA) + && this.world.environmentAttributes().getDimensionValue(EnvironmentAttributes.DEFAULT_DRIPSTONE_PARTICLE).equals(ParticleTypes.DRIPPING_DRIPSTONE_LAVA); } @Override @@ -1570,7 +1577,7 @@ public void playSound(Location loc, String sound, org.bukkit.SoundCategory categ double y = loc.getY(); double z = loc.getZ(); - ClientboundSoundPacket packet = new ClientboundSoundPacket(Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), SoundSource.valueOf(category.name()), x, y, z, volume, pitch, seed); + ClientboundSoundPacket packet = new ClientboundSoundPacket(Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), SoundSource.valueOf(category.name()), x, y, z, volume, pitch, seed); this.world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet); } @@ -1610,7 +1617,7 @@ public void playSound(Entity entity, String sound, org.bukkit.SoundCategory cate org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; - ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); + ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); ChunkMap.TrackedEntity entityTracker = this.getHandle().getChunkSource().chunkMap.entityMap.get(entity.getEntityId()); if (entityTracker != null) { entityTracker.sendToTrackingPlayersAndSelf(packet); @@ -1644,43 +1651,6 @@ private java.util.function.BiConsumer, } // Paper end - Adventure - private Map> gamerules; - public synchronized Map> getGameRulesNMS() { - if (this.gamerules != null) { - return this.gamerules; - } - - return this.gamerules = CraftWorld.getGameRulesNMS(this.getHandle().getGameRules()); - } - - public static Map> getGameRulesNMS(GameRules gameRules) { - Map> gamerules = new HashMap<>(); - gameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { - @Override - public > void visit(GameRules.Key key, GameRules.Type type) { - gamerules.put(key.getId(), key); - } - }); - return gamerules; - } - - private Map> gameruleDefinitions; - public synchronized Map> getGameRuleDefinitions() { - if (this.gameruleDefinitions != null) { - return this.gameruleDefinitions; - } - - Map> gameruleDefinitions = new HashMap<>(); - this.getHandle().getGameRules().visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() { - @Override - public > void visit(GameRules.Key key, GameRules.Type type) { - gameruleDefinitions.put(key.getId(), type); - } - }); - - return this.gameruleDefinitions = gameruleDefinitions; - } - @Override public String getGameRuleValue(String rule) { // In method contract for some reason @@ -1688,87 +1658,99 @@ public String getGameRuleValue(String rule) { return null; } - GameRules.Value value = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule)); - return value != null ? value.toString() : ""; + org.bukkit.GameRule bukkit = org.bukkit.GameRule.getByName(rule); + if (bukkit == null) { + throw new IllegalArgumentException("Unknown gamerule: " + rule); + } + + return this.getHandle().getGameRules().getAsString(CraftGameRule.bukkitToMinecraft(bukkit)); } + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public boolean setGameRuleValue(String rule, String value) { // No null values allowed if (rule == null || value == null) return false; - if (!this.isGameRule(rule)) return false; - // Paper start - Add WorldGameRuleChangeEvent - GameRule gameRule = GameRule.getByName(rule); - io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, gameRule, value); - if (!event.callEvent()) return false; - // Paper end - Add WorldGameRuleChangeEvent + org.bukkit.GameRule bukkit = org.bukkit.GameRule.getByName(rule); + if (bukkit == null) { + return false; + } - GameRules.Value handle = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule)); - handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent - handle.onChanged(this.getHandle()); - return true; + GameRule nms = CraftGameRule.bukkitToMinecraft(bukkit); + if (!this.getHandle().getGameRules().rules.has(nms)) { + return false; + } + return !CraftEventFactory.handleGameRuleSet(nms, nms.deserialize(value).getOrThrow(), this.getHandle(), null).cancelled(); } @Override public String[] getGameRules() { - return this.getGameRulesNMS().keySet().toArray(new String[this.getGameRulesNMS().size()]); + return this.getHandle().getGameRules().availableRules() + .map(GameRule::id) + .toArray(String[]::new); } @Override public boolean isGameRule(String rule) { Preconditions.checkArgument(rule != null, "String rule cannot be null"); Preconditions.checkArgument(!rule.isEmpty(), "String rule cannot be empty"); - return this.getGameRulesNMS().containsKey(rule); + + org.bukkit.GameRule bukkit = org.bukkit.GameRule.getByName(rule); + if (bukkit == null) { + return false; + } + + return this.getHandle().getGameRules().rules.has(CraftGameRule.bukkitToMinecraft(bukkit)); + } + + public static T shimLegacyValue(T value, org.bukkit.GameRule gameRule){ + //noinspection rawtypes unchecked + if (gameRule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { + //noinspection unchecked + return (T) legacyGameRuleWrapper.getToLegacyFromModern().apply(value); + } + + return value; } @Override - public T getGameRuleValue(GameRule rule) { + public @Nullable T getGameRuleValue(org.bukkit.@NotNull GameRule rule) { Preconditions.checkArgument(rule != null, "GameRule cannot be null"); - GameRules.Key> key = this.getGameRulesNMS().get(rule.getName()); - Preconditions.checkArgument(key != null, "GameRule '%s' is not available", rule.getName()); - return this.getGameRuleResult(rule, this.getHandle().getGameRules().getRule(key)); + T value = this.getHandle().getGameRules().get(CraftGameRule.bukkitToMinecraft(rule)); + return shimLegacyValue(value, rule); } @Override - public T getGameRuleDefault(GameRule rule) { + public @Nullable T getGameRuleDefault(org.bukkit.@NotNull GameRule rule) { Preconditions.checkArgument(rule != null, "GameRule cannot be null"); - GameRules.Type type = this.getGameRuleDefinitions().get(rule.getName()); - Preconditions.checkArgument(type != null, "GameRule '%s' is not available", rule.getName()); + T value = CraftGameRule.bukkitToMinecraft(rule).defaultValue(); - return this.getGameRuleResult(rule, type.createRule()); + return shimLegacyValue(value, rule); } @Override - public boolean setGameRule(GameRule rule, T newValue) { + public boolean setGameRule(org.bukkit.@NotNull GameRule rule, @NotNull T newValue) { Preconditions.checkArgument(rule != null, "GameRule cannot be null"); Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); - if (!this.isGameRule(rule.getName())) return false; - // Paper start - Add WorldGameRuleChangeEvent - io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, rule, String.valueOf(newValue)); - if (!event.callEvent()) return false; - // Paper end - Add WorldGameRuleChangeEvent - - GameRules.Value handle = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule.getName())); - handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent - handle.onChanged(this.getHandle()); - return true; - } - - private T getGameRuleResult(GameRule rule, GameRules.Value value) { - if (value == null) { - return null; + GameRule<@NotNull T> nms = CraftGameRule.bukkitToMinecraft(rule); + if (!this.getHandle().getGameRules().rules.has(nms)) { + return false; } - if (value instanceof GameRules.BooleanValue) { - return rule.getType().cast(((GameRules.BooleanValue) value).get()); - } else if (value instanceof GameRules.IntegerValue) { - return rule.getType().cast(value.getCommandResult()); + final T convertedValue; + if (rule instanceof CraftGameRule.LegacyGameRuleWrapper legacyGameRuleWrapper) { + convertedValue = (T) legacyGameRuleWrapper.getFromLegacyToModern().apply(newValue); } else { - throw new IllegalArgumentException("Invalid GameRule type (" + value + ") for GameRule " + rule.getName()); + nms.valueCodec().encodeStart(NullOps.INSTANCE, newValue).ifError(error -> { + throw CraftGameRule.INVALID_VALUE.apply(newValue.toString(), error); + }); + convertedValue = newValue; } + + return !CraftEventFactory.handleGameRuleSet(nms, convertedValue, this.getHandle(), null).cancelled(); } @Override @@ -1882,7 +1864,7 @@ private StructureSearchResult locateNearestStructure(Location origin, List getStructures(int x, int z, Structure stru Preconditions.checkArgument(structure != null, "Structure cannot be null"); net.minecraft.core.Registry registry = CraftRegistry.getMinecraftRegistry(Registries.STRUCTURE); - ResourceLocation key = registry.getKey(CraftStructure.bukkitToMinecraft(structure)); + Identifier key = registry.getKey(CraftStructure.bukkitToMinecraft(structure)); return this.getStructures(x, z, struct -> registry.getKey(struct).equals(key)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java index d3bb33464742..e52f412d01cf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java @@ -1,7 +1,6 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; -import java.util.concurrent.TimeUnit; import net.minecraft.core.BlockPos; import org.bukkit.Location; import org.bukkit.World; @@ -39,22 +38,18 @@ public double getSize() { @Override public void setSize(double newSize) { - this.setSize(newSize, 0L); - } - - @Override - public void setSize(double newSize, long time) { - this.setSize(Math.min(this.getMaxSize(), Math.max(1.0D, newSize)), TimeUnit.SECONDS, Math.min(9223372036854775L, Math.max(0L, time))); + Preconditions.checkArgument(newSize >= 1.0D && newSize <= this.getMaxSize(), "newSize must be between 1.0D and %s", this.getMaxSize()); + this.handle.setSize(newSize); } @Override - public void setSize(double newSize, TimeUnit unit, long time) { - Preconditions.checkArgument(unit != null, "TimeUnit cannot be null."); - Preconditions.checkArgument(time >= 0, "time cannot be lower than 0"); + public void changeSize(double newSize, long ticks) { + Preconditions.checkArgument(ticks >= 0 && ticks <= Integer.MAX_VALUE, "ticks must be between 0-%s", Integer.MAX_VALUE); Preconditions.checkArgument(newSize >= 1.0D && newSize <= this.getMaxSize(), "newSize must be between 1.0D and %s", this.getMaxSize()); - if (time > 0L) { - this.handle.lerpSizeBetween(this.handle.getSize(), newSize, unit.toMillis(time)); + if (ticks > 0L) { + final long startTime = (this.getWorld() != null) ? this.getWorld().getGameTime() : 0; // Virtual Borders don't have a World + this.handle.lerpSizeBetween(this.handle.getSize(), newSize, ticks, startTime); } else { this.handle.setSize(newSize); } @@ -102,13 +97,15 @@ public void setDamageAmount(double damage) { } @Override - public int getWarningTime() { + public int getWarningTimeTicks() { return this.handle.getWarningTime(); } @Override - public void setWarningTime(int time) { - this.handle.setWarningTime(time); + public void setWarningTimeTicks(final int ticks) { + Preconditions.checkArgument(ticks >= 0, "ticks cannot be lower than 0"); + + this.handle.setWarningTime(ticks); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java index bdb4d0b55a41..c1987c186928 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java @@ -16,10 +16,6 @@ public class CraftAttribute extends OldEnumHolderable minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.ATTRIBUTE); } @@ -38,10 +34,6 @@ public static Attribute stringToBukkit(String string) { return CraftRegistry.get(RegistryKey.ATTRIBUTE, key, ApiVersion.CURRENT); } - public static net.minecraft.world.entity.ai.attributes.Attribute bukkitToMinecraft(Attribute bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Attribute bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } 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 c00a267eaa5c..6b5853ced761 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 @@ -15,7 +15,7 @@ public final class CapturedBlockState extends CraftBlockState { private final boolean treeBlock; - public CapturedBlockState(Block block, int capturedFlags, boolean treeBlock) { + public CapturedBlockState(Block block, @net.minecraft.world.level.block.Block.UpdateFlags int capturedFlags, boolean treeBlock) { super(block, capturedFlags); this.treeBlock = treeBlock; @@ -38,7 +38,7 @@ public boolean update(boolean force, boolean applyPhysics) { } @Override - public boolean place(int flags) { + public boolean place(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { boolean result = super.place(flags); this.addBees(); @@ -74,7 +74,7 @@ public CapturedBlockState copy(Location location) { return new CapturedBlockState(this, location); } - public static CapturedBlockState getTreeBlockState(Level world, BlockPos pos, int flag) { - return new CapturedBlockState(CraftBlock.at(world, pos), flag, true); + public static CapturedBlockState getTreeBlockState(Level world, BlockPos pos, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { + return new CapturedBlockState(CraftBlock.at(world, pos), flags, true); } } 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 61d1bf58204c..687311a9224d 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 @@ -4,9 +4,9 @@ import java.util.Collection; import java.util.Collections; import java.util.Optional; -import net.minecraft.advancements.critereon.DataComponentMatchers; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java index 7dd35a6d0c08..14e6fb69e9af 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.block; import io.papermc.paper.util.OldEnumHolderable; +import java.util.Objects; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import org.bukkit.NamespacedKey; @@ -9,29 +10,16 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; -import java.util.Objects; @NullMarked public class CraftBiome extends OldEnumHolderable implements Biome { private static int count = 0; - public static Biome minecraftToBukkit(net.minecraft.world.level.biome.Biome minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.BIOME); - } - public static Biome minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.BIOME); } - public static net.minecraft.world.level.biome.@Nullable Biome bukkitToMinecraft(Biome bukkit) { - if (bukkit == Biome.CUSTOM) { - return null; - } - - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static @Nullable Holder bukkitToMinecraftHolder(Biome bukkit) { if (bukkit == Biome.CUSTOM) { return null; @@ -45,7 +33,7 @@ public CraftBiome(final Holder holder) { /** * Implementation for the deprecated, API only, CUSTOM biome. - * As per {@link #bukkitToMinecraft(Biome)} and {@link #bukkitToMinecraftHolder(Biome)} it cannot be + * As per {@link #bukkitToMinecraftHolder(Biome)} it cannot be * converted into an internal biome and only serves backwards compatibility reasons. */ @Deprecated(forRemoval = true, since = "1.21.5") 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 73365f4b90e8..31e665388bc6 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 @@ -154,7 +154,7 @@ public void setData(final byte data, boolean applyPhysics) { } } - private void setData(final byte data, int flags) { + private void setData(final byte data, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flags); } @@ -210,7 +210,7 @@ public static boolean setBlockState(LevelAccessor world, BlockPos pos, net.minec return world.setBlock(pos, newState, net.minecraft.world.level.block.Block.UPDATE_ALL); } else { boolean success = world.setBlock(pos, newState, - net.minecraft.world.level.block.Block.UPDATE_CLIENTS | + 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) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index 5d4faad9df48..26feb76c5263 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -201,7 +201,7 @@ public boolean update(boolean force, boolean applyPhysics) { } @Override - public boolean place(int flags) { + public boolean place(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { boolean result = super.place(flags); this.getWorldHandle().getBlockEntity(this.getPosition(), this.blockEntity.getType()).ifPresent(blockEntity -> { 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 196835bdf95b..3036f3fa8b58 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 @@ -28,6 +28,7 @@ public class CraftBlockState implements BlockState { protected final CraftWorld world; private final BlockPos position; protected net.minecraft.world.level.block.state.BlockState data; + @net.minecraft.world.level.block.Block.UpdateFlags protected int capturedFlags; // todo move out of this class private WeakReference weakWorld; @@ -39,7 +40,7 @@ protected CraftBlockState(final Block block) { } @Deprecated - protected CraftBlockState(final Block block, int capturedFlags) { + protected CraftBlockState(final Block block, @net.minecraft.world.level.block.Block.UpdateFlags int capturedFlags) { this(block); this.capturedFlags = capturedFlags; } @@ -181,11 +182,11 @@ public Material getType() { return this.data.getBukkitMaterial(); } - public void setFlags(int flags) { + public void setFlags(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { this.capturedFlags = flags; } - public int getFlags() { + public @net.minecraft.world.level.block.Block.UpdateFlags int getFlags() { return this.capturedFlags; } @@ -244,7 +245,7 @@ public boolean update(boolean force, boolean applyPhysics) { } // used when the flags matter for non API usage - public boolean place(int flags) { + public boolean place(@net.minecraft.world.level.block.Block.UpdateFlags int flags) { if (!this.isPlaced()) { return false; } 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 cdb594244993..075921649b8a 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 @@ -2,9 +2,9 @@ import java.util.Collections; import java.util.Optional; -import net.minecraft.advancements.critereon.DataComponentMatchers; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.component.DataComponentExactPredicate; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index b652f93063f7..a8b57a406b9f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -74,7 +74,7 @@ public void setCookTimeTotal(int cookTimeTotal) { public Map, Integer> getRecipesUsed() { ImmutableMap.Builder, Integer> recipesUsed = ImmutableMap.builder(); this.getSnapshot().recipesUsed.reference2IntEntrySet().fastForEach(entrySet -> { - Recipe recipe = Bukkit.getRecipe(CraftNamespacedKey.fromMinecraft(entrySet.getKey().location())); + Recipe recipe = Bukkit.getRecipe(CraftNamespacedKey.fromMinecraft(entrySet.getKey().identifier())); if (recipe instanceof CookingRecipe cookingRecipe) { recipesUsed.put(cookingRecipe, entrySet.getValue()); } @@ -106,17 +106,17 @@ public void setCookSpeedMultiplier(double multiplier) { @Override public int getRecipeUsedCount(org.bukkit.NamespacedKey furnaceRecipe) { - return this.getSnapshot().recipesUsed.getInt(io.papermc.paper.util.MCUtil.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); + return this.getSnapshot().recipesUsed.getInt(CraftNamespacedKey.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); } @Override public boolean hasRecipeUsedCount(org.bukkit.NamespacedKey furnaceRecipe) { - return this.getSnapshot().recipesUsed.containsKey(io.papermc.paper.util.MCUtil.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); + return this.getSnapshot().recipesUsed.containsKey(CraftNamespacedKey.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe)); } @Override public void setRecipeUsedCount(org.bukkit.inventory.CookingRecipe furnaceRecipe, int count) { - final var location = io.papermc.paper.util.MCUtil.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe.getKey()); + final var location = CraftNamespacedKey.toResourceKey(net.minecraft.core.registries.Registries.RECIPE, furnaceRecipe.getKey()); java.util.Optional> nmsRecipe = (this.isPlaced() ? this.world.getHandle().recipeAccess() : net.minecraft.server.MinecraftServer.getServer().getRecipeManager()).byKey(location); com.google.common.base.Preconditions.checkArgument(nmsRecipe.isPresent() && nmsRecipe.get().value() instanceof net.minecraft.world.item.crafting.AbstractCookingRecipe, furnaceRecipe.getKey() + " is not recognized as a valid and registered furnace recipe"); if (count > 0) { 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 ed3fcbbaaaa2..f044c303075f 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 @@ -7,8 +7,8 @@ import io.papermc.paper.adventure.PaperAdventure; import io.papermc.paper.datacomponent.item.PaperResolvableProfile; import net.kyori.adventure.text.Component; -import net.minecraft.Util; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Util; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.players.NameAndId; import net.minecraft.world.entity.player.PlayerSkin; @@ -163,7 +163,7 @@ public void setOwnerProfile(PlayerProfile profile) { @Override public NamespacedKey getNoteBlockSound() { - ResourceLocation key = this.getSnapshot().getNoteBlockSound(); + Identifier key = this.getSnapshot().getNoteBlockSound(); return (key != null) ? CraftNamespacedKey.fromMinecraft(key) : null; } 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 1d87f637d262..b7f08dc4133b 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 @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.block; import com.google.common.base.Preconditions; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.entity.StructureBlockEntity; import net.minecraft.world.level.block.state.properties.StructureMode; @@ -192,7 +193,7 @@ protected void applyTo(StructureBlockEntity blockEntity) { // From StructureBlockEntity#setMode(BlockPropertyStructureMode) net.minecraft.world.level.block.state.BlockState state = access.getBlockState(this.getPosition()); if (state.is(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) { - access.setBlock(this.getPosition(), state.setValue(net.minecraft.world.level.block.StructureBlock.MODE, blockEntity.getMode()), 2); + access.setBlock(this.getPosition(), state.setValue(net.minecraft.world.level.block.StructureBlock.MODE, blockEntity.getMode()), Block.UPDATE_CLIENTS); } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java index fd6acd6acf4e..f265a266d988 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/banner/CraftPatternType.java @@ -11,18 +11,10 @@ public class CraftPatternType extends OldEnumHolderable minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.BANNER_PATTERN); } - public static BannerPattern bukkitToMinecraft(PatternType bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(PatternType bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } 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 66cebe94bac3..68bb1b852273 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 @@ -579,7 +579,7 @@ public static CraftBlockData newData(BlockType blockType, String data) { if (blockType != null) { Block block = CraftBlockType.bukkitToMinecraftNew(blockType); if (block != null) { - net.minecraft.resources.ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block); + net.minecraft.resources.Identifier key = BuiltInRegistries.BLOCK.getKey(block); data = data == null ? key.toString() : key + data; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index 6f2c63dd2eb7..1eb5ad45103a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -75,7 +75,8 @@ public static CommandSourceStack getListener(CommandSender sender) { if (sender instanceof CraftEntity entity) { if (sender instanceof CommandMinecart) { return ((CraftMinecartCommand) sender).getHandle().getCommandBlock().createCommandSourceStack( - ((CraftMinecartCommand) sender).getHandle().getCommandBlock().createSource() + (ServerLevel) entity.getHandle().level(), + ((CraftMinecartCommand) sender).getHandle().getCommandBlock().createSource((ServerLevel) entity.getHandle().level()) ); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java index 7e13f9227ca1..38b07b508205 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/configuration/ConfigSerializationUtil.java @@ -10,7 +10,7 @@ import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.craftbukkit.CraftRegistry; @@ -47,14 +47,14 @@ public static T getObject(Class clazz, Map map, String key, boolean public static void setHolderSet(Map result, String key, HolderSet holders) { holders.unwrap() .ifLeft(tag -> result.put(key, "#" + tag.location().toString())) // Tag - .ifRight(list -> result.put(key, list.stream().map((entry) -> entry.unwrapKey().orElseThrow().location().toString()).toList())); // List + .ifRight(list -> result.put(key, list.stream().map((entry) -> entry.unwrapKey().orElseThrow().identifier().toString()).toList())); // List } public static HolderSet getHolderSet(Object from, ResourceKey> registryKey) { Registry registry = CraftRegistry.getMinecraftRegistry(registryKey); if (from instanceof String parseString && parseString.startsWith("#")) { // Tag parseString = parseString.substring(1); - ResourceLocation key = ResourceLocation.tryParse(parseString); + Identifier key = Identifier.tryParse(parseString); if (key != null) { Optional> tag = registry.get(TagKey.create(registryKey, key)); if (tag.isPresent()) { @@ -65,7 +65,7 @@ public static HolderSet getHolderSet(Object from, ResourceKey List> holderList = new ArrayList<>(parseList.size()); for (Object entry : parseList) { - ResourceLocation key = ResourceLocation.tryParse(entry.toString()); + Identifier key = Identifier.tryParse(entry.toString()); if (key == null) { continue; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java index ecd0ef7abc5d..1f3f7f83fd24 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java @@ -81,12 +81,4 @@ public static DamageType minecraftHolderToBukkit(Holder bukkitToMinecraftHolder(DamageType bukkitDamageType) { return CraftRegistry.bukkitToMinecraftHolder(bukkitDamageType); } - - public static net.minecraft.world.damagesource.DamageType bukkitToMinecraft(DamageType bukkitDamageType) { - return CraftRegistry.bukkitToMinecraft(bukkitDamageType); - } - - public static DamageType minecraftToBukkit(net.minecraft.world.damagesource.DamageType minecraftDamageType) { - return CraftRegistry.minecraftToBukkit(minecraftDamageType, Registries.DAMAGE_TYPE); - } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 286ed00c01bc..45b70a28e0c3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.util.Holderable; import java.util.Locale; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.tags.EnchantmentTags; @@ -20,16 +20,8 @@ public class CraftEnchantment extends Enchantment implements Holderable { - public static Enchantment minecraftToBukkit(net.minecraft.world.item.enchantment.Enchantment minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.ENCHANTMENT); - } - public static Enchantment minecraftHolderToBukkit(Holder minecraft) { - return CraftEnchantment.minecraftToBukkit(minecraft.value()); - } - - public static net.minecraft.world.item.enchantment.Enchantment bukkitToMinecraft(Enchantment bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.ENCHANTMENT); } public static Holder bukkitToMinecraftHolder(Enchantment bukkit) { @@ -236,7 +228,7 @@ public io.papermc.paper.registry.set.RegistryKeySet { // Paper +public abstract class CraftAbstractSkeleton extends CraftMonster implements AbstractSkeleton, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftAbstractSkeleton(CraftServer server, net.minecraft.world.entity.monster.AbstractSkeleton entity) { + public CraftAbstractSkeleton(CraftServer server, net.minecraft.world.entity.monster.skeleton.AbstractSkeleton entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.AbstractSkeleton getHandle() { - return (net.minecraft.world.entity.monster.AbstractSkeleton) this.entity; + public net.minecraft.world.entity.monster.skeleton.AbstractSkeleton getHandle() { + return (net.minecraft.world.entity.monster.skeleton.AbstractSkeleton) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java index 11a72607c484..6add47c0e3e0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.npc.villager.Villager; import net.minecraft.world.item.trading.Merchant; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; @@ -11,12 +11,12 @@ public abstract class CraftAbstractVillager extends CraftAgeable implements CraftMerchant, AbstractVillager, InventoryHolder { - public CraftAbstractVillager(CraftServer server, net.minecraft.world.entity.npc.AbstractVillager entity) { + public CraftAbstractVillager(CraftServer server, net.minecraft.world.entity.npc.villager.AbstractVillager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.npc.AbstractVillager getHandle() { + public net.minecraft.world.entity.npc.villager.AbstractVillager getHandle() { return (Villager) this.entity; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java index df1e31c60f3d..ebb865373672 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java @@ -5,13 +5,13 @@ import org.bukkit.event.entity.EntityRemoveEvent; public abstract class CraftAbstractWindCharge extends CraftFireball implements AbstractWindCharge { - public CraftAbstractWindCharge(CraftServer server, net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge entity) { + public CraftAbstractWindCharge(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge getHandle() { - return (net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 7926dca4e40f..332ae05a221a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -20,13 +20,13 @@ public class CraftArrow extends CraftAbstractArrow implements Arrow { - public CraftArrow(CraftServer server, net.minecraft.world.entity.projectile.Arrow entity) { + public CraftArrow(CraftServer server, net.minecraft.world.entity.projectile.arrow.Arrow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.Arrow getHandle() { - return (net.minecraft.world.entity.projectile.Arrow) this.entity; + public net.minecraft.world.entity.projectile.arrow.Arrow getHandle() { + return (net.minecraft.world.entity.projectile.arrow.Arrow) this.entity; } @Override @@ -110,7 +110,7 @@ public PotionType getBasePotionType() { @Override public void setColor(Color color) { - int colorRGB = (color == null) ? net.minecraft.world.entity.projectile.Arrow.NO_EFFECT_COLOR : color.asARGB(); // Paper + int colorRGB = (color == null) ? net.minecraft.world.entity.projectile.arrow.Arrow.NO_EFFECT_COLOR : color.asARGB(); // Paper PotionContents old = this.getHandle().getPotionContents(); this.getHandle().setPotionContents(new PotionContents(old.potion(), Optional.of(colorRGB), old.customEffects(), old.customName())); } @@ -118,7 +118,7 @@ public void setColor(Color color) { @Override public Color getColor() { int color = this.getHandle().getColor(); // Paper - if (color == net.minecraft.world.entity.projectile.Arrow.NO_EFFECT_COLOR) { // Paper + if (color == net.minecraft.world.entity.projectile.arrow.Arrow.NO_EFFECT_COLOR) { // Paper return null; } return Color.fromARGB(color); // Paper 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 1016d7626114..7602f93e1f61 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 @@ -9,13 +9,13 @@ public class CraftBee extends CraftAnimals implements Bee { - public CraftBee(CraftServer server, net.minecraft.world.entity.animal.Bee entity) { + public CraftBee(CraftServer server, net.minecraft.world.entity.animal.bee.Bee entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Bee getHandle() { - return (net.minecraft.world.entity.animal.Bee) this.entity; + public net.minecraft.world.entity.animal.bee.Bee getHandle() { + return (net.minecraft.world.entity.animal.bee.Bee) this.entity; } @Override @@ -64,12 +64,12 @@ public void setHasStung(boolean stung) { @Override public int getAnger() { - return this.getHandle().getRemainingPersistentAngerTime(); + return (int) (this.getHandle().getPersistentAngerEndTime() - this.getHandle().level().getGameTime()); } @Override public void setAnger(int anger) { - this.getHandle().setRemainingPersistentAngerTime(anger); + this.getHandle().setTimeToRemainAngry(anger); } @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 aba0a70af908..02a4a8641050 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,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.TreeSpecies; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Boat; @@ -89,7 +89,7 @@ public org.bukkit.Material getBoatMaterial() { @Override public Status getStatus() { // Paper start - Fix NPE on Boat getStatus - final net.minecraft.world.entity.vehicle.AbstractBoat handle = this.getHandle(); + 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 @@ -142,7 +142,7 @@ public static Boat.Type boatTypeFromNms(EntityType boatType) { throw new EnumConstantNotPresentException(Type.class, boatType.toString()); } - public static Status boatStatusFromNms(net.minecraft.world.entity.vehicle.AbstractBoat.Status enumStatus) { // Paper - remap fixes + public static Status boatStatusFromNms(net.minecraft.world.entity.vehicle.boat.AbstractBoat.Status enumStatus) { // Paper - remap fixes return switch (enumStatus) { default -> throw new EnumConstantNotPresentException(Status.class, enumStatus.name()); case IN_AIR -> Status.IN_AIR; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java index 3db0be03f46d..a2eab26f3b79 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java @@ -6,13 +6,13 @@ public class CraftBogged extends CraftAbstractSkeleton implements Bogged, io.papermc.paper.entity.PaperShearable { // Paper - Shear API - public CraftBogged(CraftServer server, net.minecraft.world.entity.monster.Bogged entity) { + public CraftBogged(CraftServer server, net.minecraft.world.entity.monster.skeleton.Bogged entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Bogged getHandle() { - return (net.minecraft.world.entity.monster.Bogged) this.entity; + public net.minecraft.world.entity.monster.skeleton.Bogged getHandle() { + return (net.minecraft.world.entity.monster.skeleton.Bogged) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java index 59dd96368973..416d0c45a702 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java @@ -4,12 +4,12 @@ import org.bukkit.entity.BreezeWindCharge; public class CraftBreezeWindCharge extends CraftAbstractWindCharge implements BreezeWindCharge { - public CraftBreezeWindCharge(CraftServer server, net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge entity) { + public CraftBreezeWindCharge(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge getHandle() { - return (net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.BreezeWindCharge) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamelHusk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamelHusk.java new file mode 100644 index 000000000000..e0008d4708bc --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCamelHusk.java @@ -0,0 +1,16 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.animal.camel.CamelHusk; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; +import org.bukkit.craftbukkit.CraftServer; + +public class CraftCamelHusk extends CraftCamel implements org.bukkit.entity.CamelHusk { + public CraftCamelHusk(final CraftServer server, final CamelHusk entity) { + super(server, entity); + } + + @Override + public CamelHusk getHandle() { + return (CamelHusk) this.entity; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index c3e28e291e7c..0ff5f7417259 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -4,7 +4,7 @@ import io.papermc.paper.util.OldEnumHolderable; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.CatVariant; +import net.minecraft.world.entity.animal.feline.CatVariant; import org.bukkit.DyeColor; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; @@ -12,13 +12,13 @@ public class CraftCat extends CraftTameableAnimal implements Cat { - public CraftCat(CraftServer server, net.minecraft.world.entity.animal.Cat entity) { + public CraftCat(CraftServer server, net.minecraft.world.entity.animal.feline.Cat entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Cat getHandle() { - return (net.minecraft.world.entity.animal.Cat) this.entity; + public net.minecraft.world.entity.animal.feline.Cat getHandle() { + return (net.minecraft.world.entity.animal.feline.Cat) this.entity; } @Override @@ -46,18 +46,10 @@ public void setCollarColor(DyeColor color) { public static class CraftType extends OldEnumHolderable implements Type { private static int count = 0; - public static Type minecraftToBukkit(CatVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.CAT_VARIANT); - } - public static Type minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.CAT_VARIANT); } - public static CatVariant bukkitToMinecraft(Type bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Type bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java index 79907f902734..6e75b9518192 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java @@ -4,12 +4,12 @@ import org.bukkit.entity.CaveSpider; public class CraftCaveSpider extends CraftSpider implements CaveSpider { - public CraftCaveSpider(CraftServer server, net.minecraft.world.entity.monster.CaveSpider entity) { + public CraftCaveSpider(CraftServer server, net.minecraft.world.entity.monster.spider.CaveSpider entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.CaveSpider getHandle() { - return (net.minecraft.world.entity.monster.CaveSpider) this.entity; + public net.minecraft.world.entity.monster.spider.CaveSpider getHandle() { + return (net.minecraft.world.entity.monster.spider.CaveSpider) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java index 22ea11d7ada3..b718a5fa75eb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.inventory.Inventory; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java index d05897695fc3..166dba85fe90 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.horse.AbstractChestedHorse; +import net.minecraft.world.entity.animal.equine.AbstractChestedHorse; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ChestedHorse; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java index 5b1353d87a11..1e015dc87c62 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.HolderableBase; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.ChickenVariant; +import net.minecraft.world.entity.animal.chicken.ChickenVariant; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Chicken; @@ -13,13 +13,13 @@ @NullMarked public class CraftChicken extends CraftAnimals implements Chicken { - public CraftChicken(CraftServer server, net.minecraft.world.entity.animal.Chicken entity) { + public CraftChicken(CraftServer server, net.minecraft.world.entity.animal.chicken.Chicken entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Chicken getHandle() { - return (net.minecraft.world.entity.animal.Chicken) this.entity; + public net.minecraft.world.entity.animal.chicken.Chicken getHandle() { + return (net.minecraft.world.entity.animal.chicken.Chicken) this.entity; } @Override @@ -36,18 +36,10 @@ public void setVariant(Variant variant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(ChickenVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.CHICKEN_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.CHICKEN_VARIANT); } - public static ChickenVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java index ca8c10cca87d..d26545a066a2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java @@ -5,12 +5,12 @@ public class CraftCod extends io.papermc.paper.entity.PaperSchoolableFish implements Cod { // Paper - School Fish API - public CraftCod(CraftServer server, net.minecraft.world.entity.animal.Cod entity) { + public CraftCod(CraftServer server, net.minecraft.world.entity.animal.fish.Cod entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Cod getHandle() { - return (net.minecraft.world.entity.animal.Cod) this.entity; + public net.minecraft.world.entity.animal.fish.Cod getHandle() { + return (net.minecraft.world.entity.animal.fish.Cod) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java index 178cadf023bf..e6d884596d20 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ComplexEntityPart; import org.bukkit.entity.ComplexLivingEntity; 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 0ea9e83df77f..36d838fe5abc 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 @@ -10,13 +10,13 @@ @NullMarked public class CraftCopperGolem extends CraftGolem implements CopperGolem, PaperShearable { - public CraftCopperGolem(final CraftServer server, final net.minecraft.world.entity.animal.coppergolem.CopperGolem entity) { + public CraftCopperGolem(final CraftServer server, final net.minecraft.world.entity.animal.golem.CopperGolem entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.coppergolem.CopperGolem getHandle() { - return (net.minecraft.world.entity.animal.coppergolem.CopperGolem) this.entity; + public net.minecraft.world.entity.animal.golem.CopperGolem getHandle() { + return (net.minecraft.world.entity.animal.golem.CopperGolem) this.entity; } @Override @@ -33,9 +33,9 @@ public void setWeatheringState(final WeatheringCopperState state) { @Override public Oxidizing getOxidizing() { long value = this.getHandle().nextWeatheringTick; - if (value == net.minecraft.world.entity.animal.coppergolem.CopperGolem.UNSET_WEATHERING_TICK) { + if (value == net.minecraft.world.entity.animal.golem.CopperGolem.UNSET_WEATHERING_TICK) { return Oxidizing.unset(); - } else if (value == net.minecraft.world.entity.animal.coppergolem.CopperGolem.IGNORE_WEATHERING_TICK) { + } else if (value == net.minecraft.world.entity.animal.golem.CopperGolem.IGNORE_WEATHERING_TICK) { return Oxidizing.waxed(); } if (value < 0) { @@ -49,8 +49,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.coppergolem.CopperGolem.IGNORE_WEATHERING_TICK; - case Oxidizing.Unset unset -> this.getHandle().nextWeatheringTick = net.minecraft.world.entity.animal.coppergolem.CopperGolem.UNSET_WEATHERING_TICK; + 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.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/CraftCow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java index c93885fdd01e..e0adc2c33c26 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -4,7 +4,7 @@ import io.papermc.paper.registry.HolderableBase; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.animal.CowVariant; +import net.minecraft.world.entity.animal.cow.CowVariant; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Cow; @@ -13,13 +13,13 @@ @NullMarked public class CraftCow extends CraftAbstractCow implements Cow { - public CraftCow(CraftServer server, net.minecraft.world.entity.animal.Cow entity) { + public CraftCow(CraftServer server, net.minecraft.world.entity.animal.cow.Cow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Cow getHandle() { - return (net.minecraft.world.entity.animal.Cow) this.entity; + public net.minecraft.world.entity.animal.cow.Cow getHandle() { + return (net.minecraft.world.entity.animal.cow.Cow) this.entity; } @Override @@ -36,18 +36,10 @@ public void setVariant(Variant variant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(CowVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.COW_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.COW_VARIANT); } - public static CowVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java index 90dcaf8e600d..85669da35584 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java @@ -5,6 +5,8 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Display; import org.bukkit.util.Transformation; +import org.joml.Quaternionf; +import org.joml.Vector3f; public class CraftDisplay extends CraftEntity implements Display { @@ -21,7 +23,7 @@ public net.minecraft.world.entity.Display getHandle() { public Transformation getTransformation() { com.mojang.math.Transformation nms = net.minecraft.world.entity.Display.createTransformation(this.getHandle().getEntityData()); - return new Transformation(nms.getTranslation(), nms.getLeftRotation(), nms.getScale(), nms.getRightRotation()); + return new Transformation(new Vector3f(nms.getTranslation()), new Quaternionf(nms.getLeftRotation()), new Vector3f(nms.getScale()), new Quaternionf(nms.getRightRotation())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java index 0400e181e4cb..880127650213 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java @@ -7,13 +7,13 @@ public class CraftDolphin extends CraftAgeable implements Dolphin { - public CraftDolphin(CraftServer server, net.minecraft.world.entity.animal.Dolphin entity) { + public CraftDolphin(CraftServer server, net.minecraft.world.entity.animal.dolphin.Dolphin entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Dolphin getHandle() { - return (net.minecraft.world.entity.animal.Dolphin) this.entity; + public net.minecraft.world.entity.animal.dolphin.Dolphin getHandle() { + return (net.minecraft.world.entity.animal.dolphin.Dolphin) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java index 85820f25d735..dff9bb9c37e6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java @@ -6,7 +6,7 @@ public class CraftDonkey extends CraftChestedHorse implements Donkey { - public CraftDonkey(CraftServer server, net.minecraft.world.entity.animal.horse.Donkey entity) { + public CraftDonkey(CraftServer server, net.minecraft.world.entity.animal.equine.Donkey entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java index 00b4487b10f5..ce443bb35ae6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java @@ -5,7 +5,7 @@ public class CraftDragonFireball extends CraftFireball implements DragonFireball { - public CraftDragonFireball(CraftServer server, net.minecraft.world.entity.projectile.DragonFireball entity) { + public CraftDragonFireball(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.DragonFireball entity) { super(server, entity); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java index 4dfed6e60ce3..45172aaf11bf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java @@ -3,14 +3,14 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Drowned; -public class CraftDrowned extends CraftZombie implements Drowned, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public class CraftDrowned extends CraftZombie implements Drowned, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftDrowned(CraftServer server, net.minecraft.world.entity.monster.Drowned entity) { + public CraftDrowned(CraftServer server, net.minecraft.world.entity.monster.zombie.Drowned entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Drowned getHandle() { - return (net.minecraft.world.entity.monster.Drowned) this.entity; + public net.minecraft.world.entity.monster.zombie.Drowned getHandle() { + return (net.minecraft.world.entity.monster.zombie.Drowned) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java index 6b1c6e0239fc..9d578ee22f3f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownEgg; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Egg; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java index a716433db42e..a1854acb8a15 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; import java.util.Set; -import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; import org.bukkit.boss.BossBar; import org.bukkit.boss.DragonBattle; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java index 9d7268b6b4e9..25e9b002df1f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Entity; public class CraftEnderDragonPart extends CraftComplexPart implements EnderDragonPart { - public CraftEnderDragonPart(CraftServer server, net.minecraft.world.entity.boss.EnderDragonPart entity) { + public CraftEnderDragonPart(CraftServer server, net.minecraft.world.entity.boss.enderdragon.EnderDragonPart entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java index eb7e63d5697d..f97a961971f3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderPearl; 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 b177e23db960..2a572ef0ba74 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 @@ -29,10 +29,11 @@ import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityProcessor; import net.minecraft.world.entity.EntitySpawnReason; -import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.entity.projectile.arrow.AbstractArrow; import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.level.storage.TagValueOutput; import net.minecraft.world.level.storage.ValueInput; @@ -330,7 +331,7 @@ public static net.minecraft.world.entity.Relative deltaRelativeToNMS(TeleportFla }; } - public static @Nullable TeleportFlag.Relative deltaRelativeToAPI(net.minecraft.world.entity.Relative nmsFlag) { + public static TeleportFlag.@Nullable Relative deltaRelativeToAPI(net.minecraft.world.entity.Relative nmsFlag) { return switch (nmsFlag) { case DELTA_X -> TeleportFlag.Relative.VELOCITY_X; case DELTA_Y -> TeleportFlag.Relative.VELOCITY_Y; @@ -1028,7 +1029,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, java.util.function.Function.identity()); + return net.minecraft.world.entity.EntityType.loadEntityRecursive(output.buildResult(), level, EntitySpawnReason.LOAD, 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 b3228adb70f9..3df77f98529a 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 @@ -5,6 +5,7 @@ import com.mojang.logging.LogUtils; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.ProblemReporter; +import net.minecraft.world.entity.EntityProcessor; import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.level.storage.TagValueInput; import net.minecraft.world.level.storage.TagValueOutput; @@ -58,7 +59,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, Function.identity()); + net.minecraft.world.entity.Entity internal = net.minecraft.world.entity.EntityType.loadEntityRecursive(this.data, level, EntitySpawnReason.LOAD, 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 47db45462429..d842c2c21570 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 @@ -19,7 +19,7 @@ public static EntityType minecraftToBukkit(net.minecraft.world.entity.EntityType 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().location())); + EntityType bukkit = Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); Preconditions.checkArgument(bukkit != null); 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 991f1dc8ced1..3f9a42944e5d 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 @@ -16,13 +16,13 @@ import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.PrimedTnt; -import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile; import net.minecraft.world.entity.projectile.EyeOfEnder; import net.minecraft.world.entity.projectile.FireworkRocketEntity; -import net.minecraft.world.entity.projectile.ThrownEgg; -import net.minecraft.world.entity.projectile.ThrownLingeringPotion; -import net.minecraft.world.entity.projectile.ThrownSplashPotion; -import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; @@ -70,6 +70,7 @@ import org.bukkit.entity.Breeze; import org.bukkit.entity.BreezeWindCharge; import org.bukkit.entity.Camel; +import org.bukkit.entity.CamelHusk; import org.bukkit.entity.Cat; import org.bukkit.entity.CaveSpider; import org.bukkit.entity.Chicken; @@ -128,10 +129,12 @@ import org.bukkit.entity.Marker; import org.bukkit.entity.Mule; import org.bukkit.entity.MushroomCow; +import org.bukkit.entity.Nautilus; import org.bukkit.entity.Ocelot; import org.bukkit.entity.OminousItemSpawner; import org.bukkit.entity.Painting; import org.bukkit.entity.Panda; +import org.bukkit.entity.Parched; import org.bukkit.entity.Parrot; import org.bukkit.entity.Phantom; import org.bukkit.entity.Pig; @@ -184,6 +187,7 @@ import org.bukkit.entity.Zoglin; import org.bukkit.entity.Zombie; import org.bukkit.entity.ZombieHorse; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.entity.ZombieVillager; import org.bukkit.entity.boat.AcaciaBoat; import org.bukkit.entity.boat.AcaciaChestBoat; @@ -358,6 +362,10 @@ Level minecraftWorld() { 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.ENDER_DRAGON, EnderDragon.class, CraftEnderDragon::new, spawnData -> { @@ -377,13 +385,13 @@ Level minecraftWorld() { register(new EntityTypeData<>(EntityType.PAINTING, Painting.class, CraftPainting::new, createHanging(Painting.class, (spawnData, hangingData) -> { if (spawnData.normalWorld && hangingData.randomize()) { // Paper start - if randomizeData fails, force it - final net.minecraft.world.entity.decoration.Painting entity = net.minecraft.world.entity.decoration.Painting.create(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction()).orElse(null); + final net.minecraft.world.entity.decoration.painting.Painting entity = net.minecraft.world.entity.decoration.painting.Painting.create(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction()).orElse(null); if (entity != null) { return entity; } } /*else*/ { // Paper end - if randomizeData fails, force it - net.minecraft.world.entity.decoration.Painting entity = new net.minecraft.world.entity.decoration.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.EntityType.PAINTING, spawnData.minecraftWorld()); entity.absSnapTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); entity.setDirection(hangingData.direction()); return entity; @@ -452,7 +460,7 @@ Level minecraftWorld() { 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.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.Snowball(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.SNOWBALL)))); + 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)))); register(new EntityTypeData<>(EntityType.EYE_OF_ENDER, EnderSignal.class, CraftEnderSignal::new, spawnData -> new EyeOfEnder(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z()))); register(new EntityTypeData<>(EntityType.SPLASH_POTION, SplashPotion.class, CraftThrownSplashPotion::new, spawnData -> new ThrownSplashPotion(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.SPLASH_POTION)))); register(new EntityTypeData<>(EntityType.LINGERING_POTION, LingeringPotion.class, CraftThrownLingeringPotion::new, spawnData -> new ThrownLingeringPotion(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new ItemStack(Items.LINGERING_POTION)))); @@ -558,7 +566,7 @@ private static Function list = spawnData.world().getEntities(null, bb); for (Iterator it = list.iterator(); !taken && it.hasNext(); ) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java index 73b50136708d..1142007368e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java @@ -1,19 +1,19 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.world.entity.animal.sheep.Sheep; -import net.minecraft.world.entity.monster.SpellcasterIllager; +import net.minecraft.world.entity.monster.illager.SpellcasterIllager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Evoker; public class CraftEvoker extends CraftSpellcaster implements Evoker { - public CraftEvoker(CraftServer server, net.minecraft.world.entity.monster.Evoker entity) { + public CraftEvoker(CraftServer server, net.minecraft.world.entity.monster.illager.Evoker entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Evoker getHandle() { - return (net.minecraft.world.entity.monster.Evoker) this.entity; + public net.minecraft.world.entity.monster.illager.Evoker getHandle() { + return (net.minecraft.world.entity.monster.illager.Evoker) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 7e53e12c8ec5..72291b2142ba 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import net.minecraft.world.entity.projectile.hurtingprojectile.AbstractHurtingProjectile; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.CraftVector; import org.bukkit.entity.Fireball; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java index 207f06a854d2..331a3ccac263 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.AbstractFish; +import net.minecraft.world.entity.animal.fish.AbstractFish; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Fish; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index dbf84ba61bf9..8f3e0ddd4033 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -11,13 +11,13 @@ public class CraftFox extends CraftAnimals implements Fox { - public CraftFox(CraftServer server, net.minecraft.world.entity.animal.Fox entity) { + public CraftFox(CraftServer server, net.minecraft.world.entity.animal.fox.Fox entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Fox getHandle() { - return (net.minecraft.world.entity.animal.Fox) this.entity; + public net.minecraft.world.entity.animal.fox.Fox getHandle() { + return (net.minecraft.world.entity.animal.fox.Fox) this.entity; } @Override @@ -29,7 +29,7 @@ public Type getFoxType() { public void setFoxType(Type type) { Preconditions.checkArgument(type != null, "type"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.Fox.Variant.values()[type.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.fox.Fox.Variant.values()[type.ordinal()]); } @Override @@ -72,30 +72,30 @@ private AnimalTamer getTrustedPlayer(EntityDataAccessor implements Variant { private static int count = 0; - public static Variant minecraftToBukkit(FrogVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.FROG_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.FROG_VARIANT); } - public static FrogVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java index dac2ac14a170..c133adda1f25 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java @@ -6,13 +6,13 @@ public class CraftGlowSquid extends CraftSquid implements GlowSquid { - public CraftGlowSquid(CraftServer server, net.minecraft.world.entity.GlowSquid entity) { + public CraftGlowSquid(CraftServer server, net.minecraft.world.entity.animal.squid.GlowSquid entity) { super(server, entity); } @Override - public net.minecraft.world.entity.GlowSquid getHandle() { - return (net.minecraft.world.entity.GlowSquid) this.entity; + public net.minecraft.world.entity.animal.squid.GlowSquid getHandle() { + return (net.minecraft.world.entity.animal.squid.GlowSquid) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java index 9cb3dd093f7c..05b703d606c1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.AbstractGolem; +import net.minecraft.world.entity.animal.golem.AbstractGolem; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Golem; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHappyGhast.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHappyGhast.java index e0408e61141e..bc7a457ea877 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHappyGhast.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHappyGhast.java @@ -4,7 +4,7 @@ import org.bukkit.entity.HappyGhast; public class CraftHappyGhast extends CraftAnimals implements HappyGhast { - public CraftHappyGhast(final CraftServer server, final net.minecraft.world.entity.animal.HappyGhast entity) { + public CraftHappyGhast(final CraftServer server, final net.minecraft.world.entity.animal.happyghast.HappyGhast entity) { super(server, entity); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index ef8073dfd4c5..3ad11debbabf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -2,7 +2,7 @@ import com.google.common.base.Preconditions; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.animal.horse.Markings; +import net.minecraft.world.entity.animal.equine.Markings; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventoryHorse; import org.bukkit.entity.Horse; @@ -10,13 +10,13 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { - public CraftHorse(CraftServer server, net.minecraft.world.entity.animal.horse.Horse entity) { + public CraftHorse(CraftServer server, net.minecraft.world.entity.animal.equine.Horse entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.Horse getHandle() { - return (net.minecraft.world.entity.animal.horse.Horse) this.entity; + public net.minecraft.world.entity.animal.equine.Horse getHandle() { + return (net.minecraft.world.entity.animal.equine.Horse) this.entity; } @Override @@ -32,7 +32,7 @@ public Color getColor() { @Override public void setColor(Color color) { Preconditions.checkArgument(color != null, "Color cannot be null"); - this.getHandle().setVariantAndMarkings(net.minecraft.world.entity.animal.horse.Variant.byId(color.ordinal()), this.getHandle().getMarkings()); + this.getHandle().setVariantAndMarkings(net.minecraft.world.entity.animal.equine.Variant.byId(color.ordinal()), this.getHandle().getMarkings()); } @Override 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 939cdd623253..5a4e98531031 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 @@ -11,18 +11,20 @@ import net.kyori.adventure.key.Key; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.game.ClientboundHorseScreenOpenPacket; +import net.minecraft.network.protocol.game.ClientboundMountScreenOpenPacket; import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; import net.minecraft.network.protocol.game.ServerboundContainerClosePacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.animal.equine.AbstractHorse; +import net.minecraft.world.entity.animal.nautilus.AbstractNautilus; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.HorseInventoryMenu; +import net.minecraft.world.inventory.AbstractMountInventoryMenu; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MerchantMenu; @@ -43,7 +45,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftContainer; import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftInventoryAbstractHorse; +import org.bukkit.craftbukkit.inventory.CraftInventorySaddledMount; import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest; import org.bukkit.craftbukkit.inventory.CraftInventoryLectern; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; @@ -203,7 +205,7 @@ public boolean sleep(Location location, boolean force) { // From BlockBed state = state.setValue(BedBlock.OCCUPIED, true); - this.getHandle().level().setBlock(pos, state, 4); + this.getHandle().level().setBlock(pos, state, net.minecraft.world.level.block.Block.UPDATE_INVISIBLE); return true; } @@ -347,8 +349,10 @@ public InventoryView openInventory(Inventory inventory) { if (menuProvider != null) { this.getHandle().openMenu(menuProvider); - } else if (inventory instanceof CraftInventoryAbstractHorse craft && craft.getInventory().getOwner() instanceof CraftAbstractHorse horse) { + } else if (inventory instanceof CraftInventorySaddledMount craft && craft.getInventory().getOwner() instanceof CraftAbstractHorse horse) { this.getHandle().openHorseInventory(horse.getHandle(), craft.getInventory()); + } else if (inventory instanceof CraftInventorySaddledMount craft && craft.getInventory().getOwner() instanceof CraftAbstractNautilus nautilus) { + this.getHandle().openNautilusInventory(nautilus.getHandle(), craft.getInventory()); } else { MenuType container = CraftContainer.getNotchInventoryType(inventory); CraftHumanEntity.openCustomInventory(inventory, player, container); @@ -473,8 +477,8 @@ public void openInventory(InventoryView inventory) { if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper if (result.getFirst() != null) adventure$title = result.getFirst(); // Paper - Add titleOverride to InventoryOpenEvent if (!player.isImmobile()) { - if (container instanceof HorseInventoryMenu horse) { - player.connection.send(new ClientboundHorseScreenOpenPacket(horse.containerId, horse.horse.getInventoryColumns(), horse.horse.getId())); + if (container instanceof AbstractMountInventoryMenu mountMenu) { + player.connection.send(new ClientboundMountScreenOpenPacket(mountMenu.containerId, getMountInventoryColumns(mountMenu), mountMenu.mount.getId())); } else { player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); } @@ -483,6 +487,15 @@ public void openInventory(InventoryView inventory) { player.initMenu(container); } + private static int getMountInventoryColumns(final AbstractMountInventoryMenu mountMenu) { + if (mountMenu.mount instanceof AbstractHorse horse) { + return horse.getInventoryColumns(); + } else if (mountMenu.mount instanceof AbstractNautilus nautilus) { + return nautilus.getInventoryColumns(); + } + throw new UnsupportedOperationException("Cannot get inventory columns for " + mountMenu.mount.getType().getDescriptionId()); + } + @Override public InventoryView openMerchant(Merchant merchant, boolean force) { Preconditions.checkNotNull(merchant, "merchant cannot be null"); @@ -645,7 +658,7 @@ public boolean hasCooldown(ItemStack item) { public int getCooldown(ItemStack item) { Preconditions.checkArgument(item != null, "Item cannot be null"); - ResourceLocation group = this.getHandle().getCooldowns().getCooldownGroup(CraftItemStack.asNMSCopy(item)); + Identifier group = this.getHandle().getCooldowns().getCooldownGroup(CraftItemStack.asNMSCopy(item)); if (group == null) { return 0; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHusk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHusk.java index 43be6123595e..df591019c64c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHusk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHusk.java @@ -5,7 +5,7 @@ public class CraftHusk extends CraftZombie implements Husk { - public CraftHusk(CraftServer server, net.minecraft.world.entity.monster.Husk entity) { + public CraftHusk(CraftServer server, net.minecraft.world.entity.monster.zombie.Husk entity) { super(server, entity); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java index fdc42e00b23e..f533a053923b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.monster.AbstractIllager; +import net.minecraft.world.entity.monster.illager.AbstractIllager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Illager; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java index ed158e3a1167..5b2f6cc85e56 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java @@ -3,14 +3,14 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Illusioner; -public class CraftIllusioner extends CraftSpellcaster implements Illusioner, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public class CraftIllusioner extends CraftSpellcaster implements Illusioner, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.Illusioner entity) { + public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.illager.Illusioner entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Illusioner getHandle() { - return (net.minecraft.world.entity.monster.Illusioner) this.entity; + public net.minecraft.world.entity.monster.illager.Illusioner getHandle() { + return (net.minecraft.world.entity.monster.illager.Illusioner) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java index 2d7be6f2afe3..54cea2ff4abb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java @@ -4,13 +4,13 @@ import org.bukkit.entity.IronGolem; public class CraftIronGolem extends CraftGolem implements IronGolem { - public CraftIronGolem(CraftServer server, net.minecraft.world.entity.animal.IronGolem entity) { + public CraftIronGolem(CraftServer server, net.minecraft.world.entity.animal.golem.IronGolem entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.IronGolem getHandle() { - return (net.minecraft.world.entity.animal.IronGolem) this.entity; + public net.minecraft.world.entity.animal.golem.IronGolem getHandle() { + return (net.minecraft.world.entity.animal.golem.IronGolem) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java index 742c02279629..f4c4252174f6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -5,13 +5,13 @@ public class CraftLargeFireball extends CraftSizedFireball implements LargeFireball { - public CraftLargeFireball(CraftServer server, net.minecraft.world.entity.projectile.LargeFireball entity) { + public CraftLargeFireball(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.LargeFireball getHandle() { - return (net.minecraft.world.entity.projectile.LargeFireball) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball) this.entity; } @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 a0fabdcb744f..dfc66145bcd4 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 @@ -27,12 +27,12 @@ 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.LargeFireball; +import net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball; import net.minecraft.world.entity.projectile.ThrowableProjectile; -import net.minecraft.world.entity.projectile.ThrownEgg; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; -import net.minecraft.world.entity.projectile.ThrownExperienceBottle; -import net.minecraft.world.entity.projectile.ThrownTrident; +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; @@ -544,7 +544,7 @@ public T launchProjectile(Class projectile, net.minecraft.world.entity.Entity launch = null; if (Snowball.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.Snowball(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SNOWBALL)); + launch = new net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SNOWBALL)); ((ThrowableProjectile) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemSnowball } else if (Egg.class.isAssignableFrom(projectile)) { launch = new ThrownEgg(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.EGG)); @@ -554,21 +554,21 @@ public T launchProjectile(Class projectile, ((ThrowableProjectile) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEnderPearl } else if (AbstractArrow.class.isAssignableFrom(projectile)) { if (TippedArrow.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); + launch = new net.minecraft.world.entity.projectile.arrow.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); ((Arrow) launch.getBukkitEntity()).setBasePotionType(PotionType.WATER); } else if (SpectralArrow.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.SpectralArrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null); + launch = new net.minecraft.world.entity.projectile.arrow.SpectralArrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null); } else if (Trident.class.isAssignableFrom(projectile)) { launch = new ThrownTrident(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.TRIDENT)); } else { - launch = new net.minecraft.world.entity.projectile.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); + launch = new net.minecraft.world.entity.projectile.arrow.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); } - ((net.minecraft.world.entity.projectile.AbstractArrow) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, Trident.class.isAssignableFrom(projectile) ? net.minecraft.world.item.TridentItem.PROJECTILE_SHOOT_POWER : 3.0F, 1.0F); // ItemBow // Paper - see TridentItem + ((net.minecraft.world.entity.projectile.arrow.AbstractArrow) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, Trident.class.isAssignableFrom(projectile) ? net.minecraft.world.item.TridentItem.PROJECTILE_SHOOT_POWER : 3.0F, 1.0F); // ItemBow // Paper - see TridentItem } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.ThrownLingeringPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); + launch = new net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); } else { - launch = new net.minecraft.world.entity.projectile.ThrownSplashPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); + launch = new net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.SPLASH_POTION)); } ((ThrowableProjectile) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), -20.0F, 0.5F, 1.0F); // ItemSplashPotion } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { @@ -582,11 +582,11 @@ public T launchProjectile(Class projectile, Vec3 vec = new Vec3(direction.getX(), direction.getY(), direction.getZ()); if (SmallFireball.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.SmallFireball(world, this.getHandle(), vec); + launch = new net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball(world, this.getHandle(), vec); } else if (WitherSkull.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.WitherSkull(world, this.getHandle(), vec); + launch = new net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull(world, this.getHandle(), vec); } else if (DragonFireball.class.isAssignableFrom(projectile)) { - launch = new net.minecraft.world.entity.projectile.DragonFireball(world, this.getHandle(), vec); + 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); @@ -594,8 +594,8 @@ public T launchProjectile(Class projectile, launch = EntityType.WIND_CHARGE.create(world, EntitySpawnReason.TRIGGERED); } - ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle()); - ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // WindChargeItem + ((net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle()); + ((net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.AbstractWindCharge) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // WindChargeItem } else { launch = new LargeFireball(world, this.getHandle(), vec, 1); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 96b88f301b55..443146323ee5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -8,15 +8,15 @@ import org.bukkit.entity.Llama; import org.bukkit.inventory.LlamaInventory; -public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.horse.Llama entity) { + public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.equine.Llama entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.Llama getHandle() { - return (net.minecraft.world.entity.animal.horse.Llama) this.entity; + public net.minecraft.world.entity.animal.equine.Llama getHandle() { + return (net.minecraft.world.entity.animal.equine.Llama) this.entity; } @Override @@ -28,7 +28,7 @@ public Color getColor() { public void setColor(Color color) { Preconditions.checkArgument(color != null, "color"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.horse.Llama.Variant.byId(color.ordinal())); + this.getHandle().setVariant(net.minecraft.world.entity.animal.equine.Llama.Variant.byId(color.ordinal())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 9c5caa4b9c11..78149d1adc3a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -2,7 +2,7 @@ import com.google.common.base.Preconditions; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Material; import org.bukkit.block.data.BlockData; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java index 0a3581cdc53b..e47ec7b25a23 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.MinecartChest; +import net.minecraft.world.entity.vehicle.minecart.MinecartChest; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.entity.minecart.StorageMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index 4279824f8a0e..d3fae5d5959e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -1,7 +1,8 @@ package org.bukkit.craftbukkit.entity; import java.util.Set; -import net.minecraft.world.entity.vehicle.MinecartCommandBlock; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.vehicle.minecart.MinecartCommandBlock; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.craftbukkit.CraftServer; @@ -68,7 +69,7 @@ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() { @Override public void lastOutput(net.kyori.adventure.text.Component lastOutput) { io.papermc.paper.commands.PaperCommandBlockHolder.super.lastOutput(lastOutput); - this.getCommandBlockHandle().onUpdated(); + this.getCommandBlockHandle().onUpdated((ServerLevel) this.getHandle().level()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java index a1f27890787b..04114f773c94 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.AbstractMinecart; -import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecart; +import net.minecraft.world.entity.vehicle.minecart.AbstractMinecartContainer; import org.bukkit.craftbukkit.CraftServer; public abstract class CraftMinecartContainer extends CraftMinecart implements com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java index 65d808c2b088..070aafdf1446 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.vehicle.MinecartFurnace; +import net.minecraft.world.entity.vehicle.minecart.MinecartFurnace; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.minecart.PoweredMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java index 7933ee5f7327..91a534e2ef94 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.MinecartHopper; +import net.minecraft.world.entity.vehicle.minecart.MinecartHopper; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.entity.minecart.HopperMinecart; @@ -16,8 +16,8 @@ public CraftMinecartHopper(CraftServer server, MinecartHopper entity) { } @Override - public net.minecraft.world.entity.vehicle.MinecartHopper getHandle() { - return (net.minecraft.world.entity.vehicle.MinecartHopper) this.entity; + public net.minecraft.world.entity.vehicle.minecart.MinecartHopper getHandle() { + return (net.minecraft.world.entity.vehicle.minecart.MinecartHopper) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java index ab1a4dceae22..f051c44b7ce3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java @@ -8,7 +8,7 @@ import net.minecraft.util.ProblemReporter; import net.minecraft.util.RandomSource; import net.minecraft.util.random.WeightedList; -import net.minecraft.world.entity.vehicle.MinecartSpawner; +import net.minecraft.world.entity.vehicle.minecart.MinecartSpawner; import net.minecraft.world.level.SpawnData; import net.minecraft.world.level.storage.TagValueInput; import org.bukkit.block.spawner.SpawnRule; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java index a043737f0344..d869a0e3a4b2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.vehicle.Minecart; +import net.minecraft.world.entity.vehicle.minecart.Minecart; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.minecart.RideableMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java index 41e706d45015..4bc70737a538 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -2,7 +2,7 @@ import com.google.common.base.Preconditions; import net.minecraft.util.Mth; -import net.minecraft.world.entity.vehicle.MinecartTNT; +import net.minecraft.world.entity.vehicle.minecart.MinecartTNT; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.minecart.ExplosiveMinecart; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java index 075bf368f7e7..909bdd845e6f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java @@ -6,7 +6,7 @@ public class CraftMule extends CraftChestedHorse implements Mule { - public CraftMule(CraftServer server, net.minecraft.world.entity.animal.horse.Mule entity) { + public CraftMule(CraftServer server, net.minecraft.world.entity.animal.equine.Mule entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java index fb25c0f554a5..a69bc672ed2e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -15,13 +15,13 @@ public class CraftMushroomCow extends CraftAbstractCow implements MushroomCow, io.papermc.paper.entity.PaperShearable { // Paper - public CraftMushroomCow(CraftServer server, net.minecraft.world.entity.animal.MushroomCow entity) { + public CraftMushroomCow(CraftServer server, net.minecraft.world.entity.animal.cow.MushroomCow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.MushroomCow getHandle() { - return (net.minecraft.world.entity.animal.MushroomCow) this.entity; + public net.minecraft.world.entity.animal.cow.MushroomCow getHandle() { + return (net.minecraft.world.entity.animal.cow.MushroomCow) this.entity; } @Override @@ -106,7 +106,7 @@ public Variant getVariant() { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "Variant cannot be null"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.MushroomCow.Variant.values()[variant.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.cow.MushroomCow.Variant.values()[variant.ordinal()]); } // Paper start diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java new file mode 100644 index 000000000000..53a436a4feb6 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftNautilus.java @@ -0,0 +1,17 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.animal.nautilus.Nautilus; +import org.bukkit.craftbukkit.CraftServer; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class CraftNautilus extends CraftAbstractNautilus implements org.bukkit.entity.Nautilus { + public CraftNautilus(final CraftServer server, final Nautilus entity) { + super(server, entity); + } + + @Override + public Nautilus getHandle() { + return (Nautilus) this.entity; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java index b4685c9773ee..0c61f068acfc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java @@ -5,13 +5,13 @@ public class CraftOcelot extends CraftAnimals implements Ocelot { - public CraftOcelot(CraftServer server, net.minecraft.world.entity.animal.Ocelot ocelot) { + public CraftOcelot(CraftServer server, net.minecraft.world.entity.animal.feline.Ocelot ocelot) { super(server, ocelot); } @Override - public net.minecraft.world.entity.animal.Ocelot getHandle() { - return (net.minecraft.world.entity.animal.Ocelot) this.entity; + public net.minecraft.world.entity.animal.feline.Ocelot getHandle() { + return (net.minecraft.world.entity.animal.feline.Ocelot) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 614a17330020..4582a36fe461 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.core.Holder; -import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import org.bukkit.Art; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftArt; @@ -10,13 +10,13 @@ public class CraftPainting extends CraftHanging implements Painting { - public CraftPainting(CraftServer server, net.minecraft.world.entity.decoration.Painting entity) { + public CraftPainting(CraftServer server, net.minecraft.world.entity.decoration.painting.Painting entity) { super(server, entity); } @Override - public net.minecraft.world.entity.decoration.Painting getHandle() { - return (net.minecraft.world.entity.decoration.Painting) this.entity; + public net.minecraft.world.entity.decoration.painting.Painting getHandle() { + return (net.minecraft.world.entity.decoration.painting.Painting) this.entity; } @Override @@ -31,7 +31,7 @@ public boolean setArt(Art art) { @Override public boolean setArt(Art art, boolean force) { - net.minecraft.world.entity.decoration.Painting painting = this.getHandle(); + net.minecraft.world.entity.decoration.painting.Painting painting = this.getHandle(); Holder oldArt = painting.getVariant(); painting.setVariant(CraftArt.bukkitToMinecraftHolder(art)); painting.setDirection(painting.getDirection()); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java index df2877d055fe..5a533dc43d15 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -6,13 +6,13 @@ public class CraftPanda extends CraftAnimals implements Panda { - public CraftPanda(CraftServer server, net.minecraft.world.entity.animal.Panda entity) { + public CraftPanda(CraftServer server, net.minecraft.world.entity.animal.panda.Panda entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Panda getHandle() { - return (net.minecraft.world.entity.animal.Panda) this.entity; + public net.minecraft.world.entity.animal.panda.Panda getHandle() { + return (net.minecraft.world.entity.animal.panda.Panda) this.entity; } @Override @@ -127,15 +127,15 @@ public int getUnhappyTicks() { return this.getHandle().getUnhappyCounter(); } - public static Gene fromNms(net.minecraft.world.entity.animal.Panda.Gene gene) { + public static Gene fromNms(net.minecraft.world.entity.animal.panda.Panda.Gene gene) { Preconditions.checkArgument(gene != null, "Gene may not be null"); return Gene.values()[gene.ordinal()]; } - public static net.minecraft.world.entity.animal.Panda.Gene toNms(Gene gene) { + public static net.minecraft.world.entity.animal.panda.Panda.Gene toNms(Gene gene) { Preconditions.checkArgument(gene != null, "Gene may not be null"); - return net.minecraft.world.entity.animal.Panda.Gene.values()[gene.ordinal()]; + return net.minecraft.world.entity.animal.panda.Panda.Gene.values()[gene.ordinal()]; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java new file mode 100644 index 000000000000..ef3cfe465820 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParched.java @@ -0,0 +1,21 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.monster.skeleton.Parched; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Skeleton; + +public class CraftParched extends CraftAbstractSkeleton implements org.bukkit.entity.Parched { + public CraftParched(final CraftServer server, final Parched entity) { + super(server, entity); + } + + @Override + public Parched getHandle() { + return (Parched) this.entity; + } + + @Override + public Skeleton.SkeletonType getSkeletonType() { + return Skeleton.SkeletonType.PARCHED; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java index 60e1da70c682..b5b5e7f4ef2d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java @@ -6,13 +6,13 @@ public class CraftParrot extends CraftTameableAnimal implements Parrot { - public CraftParrot(CraftServer server, net.minecraft.world.entity.animal.Parrot parrot) { + public CraftParrot(CraftServer server, net.minecraft.world.entity.animal.parrot.Parrot parrot) { super(server, parrot); } @Override - public net.minecraft.world.entity.animal.Parrot getHandle() { - return (net.minecraft.world.entity.animal.Parrot) this.entity; + public net.minecraft.world.entity.animal.parrot.Parrot getHandle() { + return (net.minecraft.world.entity.animal.parrot.Parrot) this.entity; } @Override @@ -24,7 +24,7 @@ public Variant getVariant() { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant cannot be null"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.Parrot.Variant.byId(variant.ordinal())); + this.getHandle().setVariant(net.minecraft.world.entity.animal.parrot.Parrot.Variant.byId(variant.ordinal())); } @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 387eed77223a..b127a2b4b36d 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 @@ -5,7 +5,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.entity.animal.pig.PigVariant; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import org.bukkit.Material; @@ -17,13 +17,13 @@ @NullMarked public class CraftPig extends CraftAnimals implements Pig { - public CraftPig(CraftServer server, net.minecraft.world.entity.animal.Pig entity) { + public CraftPig(CraftServer server, net.minecraft.world.entity.animal.pig.Pig entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Pig getHandle() { - return (net.minecraft.world.entity.animal.Pig) this.entity; + public net.minecraft.world.entity.animal.pig.Pig getHandle() { + return (net.minecraft.world.entity.animal.pig.Pig) this.entity; } @Override @@ -84,18 +84,10 @@ public void setVariant(Variant variant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(PigVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.PIG_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.PIG_VARIANT); } - public static PigVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java index fa9d7a532e9a..7ce42b761b01 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.monster.ZombifiedPiglin; +import net.minecraft.world.entity.monster.zombie.ZombifiedPiglin; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.PigZombie; @@ -17,12 +17,12 @@ public ZombifiedPiglin getHandle() { @Override public int getAnger() { - return this.getHandle().getRemainingPersistentAngerTime(); + return (int) (this.getHandle().getPersistentAngerEndTime() - this.getHandle().level().getGameTime()); } @Override public void setAnger(int level) { - this.getHandle().setRemainingPersistentAngerTime(level); + this.getHandle().setTimeToRemainAngry(level); } @Override 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 d927938df4ac..1c416a449e2d 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 @@ -5,15 +5,15 @@ import org.bukkit.entity.Pillager; import org.bukkit.inventory.Inventory; -public class CraftPillager extends CraftIllager implements Pillager, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper +public class CraftPillager extends CraftIllager implements Pillager, com.destroystokyo.paper.entity.CraftRangedEntity { // Paper - public CraftPillager(CraftServer server, net.minecraft.world.entity.monster.Pillager entity) { + public CraftPillager(CraftServer server, net.minecraft.world.entity.monster.illager.Pillager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Pillager getHandle() { - return (net.minecraft.world.entity.monster.Pillager) this.entity; + public net.minecraft.world.entity.monster.illager.Pillager getHandle() { + return (net.minecraft.world.entity.monster.illager.Pillager) this.entity; } @Override 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 7c9f48d22b93..6d31e4c351d9 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 @@ -105,12 +105,14 @@ import net.minecraft.network.protocol.game.ClientboundTabListPacket; import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket; import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.PlayerAdvancements; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.server.permissions.LevelBasedPermissionSet; +import net.minecraft.server.permissions.PermissionLevel; import net.minecraft.server.players.UserWhiteListEntry; import net.minecraft.sounds.SoundEvent; import net.minecraft.util.ProblemReporter; @@ -691,9 +693,9 @@ public T getClientOption(com.destroystokyo.paper.ClientOption type) { @Override public void sendOpLevel(byte level) { - Preconditions.checkArgument(level >= Commands.LEVEL_ALL && level <= Commands.LEVEL_OWNERS, "Level must be within [%s, %s]", Commands.LEVEL_ALL, Commands.LEVEL_OWNERS); + Preconditions.checkArgument(level >= PermissionLevel.ALL.id() && level <= PermissionLevel.OWNERS.id(), "Level must be within [%s, %s]", PermissionLevel.ALL.id(), PermissionLevel.OWNERS.id()); - this.server.getServer().getPlayerList().sendPlayerPermissionLevel(this.getHandle(), level, false); + this.server.getServer().getPlayerList().sendPlayerPermissionLevel(this.getHandle(), LevelBasedPermissionSet.forLevel(PermissionLevel.byId(level)), false); } @Override @@ -803,7 +805,7 @@ public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory catego public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { if (loc == null || sound == null || category == null || this.getHandle().connection == null) return; - this.playSound0(loc, Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); + this.playSound0(loc, Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); } private void playSound0(Location loc, Holder soundEffectHolder, net.minecraft.sounds.SoundSource categoryNMS, float volume, float pitch, long seed) { @@ -836,7 +838,7 @@ public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.S public void playSound(org.bukkit.entity.Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { if (!(entity instanceof CraftEntity) || sound == null || category == null || this.getHandle().connection == null) return; - this.playSound0(entity, Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); + this.playSound0(entity, Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), volume, pitch, seed); } private void playSound0(org.bukkit.entity.Entity entity, Holder soundEffectHolder, net.minecraft.sounds.SoundSource categoryNMS, float volume, float pitch, long seed) { @@ -855,7 +857,7 @@ private void playSound0(org.bukkit.entity.Entity entity, Holder soun public void stopSound(String sound, org.bukkit.SoundCategory category) { if (this.getHandle().connection == null) return; - this.getHandle().connection.send(new ClientboundStopSoundPacket(ResourceLocation.parse(sound), category == null ? net.minecraft.sounds.SoundSource.MASTER : net.minecraft.sounds.SoundSource.valueOf(category.name()))); + this.getHandle().connection.send(new ClientboundStopSoundPacket(Identifier.parse(sound), category == null ? net.minecraft.sounds.SoundSource.MASTER : net.minecraft.sounds.SoundSource.valueOf(category.name()))); } @Override @@ -1173,7 +1175,7 @@ public void onSetSize(net.minecraft.world.level.border.WorldBorder border, doubl } @Override - public void onLerpSize(net.minecraft.world.level.border.WorldBorder border, double fromSize, double toSize, long time) { + public void onLerpSize(net.minecraft.world.level.border.WorldBorder border, double fromSize, double toSize, long time, long gameTime) { CraftPlayer.this.getHandle().connection.send(new ClientboundSetBorderLerpSizePacket(border)); } @@ -1434,7 +1436,7 @@ public boolean hasDiscoveredRecipe(NamespacedKey recipe) { @Override public Set getDiscoveredRecipes() { ImmutableSet.Builder bukkitRecipeKeys = ImmutableSet.builder(); - this.getHandle().getRecipeBook().known.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key.location()))); + this.getHandle().getRecipeBook().known.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key.identifier()))); return bukkitRecipeKeys.build(); } @@ -1539,7 +1541,7 @@ public void setPlayerTime(long time, boolean relative) { final long gameTime = this.getHandle().level().getGameTime(); final long dayTime = this.getHandle().getPlayerTime(); - final boolean tickDayTime = this.getHandle().relativeTime && this.getHandle().level().getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DAYLIGHT); + final boolean tickDayTime = this.getHandle().relativeTime && this.getHandle().level().getGameRules().get(net.minecraft.world.level.gamerules.GameRules.ADVANCE_TIME); this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSetTimePacket(gameTime, dayTime, tickDayTime)); } @@ -2216,12 +2218,12 @@ public void sendPluginMessage(Plugin source, String channel, byte[] message) { if (this.getHandle().connection == null) return; if (this.channels().contains(channel)) { - ResourceLocation id = ResourceLocation.parse(StandardMessenger.validateAndCorrectChannel(channel)); + Identifier id = Identifier.parse(StandardMessenger.validateAndCorrectChannel(channel)); this.sendCustomPayload(id, message); } } - private void sendCustomPayload(ResourceLocation id, byte[] message) { + private void sendCustomPayload(Identifier id, byte[] message) { ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(new DiscardedPayload(id, message)); this.getHandle().connection.send(packet); } @@ -3139,7 +3141,7 @@ public void increaseWardenWarningLevel() { // Paper start @Override public Duration getIdleDuration() { - return Duration.ofMillis(net.minecraft.Util.getMillis() - this.getHandle().getLastActionTime()); + return Duration.ofMillis(net.minecraft.util.Util.getMillis() - this.getHandle().getLastActionTime()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java index 1e3b8eb597f6..eb9eeb616d5d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java @@ -5,13 +5,13 @@ public class CraftPolarBear extends CraftAnimals implements PolarBear { - public CraftPolarBear(CraftServer server, net.minecraft.world.entity.animal.PolarBear entity) { + public CraftPolarBear(CraftServer server, net.minecraft.world.entity.animal.polarbear.PolarBear entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.PolarBear getHandle() { - return (net.minecraft.world.entity.animal.PolarBear) this.entity; + public net.minecraft.world.entity.animal.polarbear.PolarBear getHandle() { + return (net.minecraft.world.entity.animal.polarbear.PolarBear) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java index e63c3bdd1b9f..21b8c89328e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.Pufferfish; +import net.minecraft.world.entity.animal.fish.Pufferfish; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.PufferFish; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index 994eb2d881fd..94d2863c5b80 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -5,13 +5,13 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { - public CraftRabbit(CraftServer server, net.minecraft.world.entity.animal.Rabbit entity) { + public CraftRabbit(CraftServer server, net.minecraft.world.entity.animal.rabbit.Rabbit entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Rabbit getHandle() { - return (net.minecraft.world.entity.animal.Rabbit) this.entity; + public net.minecraft.world.entity.animal.rabbit.Rabbit getHandle() { + return (net.minecraft.world.entity.animal.rabbit.Rabbit) this.entity; } @Override @@ -21,7 +21,7 @@ public Type getRabbitType() { @Override public void setRabbitType(Type type) { - this.getHandle().setVariant(net.minecraft.world.entity.animal.Rabbit.Variant.values()[type.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.rabbit.Rabbit.Variant.values()[type.ordinal()]); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java index 8b2c8924f66f..addf37e28357 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java @@ -6,13 +6,13 @@ public class CraftSalmon extends io.papermc.paper.entity.PaperSchoolableFish implements Salmon { // Paper - Schooling Fish API - public CraftSalmon(CraftServer server, net.minecraft.world.entity.animal.Salmon entity) { + public CraftSalmon(CraftServer server, net.minecraft.world.entity.animal.fish.Salmon entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Salmon getHandle() { - return (net.minecraft.world.entity.animal.Salmon) this.entity; + public net.minecraft.world.entity.animal.fish.Salmon getHandle() { + return (net.minecraft.world.entity.animal.fish.Salmon) this.entity; } @Override @@ -24,6 +24,6 @@ public Variant getVariant() { public void setVariant(Variant variant) { Preconditions.checkArgument(variant != null, "variant cannot be null"); - this.getHandle().setVariant(net.minecraft.world.entity.animal.Salmon.Variant.values()[variant.ordinal()]); + this.getHandle().setVariant(net.minecraft.world.entity.animal.fish.Salmon.Variant.values()[variant.ordinal()]); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java index 579ec5453078..6cab47b6c934 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.Fireball; +import net.minecraft.world.entity.projectile.hurtingprojectile.Fireball; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; 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 af73ee0ce87d..1cd0d2738e5e 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 @@ -6,13 +6,13 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton { - public CraftSkeleton(CraftServer server, net.minecraft.world.entity.monster.Skeleton entity) { + public CraftSkeleton(CraftServer server, net.minecraft.world.entity.monster.skeleton.Skeleton entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Skeleton getHandle() { - return (net.minecraft.world.entity.monster.Skeleton) this.entity; + public net.minecraft.world.entity.monster.skeleton.Skeleton getHandle() { + return (net.minecraft.world.entity.monster.skeleton.Skeleton) this.entity; } @Override @@ -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.DATA_STRAY_CONVERSION_ID, false); + this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.skeleton.Skeleton.DATA_STRAY_CONVERSION_ID, false); } else { this.getHandle().startFreezeConversion(time); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java index f40729e9cf8c..b1acf372976a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java @@ -6,13 +6,13 @@ public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHorse { - public CraftSkeletonHorse(CraftServer server, net.minecraft.world.entity.animal.horse.SkeletonHorse entity) { + public CraftSkeletonHorse(CraftServer server, net.minecraft.world.entity.animal.equine.SkeletonHorse entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.SkeletonHorse getHandle() { - return (net.minecraft.world.entity.animal.horse.SkeletonHorse) this.entity; + public net.minecraft.world.entity.animal.equine.SkeletonHorse getHandle() { + return (net.minecraft.world.entity.animal.equine.SkeletonHorse) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java index fbd3f86bfd04..05783caadd2d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java @@ -5,12 +5,12 @@ public class CraftSmallFireball extends CraftSizedFireball implements SmallFireball { - public CraftSmallFireball(CraftServer server, net.minecraft.world.entity.projectile.SmallFireball entity) { + public CraftSmallFireball(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.SmallFireball getHandle() { - return (net.minecraft.world.entity.projectile.SmallFireball) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.SmallFireball) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java index b31f2a939e95..d7b05f5bdbd3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -5,12 +5,12 @@ public class CraftSnowball extends CraftThrowableProjectile implements Snowball { - public CraftSnowball(CraftServer server, net.minecraft.world.entity.projectile.Snowball entity) { + public CraftSnowball(CraftServer server, net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.Snowball getHandle() { - return (net.minecraft.world.entity.projectile.Snowball) this.entity; + public net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball getHandle() { + return (net.minecraft.world.entity.projectile.throwableitemprojectile.Snowball) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java index f03f9f94c51e..0a912863fe9f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.SnowGolem; +import net.minecraft.world.entity.animal.golem.SnowGolem; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Snowman; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java index 4afd6e013ac7..638fc96ade16 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java @@ -5,13 +5,13 @@ public class CraftSpectralArrow extends CraftAbstractArrow implements SpectralArrow { - public CraftSpectralArrow(CraftServer server, net.minecraft.world.entity.projectile.SpectralArrow entity) { + public CraftSpectralArrow(CraftServer server, net.minecraft.world.entity.projectile.arrow.SpectralArrow entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.SpectralArrow getHandle() { - return (net.minecraft.world.entity.projectile.SpectralArrow) this.entity; + public net.minecraft.world.entity.projectile.arrow.SpectralArrow getHandle() { + return (net.minecraft.world.entity.projectile.arrow.SpectralArrow) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java index b28ef9d0003c..a6bad13a0ef8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.monster.SpellcasterIllager; +import net.minecraft.world.entity.monster.illager.SpellcasterIllager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Spellcaster; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java index 90be754d6aa0..133ef079af63 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java @@ -5,12 +5,12 @@ public class CraftSpider extends CraftMonster implements Spider { - public CraftSpider(CraftServer server, net.minecraft.world.entity.monster.Spider entity) { + public CraftSpider(CraftServer server, net.minecraft.world.entity.monster.spider.Spider entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Spider getHandle() { - return (net.minecraft.world.entity.monster.Spider) this.entity; + public net.minecraft.world.entity.monster.spider.Spider getHandle() { + return (net.minecraft.world.entity.monster.spider.Spider) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java index d1a49aaa259c..4537b8f6b70b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java @@ -5,12 +5,12 @@ public class CraftSquid extends CraftAgeable implements Squid { - public CraftSquid(CraftServer server, net.minecraft.world.entity.animal.Squid entity) { + public CraftSquid(CraftServer server, net.minecraft.world.entity.animal.squid.Squid entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Squid getHandle() { - return (net.minecraft.world.entity.animal.Squid) this.entity; + public net.minecraft.world.entity.animal.squid.Squid getHandle() { + return (net.minecraft.world.entity.animal.squid.Squid) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java index 397ca2e097a1..80b39f324d1a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java @@ -6,7 +6,7 @@ public class CraftStray extends CraftAbstractSkeleton implements Stray { - public CraftStray(CraftServer server, net.minecraft.world.entity.monster.Stray entity) { + public CraftStray(CraftServer server, net.minecraft.world.entity.monster.skeleton.Stray entity) { super(server, entity); } 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 f34b81ac5a1a..7044d72edb6e 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 @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrowableItemProjectile; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrowableItemProjectile; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.ThrowableProjectile; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java index 9e4b555450d4..325a7ec636bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownExperienceBottle; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownExperienceBottle; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ThrownExpBottle; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java index 8be9f69889cd..091c27150dbc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.projectile.ThrownLingeringPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; 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 61becdf5c4ad..77a3a2ca5caa 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 @@ -4,7 +4,7 @@ import java.util.Collection; import net.minecraft.core.component.DataComponents; import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.projectile.AbstractThrownPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.AbstractThrownPotion; import net.minecraft.world.item.alchemy.PotionContents; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java index 8e7078878b62..05b962ff4c2c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.projectile.ThrownSplashPotion; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java index 174332208a0e..4e2acd754b38 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java @@ -5,12 +5,12 @@ public class CraftTraderLlama extends CraftLlama implements TraderLlama { - public CraftTraderLlama(CraftServer server, net.minecraft.world.entity.animal.horse.TraderLlama entity) { + public CraftTraderLlama(CraftServer server, net.minecraft.world.entity.animal.equine.TraderLlama entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.horse.TraderLlama getHandle() { - return (net.minecraft.world.entity.animal.horse.TraderLlama) this.entity; + public net.minecraft.world.entity.animal.equine.TraderLlama getHandle() { + return (net.minecraft.world.entity.animal.equine.TraderLlama) this.entity; } } 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 6d4f7d5164eb..505b8603829e 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 @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.projectile.ThrownTrident; +import net.minecraft.world.entity.projectile.arrow.ThrownTrident; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.Trident; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java index 6ec2e173c58f..928caed39022 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -6,13 +6,13 @@ public class CraftTropicalFish extends io.papermc.paper.entity.PaperSchoolableFish implements TropicalFish { // Paper - Schooling Fish API - public CraftTropicalFish(CraftServer server, net.minecraft.world.entity.animal.TropicalFish entity) { + public CraftTropicalFish(CraftServer server, net.minecraft.world.entity.animal.fish.TropicalFish entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.TropicalFish getHandle() { - return (net.minecraft.world.entity.animal.TropicalFish) this.entity; + public net.minecraft.world.entity.animal.fish.TropicalFish getHandle() { + return (net.minecraft.world.entity.animal.fish.TropicalFish) this.entity; } @Override @@ -46,7 +46,7 @@ public void setPattern(Pattern pattern) { } public static int getData(DyeColor patternColor, DyeColor bodyColor, Pattern type) { - net.minecraft.world.entity.animal.TropicalFish.Pattern pattern = net.minecraft.world.entity.animal.TropicalFish.Pattern.valueOf(type.name()); + net.minecraft.world.entity.animal.fish.TropicalFish.Pattern pattern = net.minecraft.world.entity.animal.fish.TropicalFish.Pattern.valueOf(type.name()); return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 | pattern.getPackedId(); } @@ -59,6 +59,6 @@ public static DyeColor getBodyColor(int data) { } public static Pattern getPattern(int data) { - return Pattern.valueOf(net.minecraft.world.entity.animal.TropicalFish.getPattern(data).name()); + return Pattern.valueOf(net.minecraft.world.entity.animal.fish.TropicalFish.getPattern(data).name()); } } 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 3aae36e3bd03..5d8dd7a9ec44 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 @@ -6,13 +6,13 @@ public class CraftTurtle extends CraftAnimals implements Turtle { - public CraftTurtle(CraftServer server, net.minecraft.world.entity.animal.Turtle entity) { + public CraftTurtle(CraftServer server, net.minecraft.world.entity.animal.turtle.Turtle entity) { super(server, entity); } @Override - public net.minecraft.world.entity.animal.Turtle getHandle() { - return (net.minecraft.world.entity.animal.Turtle) this.entity; + public net.minecraft.world.entity.animal.turtle.Turtle getHandle() { + return (net.minecraft.world.entity.animal.turtle.Turtle) this.entity; } @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 df332b6938b8..22704813d84f 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 @@ -8,9 +8,10 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; -import net.minecraft.world.entity.monster.Zombie; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.monster.zombie.Zombie; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerType; import net.minecraft.world.level.block.BedBlock; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Location; @@ -24,13 +25,13 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { - public CraftVillager(CraftServer server, net.minecraft.world.entity.npc.Villager entity) { + public CraftVillager(CraftServer server, net.minecraft.world.entity.npc.villager.Villager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.npc.Villager getHandle() { - return (net.minecraft.world.entity.npc.Villager) this.entity; + public net.minecraft.world.entity.npc.villager.Villager getHandle() { + return (net.minecraft.world.entity.npc.villager.Villager) this.entity; } @Override @@ -91,11 +92,11 @@ public void setVillagerExperience(int experience) { public boolean increaseLevel(int amount) { Preconditions.checkArgument(amount > 0, "Level earned must be positive"); int supposedFinalLevel = this.getVillagerLevel() + amount; - Preconditions.checkArgument(net.minecraft.world.entity.npc.VillagerData.MIN_VILLAGER_LEVEL <= supposedFinalLevel && supposedFinalLevel <= net.minecraft.world.entity.npc.VillagerData.MAX_VILLAGER_LEVEL, - "Final level reached after the donation (%d) must be between [%d, %d]".formatted(supposedFinalLevel, net.minecraft.world.entity.npc.VillagerData.MIN_VILLAGER_LEVEL, net.minecraft.world.entity.npc.VillagerData.MAX_VILLAGER_LEVEL)); + Preconditions.checkArgument(net.minecraft.world.entity.npc.villager.VillagerData.MIN_VILLAGER_LEVEL <= supposedFinalLevel && supposedFinalLevel <= net.minecraft.world.entity.npc.villager.VillagerData.MAX_VILLAGER_LEVEL, + "Final level reached after the donation (%d) must be between [%d, %d]".formatted(supposedFinalLevel, net.minecraft.world.entity.npc.villager.VillagerData.MIN_VILLAGER_LEVEL, net.minecraft.world.entity.npc.villager.VillagerData.MAX_VILLAGER_LEVEL)); - it.unimi.dsi.fastutil.ints.Int2ObjectMap trades = - net.minecraft.world.entity.npc.VillagerTrades.TRADES.get((this.getHandle().getVillagerData().profession().unwrapKey().orElseThrow())); + it.unimi.dsi.fastutil.ints.Int2ObjectMap trades = + net.minecraft.world.entity.npc.villager.VillagerTrades.TRADES.get((this.getHandle().getVillagerData().profession().unwrapKey().orElseThrow())); if (trades == null || trades.isEmpty()) { this.getHandle().setVillagerData(this.getHandle().getVillagerData().withLevel(supposedFinalLevel)); @@ -103,7 +104,7 @@ public boolean increaseLevel(int amount) { } while (amount > 0) { - this.getHandle().increaseMerchantCareer(); + this.getHandle().increaseMerchantCareer((ServerLevel) this.getHandle().level()); amount--; } return true; @@ -158,25 +159,17 @@ public void shakeHead() { @Override public ZombieVillager zombify() { - net.minecraft.world.entity.monster.ZombieVillager entityzombievillager = Zombie.convertVillagerToZombieVillager(this.getHandle().level().getMinecraftWorld(), this.getHandle(), this.getHandle().blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.CUSTOM); + net.minecraft.world.entity.monster.zombie.ZombieVillager entityzombievillager = Zombie.convertVillagerToZombieVillager(this.getHandle().level().getMinecraftWorld(), this.getHandle(), this.getHandle().blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.CUSTOM); return (entityzombievillager != null) ? (ZombieVillager) entityzombievillager.getBukkitEntity() : null; } public static class CraftType extends OldEnumHolderable implements Type { private static int count = 0; - public static Type minecraftToBukkit(VillagerType minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.VILLAGER_TYPE); - } - public static Type minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.VILLAGER_TYPE); } - public static VillagerType bukkitToMinecraft(Type bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Type bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } @@ -197,14 +190,6 @@ public static Holder bukkitToMinecraftHolder(Profession bukk return CraftRegistry.bukkitToMinecraftHolder(bukkit); } - public static Profession minecraftToBukkit(VillagerProfession minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.VILLAGER_PROFESSION); - } - - public static VillagerProfession bukkitToMinecraft(Profession bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public CraftProfession(final Holder holder) { super(holder, count++); } 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 c09a3e065bbb..745f5e77e5a7 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 @@ -10,13 +10,13 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { - public CraftVillagerZombie(CraftServer server, net.minecraft.world.entity.monster.ZombieVillager entity) { + public CraftVillagerZombie(CraftServer server, net.minecraft.world.entity.monster.zombie.ZombieVillager entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.ZombieVillager getHandle() { - return (net.minecraft.world.entity.monster.ZombieVillager) this.entity; + public net.minecraft.world.entity.monster.zombie.ZombieVillager getHandle() { + return (net.minecraft.world.entity.monster.zombie.ZombieVillager) this.entity; } @Override @@ -64,7 +64,7 @@ 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().getEntityData().set(net.minecraft.world.entity.monster.ZombieVillager.DATA_CONVERTING_ID, false); + 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); } else { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java index 4207a1cd7572..e670779ecbfe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java @@ -5,13 +5,13 @@ public class CraftVindicator extends CraftIllager implements Vindicator { - public CraftVindicator(CraftServer server, net.minecraft.world.entity.monster.Vindicator entity) { + public CraftVindicator(CraftServer server, net.minecraft.world.entity.monster.illager.Vindicator entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Vindicator getHandle() { - return (net.minecraft.world.entity.monster.Vindicator) this.entity; + public net.minecraft.world.entity.monster.illager.Vindicator getHandle() { + return (net.minecraft.world.entity.monster.illager.Vindicator) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java index e698cbf4f1e7..60d158ddb6e4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -6,13 +6,13 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements WanderingTrader { - public CraftWanderingTrader(CraftServer server, net.minecraft.world.entity.npc.WanderingTrader entity) { + public CraftWanderingTrader(CraftServer server, net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader entity) { super(server, entity); } @Override - public net.minecraft.world.entity.npc.WanderingTrader getHandle() { - return (net.minecraft.world.entity.npc.WanderingTrader) this.entity; + public net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader getHandle() { + return (net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java index be249743cb53..fc84fdd157af 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.world.entity.animal.WaterAnimal; +import net.minecraft.world.entity.animal.fish.WaterAnimal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.WaterMob; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java index bb3301ff6a93..394ba22015df 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java @@ -5,12 +5,12 @@ public class CraftWindCharge extends CraftAbstractWindCharge implements WindCharge { - public CraftWindCharge(CraftServer server, net.minecraft.world.entity.projectile.windcharge.WindCharge entity) { + public CraftWindCharge(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.windcharge.WindCharge getHandle() { - return (net.minecraft.world.entity.projectile.windcharge.WindCharge) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge) this.entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java index 79eee42227ea..e05cc9c0628b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java @@ -6,7 +6,7 @@ public class CraftWitherSkeleton extends CraftAbstractSkeleton implements WitherSkeleton { - public CraftWitherSkeleton(CraftServer server, net.minecraft.world.entity.monster.WitherSkeleton entity) { + public CraftWitherSkeleton(CraftServer server, net.minecraft.world.entity.monster.skeleton.WitherSkeleton entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java index 027849368189..7ed4524d4220 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java @@ -5,13 +5,13 @@ public class CraftWitherSkull extends CraftFireball implements WitherSkull { - public CraftWitherSkull(CraftServer server, net.minecraft.world.entity.projectile.WitherSkull entity) { + public CraftWitherSkull(CraftServer server, net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull entity) { super(server, entity); } @Override - public net.minecraft.world.entity.projectile.WitherSkull getHandle() { - return (net.minecraft.world.entity.projectile.WitherSkull) this.entity; + public net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull getHandle() { + return (net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull) this.entity; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index 723a8e659485..1e24ae852691 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -92,18 +92,10 @@ public void setSoundVariant(SoundVariant soundVariant) { public static class CraftVariant extends HolderableBase implements Variant { - public static Variant minecraftToBukkit(WolfVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.WOLF_VARIANT); - } - public static Variant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.WOLF_VARIANT); } - public static WolfVariant bukkitToMinecraft(Variant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(Variant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } @@ -115,18 +107,10 @@ public CraftVariant(final Holder holder) { public static class CraftSoundVariant extends HolderableBase implements SoundVariant { - public static SoundVariant minecraftToBukkit(WolfSoundVariant minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.WOLF_SOUND_VARIANT); - } - public static SoundVariant minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.WOLF_SOUND_VARIANT); } - public static WolfSoundVariant bukkitToMinecraft(SoundVariant bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(SoundVariant bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } 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 9851c3890c93..58f0b6987122 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 @@ -1,20 +1,20 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.world.entity.monster.ZombieVillager; +import net.minecraft.world.entity.monster.zombie.ZombieVillager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Villager; import org.bukkit.entity.Zombie; public class CraftZombie extends CraftMonster implements Zombie { - public CraftZombie(CraftServer server, net.minecraft.world.entity.monster.Zombie entity) { + public CraftZombie(CraftServer server, net.minecraft.world.entity.monster.zombie.Zombie entity) { super(server, entity); } @Override - public net.minecraft.world.entity.monster.Zombie getHandle() { - return (net.minecraft.world.entity.monster.Zombie) this.entity; + public net.minecraft.world.entity.monster.zombie.Zombie getHandle() { + return (net.minecraft.world.entity.monster.zombie.Zombie) this.entity; } @Override @@ -63,7 +63,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.Zombie.DATA_DROWNED_CONVERSION_ID, false); + this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.zombie.Zombie.DATA_DROWNED_CONVERSION_ID, false); } else { this.getHandle().startUnderWaterConversion(time); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java index 1b3b52a54339..549fb4ec9eba 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java @@ -6,7 +6,7 @@ public class CraftZombieHorse extends CraftAbstractHorse implements ZombieHorse { - public CraftZombieHorse(CraftServer server, net.minecraft.world.entity.animal.horse.ZombieHorse entity) { + public CraftZombieHorse(CraftServer server, net.minecraft.world.entity.animal.equine.ZombieHorse entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java new file mode 100644 index 000000000000..6ad86ba7abac --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieNautilus.java @@ -0,0 +1,50 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import io.papermc.paper.registry.HolderableBase; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilus; +import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.CraftServer; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class CraftZombieNautilus extends CraftAbstractNautilus implements org.bukkit.entity.ZombieNautilus { + public CraftZombieNautilus(final CraftServer server, final ZombieNautilus entity) { + super(server, entity); + } + + @Override + public ZombieNautilus getHandle() { + return (ZombieNautilus) this.entity; + } + + @Override + public org.bukkit.entity.ZombieNautilus.Variant getVariant() { + return CraftVariant.minecraftHolderToBukkit(this.getHandle().getVariant()); + } + + @Override + public void setVariant(org.bukkit.entity.ZombieNautilus.Variant variant) { + Preconditions.checkArgument(variant != null, "variant cannot be null"); + + this.getHandle().setVariant(CraftVariant.bukkitToMinecraftHolder(variant)); + } + + public static class CraftVariant extends HolderableBase implements org.bukkit.entity.ZombieNautilus.Variant { + + public static org.bukkit.entity.ZombieNautilus.Variant minecraftHolderToBukkit(Holder minecraft) { + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.ZOMBIE_NAUTILUS_VARIANT); + } + + public static Holder bukkitToMinecraftHolder(Variant bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); + } + + public CraftVariant(final Holder holder) { + super(holder); + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java index 0ffa2e8e054f..5ffa0cb44a69 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.AcaciaBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java index 29bb5460b3a8..0eb78998950e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftAcaciaChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.AcaciaChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java index eea576358532..20a32fb30e03 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooChestRaft.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.BambooChestRaft; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java index 05952dd62c21..de041ab79e85 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBambooRaft.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.BambooRaft; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java index 1d629bf9df9a..6d71b6d16ada 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.BirchBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java index 24734c47a71e..91221cae40de 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftBirchChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.BirchChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java index 3f55982cc5d5..08989c870d0c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.CherryBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java index a983236cab83..a4fe6736abda 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftCherryChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.CherryChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java index 06c64e922040..fad036eb8454 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.DarkOakBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java index f49955cfea72..14e7e6fce308 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftDarkOakChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.DarkOakChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java index 400bfe452321..0fd049f60206 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.JungleBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java index e8d6cd4c96d0..86e106945235 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftJungleChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.JungleChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java index c1f0c3e55811..ca184c73053b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.MangroveBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java index 97eb913be028..95978027fe8c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftMangroveChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.MangroveChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java index 7e3e8f5fda0a..98fb6c02c7bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.OakBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java index 7beb16449195..b7d78ee954ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftOakChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.OakChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java index e6d65858edd8..88f82dd5d822 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.PaleOakBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java index bcc91c8319f5..eef9cada0367 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftPaleOakChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.PaleOakChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java index 92eb7ea21174..8cff0a245483 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.entity.boat.SpruceBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java index 64cc4dc33aa5..a01ac047c83c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/boat/CraftSpruceChestBoat.java @@ -1,6 +1,6 @@ package org.bukkit.craftbukkit.entity.boat; -import net.minecraft.world.entity.vehicle.AbstractChestBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractChestBoat; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftChestBoat; import org.bukkit.entity.boat.SpruceChestBoat; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java index 291a19c39b0a..558921d7caa4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryKey.java @@ -17,7 +17,7 @@ public static MemoryKey minecraftToBukkit(MemoryModuleType minecraf } net.minecraft.core.Registry> registry = CraftRegistry.getMinecraftRegistry(Registries.MEMORY_MODULE_TYPE); - MemoryKey bukkit = (MemoryKey) Registry.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); + MemoryKey bukkit = (MemoryKey) Registry.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); return bukkit; } 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 d5496e5fbb5f..b950465debc2 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 @@ -6,19 +6,23 @@ import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import com.mojang.datafixers.util.Either; -import io.papermc.paper.adventure.PaperAdventure; -import io.papermc.paper.connection.HorriblePlayerLoginEventHack; -import io.papermc.paper.connection.PlayerConnection; -import io.papermc.paper.event.connection.PlayerConnectionValidateLoginEvent; -import io.papermc.paper.event.entity.ItemTransportingEntityValidateTargetEvent; import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.block.bed.BedEnterProblem; +import io.papermc.paper.connection.HorriblePlayerLoginEventHack; +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.ItemTransportingEntityValidateTargetEvent; +import io.papermc.paper.event.player.PlayerBedFailEnterEvent; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.Connection; @@ -32,6 +36,8 @@ import net.minecraft.util.Unit; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; +import net.minecraft.world.LockCode; +import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.effect.MobEffectInstance; @@ -39,15 +45,15 @@ import net.minecraft.world.entity.Leashable; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.PathfinderMob; -import net.minecraft.world.entity.animal.AbstractFish; -import net.minecraft.world.entity.animal.AbstractGolem; +import net.minecraft.world.entity.animal.fish.AbstractFish; +import net.minecraft.world.entity.animal.golem.AbstractGolem; import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.WaterAnimal; +import net.minecraft.world.entity.animal.fish.WaterAnimal; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.monster.Ghast; import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.monster.Slime; -import net.minecraft.world.entity.monster.SpellcasterIllager; +import net.minecraft.world.entity.monster.illager.SpellcasterIllager; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.entity.raid.Raid; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -62,8 +68,10 @@ import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.gamerules.GameRule; import net.minecraft.world.level.redstone.Redstone; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootTable; @@ -82,9 +90,11 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Sign; import org.bukkit.block.sign.Side; +import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.CraftExplosionResult; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.CraftLootTable; import org.bukkit.craftbukkit.CraftRaid; import org.bukkit.craftbukkit.CraftServer; @@ -266,6 +276,7 @@ import org.bukkit.inventory.view.AnvilView; import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class CraftEventFactory { @@ -288,19 +299,140 @@ public static boolean callPlayerSignOpenEvent(Player player, Sign sign, Side sid return !event.isCancelled(); } - public static Either callPlayerBedEnterEvent(net.minecraft.world.entity.player.Player player, BlockPos bed, Either nmsBedResult) { - BedEnterResult bedEnterResult = nmsBedResult.mapBoth(sleepingProblem -> { - return switch (sleepingProblem) { - case NOT_POSSIBLE_HERE -> BedEnterResult.NOT_POSSIBLE_HERE; - case NOT_POSSIBLE_NOW -> BedEnterResult.NOT_POSSIBLE_NOW; - case TOO_FAR_AWAY -> BedEnterResult.TOO_FAR_AWAY; - case NOT_SAFE -> BedEnterResult.NOT_SAFE; - case OBSTRUCTED -> BedEnterResult.OBSTRUCTED; - default -> BedEnterResult.OTHER_PROBLEM; - }; - }, t -> BedEnterResult.OK).map(java.util.function.Function.identity(), java.util.function.Function.identity()); + public static com.mojang.datafixers.util.Pair asFailReason( + final net.minecraft.world.entity.player.Player player, final net.minecraft.world.attribute.BedRule bedRule, final net.minecraft.world.entity.player.Player.BedSleepingProblem sleepingProblem) { + PlayerBedFailEnterEvent.FailReason failReason = null; + io.papermc.paper.block.bed.BedEnterProblem enterProblem = null; + Component errorMessage = sleepingProblem.message(); + if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OTHER_PROBLEM) { + failReason = PlayerBedFailEnterEvent.FailReason.OTHER_PROBLEM; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OTHER; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.NOT_SAFE) { + failReason = PlayerBedFailEnterEvent.FailReason.NOT_SAFE; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.NOT_SAFE; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OBSTRUCTED) { + failReason = PlayerBedFailEnterEvent.FailReason.OBSTRUCTED; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OBSTRUCTED; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.TOO_FAR_AWAY) { + failReason = PlayerBedFailEnterEvent.FailReason.TOO_FAR_AWAY; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.TOO_FAR_AWAY; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.EXPLOSION) { + failReason = PlayerBedFailEnterEvent.FailReason.EXPLOSION; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.EXPLOSION; + errorMessage = bedRule.errorMessage().orElse(null); + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.NEVER) { + failReason = PlayerBedFailEnterEvent.FailReason.NOT_POSSIBLE_HERE; + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.WHEN_DARK) { + failReason = PlayerBedFailEnterEvent.FailReason.NOT_POSSIBLE_NOW; + } + + if (failReason == null) { + // Don't know what the fail reason is, defaulting to OTHER to prevent server crashes + failReason = PlayerBedFailEnterEvent.FailReason.OTHER_PROBLEM; + enterProblem = BedEnterProblem.OTHER; + } + + return com.mojang.datafixers.util.Pair.of( + failReason, + new io.papermc.paper.block.bed.BedEnterActionImpl( + CraftEventFactory.asBedRuleResult(bedRule.canSleep(), bedRule.canSleep().test(player.level())), + CraftEventFactory.asBedRuleResult(bedRule.canSetSpawn(), bedRule.canSetSpawn().test(player.level())), + enterProblem, + errorMessage == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(errorMessage) + ) + ); + } - PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.level(), bed), bedEnterResult); + public static io.papermc.paper.block.bed.BedRuleResult asBedRuleResult(net.minecraft.world.attribute.BedRule.Rule rule, boolean value) { + if (rule == net.minecraft.world.attribute.BedRule.Rule.ALWAYS) { + return io.papermc.paper.block.bed.BedRuleResult.ALLOWED; + } else if (rule == net.minecraft.world.attribute.BedRule.Rule.WHEN_DARK) { + if (value) { + return io.papermc.paper.block.bed.BedRuleResult.ALLOWED; + } else { + return io.papermc.paper.block.bed.BedRuleResult.TOO_MUCH_LIGHT; + } + } else if (rule == net.minecraft.world.attribute.BedRule.Rule.NEVER) { + return io.papermc.paper.block.bed.BedRuleResult.NEVER; + } + throw new IllegalArgumentException(rule.toString()); + } + + public static PlayerBedFailEnterEvent callPlayerBedFailEnterEvent( + net.minecraft.world.entity.player.Player player, BlockPos bed, net.minecraft.world.entity.player.Player.BedSleepingProblem bedSleepingProblem) { + net.minecraft.world.attribute.BedRule bedRule = player.level().environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE); + com.mojang.datafixers.util.Pair actionPair = asFailReason(player, bedRule, bedSleepingProblem); + final var event = new PlayerBedFailEnterEvent( + (org.bukkit.entity.Player) player.getBukkitEntity(), + actionPair.getFirst(), + org.bukkit.craftbukkit.block.CraftBlock.at(player.level(), bed), + bedSleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.EXPLOSION, + actionPair.getSecond().errorMessage(), + actionPair.getSecond()); + event.callEvent(); + return event; + } + + public static Either callPlayerBedEnterEvent( + net.minecraft.world.entity.player.Player player, BlockPos bed, Either nmsBedResult) { + final net.minecraft.world.attribute.BedRule bedRule = player.level().environmentAttributes().getDimensionValue(EnvironmentAttributes.BED_RULE); + com.mojang.datafixers.util.Pair bedEnterResult = nmsBedResult.mapBoth(sleepingProblem -> { + BedEnterResult enterResult = null; + io.papermc.paper.block.bed.BedEnterProblem enterProblem = null; + Component errorMessage = sleepingProblem.message(); + if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OTHER_PROBLEM) { + enterResult = BedEnterResult.OTHER_PROBLEM; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OTHER; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.NOT_SAFE) { + enterResult = BedEnterResult.NOT_SAFE; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.NOT_SAFE; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.OBSTRUCTED) { + enterResult = BedEnterResult.OBSTRUCTED; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.OBSTRUCTED; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.TOO_FAR_AWAY) { + enterResult = BedEnterResult.TOO_FAR_AWAY; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.TOO_FAR_AWAY; + } else if (sleepingProblem == net.minecraft.world.entity.player.Player.BedSleepingProblem.EXPLOSION) { + enterResult = BedEnterResult.EXPLOSION; + enterProblem = io.papermc.paper.block.bed.BedEnterProblem.EXPLOSION; + errorMessage = bedRule.errorMessage().orElse(null); + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.NEVER) { + enterResult = BedEnterResult.NOT_POSSIBLE_HERE; + } else if (bedRule.canSleep() == net.minecraft.world.attribute.BedRule.Rule.WHEN_DARK) { + enterResult = BedEnterResult.NOT_POSSIBLE_NOW; + } + + if (enterResult == null) { + // Don't know what the fail reason is, defaulting to OTHER to prevent server crashes + enterResult = BedEnterResult.OTHER_PROBLEM; + enterProblem = BedEnterProblem.OTHER; + } + + return com.mojang.datafixers.util.Pair.of( + enterResult, + new io.papermc.paper.block.bed.BedEnterActionImpl( + CraftEventFactory.asBedRuleResult(bedRule.canSleep(), bedRule.canSleep().test(player.level())), + CraftEventFactory.asBedRuleResult(bedRule.canSetSpawn(), bedRule.canSetSpawn().test(player.level())), + enterProblem, + errorMessage == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(errorMessage) + ) + ); + }, t -> com.mojang.datafixers.util.Pair.of( + BedEnterResult.OK, + new io.papermc.paper.block.bed.BedEnterActionImpl( + CraftEventFactory.asBedRuleResult(bedRule.canSleep(), bedRule.canSleep().test(player.level())), + CraftEventFactory.asBedRuleResult(bedRule.canSetSpawn(), bedRule.canSetSpawn().test(player.level())), + null, + null + ) + )).map(java.util.function.Function.identity(), java.util.function.Function.identity()); + + PlayerBedEnterEvent event = new PlayerBedEnterEvent( + (Player) player.getBukkitEntity(), + CraftBlock.at(player.level(), bed), + bedEnterResult.getFirst(), + bedEnterResult.getSecond() + ); Bukkit.getServer().getPluginManager().callEvent(event); Result result = event.useBed(); @@ -556,7 +688,7 @@ public static EntityShootBowEvent callEntityShootBowEvent(net.minecraft.world.en return event; } - public static VillagerCareerChangeEvent callVillagerCareerChangeEvent(net.minecraft.world.entity.npc.Villager villager, Profession future, VillagerCareerChangeEvent.ChangeReason reason) { + public static VillagerCareerChangeEvent callVillagerCareerChangeEvent(net.minecraft.world.entity.npc.villager.Villager villager, Profession future, VillagerCareerChangeEvent.ChangeReason reason) { VillagerCareerChangeEvent event = new VillagerCareerChangeEvent((Villager) villager.getBukkitEntity(), future, reason); Bukkit.getPluginManager().callEvent(event); @@ -715,7 +847,7 @@ public static boolean callItemMergeEvent(ItemEntity merging, ItemEntity mergingW return !event.isCancelled(); } - public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownSplashPotion potion, @Nullable HitResult position, Map affectedEntities) { // Paper - nullable hitResult + public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownSplashPotion potion, @Nullable HitResult position, Map affectedEntities) { // Paper - nullable hitResult ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); Block hitBlock = null; @@ -736,7 +868,7 @@ public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity return event; } - public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownLingeringPotion potion, @Nullable HitResult position, net.minecraft.world.entity.AreaEffectCloud cloud) { // Paper - nullable hitResult + public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownLingeringPotion potion, @Nullable HitResult position, net.minecraft.world.entity.AreaEffectCloud cloud) { // Paper - nullable hitResult ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); AreaEffectCloud effectCloud = (AreaEffectCloud) cloud.getBukkitEntity(); @@ -759,7 +891,7 @@ public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.mine } // Paper start - Fix potions splash events - public static io.papermc.paper.event.entity.WaterBottleSplashEvent callWaterBottleSplashEvent(net.minecraft.world.entity.projectile.AbstractThrownPotion potion, @Nullable HitResult hitResult, Map affectedEntities, java.util.Set rehydrate, java.util.Set extinguish) { + public static io.papermc.paper.event.entity.WaterBottleSplashEvent callWaterBottleSplashEvent(net.minecraft.world.entity.projectile.throwableitemprojectile.AbstractThrownPotion potion, @Nullable HitResult hitResult, Map affectedEntities, java.util.Set rehydrate, java.util.Set extinguish) { ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity(); Block hitBlock = null; @@ -793,7 +925,7 @@ public static BlockFadeEvent callBlockFadeEvent(LevelAccessor world, BlockPos po return event; } - public static boolean handleMoistureChangeEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleMoistureChangeEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos); snapshot.setData(state); @@ -807,11 +939,11 @@ public static boolean handleMoistureChangeEvent(Level world, BlockPos pos, net.m public static BlockPos sourceBlockOverride = null; // SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPos up to five methods deep. - public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { return handleBlockSpreadEvent(world, source, target, state, flags, false); } - public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, int flags, boolean checkSetResult) { + public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags, boolean checkSetResult) { // Suppress during worldgen if (!(world instanceof Level)) { boolean result = world.setBlock(target, state, flags); @@ -1160,7 +1292,7 @@ public static PlayerExpChangeEvent callPlayerExpChangeEvent(net.minecraft.world. return event; } - public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos); snapshot.setData(state); @@ -1250,17 +1382,17 @@ public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, Block return event; } - public static AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container) { + public static @Nullable AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container) { // Paper start - Add titleOverride to InventoryOpenEvent return callInventoryOpenEventWithTitle(player, container).getSecond(); } - public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container) { - return CraftEventFactory.callInventoryOpenEventWithTitle(player, container, false); + public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container) { + return callInventoryOpenEventWithTitle(player, container, false); // Paper end - Add titleOverride to InventoryOpenEvent } - public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) { + public static com.mojang.datafixers.util.Pair callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) { container.startOpen(); // delegate start open logic to before InventoryOpenEvent is fired if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason @@ -1597,6 +1729,8 @@ public static Cancellable handleStatisticsIncrease(net.minecraft.world.entity.pl case TIME_SINCE_REST: case AVIATE_ONE_CM: case STRIDER_ONE_CM: + case HAPPY_GHAST_ONE_CM: + case NAUTILUS_ONE_CM: // Do not process event for these - too spammy return null; default: @@ -1778,15 +1912,15 @@ public static EntityPotionEffectEvent callEntityPotionEffectChangeEvent(net.mine return event; } - public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags) { + public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags) { return CraftEventFactory.handleBlockFormEvent(world, pos, state, flags, null); } - public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity) { + public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags, @Nullable Entity entity) { return CraftEventFactory.handleBlockFormEvent(world, pos, state, flags, entity, false); } - public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity, boolean checkSetResult) { + public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @net.minecraft.world.level.block.Block.UpdateFlags int flags, @Nullable Entity entity, boolean checkSetResult) { CraftBlockState snapshot = CraftBlockStates.getBlockState(world, pos); snapshot.setData(state); @@ -1806,7 +1940,7 @@ public static boolean handleBatToggleSleepEvent(Entity bat, boolean awake) { } public static PlayerRecipeDiscoverEvent callPlayerRecipeListUpdateEvent(net.minecraft.world.entity.player.Player player, RecipeHolder recipeHolder) { - PlayerRecipeDiscoverEvent event = new PlayerRecipeDiscoverEvent((Player) player.getBukkitEntity(), CraftNamespacedKey.fromMinecraft(recipeHolder.id().location()), recipeHolder.value().showNotification()); + PlayerRecipeDiscoverEvent event = new PlayerRecipeDiscoverEvent((Player) player.getBukkitEntity(), CraftNamespacedKey.fromMinecraft(recipeHolder.id().identifier()), recipeHolder.value().showNotification()); event.callEvent(); return event; } @@ -2078,7 +2212,7 @@ public static void callEntityRemoveEvent(Entity entity, EntityRemoveEvent.Cause Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause)); } - public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, @Nullable net.minecraft.world.phys.Vec3 vector) { + public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, net.minecraft.world.phys.@Nullable Vec3 vector) { new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent( (Player) player.getBukkitEntity(), packet.getEntityId(), packet.isAttack(), CraftEquipmentSlot.getHand(hand), @@ -2181,4 +2315,69 @@ public static boolean callTransporterValidateTarget(final PathfinderMob mob, fin event.callEvent(); return event.isAllowed(); } + + public static GameRuleSetResult handleGameRuleSet(GameRule<@NotNull T> rule, T value, ServerLevel level, @Nullable CommandSender sender) { + String valueStr = rule.serialize(value); + final var event = new io.papermc.paper.event.world.PaperWorldGameRuleChangeEvent( + level.getWorld(), + sender, + CraftGameRule.minecraftToBukkit(rule), + valueStr + ); + if (event.callEvent()) { + if (!event.getValue().equals(valueStr)) { + value = rule.deserialize(event.getValue()).getOrThrow(); // should never throw value is checked in the event + } + level.getGameRules().set(rule, value, level); + return new GameRuleSetResult<>(value, false); + } else { + return new GameRuleSetResult<>(level.getGameRules().get(rule), true); + } + } + + public record GameRuleSetResult(T value, boolean cancelled) { + + } + + private static BlockLockCheckEvent LAST_BLOCK_LOCK_CHECK_EVENT = null; + + public static boolean callBlockLockCheckEvent( + BlockEntity blockEntity, + LockCode code, + Component displayName, + net.minecraft.world.entity.player.Player p + ) { + if (p instanceof net.minecraft.server.level.ServerPlayer player + && blockEntity != null + && blockEntity.getLevel() != null + && blockEntity.getLevel().getBlockEntity(blockEntity.getBlockPos()) == blockEntity) { + final org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos()); + net.kyori.adventure.text.Component lockedMessage = net.kyori.adventure.text.Component.translatable("container.isLocked", io.papermc.paper.adventure.PaperAdventure.asAdventure(displayName)); + net.kyori.adventure.sound.Sound lockedSound = net.kyori.adventure.sound.Sound.sound(org.bukkit.Sound.BLOCK_CHEST_LOCKED, net.kyori.adventure.sound.Sound.Source.BLOCK, 1.0F, 1.0F); + final io.papermc.paper.event.block.BlockLockCheckEvent event = new io.papermc.paper.event.block.BlockLockCheckEvent(block, player.getBukkitEntity(), lockedMessage, lockedSound); + event.callEvent(); + if (event.getResult() == org.bukkit.event.Event.Result.ALLOW) { + return true; + } else if (event.getResult() == org.bukkit.event.Event.Result.DENY || !code.canUnlock(player, event.isUsingCustomKeyItemStack() ? org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getKeyItem()) : player.getMainHandItem())) { + LAST_BLOCK_LOCK_CHECK_EVENT = event; + return false; + } + } + return true; + } + + public static boolean sendChestLockedNotifications(Vec3 pos) { + if (LAST_BLOCK_LOCK_CHECK_EVENT != null) { + final io.papermc.paper.event.block.BlockLockCheckEvent event = LAST_BLOCK_LOCK_CHECK_EVENT; + LAST_BLOCK_LOCK_CHECK_EVENT = null; + if (event.getLockedMessage() != null) { + event.getPlayer().sendActionBar(event.getLockedMessage()); + } + if (event.getLockedSound() != null) { + event.getPlayer().getWorld().playSound(event.getLockedSound(), pos.x(), pos.y(), pos.z()); + } + return true; + } + return false; + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java index fc848f288363..524c28b4c876 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/structure/CraftStructure.java @@ -18,6 +18,14 @@ public static net.minecraft.world.level.levelgen.structure.Structure bukkitToMin return CraftRegistry.bukkitToMinecraft(bukkit); } + public static Structure minecraftHolderToBukkit(Holder minecraft) { + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.STRUCTURE); + } + + public static Holder bukkitToMinecraftHolder(Structure bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit); + } + private final Holder holder; public CraftStructure(Holder holder) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java index 3f7f9e479d31..ea0a6fc1798a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java @@ -2,9 +2,8 @@ import net.minecraft.world.Container; import org.bukkit.inventory.HorseInventory; -import org.bukkit.inventory.ItemStack; -public class CraftInventoryHorse extends CraftSaddledInventory implements HorseInventory { +public class CraftInventoryHorse extends CraftInventorySaddledHorse implements HorseInventory { public CraftInventoryHorse(Container inventory, Container bodyArmorInventory, Container saddleInventory) { super(inventory, bodyArmorInventory, saddleInventory); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java index 8eb2677d46f9..c526ab5bec73 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java @@ -4,7 +4,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.LlamaInventory; -public class CraftInventoryLlama extends CraftInventoryAbstractHorse implements LlamaInventory { +public class CraftInventoryLlama extends CraftInventorySaddledMount implements LlamaInventory { public CraftInventoryLlama(Container inventory, Container bodyArmorInventory, Container saddleInventory) { super(inventory, bodyArmorInventory, saddleInventory); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledHorse.java new file mode 100644 index 000000000000..cc2a7c0621f8 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledHorse.java @@ -0,0 +1,12 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.world.Container; +import org.bukkit.inventory.SaddledHorseInventory; + +public class CraftInventorySaddledHorse extends CraftInventorySaddledMount implements SaddledHorseInventory { + + public CraftInventorySaddledHorse(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { + super(inventory, bodyArmorInventory, saddleInventory); + } + +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java similarity index 63% rename from paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java rename to paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java index 167c2c9a07ad..261622a31241 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAbstractHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySaddledMount.java @@ -2,17 +2,17 @@ import com.google.common.base.Preconditions; import net.minecraft.world.Container; -import net.minecraft.world.inventory.HorseInventoryMenu; +import net.minecraft.world.inventory.AbstractMountInventoryMenu; import org.apache.commons.lang3.ArrayUtils; -import org.bukkit.inventory.AbstractHorseInventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.SaddledMountInventory; -public class CraftInventoryAbstractHorse extends CraftInventory implements AbstractHorseInventory { +public class CraftInventorySaddledMount extends CraftInventory implements SaddledMountInventory { private final Container bodyArmorInventory; private final Container saddleInventory; - public CraftInventoryAbstractHorse(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { + public CraftInventorySaddledMount(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { super(inventory); this.bodyArmorInventory = bodyArmorInventory; this.saddleInventory = saddleInventory; @@ -20,12 +20,12 @@ public CraftInventoryAbstractHorse(Container inventory, final Container bodyArmo @Override public ItemStack getSaddle() { - return this.getItem(HorseInventoryMenu.SLOT_SADDLE); + return this.getItem(AbstractMountInventoryMenu.SLOT_SADDLE); } @Override public void setSaddle(ItemStack stack) { - this.setItem(HorseInventoryMenu.SLOT_SADDLE, stack); + this.setItem(AbstractMountInventoryMenu.SLOT_SADDLE, stack); } public Container getMainInventory() { @@ -41,11 +41,11 @@ public Container getSaddleInventory() { } public ItemStack getArmor() { - return this.getItem(HorseInventoryMenu.SLOT_BODY_ARMOR); + return this.getItem(AbstractMountInventoryMenu.SLOT_BODY_ARMOR); } public void setArmor(ItemStack armor) { - this.setItem(HorseInventoryMenu.SLOT_BODY_ARMOR, armor); + this.setItem(AbstractMountInventoryMenu.SLOT_BODY_ARMOR, armor); } @Override @@ -62,11 +62,11 @@ public boolean isEmpty() { public ItemStack[] getContents() { ItemStack[] items = new ItemStack[this.getSize()]; - items[HorseInventoryMenu.SLOT_SADDLE] = this.getSaddle(); - items[HorseInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor(); + items[AbstractMountInventoryMenu.SLOT_SADDLE] = this.getSaddle(); + items[AbstractMountInventoryMenu.SLOT_BODY_ARMOR] = this.getArmor(); - for (int i = HorseInventoryMenu.SLOT_HORSE_INVENTORY_START; i < items.length; i++) { - net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - HorseInventoryMenu.SLOT_HORSE_INVENTORY_START); + for (int i = AbstractMountInventoryMenu.SLOT_INVENTORY_START; i < items.length; i++) { + net.minecraft.world.item.ItemStack item = this.getMainInventory().getItem(i - AbstractMountInventoryMenu.SLOT_INVENTORY_START); items[i] = item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } @@ -77,29 +77,29 @@ public ItemStack[] getContents() { public void setContents(ItemStack[] items) { Preconditions.checkArgument(items.length <= this.getSize(), "Invalid inventory size (%s); expected %s or less", items.length, this.getSize()); - this.setSaddle(ArrayUtils.get(items, HorseInventoryMenu.SLOT_SADDLE)); - this.setArmor(ArrayUtils.get(items, HorseInventoryMenu.SLOT_BODY_ARMOR)); + this.setSaddle(ArrayUtils.get(items, AbstractMountInventoryMenu.SLOT_SADDLE)); + this.setArmor(ArrayUtils.get(items, AbstractMountInventoryMenu.SLOT_BODY_ARMOR)); - for (int i = HorseInventoryMenu.SLOT_HORSE_INVENTORY_START; i < this.getSize(); i++) { + for (int i = AbstractMountInventoryMenu.SLOT_INVENTORY_START; i < this.getSize(); i++) { net.minecraft.world.item.ItemStack item = i >= items.length ? net.minecraft.world.item.ItemStack.EMPTY : CraftItemStack.asNMSCopy(items[i]); - this.getMainInventory().setItem(i - HorseInventoryMenu.SLOT_HORSE_INVENTORY_START, item); + this.getMainInventory().setItem(i - AbstractMountInventoryMenu.SLOT_INVENTORY_START, item); } } @Override public ItemStack getItem(final int index) { - if (index == HorseInventoryMenu.SLOT_SADDLE) { + if (index == AbstractMountInventoryMenu.SLOT_SADDLE) { final net.minecraft.world.item.ItemStack item = this.getSaddleInventory().getItem(0); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); - } else if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) { + } else if (index == AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { final net.minecraft.world.item.ItemStack item = this.getArmorInventory().getItem(0); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); } else { int shiftedIndex = index; - if (index > HorseInventoryMenu.SLOT_SADDLE) { + if (index > AbstractMountInventoryMenu.SLOT_SADDLE) { shiftedIndex--; } - if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) { + if (index > AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { shiftedIndex--; } @@ -110,16 +110,16 @@ public ItemStack getItem(final int index) { @Override public void setItem(final int index, final ItemStack item) { - if (index == HorseInventoryMenu.SLOT_SADDLE) { + if (index == AbstractMountInventoryMenu.SLOT_SADDLE) { this.getSaddleInventory().setItem(0, CraftItemStack.asNMSCopy(item)); - } else if (index == HorseInventoryMenu.SLOT_BODY_ARMOR) { + } else if (index == AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { this.getArmorInventory().setItem(0, CraftItemStack.asNMSCopy(item)); } else { int shiftedIndex = index; - if (index > HorseInventoryMenu.SLOT_SADDLE) { + if (index > AbstractMountInventoryMenu.SLOT_SADDLE) { shiftedIndex--; } - if (index > HorseInventoryMenu.SLOT_BODY_ARMOR) { + if (index > AbstractMountInventoryMenu.SLOT_BODY_ARMOR) { shiftedIndex--; } this.getMainInventory().setItem(shiftedIndex, CraftItemStack.asNMSCopy(item)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index f896417d37ba..4abee7b6d922 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -10,7 +10,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.EnchantmentTags; import net.minecraft.util.RandomSource; import net.minecraft.world.item.Item; @@ -302,7 +302,7 @@ public ItemStack getSpawnEgg0(org.bukkit.entity.EntityType type) { return null; } String typeId = type.getKey().toString(); - net.minecraft.resources.ResourceLocation typeKey = ResourceLocation.parse(typeId); + net.minecraft.resources.Identifier typeKey = Identifier.parse(typeId); net.minecraft.world.entity.EntityType nmsType = net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.getValue(typeKey); net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.byId(nmsType); return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror(); 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 905f04654842..546b7aa1055c 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 @@ -3,20 +3,13 @@ import com.destroystokyo.paper.inventory.meta.ArmorStandMeta; import java.util.function.BiFunction; import net.minecraft.world.item.BannerItem; -import net.minecraft.world.item.BedItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BundleItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.SignItem; import net.minecraft.world.item.SpawnEggItem; -import net.minecraft.world.level.block.AbstractChestBlock; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.ChestBlock; -import net.minecraft.world.level.block.CopperGolemStatueBlock; import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.ShelfBlock; -import net.minecraft.world.level.block.ShulkerBoxBlock; import org.bukkit.inventory.ItemType; import org.bukkit.inventory.meta.ArmorMeta; import org.bukkit.inventory.meta.AxolotlBucketMeta; 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 96c0797aaea7..002682049fe8 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 @@ -9,9 +9,9 @@ import java.util.function.Consumer; import java.util.function.Predicate; import net.kyori.adventure.text.Component; -import net.minecraft.advancements.critereon.DataComponentMatchers; -import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.DataComponentMatchers; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.component.DataComponentExactPredicate; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java index a90d0d5e95b3..065309bf3e41 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java @@ -61,15 +61,11 @@ public Class getInventoryViewClass() { return this.typeData.get().viewClass(); } - public static net.minecraft.world.inventory.MenuType bukkitToMinecraft(MenuType bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static MenuType minecraftToBukkit(net.minecraft.world.inventory.MenuType minecraft) { return CraftRegistry.minecraftToBukkit(minecraft, Registries.MENU); } public static MenuType minecraftHolderToBukkit(Holder> minecraft) { - return CraftMenuType.minecraftToBukkit(minecraft.value()); + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.MENU); } } 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 75fa6f99c939..71c14b8c4d46 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 @@ -84,7 +84,7 @@ public MerchantOffers getOffers() { // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent @Override public void processTrade(MerchantOffer offer, @javax.annotation.Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent - /* Based on {@link net.minecraft.world.entity.npc.AbstractVillager#processTrade(MerchantOffer, io.papermc.paper.event.player.PlayerPurchaseEvent)} */ + /* Based on {@link net.minecraft.world.entity.npc.villager.AbstractVillager#processTrade(MerchantOffer, io.papermc.paper.event.player.PlayerPurchaseEvent)} */ if (getTradingPlayer() instanceof net.minecraft.server.level.ServerPlayer) { if (event == null || event.willIncreaseTradeUses()) { offer.increaseUses(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java index 4f4c1748f802..ded1e398ff3b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCompass.java @@ -11,7 +11,7 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.component.LodestoneTracker; @@ -54,7 +54,7 @@ public class CraftMetaCompass extends CraftMetaItem implements CompassMeta { super(map); String lodestoneWorldKey = SerializableMeta.getString(map, CraftMetaCompass.LODESTONE_POS_WORLD.BUKKIT, true); if (lodestoneWorldKey != null) { - ResourceKey lodestoneWorld = ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(lodestoneWorldKey)); + ResourceKey lodestoneWorld = ResourceKey.create(Registries.DIMENSION, Identifier.tryParse(lodestoneWorldKey)); int lodestoneX = (Integer) map.get(CraftMetaCompass.LODESTONE_POS_X.BUKKIT); int lodestoneY = (Integer) map.get(CraftMetaCompass.LODESTONE_POS_Y.BUKKIT); int lodestoneZ = (Integer) map.get(CraftMetaCompass.LODESTONE_POS_Z.BUKKIT); @@ -182,7 +182,7 @@ Builder serialize(Builder builder) { if (this.isLodestoneCompass()) { if (this.tracker.target().isPresent()) { - builder.put(CraftMetaCompass.LODESTONE_POS_WORLD.BUKKIT, this.tracker.target().get().dimension().location().toString()); + builder.put(CraftMetaCompass.LODESTONE_POS_WORLD.BUKKIT, this.tracker.target().get().dimension().identifier().toString()); builder.put(CraftMetaCompass.LODESTONE_POS_X.BUKKIT, this.tracker.target().get().pos().getX()); builder.put(CraftMetaCompass.LODESTONE_POS_Y.BUKKIT, this.tracker.target().get().pos().getY()); builder.put(CraftMetaCompass.LODESTONE_POS_Z.BUKKIT, this.tracker.target().get().pos().getZ()); 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 c0f44885f4dc..3825cd713a42 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 @@ -55,7 +55,7 @@ import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.SnbtPrinterTagVisitor; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.tags.TagKey; import net.minecraft.util.Unit; import net.minecraft.world.entity.EquipmentSlotGroup; @@ -236,9 +236,9 @@ DataComponentPatch build() { @Specific(Specific.To.NBT) static final ItemMetaKeyType TOOLTIP_DISPLAY = new ItemMetaKeyType<>(DataComponents.TOOLTIP_DISPLAY, "tool-tip-display"); @Specific(Specific.To.NBT) - static final ItemMetaKeyType TOOLTIP_STYLE = new ItemMetaKeyType<>(DataComponents.TOOLTIP_STYLE, "tool-tip-style"); + static final ItemMetaKeyType TOOLTIP_STYLE = new ItemMetaKeyType<>(DataComponents.TOOLTIP_STYLE, "tool-tip-style"); @Specific(Specific.To.NBT) - static final ItemMetaKeyType ITEM_MODEL = new ItemMetaKeyType<>(DataComponents.ITEM_MODEL, "item-model"); + static final ItemMetaKeyType ITEM_MODEL = new ItemMetaKeyType<>(DataComponents.ITEM_MODEL, "item-model"); @Specific(Specific.To.NBT) static final ItemMetaKeyType UNBREAKABLE = new ItemMetaKeyType<>(DataComponents.UNBREAKABLE, "Unbreakable"); @Specific(Specific.To.NBT) @@ -302,8 +302,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( @@ -794,7 +794,7 @@ static Multimap buildModifiers(ItemAttributeModifi for (Object removedObject : removed) { String removedString = (String) removedObject; - DataComponentType component = componentTypeRegistry.getValue(ResourceLocation.parse(removedString)); + DataComponentType component = componentTypeRegistry.getValue(Identifier.parse(removedString)); if (component != null) { this.removedTags.add(component); } @@ -1841,7 +1841,7 @@ public String getAsComponentString() { for (Entry, Optional> entry : patch.entrySet()) { DataComponentType componentType = entry.getKey(); Optional componentValue = entry.getValue(); - String componentKey = componentTypeRegistry.getResourceKey(componentType).orElseThrow().location().toString(); + String componentKey = componentTypeRegistry.getResourceKey(componentType).orElseThrow().identifier().toString(); if (componentValue.isPresent()) { net.minecraft.nbt.Tag componentValueAsNBT = (net.minecraft.nbt.Tag) ((DataComponentType) componentType).codecOrThrow().encodeStart(ops, componentValue.get()).getOrThrow(); @@ -2278,7 +2278,7 @@ ImmutableMap.Builder serialize(ImmutableMap.Builder removedTags = new ArrayList<>(); for (DataComponentType removed : this.removedTags) { - String componentKey = componentTypeRegistry.getResourceKey(removed).orElseThrow().location().toString(); + String componentKey = componentTypeRegistry.getResourceKey(removed).orElseThrow().identifier().toString(); removedTags.add(componentKey); } @@ -2519,14 +2519,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.critereon.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(m)).build(); + return net.minecraft.advancements.criterion.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())) @@ -2557,22 +2557,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.critereon.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(Objects.requireNonNull(org.bukkit.Registry.MATERIAL.get(key)))).build()); + predicates.add(net.minecraft.advancements.criterion.BlockPredicate.Builder.block().of(blockRegistry, CraftBlockType.bukkitToMinecraft(Objects.requireNonNull(org.bukkit.Registry.MATERIAL.get(key)))).build()); } else if (namespaced instanceof final com.destroystokyo.paper.NamespacedTag tag) { - predicates.add(net.minecraft.advancements.critereon.BlockPredicate.Builder.block().of(blockRegistry, net.minecraft.tags.TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(tag.getNamespace(), tag.getKey()))).build()); + 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()); } } 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.critereon.BlockPredicate predicate : predicates) { + for (final net.minecraft.advancements.criterion.BlockPredicate predicate : predicates) { if (predicate.blocks().isEmpty()) { continue; } @@ -2582,7 +2582,7 @@ private static Set convertToLegacyNamespaced } else { holders.forEach(h -> { h.unwrapKey().ifPresent(key -> { - namespaceds.add(new org.bukkit.NamespacedKey(key.location().getNamespace(), key.location().getPath())); + namespaceds.add(new org.bukkit.NamespacedKey(key.identifier().getNamespace(), key.identifier().getPath())); }); }); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java index b162af62cfc3..e6ef13de6a15 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java @@ -35,7 +35,7 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo getOrEmpty(tag, CraftMetaKnowledgeBook.BOOK_RECIPES).ifPresent((recipes) -> { for (ResourceKey recipe : recipes) { - this.addRecipe(CraftNamespacedKey.fromMinecraft(recipe.location())); + this.addRecipe(CraftNamespacedKey.fromMinecraft(recipe.identifier())); } }); } 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 228da1dc019b..0266193900db 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 @@ -5,13 +5,13 @@ import java.util.Map; import java.util.Objects; import com.mojang.datafixers.util.Either; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.UUIDUtil; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.player.PlayerSkin; import net.minecraft.world.item.component.ResolvableProfile; import org.bukkit.Bukkit; @@ -35,11 +35,11 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { @ItemMetaKey.Specific(ItemMetaKey.Specific.To.NBT) static final ItemMetaKey BLOCK_ENTITY_TAG = new ItemMetaKey("BlockEntityTag"); - static final ItemMetaKeyType NOTE_BLOCK_SOUND = new ItemMetaKeyType<>(DataComponents.NOTE_BLOCK_SOUND, "note_block_sound"); + static final ItemMetaKeyType NOTE_BLOCK_SOUND = new ItemMetaKeyType<>(DataComponents.NOTE_BLOCK_SOUND, "note_block_sound"); static final int MAX_OWNER_LENGTH = 16; private ResolvableProfile profile; - private ResourceLocation noteBlockSound; + private Identifier noteBlockSound; CraftMetaSkull(CraftMetaItem meta) { super(meta); @@ -93,7 +93,7 @@ void deserializeInternal(CompoundTag tag, Object context) { tag.getCompound(CraftMetaSkull.BLOCK_ENTITY_TAG.NBT) .flatMap(blockEntityTag -> blockEntityTag.copy().getString(CraftMetaSkull.NOTE_BLOCK_SOUND.NBT)) .ifPresent(noteBlockSound -> { - this.noteBlockSound = ResourceLocation.tryParse(noteBlockSound); + this.noteBlockSound = Identifier.tryParse(noteBlockSound); }); } @@ -148,7 +148,7 @@ public String getOwner() { } @Override - public void setPlayerProfile(@Nullable com.destroystokyo.paper.profile.PlayerProfile profile) { + public void setPlayerProfile(com.destroystokyo.paper.profile.@Nullable PlayerProfile profile) { setProfile((profile == null) ? null : com.destroystokyo.paper.profile.CraftPlayerProfile.asResolvableProfileCopy(profile)); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java deleted file mode 100644 index 94364ec22058..000000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.bukkit.craftbukkit.inventory; - -import net.minecraft.world.Container; -import org.bukkit.inventory.SaddledHorseInventory; - -public class CraftSaddledInventory extends CraftInventoryAbstractHorse implements SaddledHorseInventory { - - public CraftSaddledInventory(Container inventory, final Container bodyArmorInventory, final Container saddleInventory) { - super(inventory, bodyArmorInventory, saddleInventory); - } - -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java index 2090613ef840..9db372844211 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java @@ -11,7 +11,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.item.equipment.EquipmentAssets; import net.minecraft.world.item.equipment.Equippable; @@ -69,8 +69,8 @@ public CraftEquippableComponent(Map map) { this.handle = new Equippable(slot, (equipSound != null) ? CraftSound.bukkitToMinecraftHolder(equipSound) : SoundEvents.ARMOR_EQUIP_GENERIC, - Optional.ofNullable(model).map(ResourceLocation::parse).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), - Optional.ofNullable(cameraOverlay).map(ResourceLocation::parse), + Optional.ofNullable(model).map(Identifier::parse).map((k) -> ResourceKey.create(EquipmentAssets.ROOT_ID, k)), + Optional.ofNullable(cameraOverlay).map(Identifier::parse), Optional.ofNullable(allowedEntities), (dispensable != null) ? dispensable : true, (swappable != null) ? swappable : true, @@ -132,7 +132,7 @@ public void setEquipSound(Sound sound) { @Override public NamespacedKey getModel() { - return this.handle.assetId().map((a) -> CraftNamespacedKey.fromMinecraft(a.location())).orElse(null); + return this.handle.assetId().map((a) -> CraftNamespacedKey.fromMinecraft(a.identifier())).orElse(null); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java index eff1cad2c360..616d409a8753 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java @@ -7,7 +7,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.EitherHolder; import net.minecraft.world.item.JukeboxPlayable; import org.bukkit.JukeboxSong; @@ -35,7 +35,7 @@ public CraftJukeboxComponent(CraftJukeboxComponent jukebox) { public CraftJukeboxComponent(Map map) { String song = SerializableMeta.getObject(String.class, map, "song", false); - this.handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, ResourceLocation.parse(song)))); + this.handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, Identifier.parse(song)))); } @Override @@ -57,7 +57,7 @@ public JukeboxSong getSong() { @Override public NamespacedKey getSongKey() { - return CraftNamespacedKey.fromMinecraft(this.handle.song().key().orElseThrow().location()); + return CraftNamespacedKey.fromMinecraft(this.handle.song().key().orElseThrow().identifier()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java index b6f285d5e84b..84025d9c2b7e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftUseCooldownComponent.java @@ -4,7 +4,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.component.UseCooldown; import org.bukkit.NamespacedKey; import org.bukkit.configuration.serialization.SerializableAs; @@ -29,7 +29,7 @@ public CraftUseCooldownComponent(Map map) { Float seconds = SerializableMeta.getObject(Float.class, map, "seconds", false); String cooldownGroup = SerializableMeta.getString(map, "cooldown-group", true); - this.handle = new UseCooldown(seconds, Optional.ofNullable(cooldownGroup).map(ResourceLocation::parse)); + this.handle = new UseCooldown(seconds, Optional.ofNullable(cooldownGroup).map(Identifier::parse)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java index 5a7a0520f513..1df7df13a602 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimMaterial.java @@ -12,18 +12,10 @@ public class CraftTrimMaterial extends HolderableBase implements TrimMaterial { - public static TrimMaterial minecraftToBukkit(net.minecraft.world.item.equipment.trim.TrimMaterial minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.TRIM_MATERIAL); - } - public static TrimMaterial minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.TRIM_MATERIAL); } - public static net.minecraft.world.item.equipment.trim.TrimMaterial bukkitToMinecraft(TrimMaterial bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(TrimMaterial bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java index 89925377dcad..5bb67269b055 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/trim/CraftTrimPattern.java @@ -12,18 +12,10 @@ public class CraftTrimPattern extends HolderableBase implements TrimPattern { - public static TrimPattern minecraftToBukkit(net.minecraft.world.item.equipment.trim.TrimPattern minecraft) { - return CraftRegistry.minecraftToBukkit(minecraft, Registries.TRIM_PATTERN); - } - public static TrimPattern minecraftHolderToBukkit(Holder minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.TRIM_PATTERN); } - public static net.minecraft.world.item.equipment.trim.TrimPattern bukkitToMinecraft(TrimPattern bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(TrimPattern bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java index 96dda6e0baa5..7a33cabd19c7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenus.java @@ -2,7 +2,7 @@ import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.npc.villager.Villager; import net.minecraft.world.inventory.MerchantMenu; import net.minecraft.world.item.trading.Merchant; import net.minecraft.world.item.trading.MerchantOffers; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java index d46f942e1c41..c32be77880c6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/view/builder/CraftMerchantInventoryViewBuilder.java @@ -4,7 +4,7 @@ import io.papermc.paper.adventure.PaperAdventure; import net.kyori.adventure.text.Component; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.npc.AbstractVillager; +import net.minecraft.world.entity.npc.villager.AbstractVillager; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.MerchantMenu; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index 0b9b29753984..ced48449ad7e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -13,7 +13,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.Bootstrap; import net.minecraft.server.MinecraftServer; import net.minecraft.util.datafix.DataFixers; @@ -338,7 +338,7 @@ public static void init() { } String name = blockTag.get("Name").asString(""); - Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(name)); + Block block = BuiltInRegistries.BLOCK.getValue(Identifier.parse(name)); if (block == null) { continue; } @@ -412,7 +412,7 @@ public static void init() { } // Preconditions.checkState(newId.contains("minecraft:"), "Unknown new material for " + matData); - Item newMaterial = BuiltInRegistries.ITEM.getValue(ResourceLocation.parse(newId)); + Item newMaterial = BuiltInRegistries.ITEM.getValue(Identifier.parse(newId)); if (newMaterial == Items.AIR) { continue; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java index db51e0f1ad8c..77f89f390f09 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java @@ -15,7 +15,7 @@ import java.util.logging.Logger; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; -import net.minecraft.Util; +import net.minecraft.util.Util; import org.bukkit.map.MapPalette; public class CraftMapColorCache implements MapPalette.MapColorCache { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java index c0cf9065decb..f8313826f604 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCursor.java @@ -13,18 +13,10 @@ public static final class CraftType extends OldEnumHolderable minecraft) { return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.MAP_DECORATION_TYPE); } - public static MapDecorationType bukkitToMinecraft(MapCursor.Type bukkit) { - return CraftRegistry.bukkitToMinecraft(bukkit); - } - public static Holder bukkitToMinecraftHolder(MapCursor.Type bukkit) { return CraftRegistry.bukkitToMinecraftHolder(bukkit); } 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 add1575ef432..4881e366c8d4 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 @@ -26,7 +26,7 @@ public class CraftPotionEffectType extends PotionEffectType implements Holderable, io.papermc.paper.world.flag.PaperFeatureDependent { public static PotionEffectType minecraftHolderToBukkit(Holder minecraft) { - return CraftPotionEffectType.minecraftToBukkit(minecraft.value()); + return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.MOB_EFFECT); } public static PotionEffectType minecraftToBukkit(MobEffect minecraft) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java index 24010b74ac13..a304fafd78f6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java @@ -29,7 +29,7 @@ public static PotionType minecraftToBukkit(Potion minecraft) { Preconditions.checkArgument(minecraft != null); net.minecraft.core.Registry registry = CraftRegistry.getMinecraftRegistry(Registries.POTION); - PotionType bukkit = Registry.POTION.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); + PotionType bukkit = Registry.POTION.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().identifier())); Preconditions.checkArgument(bukkit != null); 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 362f0427d0c6..4d4c7861323a 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 @@ -18,7 +18,7 @@ import java.util.stream.Collectors; import com.mojang.datafixers.util.Either; import io.papermc.paper.profile.MutablePropertyMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.players.NameAndId; import net.minecraft.world.entity.player.PlayerSkin; 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 f4fca4614a5d..8065aedbee7f 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 @@ -16,6 +16,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProcessor; @@ -103,7 +104,7 @@ public void place(RegionAccessor regionAccessor, BlockVector location, boolean i access.setDelegate(handle); access.setStructureTransformer(new CraftStructureTransformer(handle, new ChunkPos(pos), blockTransformers, entityTransformers)); - this.structure.placeInWorld(access, pos, pos, definedstructureinfo, randomSource, 2); + this.structure.placeInWorld(access, pos, pos, definedstructureinfo, randomSource, Block.UPDATE_CLIENTS); access.getStructureTransformer().discard(); } 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 0fc33b97d502..5cdc356f7288 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 @@ -16,7 +16,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; import org.bukkit.NamespacedKey; @@ -37,7 +37,7 @@ public CraftStructureManager(StructureTemplateManager structureManager, Registry @Override public Map getStructures() { Map cachedStructures = new HashMap<>(); - for (Map.Entry> entry : this.structureManager.structureRepository.entrySet()) { + for (Map.Entry> entry : this.structureManager.structureRepository.entrySet()) { entry.getValue().ifPresent(definedStructure -> cachedStructures.put(CraftNamespacedKey.fromMinecraft(entry.getKey()), new CraftStructure(definedStructure, this.registry))); } return Collections.unmodifiableMap(cachedStructures); @@ -56,7 +56,7 @@ public Structure getStructure(NamespacedKey structureKey) { @Override public Structure loadStructure(NamespacedKey structureKey, boolean register) { - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); Optional structure = this.structureManager.structureRepository.get(minecraftKey); structure = structure == null ? Optional.empty() : structure; @@ -77,7 +77,7 @@ public Structure loadStructure(NamespacedKey structureKey) { @Override public void saveStructure(NamespacedKey structureKey) { - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); this.structureManager.save(minecraftKey); } @@ -96,7 +96,7 @@ public void saveStructure(NamespacedKey structureKey, Structure structure) throw public Structure registerStructure(NamespacedKey structureKey, Structure structure) { Preconditions.checkArgument(structureKey != null, "NamespacedKey structureKey cannot be null"); Preconditions.checkArgument(structure != null, "Structure cannot be null"); - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); final Optional optionalDefinedStructure = Optional.of(((CraftStructure) structure).getHandle()); final Optional previousStructure = this.structureManager.structureRepository.put(minecraftKey, optionalDefinedStructure); @@ -106,7 +106,7 @@ public Structure registerStructure(NamespacedKey structureKey, Structure structu @Override public Structure unregisterStructure(NamespacedKey structureKey) { Preconditions.checkArgument(structureKey != null, "NamespacedKey structureKey cannot be null"); - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); final Optional previousStructure = this.structureManager.structureRepository.remove(minecraftKey); return previousStructure == null ? null : previousStructure.map((s) -> new CraftStructure(s, this.registry)).orElse(null); @@ -119,7 +119,7 @@ public void deleteStructure(NamespacedKey structureKey) throws IOException { @Override public void deleteStructure(NamespacedKey structureKey, boolean unregister) throws IOException { - ResourceLocation key = CraftNamespacedKey.toMinecraft(structureKey); + Identifier key = CraftNamespacedKey.toMinecraft(structureKey); if (unregister) { this.structureManager.structureRepository.remove(key); @@ -130,7 +130,7 @@ public void deleteStructure(NamespacedKey structureKey, boolean unregister) thro @Override public File getStructureFile(NamespacedKey structureKey) { - ResourceLocation minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); + Identifier minecraftKey = this.createAndValidateMinecraftStructureKey(structureKey); return this.structureManager.createAndValidatePathToGeneratedStructure(minecraftKey, ".nbt").toFile(); } @@ -172,10 +172,10 @@ public Structure createStructure() { return new CraftStructure(new StructureTemplate(), this.registry); } - private ResourceLocation createAndValidateMinecraftStructureKey(NamespacedKey structureKey) { + private Identifier createAndValidateMinecraftStructureKey(NamespacedKey structureKey) { Preconditions.checkArgument(structureKey != null, "NamespacedKey structureKey cannot be null"); - ResourceLocation key = CraftNamespacedKey.toMinecraft(structureKey); + Identifier key = CraftNamespacedKey.toMinecraft(structureKey); Preconditions.checkArgument(!key.getPath().contains("//"), "Resource key for Structures can not contain \"//\""); return key; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java index ee97ff023f9d..e3c92ae2bd71 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftDamageTag.java @@ -21,6 +21,6 @@ public boolean isTagged(DamageType type) { @Override public Set getValues() { - return this.getHandle().stream().map(Holder::value).map(CraftDamageType::minecraftToBukkit).collect(Collectors.toUnmodifiableSet()); + return this.getHandle().stream().map(CraftDamageType::minecraftHolderToBukkit).collect(Collectors.toUnmodifiableSet()); } } 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 d6d8840f3298..4a1b8038a144 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 @@ -17,7 +17,7 @@ public final class ApiVersion implements Comparable, Serializable { static { versions = new HashMap<>(); - CURRENT = getOrCreateVersion("1.21.10"); + CURRENT = getOrCreateVersion(Versioning.getCurrentApiVersion()); FLATTENING = getOrCreateVersion("1.13"); FIELD_NAME_PARITY = getOrCreateVersion("1.20.5"); ABSTRACT_COW = getOrCreateVersion("1.21.5"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index cb9488fbad9d..989b2f751a59 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -12,6 +12,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.dimension.DimensionType; @@ -51,7 +52,7 @@ public BlockEntity getBlockEntity(BlockPos pos) { } @Override - public boolean setBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { pos = pos.immutable(); // remove first to keep last updated order this.blocks.remove(pos); @@ -81,7 +82,7 @@ public boolean destroyBlock(BlockPos pos, boolean dropBlock, Entity entity, int return false; } - this.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3, recursionLeft); // capture block without the event + this.setBlock(pos, blockState.getFluidState().createLegacyBlock(), Block.UPDATE_ALL, recursionLeft); // capture block without the event return true; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java index d1e0c0610baa..0e2f27db42c7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CapturedBlock.java @@ -1,10 +1,11 @@ package org.bukkit.craftbukkit.util; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @NullMarked -public record CapturedBlock(BlockState state, int flags, @Nullable BlockEntity blockEntity) { +public record CapturedBlock(BlockState state, @Block.UpdateFlags int flags, @Nullable BlockEntity blockEntity) { } 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 f83067eaa4ee..299e53032471 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 @@ -38,7 +38,7 @@ import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; import net.minecraft.nbt.TagParser; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.ProblemReporter; @@ -177,7 +177,7 @@ public static MaterialData getMaterialData(Item item) { continue; } - ResourceLocation key = CraftNamespacedKey.toMinecraft(material.getKey()); + Identifier key = CraftNamespacedKey.toMinecraft(material.getKey()); BuiltInRegistries.ITEM.getOptional(key).ifPresent((item) -> { CraftMagicNumbers.MATERIAL_ITEM.put(material, item); }); @@ -301,13 +301,13 @@ private static File getBukkitDataPackFolder() { @Override public Advancement loadAdvancement(NamespacedKey key, String advancement) { Preconditions.checkArgument(Bukkit.getAdvancement(key) == null, "Advancement %s already exists", key); - ResourceLocation resourceKey = CraftNamespacedKey.toMinecraft(key); + Identifier resourceKey = CraftNamespacedKey.toMinecraft(key); JsonElement jsonelement = JsonParser.parseString(advancement); final net.minecraft.resources.RegistryOps ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JsonOps.INSTANCE); // Paper - use RegistryOps final net.minecraft.advancements.Advancement nms = net.minecraft.advancements.Advancement.CODEC.parse(ops, jsonelement).getOrThrow(JsonParseException::new); // Paper - use RegistryOps if (nms != null) { - final com.google.common.collect.ImmutableMap.Builder mapBuilder = com.google.common.collect.ImmutableMap.builder(); + final com.google.common.collect.ImmutableMap.Builder mapBuilder = com.google.common.collect.ImmutableMap.builder(); mapBuilder.putAll(MinecraftServer.getServer().getAdvancements().advancements); final AdvancementHolder holder = new AdvancementHolder(resourceKey, nms); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java index 5c13e11344e0..90a466cab30a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.util; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.Identifier; import org.bukkit.NamespacedKey; import org.jspecify.annotations.NullMarked; @@ -11,14 +12,26 @@ public CraftNamespacedKey() { } public static NamespacedKey fromString(String string) { - return CraftNamespacedKey.fromMinecraft(ResourceLocation.parse(string)); + return CraftNamespacedKey.fromMinecraft(Identifier.parse(string)); } - public static NamespacedKey fromMinecraft(ResourceLocation minecraft) { + public static NamespacedKey fromMinecraft(Identifier minecraft) { return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath()); } - public static ResourceLocation toMinecraft(NamespacedKey key) { - return ResourceLocation.fromNamespaceAndPath(key.getNamespace(), key.getKey()); + public static Identifier toMinecraft(NamespacedKey key) { + return Identifier.fromNamespaceAndPath(key.getNamespace(), key.getKey()); } + + public static NamespacedKey fromResourceKey(final ResourceKey key) { + return CraftNamespacedKey.fromMinecraft(key.identifier()); + } + + public static ResourceKey toResourceKey( + final ResourceKey> registry, + final NamespacedKey namespacedKey + ) { + return ResourceKey.create(registry, CraftNamespacedKey.toMinecraft(namespacedKey)); + } + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java index 0e14f962b268..bb117482fe9d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java @@ -21,6 +21,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.attribute.EnvironmentAttributeReader; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.flag.FeatureFlagSet; @@ -95,11 +96,6 @@ public ServerLevel getMinecraftWorld() { return this.delegate.getMinecraftWorld(); } - @Override - public long dayTime() { - return this.delegate.dayTime(); - } - @Override public long nextSubTickCount() { return this.delegate.nextSubTickCount(); @@ -176,7 +172,7 @@ public void updateNeighborsAt(BlockPos pos, Block block) { } @Override - public void neighborShapeChanged(Direction direction, BlockPos pos, BlockPos neighborPos, BlockState neighborState, int flags, int recursionLeft) { + public void neighborShapeChanged(Direction direction, BlockPos pos, BlockPos neighborPos, BlockState neighborState, @Block.UpdateFlags int flags, int recursionLeft) { this.delegate.neighborShapeChanged(direction, pos, neighborPos, neighborState, flags, recursionLeft); } @@ -245,21 +241,6 @@ public BlockPos getHeightmapPos(Heightmap.Types heightmap, BlockPos pos) { return this.delegate.getHeightmapPos(heightmap, pos); } - @Override - public float getMoonBrightness() { - return this.delegate.getMoonBrightness(); - } - - @Override - public float getTimeOfDay(float tickDelta) { - return this.delegate.getTimeOfDay(tickDelta); - } - - @Override - public int getMoonPhase() { - return this.delegate.getMoonPhase(); - } - @Override public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { return this.delegate.getChunk(chunkX, chunkZ, leastStatus, create); @@ -425,6 +406,11 @@ public FeatureFlagSet enabledFeatures() { return this.delegate.enabledFeatures(); } + @Override + public EnvironmentAttributeReader environmentAttributes() { + return this.delegate.environmentAttributes(); + } + @Override public HolderLookup holderLookup(ResourceKey> registryKey) { return this.delegate.holderLookup(registryKey); @@ -676,12 +662,12 @@ public Player getPlayerByUUID(UUID uuid) { } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { return this.delegate.setBlock(pos, state, flags, recursionLeft); } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { return this.delegate.setBlock(pos, state, flags); } @@ -711,7 +697,7 @@ public boolean addFreshEntity(Entity entity) { } @Override - public boolean addFreshEntity(Entity entity, @Nullable CreatureSpawnEvent.SpawnReason reason) { + public boolean addFreshEntity(Entity entity, CreatureSpawnEvent.@Nullable SpawnReason reason) { return this.delegate.addFreshEntity(entity, reason); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index b6132095828b..3693c069f911 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -13,6 +13,7 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.util.RandomSource; import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.attribute.EnvironmentAttributeReader; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.flag.FeatureFlagSet; @@ -188,6 +189,11 @@ public FeatureFlagSet enabledFeatures() { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public EnvironmentAttributeReader environmentAttributes() { + return EnvironmentAttributeReader.EMPTY; + } + @Override public float getShade(Direction direction, boolean shaded) { throw new UnsupportedOperationException("Not supported yet."); @@ -244,7 +250,7 @@ public boolean isFluidAtPosition(BlockPos pos, Predicate state) { } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { return false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java index aed42b21137f..c698c8438052 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java @@ -51,7 +51,7 @@ public boolean addFreshEntity(Entity entity, @Nullable SpawnReason reason) { return super.addFreshEntity(entity, reason); } - public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, int flags, int recursionLeft) { + public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, @Block.UpdateFlags int flags, int recursionLeft) { craftBlockState = this.structureTransformer.transformCraftState(craftBlockState); // This code is based on the method 'net.minecraft.world.level.levelgen.structure.StructurePiece#placeBlock' // It ensures that any kind of block is updated correctly upon placing it @@ -77,12 +77,12 @@ public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, return result; } - public boolean setCraftBlock(BlockPos pos, CraftBlockState craftBlockState, int flags) { + public boolean setCraftBlock(BlockPos pos, CraftBlockState craftBlockState, @Block.UpdateFlags int flags) { return this.setCraftBlock(pos, craftBlockState, flags, Block.UPDATE_LIMIT); } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { if (this.canTransformBlocks()) { return this.setCraftBlock(pos, (CraftBlockState) CraftBlockStates.getBlockState(this, pos, state, null), flags, recursionLeft); } @@ -90,7 +90,7 @@ public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursion } @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags) { return this.setBlock(pos, state, flags, Block.UPDATE_LIMIT); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java index 774556a62eb2..e0d339bc9b5f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -1,29 +1,52 @@ package org.bukkit.craftbukkit.util; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.util.Properties; +import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import net.minecraft.SharedConstants; import org.bukkit.Bukkit; public final class Versioning { - public static String getBukkitVersion() { - String result = "Unknown-Version"; + private static final String BUKKIT_VERSION; + private static final String API_VERSION; - InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties"); - Properties properties = new Properties(); + static { + String bukkitVersion = "Unknown-Version"; + String apiVersion = null; + try (final InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("apiVersioning.json")) { + if (stream == null) { + throw new IOException("apiVersioning.json not found in classpath"); + } - if (stream != null) { - try { - properties.load(stream); + final JsonObject jsonObject = new Gson() + .fromJson(new BufferedReader(new InputStreamReader(stream)), JsonObject.class); - result = properties.getProperty("version"); - } catch (IOException ex) { - Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get Bukkit version!", ex); + if (jsonObject == null) { + throw new IOException("apiVersioning.json is not a valid JSON file"); } + + bukkitVersion = jsonObject.get("version").getAsString(); + apiVersion = jsonObject.get("currentApiVersion").getAsString(); + } catch (final IOException ex) { + Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get Bukkit version!", ex); + } + BUKKIT_VERSION = bukkitVersion; + if (apiVersion == null) { + apiVersion = SharedConstants.getCurrentVersion().id(); } + API_VERSION = apiVersion; + } + + public static String getBukkitVersion() { + return BUKKIT_VERSION; + } - return result; + public static String getCurrentApiVersion() { + return API_VERSION; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java index 8893a94d5429..a454350085f2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java @@ -98,6 +98,7 @@ public static Permission registerPermissions(Permission parent) { DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "weather", "Allows the user to set the weather", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "whitelist", "Allows the user to manage the server whitelist", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "worldborder", "Allows the user to manage the world border", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "stopwatch", "Allows the user to use the /stopwatch command", PermissionDefault.OP, commands); // Paper end DefaultPermissions.registerPermission("minecraft.admin.command_feedback", "Receive command broadcasts when sendCommandFeedback is true", PermissionDefault.OP, commands); diff --git a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java index ba539e6a37eb..97d81401484b 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java @@ -15,7 +15,7 @@ import java.util.Set; import java.util.logging.Level; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.RangedAttribute; @@ -202,7 +202,7 @@ private static void nettyThreads() { } public static boolean disableStatSaving; - public static Map forcedStats = new HashMap<>(); + public static Map forcedStats = new HashMap<>(); private static void stats() { SpigotConfig.disableStatSaving = SpigotConfig.getBoolean("stats.disable-saving", false); @@ -215,7 +215,7 @@ private static void stats() { for (String name : section.getKeys(true)) { if (section.isInt(name)) { try { - ResourceLocation key = ResourceLocation.parse(name); + Identifier key = Identifier.parse(name); if (BuiltInRegistries.CUSTOM_STAT.get(key) == null) { Bukkit.getLogger().log(Level.WARNING, "Ignoring non existent stats.forced-stats " + name); continue; diff --git a/paper-server/src/main/java/org/spigotmc/TrackingRange.java b/paper-server/src/main/java/org/spigotmc/TrackingRange.java index 7222b2dc97e5..c4384fd7ca7d 100644 --- a/paper-server/src/main/java/org/spigotmc/TrackingRange.java +++ b/paper-server/src/main/java/org/spigotmc/TrackingRange.java @@ -6,7 +6,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ExperienceOrb; import net.minecraft.world.entity.decoration.ItemFrame; -import net.minecraft.world.entity.decoration.Painting; +import net.minecraft.world.entity.decoration.painting.Painting; import net.minecraft.world.entity.item.ItemEntity; public final class TrackingRange { diff --git a/paper-server/src/main/resources/META-INF/services/io.papermc.paper.block.bed.BedEnterActionBridge b/paper-server/src/main/resources/META-INF/services/io.papermc.paper.block.bed.BedEnterActionBridge new file mode 100644 index 000000000000..540fa11b068c --- /dev/null +++ b/paper-server/src/main/resources/META-INF/services/io.papermc.paper.block.bed.BedEnterActionBridge @@ -0,0 +1 @@ +io.papermc.paper.block.bed.BedEnterActionBridgeImpl 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 9bfeb1cee6cc..ea59a360732a 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 @@ -37,7 +37,7 @@ import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.ComponentSerialization; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import org.bukkit.support.RegistryHelper; @@ -108,7 +108,7 @@ void testKey() { final Key key = key("hello", "there"); final Tag result = KEY_CODEC.encodeStart(NbtOps.INSTANCE, key).result().orElseThrow(); assertEquals("\"" + key.asString() + "\"", result.toString()); - final ResourceLocation location = ResourceLocation.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst(); + final Identifier location = Identifier.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst(); assertEquals(key.asString(), location.toString()); } @@ -138,7 +138,7 @@ void testClickEvent(final ClickEvent.Action action) { assertEquals(((ClickEvent.Payload.Text) event.payload()).value(), value); case net.minecraft.network.chat.ClickEvent.ChangePage(int page) -> assertEquals(((ClickEvent.Payload.Int) event.payload()).integer(), page); - case net.minecraft.network.chat.ClickEvent.Custom(ResourceLocation id, Optional payload) -> { + case net.minecraft.network.chat.ClickEvent.Custom(Identifier id, Optional payload) -> { assertEquals(((ClickEvent.Payload.Custom) event.payload()).key().toString(), id.toString()); assertEquals(((ClickEvent.Payload.Custom) event.payload()).nbt(), payload.orElseThrow().asString()); } @@ -237,7 +237,7 @@ static List> dynamicOps() { JavaOps.INSTANCE, JsonOps.INSTANCE ) - .map(ops -> RegistryHelper.getRegistry().createSerializationContext(ops)) + .map(ops -> RegistryHelper.registryAccess().createSerializationContext(ops)) .toList(); } diff --git a/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java b/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java index 9d37c0e2bd37..4305540893b5 100644 --- a/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java +++ b/paper-server/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java @@ -4,12 +4,12 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -@AllFeatures +@Normal public class ComponentServicesTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java b/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java index 32d38205a5a7..f70985a8e222 100644 --- a/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java +++ b/paper-server/src/test/java/io/papermc/paper/block/CraftBlockDataDestroySpeedTest.java @@ -24,13 +24,13 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static net.minecraft.resources.ResourceLocation.fromNamespaceAndPath; +import static net.minecraft.resources.Identifier.fromNamespaceAndPath; /** * CraftBlockData's {@link org.bukkit.craftbukkit.block.data.CraftBlockData#getDestroySpeed(ItemStack, boolean)} @@ -40,7 +40,7 @@ * This test is responsible for ensuring that said logic emits the expected destroy speed under heavy attribute * modifier use. */ -@AllFeatures +@VanillaFeature public class CraftBlockDataDestroySpeedTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java b/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java index cd718ed01ba5..bf4365c607b0 100644 --- a/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java +++ b/paper-server/src/test/java/io/papermc/paper/block/InstrumentSoundTest.java @@ -6,13 +6,13 @@ import org.bukkit.Instrument; import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.block.data.CraftBlockData; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertEquals; -@AllFeatures +@VanillaFeature class InstrumentSoundTest { static Stream bukkitInstruments() { 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 4b419ce023f6..7524ee0de782 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 @@ -13,7 +13,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.SimpleCommandMap; import org.bukkit.support.RegistryHelper; -import org.bukkit.support.environment.AllFeatures; import org.bukkit.support.environment.Normal; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; @@ -33,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.getDataPack().commands.getDispatcher(); + CommandDispatcher dispatcher = RegistryHelper.context().datapack().commands.getDispatcher(); dispatcher.setConsumer((context, success, result) -> {}); CommandMap commandMap = new SimpleCommandMap(Bukkit.getServer(), new BukkitBrigForwardingMap()); Map stringCommandMap = commandMap.getKnownCommands(); diff --git a/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java b/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java index 8c6292ea1716..4a4acf215163 100644 --- a/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java +++ b/paper-server/src/test/java/io/papermc/paper/contract/StepBasedCollectorRunBeforeTest.java @@ -3,11 +3,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.InsideBlockEffectApplier.StepBasedCollector; import net.minecraft.world.entity.InsideBlockEffectType; -import net.minecraft.world.entity.animal.Pig; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -19,7 +17,7 @@ * Paper relies on this implementation detail to perform some events, specifically * - net.minecraft.world.level.block.LayeredCauldronBlock#entityInside */ -@AllFeatures +@Normal public class StepBasedCollectorRunBeforeTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java b/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java deleted file mode 100644 index 1d707114f53e..000000000000 --- a/paper-server/src/test/java/io/papermc/paper/datacomponent/DataComponentTypesTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.papermc.paper.datacomponent; - -import com.google.common.collect.Collections2; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; -import org.bukkit.support.RegistryHelper; -import org.bukkit.support.environment.AllFeatures; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import java.lang.reflect.Field; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -@AllFeatures -public class DataComponentTypesTest { - - private static final Set NOT_IN_API = Set.of( - ResourceLocation.parse("custom_data"), - ResourceLocation.parse("entity_data"), - ResourceLocation.parse("bees"), - ResourceLocation.parse("debug_stick_state"), - ResourceLocation.parse("block_entity_data"), - ResourceLocation.parse("bucket_entity_data"), - ResourceLocation.parse("lock"), - ResourceLocation.parse("creative_slot_lock") - ); - - @Test - public void testAllDataComponentsAreMapped() throws IllegalAccessException { - final Set vanillaDataComponentTypes = new ObjectOpenHashSet<>( - RegistryHelper.getRegistry() - .lookupOrThrow(Registries.DATA_COMPONENT_TYPE) - .keySet() - ); - - for (final Field declaredField : DataComponentTypes.class.getDeclaredFields()) { - if (!DataComponentType.class.isAssignableFrom(declaredField.getType())) continue; - - final DataComponentType dataComponentType = (DataComponentType) declaredField.get(null); - if (!vanillaDataComponentTypes.remove(CraftNamespacedKey.toMinecraft(dataComponentType.getKey()))) { - Assertions.fail("API defined component type " + dataComponentType.key().asMinimalString() + " is unknown to vanilla registry"); - } - } - - if (!vanillaDataComponentTypes.containsAll(NOT_IN_API)) { - Assertions.fail("API defined data components that were marked as not-yet-implemented: " + NOT_IN_API.stream().filter(Predicate.not(vanillaDataComponentTypes::contains)).map(ResourceLocation::toString).collect(Collectors.joining(", "))); - } - - vanillaDataComponentTypes.removeAll(NOT_IN_API); - if (!vanillaDataComponentTypes.isEmpty()) { - Assertions.fail("API did not define following vanilla data component types: " + String.join(", ", Collections2.transform(vanillaDataComponentTypes, ResourceLocation::toString))); - } - } - -} 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 a57e8fdc35ef..1beaa37015e0 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 @@ -4,13 +4,13 @@ import net.minecraft.world.effect.MobEffectCategory; import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.potion.PotionEffectType; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -@AllFeatures +@Normal public class EffectCategoryTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java b/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java index 68a557cedbff..54b66871c48c 100644 --- a/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java +++ b/paper-server/src/test/java/io/papermc/paper/inventory/CraftMetaTropicalFishBucketTest.java @@ -5,11 +5,11 @@ import org.bukkit.entity.TropicalFish; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.TropicalFishBucketMeta; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -@AllFeatures +@VanillaFeature public class CraftMetaTropicalFishBucketTest { @Test diff --git a/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java b/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java index 1431b3faf081..a5a48f8bbead 100644 --- a/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java +++ b/paper-server/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java @@ -3,7 +3,6 @@ import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; import java.util.ArrayList; import java.util.List; -import java.util.stream.Stream; import net.minecraft.core.component.DataComponents; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.Item; @@ -12,6 +11,7 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -21,14 +21,14 @@ @AllFeatures public class ArmorSlotTypeMaterialTest { - public static Stream slotTypeParams() { - final List parameters = new ArrayList<>(); + public static List slotTypeParams() { + final List parameters = new ArrayList<>(); for (final PlayerArmorChangeEvent.SlotType slotType : PlayerArmorChangeEvent.SlotType.values()) { for (final Material item : slotType.getTypes()) { - parameters.add(new Object[]{ slotType, item }); + parameters.add(Arguments.of(slotType, item)); } } - return parameters.stream(); + return parameters; } @ParameterizedTest(name = "{argumentsWithNames}") @@ -46,15 +46,15 @@ public void testSlotType(PlayerArmorChangeEvent.SlotType slotType, Material item assertEquals(equippable.slot(), slot, item + " isn't set to the right slot"); } - public static Stream equipableParams() { - final List parameters = new ArrayList<>(); + public static List equipableParams() { + final List parameters = new ArrayList<>(); for (final Item item : net.minecraft.core.registries.BuiltInRegistries.ITEM) { final Equippable equippable = item.components().get(DataComponents.EQUIPPABLE); if (equippable != null) { - parameters.add(new Object[]{equippable, item}); + parameters.add(Arguments.of(equippable, item)); } } - return parameters.stream(); + return parameters; } @ParameterizedTest(name = "{argumentsWithNames}") diff --git a/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java b/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java index ae5e90c66aa2..8a83468ec2f4 100644 --- a/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java +++ b/paper-server/src/test/java/io/papermc/paper/item/ItemStackDataComponentTest.java @@ -369,7 +369,7 @@ void testJukeboxWithEitherKey() { void testJukeboxWithEitherHolder() { final net.minecraft.world.item.ItemStack internalStack = new net.minecraft.world.item.ItemStack(Items.STONE); internalStack.set(DataComponents.JUKEBOX_PLAYABLE, new net.minecraft.world.item.JukeboxPlayable( - new EitherHolder<>(RegistryHelper.getRegistry().lookupOrThrow(Registries.JUKEBOX_SONG).getOrThrow(JukeboxSongs.FIVE)) + new EitherHolder<>(RegistryHelper.registryAccess().lookupOrThrow(Registries.JUKEBOX_SONG).getOrThrow(JukeboxSongs.FIVE)) )); final ItemStack apiStack = CraftItemStack.asBukkitCopy(internalStack); diff --git a/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java b/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java index 7cda79980729..0c39216d75f1 100644 --- a/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java +++ b/paper-server/src/test/java/io/papermc/paper/item/MetaComparisonTest.java @@ -22,13 +22,13 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; // TODO: This should technically be used to compare legacy meta vs the newly implemented -@AllFeatures +@VanillaFeature public class MetaComparisonTest { private static final ItemFactory FACTORY = CraftItemFactory.instance(); diff --git a/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java b/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java index fe08e446e86d..b9ce8c1a98ea 100644 --- a/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java +++ b/paper-server/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java @@ -40,7 +40,7 @@ public void test() { CraftDefaultPermissions.registerCorePermissions(); Set perms = collectMinecraftCommandPerms(); - Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.simple(RegistryHelper.getRegistry(), FeatureFlags.VANILLA_SET), true); + Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.simple(RegistryHelper.registryAccess(), FeatureFlags.VANILLA_SET), true); RootCommandNode root = commands.getDispatcher().getRoot(); Set missing = new LinkedHashSet<>(); Set foundPerms = new HashSet<>(); diff --git a/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java b/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java index 8df17d82a37f..faadfafd776e 100644 --- a/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java +++ b/paper-server/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java @@ -28,8 +28,8 @@ static Stream registries() { @ParameterizedTest @MethodSource("registries") - void testEquality(final RegistryEntryMeta.Buildable registryEntry) { // TODO remove Keyed - final Registry registry = RegistryHelper.getRegistry().lookupOrThrow(registryEntry.mcKey()); + void testEquality(final RegistryEntryMeta.Buildable registryEntry) { // TODO remove Keyed + final Registry registry = RegistryHelper.registryAccess().lookupOrThrow(registryEntry.mcKey()); for (final Map.Entry, M> entry : registry.entrySet()) { final M built = registryEntry.builderFiller().fill(Conversions.global(), entry.getValue()).build(); assertEquals(entry.getValue(), built); diff --git a/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java index 41c38b1b6d25..cd26f63f6c89 100644 --- a/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java +++ b/paper-server/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java @@ -5,7 +5,7 @@ import java.util.stream.Stream; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.support.RegistryHelper; import org.bukkit.support.environment.AllFeatures; import org.checkerframework.checker.nullness.qual.Nullable; @@ -31,7 +31,7 @@ static Stream> data() { @ParameterizedTest @MethodSource("data") void testApiRegistryKeysExist(final RegistryKey key) { - final Optional> registry = RegistryHelper.getRegistry().lookup(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); + final Optional> registry = RegistryHelper.registryAccess().lookup(ResourceKey.createRegistryKey(Identifier.parse(key.key().asString()))); assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString()); } diff --git a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java index 9642618fb59f..282ead960273 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/TranslationKeyTest.java @@ -1,25 +1,15 @@ package io.papermc.paper.world; -import java.util.Locale; -import java.util.Map; import net.minecraft.network.chat.contents.TranslatableContents; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameType; -import net.minecraft.world.level.biome.Biome; import org.bukkit.Difficulty; import org.bukkit.FireworkEffect; import org.bukkit.GameMode; -import org.bukkit.GameRule; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.support.RegistryHelper; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -@AllFeatures +@Normal public class TranslationKeyTest { @Test @@ -29,14 +19,6 @@ public void testDifficultyKeys() { } } - @Test - public void testGameruleKeys() { - final Map> gameRules = CraftWorld.getGameRulesNMS(new GameRules(FeatureFlags.REGISTRY.allFlags())); - for (GameRule rule : GameRule.values()) { - Assertions.assertEquals(gameRules.get(rule.getName()).getDescriptionId(), rule.translationKey(), rule.getName() + "'s translation doesn't match"); - } - } - @Test public void testFireworkEffectType() { for (final FireworkEffect.Type type : FireworkEffect.Type.values()) { @@ -46,15 +28,6 @@ public void testFireworkEffectType() { } } - @Test - @Disabled // TODO fix - public void testCreativeCategory() { - // for (CreativeModeTab tab : CreativeModeTabs.tabs()) { - // CreativeCategory category = Objects.requireNonNull(CraftCreativeCategory.fromNMS(tab)); - // Assertions.assertEquals("translation key mismatch for " + category, ((TranslatableContents) tab.getDisplayName().getContents()).getKey(), category.translationKey()); - // } - } - @Test public void testGameMode() { for (GameType nms : GameType.values()) { @@ -63,12 +36,4 @@ public void testGameMode() { Assertions.assertEquals(((TranslatableContents) nms.getLongDisplayName().getContents()).getKey(), bukkit.translationKey(), "translation key mismatch for " + bukkit); } } - - @Test - public void testBiome() { - for (Map.Entry, Biome> nms : RegistryHelper.getBiomes().entrySet()) { - org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase(Locale.ROOT)); - Assertions.assertEquals(nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit); - } - } } diff --git a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java index 2e07ff04faa5..df2f4919eb89 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/flag/FeatureFlagTest.java @@ -9,8 +9,8 @@ import java.util.Set; import java.util.stream.Stream; import net.kyori.adventure.key.Key; +import net.minecraft.resources.Identifier; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -34,7 +34,7 @@ class FeatureFlagTest { @Test void testFeatureFlagParity() { - final Set locations = new HashSet<>(); + final Set locations = new HashSet<>(); for (final FeatureFlag flag : FeatureFlag.ALL_FLAGS.values()) { locations.add(PaperAdventure.asVanilla(flag.getKey())); } @@ -42,7 +42,7 @@ void testFeatureFlagParity() { fail("Unknown api feature flag: " + unknown); }); - for (final ResourceLocation nmsFlag : allNames()) { + for (final Identifier nmsFlag : allNames()) { assertNotNull(FeatureFlag.ALL_FLAGS.value(Key.key(nmsFlag.toString())), "can't find api flag for " + nmsFlag); } } @@ -52,12 +52,12 @@ void testFeatureFlagConversion() { assertEquals(allNames().size(), PaperFeatureFlagProviderImpl.FLAGS.size()); for (final FeatureFlag featureFlag : PaperFeatureFlagProviderImpl.FLAGS.keySet()) { final net.minecraft.world.flag.FeatureFlag nmsFlag = PaperFeatureFlagProviderImpl.FLAGS.get(featureFlag); - final ResourceLocation nmsFlagName = FeatureFlags.REGISTRY.toNames(FeatureFlagSet.of(nmsFlag)).iterator().next(); + final Identifier nmsFlagName = FeatureFlags.REGISTRY.toNames(FeatureFlagSet.of(nmsFlag)).iterator().next(); assertEquals(nmsFlagName.toString(), featureFlag.key().asString()); } } - static Set allNames() { + static Set allNames() { return FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags()); } @@ -81,14 +81,13 @@ void testApiImplementsFeatureDependant(final RegistryKey re } static Stream> nonFeatureFilteredRegistries() { - return RegistryHelper.getRegistry().registries().filter(r -> { + return RegistryHelper.registryAccess().registries().filter(r -> { final RegistryEntry entry = PaperRegistries.getEntry(r.key()); // has an API registry and isn't a filtered registry return entry != null && !FeatureElement.FILTERED_REGISTRIES.contains(r.key()); }).map(r -> PaperRegistries.getEntry(r.key()).apiKey()); } - @MethodSource("nonFeatureFilteredRegistries") @ParameterizedTest void testApiDoesntImplementFeatureDependant(final RegistryKey registryKey) { diff --git a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java index cc1fb5ae9e08..0934c184eeef 100644 --- a/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java +++ b/paper-server/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java @@ -6,7 +6,7 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.levelgen.structure.BuiltinStructureSets; import net.minecraft.world.level.levelgen.structure.StructureSet; import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement; @@ -34,15 +34,15 @@ public void save(final @NotNull File file) { final SpigotWorldConfig config = PaperConfigurations.SPIGOT_WORLD_DEFAULTS.get(); - final Registry structureSets = RegistryHelper.getRegistry().lookupOrThrow(Registries.STRUCTURE_SET); + final Registry structureSets = RegistryHelper.registryAccess().lookupOrThrow(Registries.STRUCTURE_SET); for (final ResourceKey setKey : structureSets.registryKeySet()) { - assertEquals(ResourceLocation.DEFAULT_NAMESPACE, setKey.location().getNamespace()); + assertEquals(Identifier.DEFAULT_NAMESPACE, setKey.identifier().getNamespace()); final StructureSet set = structureSets.getValueOrThrow(setKey); if (setKey == BuiltinStructureSets.STRONGHOLDS) { // special case due to seed matching world seed assertEquals(0, set.placement().salt); continue; } - int salt = switch (setKey.location().getPath()) { + int salt = switch (setKey.identifier().getPath()) { case "villages" -> config.villageSeed; case "desert_pyramids" -> config.desertSeed; case "igloos" -> config.iglooSeed; diff --git a/paper-server/src/test/java/org/bukkit/ChatTest.java b/paper-server/src/test/java/org/bukkit/ChatTest.java index f0d2a694c504..df746527706a 100644 --- a/paper-server/src/test/java/org/bukkit/ChatTest.java +++ b/paper-server/src/test/java/org/bukkit/ChatTest.java @@ -32,8 +32,8 @@ public void testURLJsonConversion() { CraftChatMessage.toJSON(components[0])); components = CraftChatMessage.fromString("123 " + ChatColor.GOLD + "https://spigotmc.org " + ChatColor.BOLD + "test"); - assertEquals("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"strikethrough\":false,\"obfuscated\":false,\"click_event\":{\"url\":\"https://spigotmc.org\",\"action\":\"open_url\"},\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\" \",\"strikethrough\":false,\"obfuscated\":false,\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\"test\",\"strikethrough\":false,\"obfuscated\":false,\"bold\":true,\"italic\":false,\"underlined\":false,\"color\":\"gold\"}]}", - CraftChatMessage.toJSON(components[0])); + Component expected = CraftChatMessage.fromJSON("{\"text\":\"\",\"extra\":[\"123 \",{\"text\":\"https://spigotmc.org\",\"strikethrough\":false,\"obfuscated\":false,\"click_event\":{\"url\":\"https://spigotmc.org\",\"action\":\"open_url\"},\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\" \",\"strikethrough\":false,\"obfuscated\":false,\"bold\":false,\"italic\":false,\"underlined\":false,\"color\":\"gold\"},{\"text\":\"test\",\"strikethrough\":false,\"obfuscated\":false,\"bold\":true,\"italic\":false,\"underlined\":false,\"color\":\"gold\"}]}"); + assertEquals(expected, components[0]); components = CraftChatMessage.fromString("multiCase http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE"); assertEquals("{\"text\":\"\",\"extra\":[\"multiCase \",{\"text\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\",\"click_event\":{\"url\":\"http://SpigotMC.ORg/SpOngeBobMeEMeGoESHeRE\",\"action\":\"open_url\"}}]}", diff --git a/paper-server/src/test/java/org/bukkit/EffectTest.java b/paper-server/src/test/java/org/bukkit/EffectTest.java index 5eaa832abbe9..90fb1a6e97a6 100644 --- a/paper-server/src/test/java/org/bukkit/EffectTest.java +++ b/paper-server/src/test/java/org/bukkit/EffectTest.java @@ -1,49 +1,54 @@ package org.bukkit; import com.google.common.base.Joiner; +import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; +import it.unimi.dsi.fastutil.ints.IntArraySet; +import it.unimi.dsi.fastutil.ints.IntSet; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import net.minecraft.world.level.block.LevelEvent; +import org.bukkit.support.environment.Normal; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import static org.bukkit.support.MatcherAssert.assertThat; +import static org.hamcrest.CoreMatchers.is; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; +@Normal public class EffectTest { - private static List collectNmsLevelEvents() throws ReflectiveOperationException { - final List events = new ArrayList<>(); - for (final Field field : LevelEvent.class.getFields()) { - if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.getType() == int.class) { - events.add((int) field.get(null)); - } - } - return events; - } - private static boolean isNotDeprecated(Effect effect) throws ReflectiveOperationException { return !Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class); } - @Test - public void checkAllApiExists() throws ReflectiveOperationException { - Map toId = new HashMap<>(); + private static final Int2ObjectArrayMap ID_TO_EFFECT = new Int2ObjectArrayMap<>(); // api + private static final IntSet LEVEL_EVENTS = new IntArraySet(); // internal + + @BeforeAll + public static void init() throws ReflectiveOperationException { for (final Effect effect : Effect.values()) { if (isNotDeprecated(effect)) { - final Effect put = toId.put(effect.getId(), effect); - assertNull(put, "duplicate API effect: " + put); + final Effect put = ID_TO_EFFECT.put(effect.getId(), effect); + assertNull(put, "Duplicate API effect: " + put); + } + } + + for (final Field field : LevelEvent.class.getFields()) { + if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.getType() == int.class) { + LEVEL_EVENTS.add((int) field.get(null)); } } + } - final Set missingEvents = new HashSet<>(); - for (final Integer event : collectNmsLevelEvents()) { - if (toId.get(event) == null) { + @Test + public void checkAllApiExists() { + final IntSet missingEvents = new IntArraySet(); + for (final int event : LEVEL_EVENTS) { + if (!ID_TO_EFFECT.containsKey(event)) { missingEvents.add(event); } } @@ -53,24 +58,22 @@ public void checkAllApiExists() throws ReflectiveOperationException { } @Test - public void checkNoExtraApi() throws ReflectiveOperationException { - Map toId = new HashMap<>(); - for (final Effect effect : Effect.values()) { - if (isNotDeprecated(effect)) { - final Effect put = toId.put(effect.getId(), effect); - assertNull(put, "duplicate API effect: " + put); - } - } - - final List nmsEvents = collectNmsLevelEvents(); + public void checkNoExtraApi() { final Set extraApiEffects = new HashSet<>(); - for (final Map.Entry entry : toId.entrySet()) { - if (!nmsEvents.contains(entry.getKey())) { - extraApiEffects.add(entry.getValue()); + ID_TO_EFFECT.forEach((key, value) -> { + if (!LEVEL_EVENTS.contains(key)) { + extraApiEffects.add(value); } - } + }); if (!extraApiEffects.isEmpty()) { fail("Extra API Effects:\n" + Joiner.on("\n").join(extraApiEffects)); } } + + @Test + public void testByIdRoundTrip() { + ID_TO_EFFECT.forEach((key, value) -> { + assertThat(Effect.getById(key), is(value)); + }); + } } diff --git a/paper-server/src/test/java/org/bukkit/GameRuleTest.java b/paper-server/src/test/java/org/bukkit/GameRuleTest.java index 7fd36402fbf6..aa60c2ea0a20 100644 --- a/paper-server/src/test/java/org/bukkit/GameRuleTest.java +++ b/paper-server/src/test/java/org/bukkit/GameRuleTest.java @@ -3,40 +3,26 @@ import static org.junit.jupiter.api.Assertions.*; import java.util.Map; import net.minecraft.world.flag.FeatureFlags; -import net.minecraft.world.level.GameRules; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; @Normal +@Deprecated public class GameRuleTest { @Test public void testBukkitRules() { - GameRule[] rules = GameRule.values(); - - for (GameRule rule : rules) { + for (GameRule rule : Registry.GAME_RULE) { GameRule registeredRule = GameRule.getByName(rule.getName()); assertNotNull(registeredRule, "Null GameRule"); assertEquals(rule, registeredRule, "Invalid GameRule equality"); } } - @Test - public void testMinecraftRules() { - Map> minecraftRules = CraftWorld.getGameRulesNMS(new GameRules(FeatureFlags.REGISTRY.allFlags())); - - for (Map.Entry> entry : minecraftRules.entrySet()) { - GameRule bukkitRule = GameRule.getByName(entry.getKey()); - - assertNotNull(bukkitRule, "Missing " + entry.getKey()); - assertEquals(bukkitRule.getName(), entry.getKey(), "Invalid GameRule Name"); - } - } - @Test public void nullGameRuleName() { - assertThrows(NullPointerException.class, () -> GameRule.getByName(null)); + assertThrows(IllegalArgumentException.class, () -> GameRule.getByName(null)); } @Test diff --git a/paper-server/src/test/java/org/bukkit/InstrumentTest.java b/paper-server/src/test/java/org/bukkit/InstrumentTest.java index 5da6b5c996c9..0363b615f3a7 100644 --- a/paper-server/src/test/java/org/bukkit/InstrumentTest.java +++ b/paper-server/src/test/java/org/bukkit/InstrumentTest.java @@ -1,12 +1,12 @@ package org.bukkit; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; import static org.bukkit.support.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; -@AllFeatures +@Normal public class InstrumentTest { // Paper - moved to internals as this test now access the sound registry. @Test diff --git a/paper-server/src/test/java/org/bukkit/MaterialTest.java b/paper-server/src/test/java/org/bukkit/MaterialTest.java index d57396a9353b..ba6bae7e59a1 100644 --- a/paper-server/src/test/java/org/bukkit/MaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/MaterialTest.java @@ -8,7 +8,7 @@ import java.util.Iterator; import java.util.Map; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.Item; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -21,7 +21,7 @@ public class MaterialTest { @Test public void verifyMapping() { - Map materials = Maps.newHashMap(); + Map materials = Maps.newHashMap(); for (Material material : Material.values()) { if (LegacyHelper.getInvalidatedMaterials().contains(material)) { continue; @@ -36,7 +36,7 @@ public void verifyMapping() { Item item = items.next(); if (item == null) continue; - ResourceLocation id = BuiltInRegistries.ITEM.getKey(item); + Identifier id = BuiltInRegistries.ITEM.getKey(item); String name = item.getDescriptionId(); Material material = materials.remove(id); diff --git a/paper-server/src/test/java/org/bukkit/ParticleTest.java b/paper-server/src/test/java/org/bukkit/ParticleTest.java index 61c7e94fb76c..414586df882d 100644 --- a/paper-server/src/test/java/org/bukkit/ParticleTest.java +++ b/paper-server/src/test/java/org/bukkit/ParticleTest.java @@ -1,6 +1,5 @@ package org.bukkit; -import static org.junit.jupiter.api.Assertions.*; import com.mojang.serialization.DataResult; import java.util.Optional; import java.util.stream.Stream; @@ -20,7 +19,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.phys.Vec3; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftParticle; @@ -29,7 +28,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.ItemStack; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.joml.Vector3f; import org.joml.Vector4f; import org.junit.jupiter.params.ParameterizedTest; @@ -37,7 +36,14 @@ import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; -@AllFeatures +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +@VanillaFeature public class ParticleTest { public static Stream data() { @@ -46,7 +52,7 @@ public static Stream data() { @ParameterizedTest @MethodSource("data") - public void testBukkitValuesPresent(ResourceLocation minecraft) { + public void testBukkitValuesPresent(Identifier minecraft) { // TODO: 10/19/23 Remove with enum PR, it is then no longer needed, since the enum PR has a extra test for this assertNotNull(Registry.PARTICLE_TYPE.get(CraftNamespacedKey.fromMinecraft(minecraft)), String.format(""" No bukkit particle found for minecraft particle %s. diff --git a/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java b/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java index 139f2c08acc0..46b31eeec639 100644 --- a/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java +++ b/paper-server/src/test/java/org/bukkit/PotionEffectTypeTest.java @@ -7,7 +7,7 @@ import java.util.Collections; import java.util.List; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.effect.MobEffectCategory; import org.bukkit.craftbukkit.potion.CraftPotionEffectTypeCategory; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -23,7 +23,7 @@ public class PotionEffectTypeTest { public void verifyMapping() { List effects = Lists.newArrayList(PotionEffectType.values()); - for (ResourceLocation key : BuiltInRegistries.MOB_EFFECT.keySet()) { + for (Identifier key : BuiltInRegistries.MOB_EFFECT.keySet()) { String name = key.getPath(); PotionEffectType effect = PotionEffectType.getByKey(CraftNamespacedKey.fromMinecraft(key)); diff --git a/paper-server/src/test/java/org/bukkit/SoundTest.java b/paper-server/src/test/java/org/bukkit/SoundTest.java index ef268c04368a..dd0362b5e4a7 100644 --- a/paper-server/src/test/java/org/bukkit/SoundTest.java +++ b/paper-server/src/test/java/org/bukkit/SoundTest.java @@ -1,11 +1,11 @@ package org.bukkit; -import static org.junit.jupiter.api.Assertions.*; - -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.Normal; import org.junit.jupiter.api.Test; -@AllFeatures +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@Normal public class SoundTest { @Test 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 e0e35de06a77..76573dbcf8e7 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 @@ -13,6 +13,7 @@ import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractCow; import org.bukkit.entity.AbstractHorse; +import org.bukkit.entity.AbstractNautilus; import org.bukkit.entity.AbstractSkeleton; import org.bukkit.entity.AbstractVillager; import org.bukkit.entity.AbstractWindCharge; @@ -122,7 +123,8 @@ public class EntityTypesTest { ThrownPotion.class, TippedArrow.class, Vehicle.class, - WaterMob.class + WaterMob.class, + AbstractNautilus.class ); static { diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java index db0d1e1b993e..d484d1de01bc 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java @@ -36,21 +36,21 @@ private void testSetRegion(OldCraftChunkData data, int minx, int miny, int minz, @Test public void testMinHeight() { - OldCraftChunkData data = new OldCraftChunkData(-128, 128, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(-128, 128, RegistryHelper.context().palettedContainerFactory().get()); assertTrue(this.testSetBlock(data, 0, -256, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.AIR), "Could not set block below min height"); assertTrue(this.testSetBlock(data, 0, -64, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Could set block above min height"); } @Test public void testMaxHeight() { - OldCraftChunkData data = new OldCraftChunkData(0, 128, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(0, 128, RegistryHelper.context().palettedContainerFactory().get()); assertTrue(this.testSetBlock(data, 0, 128, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.AIR), "Could not set block above max height"); assertTrue(this.testSetBlock(data, 0, 127, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Could set block below max height"); } @Test public void testBoundsCheckingSingle() { - OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.context().palettedContainerFactory().get()); assertTrue(this.testSetBlock(data, 0, 0, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Can set block inside chunk bounds"); assertTrue(this.testSetBlock(data, 15, 255, 15, ChunkDataTest.RED_WOOL, ChunkDataTest.RED_WOOL), "Can set block inside chunk bounds"); assertTrue(this.testSetBlock(data, -1, 0, 0, ChunkDataTest.RED_WOOL, ChunkDataTest.AIR), "Can no set block outside chunk bounds"); @@ -63,7 +63,7 @@ public void testBoundsCheckingSingle() { @Test public void testSetRegion() { - OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.palettedContainerFactory()); + OldCraftChunkData data = new OldCraftChunkData(0, 256, RegistryHelper.context().palettedContainerFactory().get()); this.testSetRegion(data, -100, 0, -100, 0, 256, 0, ChunkDataTest.RED_WOOL); // exclusively outside this.testSetRegion(data, 16, 256, 16, 0, 0, 0, ChunkDataTest.RED_WOOL); // minimum >= maximum this.testSetRegion(data, 0, 0, 0, 0, 0, 0, ChunkDataTest.RED_WOOL); // minimum == maximum diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java index 7faccf79b336..50ae0e76b4a7 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerializationTest.java @@ -1,7 +1,5 @@ package org.bukkit.craftbukkit.inventory; -import static org.bukkit.support.MatcherAssert.*; -import static org.hamcrest.Matchers.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -12,10 +10,14 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.support.environment.AllFeatures; +import org.bukkit.support.environment.VanillaFeature; import org.junit.jupiter.api.Test; -@AllFeatures +import static org.bukkit.support.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; + +@VanillaFeature public class CompositeSerializationTest { public YamlConfiguration getConfig() { 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 1f7f0fe930f6..cd783d3de3e4 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 @@ -156,21 +156,6 @@ public void testCrazyEquality() { assertThat(bukkit, is(craft)); } - @Test - public void testSpawnEggsHasMeta() { - for (Item item : BuiltInRegistries.ITEM) { - if (item instanceof net.minecraft.world.item.SpawnEggItem) { - Material material = CraftItemType.minecraftToBukkit(item); - CraftMetaItem baseMeta = (CraftMetaItem) Bukkit.getItemFactory().getItemMeta(material); - ItemMeta baseMetaItem = CraftItemStack.getItemMeta(item.getDefaultInstance()); - - assertTrue(baseMeta instanceof CraftMetaSpawnEgg, material + " is not handled in CraftItemFactory"); - assertTrue(baseMeta.applicableTo(material), material + " is not applicable to CraftMetaSpawnEgg"); - assertTrue(baseMetaItem instanceof SpawnEggMeta, material + " is not handled in CraftItemStack"); - } - } - } - // Paper start - check entity tag metas private static final java.util.Set> ENTITY_TAG_METAS = java.util.Set.of( CraftMetaEntityTag.class, 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 24548ad643d8..c6e5e2506b46 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 @@ -153,6 +153,9 @@ public class LegacyTest { Material.WAXED_OXIDIZED_COPPER_BARS, Material.WAXED_OXIDIZED_COPPER_CHAIN, Material.WAXED_OXIDIZED_COPPER_CHEST, Material.WAXED_OXIDIZED_COPPER_GOLEM_STATUE, Material.WAXED_OXIDIZED_COPPER_LANTERN, Material.WAXED_OXIDIZED_LIGHTNING_ROD, Material.WAXED_WEATHERED_COPPER_BARS, Material.WAXED_WEATHERED_COPPER_CHAIN, Material.WAXED_WEATHERED_COPPER_CHEST, Material.WAXED_WEATHERED_COPPER_GOLEM_STATUE, Material.WAXED_WEATHERED_COPPER_LANTERN, Material.WAXED_WEATHERED_LIGHTNING_ROD, Material.WEATHERED_COPPER_BARS, Material.WEATHERED_COPPER_CHAIN, Material.WEATHERED_COPPER_CHEST, Material.WEATHERED_COPPER_GOLEM_STATUE, Material.WEATHERED_COPPER_LANTERN, Material.WEATHERED_LIGHTNING_ROD, + // 1.21.11 + Material.COPPER_NAUTILUS_ARMOR, Material.COPPER_SPEAR, Material.DIAMOND_NAUTILUS_ARMOR, Material.DIAMOND_SPEAR, Material.GOLDEN_NAUTILUS_ARMOR, Material.GOLDEN_SPEAR, Material.IRON_NAUTILUS_ARMOR, Material.IRON_SPEAR, Material.NAUTILUS_SPAWN_EGG, + 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, // 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/craftbukkit/profile/PlayerProfileTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/profile/PlayerProfileTest.java index fcf773894fbc..0e35a1c505af 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/profile/PlayerProfileTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/profile/PlayerProfileTest.java @@ -9,7 +9,7 @@ import java.net.URL; import java.util.UUID; import com.mojang.authlib.properties.PropertyMap; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.world.item.component.ResolvableProfile; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java index 0cfe19d91d82..5e0e55f11410 100644 --- a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java +++ b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java @@ -1,33 +1,26 @@ package org.bukkit.potion; -import static org.junit.jupiter.api.Assertions.*; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.item.alchemy.Potion; import org.bukkit.craftbukkit.legacy.FieldRename; import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + @AllFeatures public class PotionTest { @Test public void testEffectType() { - for (MobEffect nms : BuiltInRegistries.MOB_EFFECT) { - ResourceLocation key = BuiltInRegistries.MOB_EFFECT.getKey(nms); - - PotionEffectType bukkit = CraftPotionEffectType.minecraftToBukkit(nms); + BuiltInRegistries.MOB_EFFECT.listElements().forEach(reference -> { + PotionEffectType bukkit = CraftPotionEffectType.minecraftHolderToBukkit(reference); - assertNotNull(bukkit, "No Bukkit type for " + key); + assertNotNull(bukkit, "No Bukkit type for " + reference.key()); PotionEffectType byName = FieldRename.getByName_PotionEffectType(bukkit.getName()); - assertEquals(bukkit, byName, "Same type not returned by name " + key); - } + assertEquals(bukkit, byName, "Same type not returned by name " + reference.key()); + }); } } diff --git a/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java b/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java index 0ce4001665b8..1a743ea97267 100644 --- a/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/PerRegistryTest.java @@ -1,6 +1,5 @@ package org.bukkit.registry; -import static org.junit.jupiter.api.Assertions.*; import com.google.common.collect.Lists; import java.lang.reflect.Field; import java.util.List; @@ -9,13 +8,15 @@ import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; -import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.support.environment.AllFeatures; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; + @AllFeatures public class PerRegistryTest { @@ -26,22 +27,18 @@ public static void init() { PerRegistryTest.random = new Random(); } - public static Stream data() { + public static Stream data() throws IllegalAccessException { List data = Lists.newArrayList(); Field[] registryFields = Registry.class.getFields(); for (Field registryField : registryFields) { - try { - Object object = registryField.get(null); - // Ignore Bukkit's default SimpleRegistry. It cannot be tested correctly - if (object instanceof Registry.NotARegistry) { - continue; - } - - data.add(Arguments.of(object)); - } catch (ReflectiveOperationException e) { - e.printStackTrace(); + Object object = registryField.get(null); + // Ignore Bukkit's default NotARegistry. It cannot be tested correctly + if (object instanceof Registry.NotARegistry) { + continue; } + + data.add(Arguments.of(object)); } return data.stream(); diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java index c1016e0eb00e..25434c37724d 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java @@ -1,15 +1,14 @@ package org.bukkit.registry; -import static org.junit.jupiter.api.Assertions.*; import com.google.common.base.Joiner; import java.util.HashSet; import java.util.Set; import org.bukkit.Registry; import org.bukkit.support.environment.AllFeatures; -import org.bukkit.support.extension.AllFeaturesExtension; import org.bukkit.support.provider.RegistriesArgumentProvider; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.provider.Arguments; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * This class tests, if all default registries present in {@link Registry} are added to {@link RegistriesArgumentProvider} @@ -30,12 +29,10 @@ public void testPresent() throws ClassNotFoundException { RegistriesArgumentProvider .getData() - .map(Arguments::get) - .map(array -> array[0]) - .map(clazz -> (io.papermc.paper.registry.RegistryKey) clazz) // Paper - .forEach(clazz -> { - if (!loadedRegistries.remove(clazz)) { - notFound.add(clazz); + .map(RegistriesArgumentProvider.RegistryArgument::apiRegistryKey) + .forEach(key -> { + if (!loadedRegistries.remove(key)) { + notFound.add(key); } }); diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java index c118c911972f..04caee19bd69 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryClassTest.java @@ -25,7 +25,7 @@ import java.util.stream.Stream; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlags; import org.bukkit.Bukkit; @@ -62,7 +62,7 @@ public class RegistryClassTest { private static final Map, Data> INIT_DATA = new HashMap<>(); private static final List FIELD_DATA_CACHE = new ArrayList<>(); - private static RegistryAccess.Frozen vanilla_registry; + private static RegistryAccess vanilla_registry; public static Stream fieldData() { return RegistryClassTest.FIELD_DATA_CACHE.stream(); @@ -81,14 +81,13 @@ public static void cleanUp() { } private static void initValueClasses() { - RegistryClassTest.vanilla_registry = RegistryHelper.createRegistry(FeatureFlags.VANILLA_SET); + RegistryClassTest.vanilla_registry = RegistryHelper.createRegistries(FeatureFlags.VANILLA_SET).access(); Map, List> outsideRequest = new LinkedHashMap<>(); // First init listening for outside requests RegistriesArgumentProvider.getData() - .map(Arguments::get).map(args -> args[0]) - .map(type -> (Class) type) + .map(RegistriesArgumentProvider.RegistryArgument::api) .forEach(type -> { Registry spyRegistry = Bukkit.getRegistry(type); spyOutsideRequests(outsideRequest, type, spyRegistry); @@ -96,9 +95,7 @@ private static void initValueClasses() { // Init all registries and recorde the outcome RegistriesArgumentProvider.getData() - .map(Arguments::get) - .map(args -> args[0]) - .map(type -> (Class) type) + .map(RegistriesArgumentProvider.RegistryArgument::api) .forEachOrdered(type -> { try { Registry spyRegistry = Bukkit.getRegistry(type); @@ -160,9 +157,7 @@ private static void initValueClasses() { // Cleanup RegistriesArgumentProvider.getData() - .map(Arguments::get) - .map(args -> args[0]) - .map(type -> (Class) type) + .map(RegistriesArgumentProvider.RegistryArgument::api) .forEach(type -> MockUtil.resetMock(Bukkit.getRegistry(type))); } @@ -181,8 +176,8 @@ private static void spyOutsideRequests(Map, List { - Class type = (Class) arguments.get()[0]; + RegistriesArgumentProvider.getData().map(args -> { + Class type = args.api(); Map>> annotations = RegistryClassTest.getFieldAnnotations(type); List fields = new ArrayList<>(); @@ -218,7 +213,7 @@ private static void initFieldDataCache() { fields.add(new FieldData(field, annotations.computeIfAbsent(field.getName(), k -> new ArrayList<>()))); } - return Arguments.arguments(arguments.get()[0], arguments.get()[1], fields); + return Arguments.arguments(args.api(), args.registryKey(), fields); }).forEach(FIELD_DATA_CACHE::add); } @@ -491,11 +486,11 @@ public void testMatchingFieldNames(Class type, ResourceKey< @ParameterizedTest @MethodSource("fieldData") public void testMissingConstants(Class type, ResourceKey> registryKey) throws IllegalAccessException { - net.minecraft.core.Registry registry = RegistryHelper.getRegistry().lookupOrThrow(registryKey); - List missingKeys = new ArrayList<>(); + net.minecraft.core.Registry registry = RegistryHelper.registryAccess().lookupOrThrow(registryKey); + List missingKeys = new ArrayList<>(); for (Object nmsObject : registry) { - ResourceLocation minecraftKey = registry.getKey(nmsObject); + Identifier minecraftKey = registry.getKey(nmsObject); try { Field field = type.getField(this.convertToFieldName(minecraftKey.getPath())); diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java index 7848c3bb7835..2718c82e0b6b 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryConstantsTest.java @@ -1,84 +1,96 @@ package org.bukkit.registry; -import static org.junit.jupiter.api.Assertions.*; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; +import java.util.Collection; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; -import org.bukkit.Registry; import org.bukkit.craftbukkit.util.CraftNamespacedKey; -import org.bukkit.damage.DamageType; -import org.bukkit.inventory.meta.trim.TrimMaterial; -import org.bukkit.inventory.meta.trim.TrimPattern; import org.bukkit.support.RegistryHelper; import org.bukkit.support.environment.AllFeatures; -import org.junit.jupiter.api.Test; +import org.bukkit.support.provider.RegistriesArgumentProvider; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; @AllFeatures public class RegistryConstantsTest { - @Test - public void testDamageType() { - this.testExcessConstants(DamageType.class, Registry.DAMAGE_TYPE); - this.testMissingConstants(DamageType.class, Registries.DAMAGE_TYPE); // Paper - re-enable this one - } + private static final Multimap>, Identifier> IGNORED_KEYS = HashMultimap.create(); - @Test - public void testTrimMaterial() { - this.testExcessConstants(TrimMaterial.class, org.bukkit.Registry.TRIM_MATERIAL); // Paper - remap fix - this.testMissingConstants(TrimMaterial.class, Registries.TRIM_MATERIAL); + private static void ignore(ResourceKey> registryKey, Set elements) { + Registry registry = RegistryHelper.registryAccess().lookupOrThrow(registryKey); + IGNORED_KEYS.putAll(registryKey, elements.stream().map(registry::getKey).toList()); } - @Test - public void testTrimPattern() { - this.testExcessConstants(TrimPattern.class, org.bukkit.Registry.TRIM_PATTERN); // Paper - remap fix - this.testMissingConstants(TrimPattern.class, Registries.TRIM_PATTERN); + private static void ignoreKeys(ResourceKey> registryKey, Set> keys) { + IGNORED_KEYS.putAll(registryKey, keys.stream().map(ResourceKey::identifier).toList()); } - private void testExcessConstants(Class clazz, org.bukkit.Registry registry) { // Paper - remap fix - List excessKeys = new ArrayList<>(); - - for (Field field : clazz.getFields()) { - if (field.getType() != clazz || !Modifier.isStatic(field.getModifiers())) { - continue; - } - - String name = field.getName(); - NamespacedKey key = NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)); - if (registry.get(key) == null) { - excessKeys.add(key); - } + private static void ignoreReferences(ResourceKey> registryKey, Set> references) { + IGNORED_KEYS.putAll(registryKey, references.stream().map(holder -> holder.key().identifier()).toList()); + } - } + @BeforeAll + public static void populateIgnored() { + ignore(Registries.DATA_COMPONENT_TYPE, Set.of( + DataComponents.CUSTOM_DATA, + DataComponents.ENTITY_DATA, + DataComponents.BEES, + DataComponents.DEBUG_STICK_STATE, + DataComponents.BLOCK_ENTITY_DATA, + DataComponents.BUCKET_ENTITY_DATA, + DataComponents.LOCK, + DataComponents.CREATIVE_SLOT_LOCK + )); + } - assertTrue(excessKeys.isEmpty(), excessKeys.size() + " excess constants(s) in " + clazz.getSimpleName() + " that do not exist: " + excessKeys); + public static Stream registries() { + return RegistriesArgumentProvider.getData() + .map(args -> Arguments.of(args.api(), args.apiHolder(), args.registryKey())); } - private void testMissingConstants(Class clazz, ResourceKey> nmsRegistryKey) { - List missingKeys = new ArrayList<>(); + @MethodSource("registries") + @ParameterizedTest + public void testConstants(Class api, Class apiHolder, ResourceKey> registryKey) throws IllegalAccessException { + final Set keys = new ObjectOpenHashSet<>( + RegistryHelper.registryAccess().lookupOrThrow(registryKey).keySet() + ); - net.minecraft.core.Registry nmsRegistry = RegistryHelper.getRegistry().lookupOrThrow(nmsRegistryKey); - for (M nmsObject : nmsRegistry) { - ResourceLocation minecraftKey = nmsRegistry.getKey(nmsObject); + for (final Field field : apiHolder.getDeclaredFields()) { + if (!api.isAssignableFrom(field.getType())) continue; + if (field.isAnnotationPresent(Deprecated.class)) continue; - try { - @SuppressWarnings("unchecked") - T bukkitObject = (T) clazz.getField(minecraftKey.getPath().toUpperCase(Locale.ROOT)).get(null); + final B element = api.cast(field.get(null)); + if (!keys.remove(CraftNamespacedKey.toMinecraft(element.getKey()))) { + fail("Constant " + apiHolder.getSimpleName() + " / " + field.getName() + " is unknown to vanilla registry"); + } + } - assertEquals(minecraftKey, CraftNamespacedKey.toMinecraft(bukkitObject.getKey()), "Keys are not the same for " + minecraftKey); - } catch (NoSuchFieldException e) { - missingKeys.add(minecraftKey); - } catch (Exception e) { - fail(e.getMessage()); + final Collection ignoredKeys = IGNORED_KEYS.get(registryKey); + if (!ignoredKeys.isEmpty()) { + if (!keys.containsAll(ignoredKeys)) { + Set extraKeys = ignoredKeys.stream().filter(Predicate.not(keys::contains)).collect(Collectors.toCollection(ObjectOpenHashSet::new)); + fail("Constants that should be ignored in " + apiHolder.getSimpleName() + ": " + extraKeys); } + keys.removeAll(ignoredKeys); } - assertTrue(missingKeys.isEmpty(), "Missing (" + missingKeys.size() + ") constants in " + clazz.getSimpleName() + ": " + missingKeys); + assertTrue(keys.isEmpty(), "Missing (" + keys.size() + ") constants in " + apiHolder.getSimpleName() + ": " + keys); } } diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java index 87396938f890..d242e9fbfab2 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryConversionTest.java @@ -3,9 +3,7 @@ import com.google.common.base.Joiner; import io.papermc.paper.registry.RegistryAccess; import io.papermc.paper.registry.RegistryKey; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; +import io.papermc.paper.util.Holderable; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -14,17 +12,15 @@ import net.minecraft.resources.ResourceKey; import org.bukkit.Keyed; import org.bukkit.Registry; -import org.bukkit.craftbukkit.util.Handleable; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.support.environment.AllFeatures; import org.bukkit.support.test.RegistriesTest; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.params.provider.Arguments; -import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.Mockito.mock; @@ -33,293 +29,99 @@ @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class RegistryConversionTest { - private static final String MINECRAFT_TO_BUKKIT = "minecraftToBukkit"; - private static final String BUKKIT_TO_MINECRAFT = "bukkitToMinecraft"; + private static final Set> IMPLEMENT_HOLDERABLE = new HashSet<>(); - private static final String MINECRAFT_TO_BUKKIT_NEW = "minecraftToBukkitNew"; - private static final String BUKKIT_TO_MINECRAFT_NEW = "bukkitToMinecraftNew"; - - private static final Map, Method> MINECRAFT_TO_BUKKIT_METHODS = new HashMap<>(); - private static final Map, Method> BUKKIT_TO_MINECRAFT_METHODS = new HashMap<>(); - - private static final Set> IMPLEMENT_HANDLE_ABLE = new HashSet<>(); - - public static Stream getValues(RegistryKey registryType) { // Paper - Registry registry = RegistryAccess.registryAccess().getRegistry(registryType); // Paper - return registry.stream().map(keyed -> (Handleable) keyed) - .map(handleAble -> Arguments.of(handleAble, handleAble.getHandle())); + public static Stream> getValues(RegistryKey registryKey) { + Registry registry = RegistryAccess.registryAccess().getRegistry(registryKey); + return registry.stream().map(keyed -> (Holderable) keyed); } @Order(1) @RegistriesTest - public void testHandleableImplementation(io.papermc.paper.registry.RegistryKey type, Class clazz) { // Paper + public void testHolderableImplementation(RegistryKey apiRegistryKey, Class clazz) { Set> notImplemented = new HashSet<>(); - Registry registry = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(type); // Paper + Registry registry = RegistryAccess.registryAccess().getRegistry(apiRegistryKey); for (Keyed item : registry) { - if (!(item instanceof Handleable)) { + if (!(item instanceof Holderable)) { notImplemented.add(item.getClass()); } } assertTrue(notImplemented.isEmpty(), String.format(""" - Not all implementations of the registry from the class %s have the Handleable interface implemented. - Every Implementation should implement the Handleable interface. - - The following implementation do not implement Handleable: - %s""", clazz.getName(), Joiner.on('\n').join(notImplemented))); - - RegistryConversionTest.IMPLEMENT_HANDLE_ABLE.add(clazz); + Not all implementations of the registry from the class %s have the Holderable interface implemented. + Every Implementation should implement the Holderable interface. + + The following implementation do not implement Holderable: + %s""", clazz.getName(), Joiner.on('\n').join(notImplemented))); + RegistryConversionTest.IMPLEMENT_HOLDERABLE.add(clazz); } @Order(2) @RegistriesTest - public void testMinecraftToBukkitPresent(io.papermc.paper.registry.RegistryKey type, Class clazz, ResourceKey> registryKey, - Class craftClazz, Class minecraftClazz, boolean newMethod) { - String methodName = (newMethod) ? RegistryConversionTest.MINECRAFT_TO_BUKKIT_NEW : RegistryConversionTest.MINECRAFT_TO_BUKKIT; - Method method = null; - try { - method = craftClazz.getDeclaredMethod(methodName, minecraftClazz); - } catch (NoSuchMethodException e) { - fail(String.format(""" - The class %s does not have a public static method to convert a minecraft value to a bukkit value. - - Following method should be add which, returns the bukkit value based on the minecraft value. - %s - """, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - } - - assertTrue(Modifier.isPublic(method.getModifiers()), String.format(""" - The method %s in class %s is not public. - - The method should be made public, method structure: - %s - """, methodName, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - - assertTrue(Modifier.isStatic(method.getModifiers()), String.format(""" - The method %s in class %s is not static. - - The method should be made static, method structure: - %s - """, methodName, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - - assertSame(clazz, method.getReturnType(), String.format(""" - The method %s in class %s has the wrong return value. - - The method should have the correct return value, method structure: - %s - """, methodName, craftClazz, this.buildMinecraftToBukkitMethod(clazz, methodName, minecraftClazz))); - - RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.put(clazz, method); - } - - private String buildMinecraftToBukkitMethod(Class clazz, String methodName, Class minecraftClazz) { - return String.format(""" - public static %s %s(%s minecraft) { - [...] - } - """, clazz.getSimpleName(), methodName, minecraftClazz.getName()); - } - - @Order(2) - @RegistriesTest - public void testBukkitToMinecraftPresent(io.papermc.paper.registry.RegistryKey type, Class clazz, ResourceKey> registryKey, - Class craftClazz, Class minecraftClazz, boolean newMethod) { - String methodName = (newMethod) ? RegistryConversionTest.BUKKIT_TO_MINECRAFT_NEW : RegistryConversionTest.BUKKIT_TO_MINECRAFT; - Method method = null; - try { - method = craftClazz.getDeclaredMethod(methodName, clazz); - } catch (NoSuchMethodException e) { - fail(String.format(""" - The class %s does not have a public static method to convert a bukkit value to a minecraft value. - - Following method should be add which, returns the minecraft value based on the bukkit value. - %s - """, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - } - - assertTrue(Modifier.isPublic(method.getModifiers()), String.format(""" - The method %s in class %s is not public. - - The method should be made public, method structure: - %s - """, methodName, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - - assertTrue(Modifier.isStatic(method.getModifiers()), String.format(""" - The method %s in class %s is not static. - - The method should be made static, method structure: - %s - """, methodName, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - - assertSame(minecraftClazz, method.getReturnType(), String.format(""" - The method %s in class %s has the wrong return value. - - The method should have the correct return value, method structure: - %s - """, methodName, craftClazz, this.buildBukkitToMinecraftMethod(clazz, methodName, minecraftClazz))); - - RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.put(clazz, method); - } - - private String buildBukkitToMinecraftMethod(Class clazz, String methodName, Class minecraftClazz) { - return String.format(""" - public static %s %s(%s bukkit) { - [...] - } - """, minecraftClazz.getName(), methodName, clazz.getSimpleName()); - } - - @Order(3) - @RegistriesTest - public void testMinecraftToBukkitNullValue(io.papermc.paper.registry.RegistryKey type, Class clazz) throws IllegalAccessException { // Paper - this.checkValidMinecraftToBukkit(clazz); - - try { - Object result = RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.get(clazz).invoke(null, (Object) null); - fail(String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - Got '%s' as return object. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName(), result)); - } catch (InvocationTargetException e) { - // #invoke wraps the error in a InvocationTargetException, so we need to check it this way - assertSame(IllegalArgumentException.class, e.getCause().getClass(), String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName())); - } - } - - @Order(3) - @RegistriesTest - public void testBukkitToMinecraftNullValue(io.papermc.paper.registry.RegistryKey type, Class clazz) throws IllegalAccessException { // Paper - this.checkValidBukkitToMinecraft(clazz); - - try { - Object result = RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.get(clazz).invoke(null, (Object) null); - fail(String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - Got '%s' as return object. - """, RegistryConversionTest.BUKKIT_TO_MINECRAFT, clazz.getName(), result)); - } catch (InvocationTargetException e) { - // #invoke wraps the error in a InvocationTargetException, so we need to check it this way - assertSame(IllegalArgumentException.class, e.getCause().getClass(), String.format(""" - Method %s in class %s should not accept null values and should throw a IllegalArgumentException. - """, RegistryConversionTest.BUKKIT_TO_MINECRAFT, clazz.getName())); - } - } - - @Order(3) - @RegistriesTest - public void testMinecraftToBukkit(io.papermc.paper.registry.RegistryKey type, Class clazz) { // Paper - this.checkValidMinecraftToBukkit(clazz); + public void testMinecraftHolderToBukkit(RegistryKey apiRegistryKey, Class clazz, ResourceKey> registryKey) { this.checkValidHandle(clazz); Map notMatching = new HashMap<>(); - Method method = RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.get(clazz); - - getValues(type).map(Arguments::get).forEach(arguments -> { // Paper - Keyed bukkit = (Keyed) arguments[0]; - Object minecraft = arguments[1]; - - try { - Object otherBukkit = method.invoke(null, minecraft); - if (bukkit != otherBukkit) { - notMatching.put(bukkit, otherBukkit); - } - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(e); + getValues(apiRegistryKey).forEach(bukkit -> { + Object otherBukkit = CraftRegistry.minecraftHolderToBukkit(bukkit.getHolder(), (ResourceKey) registryKey); + if (bukkit != otherBukkit) { + notMatching.put(bukkit, otherBukkit); } }); assertTrue(notMatching.isEmpty(), String.format(""" - The method %s in class %s does not match all registry items correctly. - - Following registry items where match not correctly: - %s""", RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName(), - Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); + The conversion method does not match all registry items correctly. + + Following registry items where match not correctly: + %s""", + Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); } - @Order(3) + @Order(2) @RegistriesTest - public void testBukkitToMinecraft(io.papermc.paper.registry.RegistryKey type, Class clazz) { // Paper - this.checkValidBukkitToMinecraft(clazz); + public void testBukkitToMinecraftHolder(RegistryKey apiRegistryKey, Class clazz) { this.checkValidHandle(clazz); Map notMatching = new HashMap<>(); - Method method = RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.get(clazz); - - getValues(type).map(Arguments::get).forEach(arguments -> { // Paper - Keyed bukkit = (Keyed) arguments[0]; - Object minecraft = arguments[1]; - try { - Object otherMinecraft = method.invoke(null, bukkit); - if (minecraft != otherMinecraft) { - notMatching.put(minecraft, otherMinecraft); - } - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(e); + getValues(apiRegistryKey).forEach(bukkit -> { + Object minecraft = bukkit.getHolder(); + Object otherMinecraft = CraftRegistry.bukkitToMinecraftHolder((Keyed) bukkit); + if (minecraft != otherMinecraft) { + notMatching.put(minecraft, otherMinecraft); } }); assertTrue(notMatching.isEmpty(), String.format(""" - The method %s in class %s does not match all registry items correctly. - - Following registry items where match not correctly: - %s""", RegistryConversionTest.BUKKIT_TO_MINECRAFT, clazz.getName(), - Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); + The conversion method does not match all registry items correctly. + + Following registry items where match not correctly: + %s""", Joiner.on('\n').withKeyValueSeparator(" got: ").join(notMatching))); } - static final Set> IGNORE_FOR_DIRECT_HOLDER = Set.of(RegistryKey.TRIM_MATERIAL, RegistryKey.TRIM_PATTERN, RegistryKey.INSTRUMENT, RegistryKey.BANNER_PATTERN, RegistryKey.SOUND_EVENT, RegistryKey.DIALOG); // Paper - /** * Minecraft registry can return a default key / value * when the passed minecraft value is not registry in this case, we want it to throw an error. */ - @Order(3) + @Order(2) @RegistriesTest - public void testMinecraftToBukkitNoValidMinecraft(io.papermc.paper.registry.RegistryKey type, Class clazz, ResourceKey> registryKey, // Paper - Class craftClazz, Class minecraftClazz) throws IllegalAccessException { - this.checkValidMinecraftToBukkit(clazz); - - assumeFalse(IGNORE_FOR_DIRECT_HOLDER.contains(type), "skipped because these types support direct holders"); // Paper - manually skip for now - try { - - Object minecraft = mock(minecraftClazz); - Object result = RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.get(clazz).invoke(null, minecraft); - fail(String.format(""" - Method %s in class %s should not accept a none registered value and should throw a IllegalStateException. - Got '%s' as return object. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName(), result)); - } catch (InvocationTargetException e) { - // #invoke wraps the error in a InvocationTargetException, so we need to check it this way - assertSame(IllegalStateException.class, e.getCause().getClass(), String.format(""" - Method %s in class %s should not accept a none registered value and should throw a IllegalStateException. - """, RegistryConversionTest.MINECRAFT_TO_BUKKIT, clazz.getName())); - } - } - - private void checkValidBukkitToMinecraft(Class clazz) { - assumeTrue(RegistryConversionTest.BUKKIT_TO_MINECRAFT_METHODS.containsKey(clazz), String.format(""" - Cannot test class %s, because it does not have a valid %s method. - - Check test results of testBukkitToMinecraftPresent for more information. - """, clazz.getName(), RegistryConversionTest.BUKKIT_TO_MINECRAFT)); - } - - private void checkValidMinecraftToBukkit(Class clazz) { - assumeTrue(RegistryConversionTest.MINECRAFT_TO_BUKKIT_METHODS.containsKey(clazz), String.format(""" - Cannot test class %s, because it does not have a valid %s method. - - Check test results of testMinecraftToBukkitPresent for more information. - """, clazz.getName(), RegistryConversionTest.MINECRAFT_TO_BUKKIT)); + public void testMinecraftToBukkitNoValidMinecraft( + RegistryKey apiRegistryKey, Class clazz, ResourceKey> registryKey, + Class craftClazz, Class minecraftClazz + ) { + final Registry bukkitRegistry = RegistryAccess.registryAccess().getRegistry(apiRegistryKey); + assumeFalse(((CraftRegistry) bukkitRegistry).supportsDirectHolders(), "skipped because these types support direct holders"); + Object minecraft = mock(minecraftClazz); + assertThrows(IllegalStateException.class, () -> CraftRegistry.minecraftToBukkit(minecraft, (ResourceKey) registryKey), + "Conversion method should not accept a none registered value and should throw a IllegalStateException."); } private void checkValidHandle(Class clazz) { - assumeTrue(RegistryConversionTest.IMPLEMENT_HANDLE_ABLE.contains(clazz), String.format(""" - Cannot test class %s, because it does not implement Handleable. - - Check test results of testHandleableImplementation for more information. - """, clazz.getName())); + assumeTrue(RegistryConversionTest.IMPLEMENT_HOLDERABLE.contains(clazz), String.format(""" + Cannot test class %s, because it does not implement Holderable. + + Check test results of testHolderableImplementation for more information. + """, clazz.getName())); } } diff --git a/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java b/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java index d548ff4a9656..f14573e66c86 100644 --- a/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java +++ b/paper-server/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java @@ -9,7 +9,7 @@ import net.minecraft.core.MappedRegistry; import net.minecraft.core.RegistrationInfo; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -29,20 +29,20 @@ public class RegistryLoadOrderTest { public static Stream data() { return Stream.of( - Arguments.of( - (Supplier) () -> RegistryLoadOrderTest.initInterface, - BukkitInterfaceTestType.class, - (BiFunction) CraftBukkitInterfaceTestType::new, - (Supplier) () -> BukkitInterfaceTestType.TEST_ONE, - (Supplier) () -> BukkitInterfaceTestType.TEST_TWO - ), - Arguments.of( - (Supplier) () -> RegistryLoadOrderTest.initAbstract, - BukkitAbstractTestType.class, - (BiFunction) CraftBukkitAbstractTestType::new, - (Supplier) () -> BukkitAbstractTestType.TEST_ONE, - (Supplier) () -> BukkitAbstractTestType.TEST_TWO - ) + Arguments.of( + (Supplier) () -> RegistryLoadOrderTest.initInterface, + BukkitInterfaceTestType.class, + (BiFunction) CraftBukkitInterfaceTestType::new, + (Supplier) () -> BukkitInterfaceTestType.TEST_ONE, + (Supplier) () -> BukkitInterfaceTestType.TEST_TWO + ), + Arguments.of( + (Supplier) () -> RegistryLoadOrderTest.initAbstract, + BukkitAbstractTestType.class, + (BiFunction) CraftBukkitAbstractTestType::new, + (Supplier) () -> BukkitAbstractTestType.TEST_ONE, + (Supplier) () -> BukkitAbstractTestType.TEST_TWO + ) ); } @@ -51,11 +51,11 @@ public static Stream data() { public void testRegistryLoadOrder(Supplier init, Class keyedClass, BiFunction minecraftToBukkit, Supplier first, Supplier second) { this.testClassNotLoaded(init.get()); - ResourceKey> resourceKey = ResourceKey.createRegistryKey(ResourceLocation.tryBuild("bukkit", "test-registry")); + ResourceKey> resourceKey = ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath("bukkit", "test-registry")); MappedRegistry minecraftRegistry = new MappedRegistry<>(resourceKey, Lifecycle.experimental()); - minecraftRegistry.register(ResourceKey.create(resourceKey, ResourceLocation.tryBuild("bukkit", "test-one")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); - minecraftRegistry.register(ResourceKey.create(resourceKey, ResourceLocation.tryBuild("bukkit", "test-two")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); + minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.fromNamespaceAndPath("bukkit", "test-one")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); + minecraftRegistry.register(ResourceKey.create(resourceKey, Identifier.fromNamespaceAndPath("bukkit", "test-two")), new MinecraftTestType(), new RegistrationInfo(Optional.empty(), Lifecycle.experimental())); minecraftRegistry.freeze(); RegistryLoadOrderTest.registry = new CraftRegistry<>(keyedClass, minecraftRegistry, minecraftToBukkit, (namespacedKey, apiVersion) -> namespacedKey); @@ -82,10 +82,10 @@ public void testRegistryLoadOrder(Supplier init, Class keyedClas private void testClassNotLoaded(boolean init) { assertFalse(init, """ - TestType class is already loaded, this test however tests the behavior when the class is not loaded. - This should normally not happen with how classes should be loaded. - Something has changed how classes are loaded and a more manual deeper look is required. - """); + TestType class is already loaded, this test however tests the behavior when the class is not loaded. + This should normally not happen with how classes should be loaded. + Something has changed how classes are loaded and a more manual deeper look is required. + """); } public interface BukkitInterfaceTestType extends Keyed { 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 a2094842c724..c6e49a553c30 100644 --- a/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java +++ b/paper-server/src/test/java/org/bukkit/support/DummyServerHelper.java @@ -43,12 +43,12 @@ public static Server setup() { when(instance.createBlockData(any(Material.class))).then(mock -> CraftBlockData.newData(((Material) mock.getArgument(0)).asBlockType(), null)); when(instance.getLootTable(any())).then(mock -> new CraftLootTable(mock.getArgument(0), - RegistryHelper.getDataPack().fullRegistries().getLootTable(ResourceKey.create(Registries.LOOT_TABLE, CraftNamespacedKey.toMinecraft(mock.getArgument(0)))))); + RegistryHelper.context().datapack().fullRegistries().getLootTable(ResourceKey.create(Registries.LOOT_TABLE, CraftNamespacedKey.toMinecraft(mock.getArgument(0)))))); when(instance.getTag(any(), any(), any())).then(mock -> { String registry = mock.getArgument(0); Class clazz = mock.getArgument(2); - net.minecraft.resources.ResourceLocation key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - address remapping issues + net.minecraft.resources.Identifier key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - address remapping issues switch (registry) { case org.bukkit.Tag.REGISTRY_BLOCKS -> { @@ -99,12 +99,12 @@ public static Server setup() { when(instance.getPluginManager()).thenReturn(pluginManager); // Paper end - testing additions - io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(RegistryHelper.getRegistry()); // Paper - configuration files - setup global configuration test base + io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(RegistryHelper.registryAccess()); // Paper - configuration files - setup global configuration test base // Paper start - add test for recipe conversion when(instance.recipeIterator()).thenAnswer(ignored -> com.google.common.collect.Iterators.transform( - RegistryHelper.getDataPack().getRecipeManager().recipes.byType.entries().iterator(), + RegistryHelper.context().datapack().getRecipeManager().recipes.byType.entries().iterator(), input -> input.getValue().toBukkitRecipe() ) ); diff --git a/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java b/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java index 7af2acd0fc1d..8bf9b94d0bb6 100644 --- a/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java +++ b/paper-server/src/test/java/org/bukkit/support/RegistryHelper.java @@ -1,142 +1,144 @@ package org.bukkit.support; -import com.google.common.util.concurrent.MoreExecutors; import java.util.List; import java.util.Locale; +import java.util.function.Supplier; +import java.util.regex.Pattern; +import java.util.stream.Stream; import net.minecraft.SharedConstants; import net.minecraft.commands.Commands; import net.minecraft.core.HolderLookup; import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; import net.minecraft.resources.RegistryDataLoader; import net.minecraft.server.Bootstrap; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.RegistryLayer; import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.repository.Pack; import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.server.packs.repository.ServerPacksSource; import net.minecraft.server.packs.resources.MultiPackResourceManager; import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.permissions.LevelBasedPermissionSet; import net.minecraft.tags.TagLoader; +import net.minecraft.util.Util; import net.minecraft.world.flag.FeatureFlagSet; -import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.flag.FeatureFlags; +import net.minecraft.world.level.DataPackConfig; +import net.minecraft.world.level.WorldDataConfiguration; import net.minecraft.world.level.chunk.PalettedContainerFactory; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; public final class RegistryHelper { - private static ReloadableServerResources dataPack; - private static RegistryAccess.Frozen registry; - private static Registry biomes; - private static PalettedContainerFactory palettedContainerFactory; + private static SetupContext setupContext; private RegistryHelper() { } - public static ReloadableServerResources getDataPack() { - if (RegistryHelper.dataPack == null) { - RegistryHelper.throwError("dataPack"); - } - return RegistryHelper.dataPack; + public static RegistryAccess registryAccess() { + return context().registries(); } - public static RegistryAccess.Frozen getRegistry() { - if (RegistryHelper.registry == null) { - RegistryHelper.throwError("registry"); + public static SetupContext context() { + if (setupContext == null) { + throw new IllegalStateException(""" + Trying to access shared context while it is not setup. + Make sure that either the class or method you test has the right test environment annotation present. + You can find them in the package src/test/java/org.bukkit.support.environment"""); } - return RegistryHelper.registry; + return setupContext; } - public static Registry getBiomes() { - if (RegistryHelper.biomes == null) { - RegistryHelper.throwError("biomes"); - } - return RegistryHelper.biomes; + public record SetupContext( + ReloadableServerResources datapack, + RegistryAccess registries, + Supplier palettedContainerFactory + ) { } - public static PalettedContainerFactory palettedContainerFactory() { - if (RegistryHelper.palettedContainerFactory == null) { - RegistryHelper.throwError("palettedContainerFactory"); + public record PackedRegistries(LayeredRegistryAccess layers, List> pendingTags) { + + public RegistryAccess access() { + return this.layers.compositeAccess().freeze(); } - return RegistryHelper.palettedContainerFactory; } - public static RegistryAccess.Frozen createRegistry(FeatureFlagSet featureFlagSet) { - MultiPackResourceManager ireloadableresourcemanager = RegistryHelper.createResourceManager(featureFlagSet); + public static PackedRegistries createRegistries(FeatureFlagSet enabledFeatures) { + return createRegistries(RegistryHelper.createResourceManager(enabledFeatures)); + } + + public static PackedRegistries createRegistries(ResourceManager resourceManager) { // add tags and loot tables for unit tests - LayeredRegistryAccess layeredregistryaccess = RegistryLayer.createRegistryAccess(); - List> list = TagLoader.loadTagsForExistingRegistries(ireloadableresourcemanager, layeredregistryaccess.getLayer(RegistryLayer.STATIC)); - RegistryAccess.Frozen iregistrycustom_dimension = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN); - List> list1 = TagLoader.buildUpdatedLookups(iregistrycustom_dimension, list); - RegistryAccess.Frozen iregistrycustom_dimension1 = RegistryDataLoader.load((ResourceManager) ireloadableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES); - LayeredRegistryAccess layers = layeredregistryaccess.replaceFrom(RegistryLayer.WORLDGEN, iregistrycustom_dimension1); - // Paper start - load registry here to ensure bukkit object registry are correctly delayed if needed + LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); + List> pendingTags = TagLoader.loadTagsForExistingRegistries(resourceManager, layers.getLayer(RegistryLayer.STATIC)); + + List> lookupsWithPendingTags = TagLoader.buildUpdatedLookups(layers.getAccessForLoading(RegistryLayer.WORLDGEN), pendingTags); + RegistryAccess.Frozen worldGenRegistries = RegistryDataLoader.load(resourceManager, lookupsWithPendingTags, RegistryDataLoader.WORLDGEN_REGISTRIES); + layers = layers.replaceFrom(RegistryLayer.WORLDGEN, worldGenRegistries); + + List> staticAndWorldgenLookups = Stream.concat(lookupsWithPendingTags.stream(), worldGenRegistries.listRegistries()).toList(); + RegistryAccess.Frozen dimensionRegistries = RegistryDataLoader.load(resourceManager, staticAndWorldgenLookups, RegistryDataLoader.DIMENSION_REGISTRIES); + layers = layers.replaceFrom(RegistryLayer.DIMENSIONS, dimensionRegistries); + // load registry here to ensure bukkit object registry are correctly delayed if needed try { - Class.forName("org.bukkit.Registry"); - } catch (final ClassNotFoundException ignored) {} - // Paper end - load registry here to ensure bukkit object registry are correctly delayed if needed + Class.forName(org.bukkit.Registry.class.getName()); + } catch (final ClassNotFoundException ignored) { + } - return layers.compositeAccess().freeze(); + return new PackedRegistries(layers, pendingTags); } - public static void setup(FeatureFlagSet featureFlagSet) { + public static void setup(FeatureFlagSet enabledFeatures) { SharedConstants.tryDetectVersion(); Bootstrap.bootStrap(); + Bootstrap.validate(); - MultiPackResourceManager ireloadableresourcemanager = RegistryHelper.createResourceManager(featureFlagSet); - // add tags and loot tables for unit tests - LayeredRegistryAccess layeredregistryaccess = RegistryLayer.createRegistryAccess(); - List> list = TagLoader.loadTagsForExistingRegistries(ireloadableresourcemanager, layeredregistryaccess.getLayer(RegistryLayer.STATIC)); - RegistryAccess.Frozen iregistrycustom_dimension = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN); - List> list1 = TagLoader.buildUpdatedLookups(iregistrycustom_dimension, list); - RegistryAccess.Frozen iregistrycustom_dimension1 = RegistryDataLoader.load((ResourceManager) ireloadableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES); - LayeredRegistryAccess layers = layeredregistryaccess.replaceFrom(RegistryLayer.WORLDGEN, iregistrycustom_dimension1); - // Paper start - load registry here to ensure bukkit object registry are correctly delayed if needed - try { - Class.forName("org.bukkit.Registry"); - } catch (final ClassNotFoundException ignored) {} - // Paper end - load registry here to ensure bukkit object registry are correctly delayed if needed - RegistryHelper.registry = layers.compositeAccess().freeze(); - // Register vanilla pack - RegistryHelper.dataPack = ReloadableServerResources.loadResources(ireloadableresourcemanager, layers, list, featureFlagSet, Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); + ResourceManager resourceManager = RegistryHelper.createResourceManager(enabledFeatures); + PackedRegistries registries = createRegistries(resourceManager); + + // Register vanilla packs + ReloadableServerResources datapack = ReloadableServerResources.loadResources(resourceManager, registries.layers(), registries.pendingTags(), enabledFeatures, Commands.CommandSelection.DEDICATED, LevelBasedPermissionSet.ALL_PERMISSIONS, Util.backgroundExecutor(), Runnable::run).join(); // Bind tags - RegistryHelper.dataPack.updateStaticRegistryTags(); - // Biome shortcut - RegistryHelper.biomes = RegistryHelper.registry.lookupOrThrow(Registries.BIOME); - // PalettedContainerFactory shortcut - RegistryHelper.palettedContainerFactory = PalettedContainerFactory.create(RegistryHelper.registry); + datapack.updateStaticRegistryTags(); + + RegistryAccess registryAccess = registries.access(); + setupContext = new SetupContext( + datapack, + registryAccess, + () -> PalettedContainerFactory.create(registryAccess) + ); } - public static Class updateClass(Class aClass, NamespacedKey key) { - Class theClass; + public static Class getFieldType(Class apiClass, NamespacedKey key) { + Class fieldType = apiClass; // Some registries have extra Typed classes such as BlockType and ItemType. // To avoid class cast exceptions during init mock the Typed class. // To get the correct class, we just use the field type. try { - theClass = (Class) aClass.getField(key.getKey().toUpperCase(Locale.ROOT).replace('.', '_')).getType(); - } catch (ClassCastException | NoSuchFieldException e) { + fieldType = (Class) apiClass.getField(formatKeyAsField(key.getKey())).getType(); + } catch (NoSuchFieldException e) { + // continue with the less accurate type + } catch (ClassCastException e) { throw new RuntimeException(e); } - return theClass; + return fieldType; } - private static MultiPackResourceManager createResourceManager(FeatureFlagSet featureFlagSet) { - // Populate available packs - PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository(); - resourceRepository.reload(); - // Set up resource manager - return new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().filter(pack -> pack.getRequestedFeatures().isSubsetOf(featureFlagSet)).map(Pack::open).toList()); + private static MultiPackResourceManager createResourceManager(FeatureFlagSet enabledFeatures) { + PackRepository packRepository = ServerPacksSource.createVanillaTrustedRepository(); + MinecraftServer.configurePackRepository(packRepository, new WorldDataConfiguration(new DataPackConfig(FeatureFlags.REGISTRY.toNames(enabledFeatures).stream().map(Identifier::getPath).toList(), List.of()), enabledFeatures), true, false); + return new MultiPackResourceManager(PackType.SERVER_DATA, packRepository.openAllSelected()); } - private static void throwError(String field) { - throw new IllegalStateException(String.format(""" - Trying to access %s will it is not setup. - Make sure that either the class or method you test has the right test environment annotation present. - You can find them in the package src/test/java/org.bukkit.support.environment""", field)); + private static final Pattern ILLEGAL_FIELD_CHARACTERS = Pattern.compile("[.-/]"); + + public static String formatKeyAsField(String path) { + return ILLEGAL_FIELD_CHARACTERS.matcher(path.toUpperCase(Locale.ENGLISH)).replaceAll("_"); } } diff --git a/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java index a17f783d0c75..990b496716ee 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/AllFeaturesExtension.java @@ -33,12 +33,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.REGISTRY.allFlags()); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override diff --git a/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java index ae8a16160b8f..ee39652e1500 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/LegacyExtension.java @@ -19,12 +19,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override diff --git a/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java index a809ea2f0d2b..0d35cb4e8f3a 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/NormalExtension.java @@ -1,7 +1,5 @@ package org.bukkit.support.extension; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; import java.util.HashMap; import java.util.Map; import net.minecraft.core.RegistryAccess; @@ -17,6 +15,12 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.mockito.stubbing.Answer; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; + public class NormalExtension extends BaseExtension { private static final Answer DEFAULT_ANSWER = invocation -> { @@ -38,7 +42,6 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); when(server.getRegistry(any())) @@ -47,7 +50,6 @@ public void init(ExtensionContext extensionContext) { return registries.computeIfAbsent(keyed, k -> createMockBukkitRegistry(keyed)); }); - RegistryAccess registry = mock(withSettings().stubOnly().defaultAnswer(NormalExtension.DEFAULT_ANSWER)); CraftRegistry.setMinecraftRegistry(registry); } @@ -61,8 +63,8 @@ private Registry createMockBukkitRegistry(Class keyed) { Registry registry = mock(withSettings().stubOnly().defaultAnswer(NormalExtension.DEFAULT_ANSWER)); doAnswer(invocation -> - mocks.computeIfAbsent(invocation.getArgument(0), k -> mock(RegistryHelper.updateClass(keyed, invocation.getArgument(0)), withSettings().stubOnly().defaultAnswer(DEFAULT_ANSWER))) - ).when(registry).get((NamespacedKey) any()); // Allow static classes to fill there fields, so that it does not error out, just by loading them // Paper - registry modification api - specifically call namespaced key overload + mocks.computeIfAbsent(invocation.getArgument(0), k -> mock(RegistryHelper.getFieldType(keyed, invocation.getArgument(0)), withSettings().stubOnly().defaultAnswer(DEFAULT_ANSWER))) + ).when(registry).get((NamespacedKey) any()); // Allow static classes to fill their fields, so that it does not error out, just by loading them // Paper - registry modification api - specifically call namespaced key overload return registry; } diff --git a/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java index eb0960fa1169..44a64e8635df 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/SlowExtension.java @@ -19,12 +19,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override diff --git a/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java b/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java index 66db95cfcaaa..aabd9e5e4176 100644 --- a/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java +++ b/paper-server/src/test/java/org/bukkit/support/extension/VanillaFeatureExtension.java @@ -19,12 +19,11 @@ public void init(ExtensionContext extensionContext) { RegistryHelper.setup(FeatureFlags.VANILLA_SET); Server server = DummyServerHelper.setup(); - Bukkit.setServer(server); // Paper - Add RegistryAccess for managing registries - replaced with registry access - CraftRegistry.setMinecraftRegistry(RegistryHelper.getRegistry()); + CraftRegistry.setMinecraftRegistry(RegistryHelper.registryAccess()); } @Override 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 919f13143dba..00b949fc0982 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 @@ -1,32 +1,39 @@ package org.bukkit.support.provider; import com.google.common.collect.Lists; +import io.papermc.paper.datacomponent.DataComponentTypes; import io.papermc.paper.dialog.Dialog; import io.papermc.paper.dialog.PaperDialog; +import io.papermc.paper.registry.PaperRegistries; import io.papermc.paper.registry.RegistryKey; import java.util.List; import java.util.stream.Stream; +import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.entity.animal.CatVariant; -import net.minecraft.world.entity.animal.ChickenVariant; -import net.minecraft.world.entity.animal.CowVariant; -import net.minecraft.world.entity.animal.PigVariant; +import net.minecraft.world.entity.animal.feline.CatVariant; +import net.minecraft.world.entity.animal.chicken.ChickenVariant; +import net.minecraft.world.entity.animal.cow.CowVariant; +import net.minecraft.world.entity.animal.pig.PigVariant; +import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant; import net.minecraft.world.entity.animal.frog.FrogVariant; import net.minecraft.world.entity.animal.wolf.WolfSoundVariant; import net.minecraft.world.entity.animal.wolf.WolfVariant; -import net.minecraft.world.entity.decoration.PaintingVariant; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; +import net.minecraft.world.entity.npc.villager.VillagerProfession; +import net.minecraft.world.entity.npc.villager.VillagerType; import net.minecraft.world.item.Instrument; import net.minecraft.world.level.block.entity.BannerPattern; import net.minecraft.world.level.saveddata.maps.MapDecorationType; import org.bukkit.Art; import org.bukkit.Fluid; import org.bukkit.GameEvent; +import org.bukkit.GameRule; +import org.bukkit.GameRules; import org.bukkit.JukeboxSong; +import org.bukkit.Keyed; import org.bukkit.MusicInstrument; import org.bukkit.Sound; import org.bukkit.attribute.Attribute; @@ -36,6 +43,7 @@ import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftFluid; import org.bukkit.craftbukkit.CraftGameEvent; +import org.bukkit.craftbukkit.CraftGameRule; import org.bukkit.craftbukkit.CraftJukeboxSong; import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.CraftSound; @@ -52,6 +60,7 @@ import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftVillager; import org.bukkit.craftbukkit.entity.CraftWolf; +import org.bukkit.craftbukkit.entity.CraftZombieNautilus; import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructureType; import org.bukkit.craftbukkit.inventory.CraftItemType; @@ -69,6 +78,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; +import org.bukkit.entity.ZombieNautilus; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; import org.bukkit.inventory.ItemType; @@ -77,63 +87,85 @@ import org.bukkit.inventory.meta.trim.TrimPattern; import org.bukkit.map.MapCursor; import org.bukkit.potion.PotionEffectType; +import org.jspecify.annotations.NullMarked; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.ArgumentsProvider; +@NullMarked public class RegistriesArgumentProvider implements ArgumentsProvider { - private static final List DATA = Lists.newArrayList(); + public record RegistryArgument(ResourceKey> registryKey, + RegistryKey apiRegistryKey, + Class api, Class apiHolder, + Class impl, + Class internal) implements Arguments { + @Override + public Object[] get() { + return new Object[]{ + this.apiRegistryKey, + this.api, + this.registryKey, + this.impl, + this.internal, + this.apiHolder + }; + } + } + + private static final List> DATA = Lists.newArrayList(); static { - // Order: RegistryKey, Bukkit class, Minecraft Registry key, CraftBukkit class, Minecraft class - register(RegistryKey.PAINTING_VARIANT, Art.class, Registries.PAINTING_VARIANT, CraftArt.class, PaintingVariant.class); - register(RegistryKey.ATTRIBUTE, Attribute.class, Registries.ATTRIBUTE, CraftAttribute.class, net.minecraft.world.entity.ai.attributes.Attribute.class); - register(RegistryKey.BIOME, Biome.class, Registries.BIOME, CraftBiome.class, net.minecraft.world.level.biome.Biome.class); - register(RegistryKey.ENCHANTMENT, Enchantment.class, Registries.ENCHANTMENT, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class); - register(RegistryKey.FLUID, Fluid.class, Registries.FLUID, CraftFluid.class, net.minecraft.world.level.material.Fluid.class); - register(RegistryKey.GAME_EVENT, GameEvent.class, Registries.GAME_EVENT, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class); - register(RegistryKey.INSTRUMENT, MusicInstrument.class, Registries.INSTRUMENT, CraftMusicInstrument.class, Instrument.class); - register(RegistryKey.MOB_EFFECT, PotionEffectType.class, Registries.MOB_EFFECT, CraftPotionEffectType.class, MobEffect.class); - register(RegistryKey.SOUND_EVENT, Sound.class, Registries.SOUND_EVENT, CraftSound.class, SoundEvent.class); - register(RegistryKey.STRUCTURE, Structure.class, Registries.STRUCTURE, CraftStructure.class, net.minecraft.world.level.levelgen.structure.Structure.class); - register(RegistryKey.STRUCTURE_TYPE, StructureType.class, Registries.STRUCTURE_TYPE, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class); - register(RegistryKey.VILLAGER_TYPE, Villager.Type.class, Registries.VILLAGER_TYPE, CraftVillager.CraftType.class, VillagerType.class); - register(RegistryKey.VILLAGER_PROFESSION, Villager.Profession.class, Registries.VILLAGER_PROFESSION, CraftVillager.CraftProfession.class, VillagerProfession.class); - register(RegistryKey.TRIM_MATERIAL, TrimMaterial.class, Registries.TRIM_MATERIAL, CraftTrimMaterial.class, net.minecraft.world.item.equipment.trim.TrimMaterial.class); - register(RegistryKey.TRIM_PATTERN, TrimPattern.class, Registries.TRIM_PATTERN, CraftTrimPattern.class, net.minecraft.world.item.equipment.trim.TrimPattern.class); - register(RegistryKey.DAMAGE_TYPE, DamageType.class, Registries.DAMAGE_TYPE, CraftDamageType.class, net.minecraft.world.damagesource.DamageType.class); - register(RegistryKey.JUKEBOX_SONG, JukeboxSong.class, Registries.JUKEBOX_SONG, CraftJukeboxSong.class, net.minecraft.world.item.JukeboxSong.class); - register(RegistryKey.WOLF_VARIANT, Wolf.Variant.class, Registries.WOLF_VARIANT, CraftWolf.CraftVariant.class, WolfVariant.class); - register(RegistryKey.WOLF_SOUND_VARIANT, Wolf.SoundVariant.class, Registries.WOLF_SOUND_VARIANT, CraftWolf.CraftSoundVariant.class, WolfSoundVariant.class); - register(RegistryKey.ITEM, ItemType.class, Registries.ITEM, CraftItemType.class, net.minecraft.world.item.Item.class, true); - register(RegistryKey.BLOCK, BlockType.class, Registries.BLOCK, CraftBlockType.class, net.minecraft.world.level.block.Block.class, true); - register(RegistryKey.FROG_VARIANT, Frog.Variant.class, Registries.FROG_VARIANT, CraftFrog.CraftVariant.class, FrogVariant.class); - register(RegistryKey.CAT_VARIANT, Cat.Type.class, Registries.CAT_VARIANT, CraftCat.CraftType.class, CatVariant.class); - register(RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, CraftMapCursor.CraftType.class, MapDecorationType.class); - register(RegistryKey.BANNER_PATTERN, PatternType.class, Registries.BANNER_PATTERN, CraftPatternType.class, BannerPattern.class); - register(RegistryKey.MENU, MenuType.class, Registries.MENU, CraftMenuType.class, net.minecraft.world.inventory.MenuType.class); - register(RegistryKey.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.DataComponentType.class, Registries.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.PaperDataComponentType.class, net.minecraft.core.component.DataComponentType.class); - register(RegistryKey.CHICKEN_VARIANT, Chicken.Variant.class, Registries.CHICKEN_VARIANT, CraftChicken.CraftVariant.class, ChickenVariant.class); - register(RegistryKey.COW_VARIANT, Cow.Variant.class, Registries.COW_VARIANT, CraftCow.CraftVariant.class, CowVariant.class); - register(RegistryKey.PIG_VARIANT, Pig.Variant.class, Registries.PIG_VARIANT, CraftPig.CraftVariant.class, PigVariant.class); - register(RegistryKey.DIALOG, Dialog.class, Registries.DIALOG, PaperDialog.class, net.minecraft.server.dialog.Dialog.class); + register(Registries.PAINTING_VARIANT, Art.class, CraftArt.class, PaintingVariant.class); + register(Registries.ATTRIBUTE, Attribute.class, CraftAttribute.class, net.minecraft.world.entity.ai.attributes.Attribute.class); + register(Registries.BIOME, Biome.class, CraftBiome.class, net.minecraft.world.level.biome.Biome.class); + register(Registries.ENCHANTMENT, Enchantment.class, CraftEnchantment.class, net.minecraft.world.item.enchantment.Enchantment.class); + register(Registries.FLUID, Fluid.class, CraftFluid.class, net.minecraft.world.level.material.Fluid.class); + register(Registries.GAME_EVENT, GameEvent.class, CraftGameEvent.class, net.minecraft.world.level.gameevent.GameEvent.class); + register(Registries.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument.class, Instrument.class); + register(Registries.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType.class, MobEffect.class); + register(Registries.SOUND_EVENT, Sound.class, CraftSound.class, SoundEvent.class); + register(Registries.STRUCTURE, Structure.class, CraftStructure.class, net.minecraft.world.level.levelgen.structure.Structure.class); + register(Registries.STRUCTURE_TYPE, StructureType.class, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class); + register(Registries.VILLAGER_TYPE, Villager.Type.class, CraftVillager.CraftType.class, VillagerType.class); + register(Registries.VILLAGER_PROFESSION, Villager.Profession.class, CraftVillager.CraftProfession.class, VillagerProfession.class); + register(Registries.TRIM_MATERIAL, TrimMaterial.class, CraftTrimMaterial.class, net.minecraft.world.item.equipment.trim.TrimMaterial.class); + register(Registries.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern.class, net.minecraft.world.item.equipment.trim.TrimPattern.class); + register(Registries.DAMAGE_TYPE, DamageType.class, CraftDamageType.class, net.minecraft.world.damagesource.DamageType.class); + register(Registries.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong.class, net.minecraft.world.item.JukeboxSong.class); + register(Registries.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant.class, WolfVariant.class); + register(Registries.WOLF_SOUND_VARIANT, Wolf.SoundVariant.class, CraftWolf.CraftSoundVariant.class, WolfSoundVariant.class); + register(Registries.ITEM, ItemType.class, CraftItemType.class, net.minecraft.world.item.Item.class); + register(Registries.BLOCK, BlockType.class, CraftBlockType.class, net.minecraft.world.level.block.Block.class); + register(Registries.FROG_VARIANT, Frog.Variant.class, CraftFrog.CraftVariant.class, FrogVariant.class); + register(Registries.CAT_VARIANT, Cat.Type.class, CraftCat.CraftType.class, CatVariant.class); + register(Registries.MAP_DECORATION_TYPE, MapCursor.Type.class, CraftMapCursor.CraftType.class, MapDecorationType.class); + register(Registries.BANNER_PATTERN, PatternType.class, CraftPatternType.class, BannerPattern.class); + register(Registries.MENU, MenuType.class, CraftMenuType.class, net.minecraft.world.inventory.MenuType.class); + register(Registries.DATA_COMPONENT_TYPE, io.papermc.paper.datacomponent.DataComponentType.class, DataComponentTypes.class, io.papermc.paper.datacomponent.PaperDataComponentType.class, net.minecraft.core.component.DataComponentType.class); + register(Registries.CHICKEN_VARIANT, Chicken.Variant.class, CraftChicken.CraftVariant.class, ChickenVariant.class); + register(Registries.COW_VARIANT, Cow.Variant.class, CraftCow.CraftVariant.class, CowVariant.class); + register(Registries.PIG_VARIANT, Pig.Variant.class, CraftPig.CraftVariant.class, PigVariant.class); + register(Registries.ZOMBIE_NAUTILUS_VARIANT, ZombieNautilus.Variant.class, CraftZombieNautilus.CraftVariant.class, ZombieNautilusVariant.class); + 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); } - private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft) { // Paper - RegistriesArgumentProvider.register(registryKey, bukkit, registry, craft, minecraft, false); + private static void register(ResourceKey> registryKey, Class api, Class impl, Class internal) { + register(registryKey, api, api, impl, internal); } - private static void register(RegistryKey registryKey, Class bukkit, ResourceKey registry, Class craft, Class minecraft, boolean newClass) { // Paper - RegistriesArgumentProvider.DATA.add(Arguments.of(registryKey, bukkit, registry, craft, minecraft, newClass)); + @SuppressWarnings({"rawtypes", "unchecked"}) + private static void register(ResourceKey> registryKey, Class api, Class apiHolder, Class impl, Class internal) { + DATA.add(new RegistryArgument<>(registryKey, PaperRegistries.registryFromNms((ResourceKey) registryKey), api, apiHolder, impl, internal)); } @Override - public Stream provideArguments(ExtensionContext extensionContext) throws Exception { - return RegistriesArgumentProvider.getData(); + public Stream provideArguments(ExtensionContext extensionContext) { + return getData(); } - public static Stream getData() { - return RegistriesArgumentProvider.DATA.stream(); + public static Stream> getData() { + return DATA.stream(); } } diff --git a/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java index 2d268498b545..07274a08e05e 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/AllFeaturesTestSuite.java @@ -14,7 +14,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for test which need registry values present, with all feature flags set") @IncludeTags("AllFeatures") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @SelectClasses({RegistryClassTest.class, PerRegistryTest.class, RegistryConversionTest.class}) // Make sure general registry tests are run first @ExcludeClassNamePatterns("org.bukkit.craftbukkit.inventory.ItemStack.*Test") @ConfigurationParameter(key = "TestSuite", value = "AllFeatures") diff --git a/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java index ac3c1c88ce5d..14acf9c9db27 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/LegacyTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for legacy tests") @IncludeTags("Legacy") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "Legacy") public class LegacyTestSuite { } diff --git a/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java index 76f61fb60612..625d88420c9f 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/NormalTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for standalone tests, which don't need any registry values present") @IncludeTags("Normal") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "Normal") public class NormalTestSuite { } diff --git a/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java index 60be4c20101b..212607736d25 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/SlowTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for slow tests, which don't need to run every time") @IncludeTags("Slow") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "Slow") public class SlowTestSuite { } diff --git a/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java b/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java index d0e2eacfcd48..d06cf4b8131a 100644 --- a/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java +++ b/paper-server/src/test/java/org/bukkit/support/suite/VanillaFeatureTestSuite.java @@ -9,7 +9,7 @@ @Suite(failIfNoTests = false) @SuiteDisplayName("Test suite for test which need vanilla registry values present") @IncludeTags("VanillaFeature") -@SelectPackages({"org.bukkit", "io.papermc"}) +@SelectPackages({"org.bukkit", "io.papermc.paper", "com.destroystokyo.paper"}) @ConfigurationParameter(key = "TestSuite", value = "VanillaFeature") public class VanillaFeatureTestSuite { } diff --git a/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java b/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java index c84f3807350f..24c67ff96d90 100644 --- a/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java +++ b/paper-server/src/test/java/org/bukkit/support/test/RegistriesTest.java @@ -5,15 +5,13 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.bukkit.support.provider.RegistriesArgumentProvider; +import org.junit.jupiter.params.ArgumentCountValidationMode; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; -/** - * Order: Bukkit class, Minecraft Registry key, CraftBukkit class, Minecraft class - */ @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @ArgumentsSource(RegistriesArgumentProvider.class) -@ParameterizedTest +@ParameterizedTest(argumentCountValidation = ArgumentCountValidationMode.NONE) public @interface RegistriesTest { } diff --git a/test-plugin/build.gradle.kts b/test-plugin/build.gradle.kts index af38ca2cf1e3..3dd4b5f5cad5 100644 --- a/test-plugin/build.gradle.kts +++ b/test-plugin/build.gradle.kts @@ -5,13 +5,9 @@ dependencies { } tasks.processResources { - var apiVersion = rootProject.providers.gradleProperty("mcVersion").get() - // Bukkit api versioning does not support suffixed versions - apiVersion = apiVersion.substringBefore('-') - val props = mapOf( "version" to project.version, - "apiversion" to "\"$apiVersion\"", + "apiversion" to "\"${rootProject.providers.gradleProperty("apiVersion").get()}\"", ) inputs.properties(props) filesMatching("paper-plugin.yml") {