From eed041d629ce2c7bf8d95808c43f5099b94abc7b Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Fri, 14 Jun 2024 01:05:00 +1000 Subject: [PATCH] Update to Minecraft 1.21 By: md_5 --- .../commands/CommandDispatcher.patch | 22 +- .../arguments/blocks/ArgumentBlock.patch | 2 +- .../selector/ArgumentParserSelector.patch | 4 +- .../arguments/selector/EntitySelector.patch | 2 +- .../core/cauldron/CauldronInteraction.patch | 10 +- .../core/component/DataComponentPatch.patch | 4 +- .../core/dispenser/DispenseBehaviorItem.patch | 8 +- .../dispenser/DispenseBehaviorShears.patch | 8 +- .../core/dispenser/IDispenseBehavior.patch | 55 +-- .../minecraft/network/NetworkManager.patch | 10 +- .../network/chat/IChatBaseComponent.patch | 2 +- .../protocol/PlayerConnectionUtils.patch | 4 +- .../server/AdvancementDataWorld.patch | 4 +- .../minecraft/server/DispenserRegistry.patch | 6 +- .../minecraft/server/MinecraftServer.patch | 82 ++-- .../server/dedicated/DedicatedServer.patch | 34 +- .../dedicated/DedicatedServerProperties.patch | 8 +- .../server/level/ChunkMapDistance.patch | 41 +- .../server/level/ChunkProviderServer.patch | 38 +- .../minecraft/server/level/EntityPlayer.patch | 393 +++++++++--------- .../server/level/EntityTrackerEntry.patch | 33 +- .../minecraft/server/level/PlayerChunk.patch | 70 ++-- .../server/level/PlayerChunkMap.patch | 98 +---- .../server/level/PlayerInteractManager.patch | 29 +- .../level/RegionLimitedWorldAccess.patch | 4 +- .../minecraft/server/level/TicketType.patch | 2 +- .../minecraft/server/level/WorldServer.patch | 125 ++---- .../server/network/HandshakeListener.patch | 6 +- .../server/network/LoginListener.patch | 28 +- .../server/network/PacketStatusListener.patch | 4 +- .../server/network/PlayerConnection.patch | 188 +++++---- .../ServerCommonPacketListenerImpl.patch | 58 ++- ...erverConfigurationPacketListenerImpl.patch | 29 +- .../minecraft/server/players/PlayerList.patch | 220 ++++------ .../util/datafix/DataConverterRegistry.patch | 12 +- .../net/minecraft/world/IInventory.patch | 9 +- .../world/damagesource/DamageSources.patch | 10 +- .../net/minecraft/world/entity/Entity.patch | 350 ++++++---------- .../world/entity/EntityAreaEffectCloud.patch | 88 ++-- .../world/entity/EntityCreature.patch | 16 - .../world/entity/EntityExperienceOrb.patch | 45 +- .../world/entity/EntityInsentient.patch | 165 ++------ .../minecraft/world/entity/EntityLiving.patch | 189 ++++----- .../world/entity/EntityTameableAnimal.patch | 31 ++ .../minecraft/world/entity/Leashable.patch | 121 ++++++ .../ai/goal/PathfinderGoalFollowOwner.patch | 31 -- .../world/entity/animal/Bucketable.patch | 9 +- .../world/entity/animal/EntityBee.patch | 24 +- .../world/entity/animal/EntityCat.patch | 10 +- .../world/entity/animal/EntityDolphin.patch | 8 +- .../world/entity/animal/EntityIronGolem.patch | 2 +- .../world/entity/animal/EntityOcelot.patch | 4 +- .../world/entity/animal/EntityPanda.patch | 4 +- .../world/entity/animal/EntityParrot.patch | 4 +- .../world/entity/animal/EntityRabbit.patch | 6 +- .../world/entity/animal/EntitySheep.patch | 39 +- .../world/entity/animal/EntityWolf.patch | 17 +- .../world/entity/animal/allay/Allay.patch | 36 +- .../entity/animal/armadillo/Armadillo.patch | 10 +- .../world/entity/animal/axolotl/Axolotl.patch | 8 +- .../world/entity/animal/camel/Camel.patch | 2 +- .../world/entity/animal/frog/Tadpole.patch | 3 +- .../animal/horse/EntityHorseAbstract.patch | 18 +- .../boss/enderdragon/EntityEnderCrystal.patch | 4 +- .../boss/enderdragon/EntityEnderDragon.patch | 32 +- .../entity/boss/wither/EntityWither.patch | 12 +- ...anging.patch => BlockAttachedEntity.patch} | 87 +--- .../entity/decoration/EntityArmorStand.patch | 109 ++--- .../entity/decoration/EntityItemFrame.patch | 59 +-- .../world/entity/decoration/EntityLeash.patch | 40 +- .../entity/decoration/EntityPainting.patch | 51 +++ .../entity/item/EntityFallingBlock.patch | 12 +- .../world/entity/item/EntityItem.patch | 20 +- .../world/entity/item/EntityTNTPrimed.patch | 18 +- .../world/entity/monster/EntityCreeper.patch | 11 +- .../world/entity/monster/EntityEnderman.patch | 12 +- .../world/entity/monster/EntityGhast.patch | 4 +- .../monster/EntityIllagerIllusioner.patch | 4 +- .../entity/monster/EntityPigZombie.patch | 6 +- .../world/entity/monster/EntityPillager.patch | 4 +- .../world/entity/monster/EntityRavager.patch | 4 +- .../world/entity/monster/EntityShulker.patch | 2 +- .../world/entity/monster/EntitySkeleton.patch | 2 +- .../monster/EntitySkeletonAbstract.patch | 4 +- .../entity/monster/EntitySkeletonWither.patch | 2 +- .../world/entity/monster/EntitySlime.patch | 8 +- .../world/entity/monster/EntityWitch.patch | 2 +- .../world/entity/monster/EntityZombie.patch | 34 +- .../entity/monster/EntityZombieVillager.patch | 47 +-- .../entity/monster/piglin/EntityPiglin.patch | 2 +- .../world/entity/monster/warden/Warden.patch | 33 +- .../world/entity/npc/EntityVillager.patch | 16 +- .../entity/npc/EntityVillagerAbstract.patch | 4 +- .../world/entity/player/EntityHuman.patch | 216 ++++------ .../world/entity/projectile/EntityArrow.patch | 69 ++- .../projectile/EntityDragonFireball.patch | 6 +- .../world/entity/projectile/EntityEgg.patch | 16 +- .../entity/projectile/EntityEnderPearl.patch | 109 +++-- .../entity/projectile/EntityEvokerFangs.patch | 8 +- .../entity/projectile/EntityFireball.patch | 14 +- .../projectile/EntityFireballFireball.patch | 2 +- .../entity/projectile/EntityFireworks.patch | 10 +- .../entity/projectile/EntityFishingHook.patch | 32 +- .../projectile/EntityLargeFireball.patch | 12 +- .../entity/projectile/EntityLlamaSpit.patch | 8 +- .../entity/projectile/EntityPotion.patch | 14 +- .../entity/projectile/EntityProjectile.patch | 6 +- .../projectile/EntityShulkerBullet.patch | 14 +- .../projectile/EntitySmallFireball.patch | 28 +- .../projectile/EntitySpectralArrow.patch | 2 +- .../projectile/EntityThrownTrident.patch | 22 +- .../entity/projectile/EntityTippedArrow.patch | 4 +- .../entity/projectile/EntityWitherSkull.patch | 12 +- .../world/entity/projectile/IProjectile.patch | 14 +- .../windcharge/AbstractWindCharge.patch | 20 +- .../world/entity/raid/EntityRaider.patch | 21 +- .../minecraft/world/entity/raid/Raid.patch | 28 +- .../world/entity/vehicle/ChestBoat.patch | 2 +- .../world/entity/vehicle/EntityBoat.patch | 41 +- .../vehicle/EntityMinecartAbstract.patch | 8 +- .../minecraft/world/food/FoodMetaData.patch | 49 ++- .../inventory/ContainerEnchantTable.patch | 46 +- .../world/inventory/ContainerFurnace.patch | 11 +- .../world/inventory/ContainerGrindstone.patch | 10 +- .../world/inventory/ContainerHorse.patch | 14 +- .../world/inventory/ContainerPlayer.patch | 23 +- .../world/inventory/ContainerSmithing.patch | 14 +- .../inventory/ContainerStonecutter.patch | 10 +- .../world/inventory/ContainerWorkbench.patch | 23 +- .../world/inventory/CrafterMenu.patch | 4 +- .../world/inventory/InventoryCrafting.patch | 29 ++ .../net/minecraft/world/item/ItemArmor.patch | 8 +- .../net/minecraft/world/item/ItemBucket.patch | 12 +- .../minecraft/world/item/ItemEnderEye.patch | 6 +- .../minecraft/world/item/ItemFishingRod.patch | 15 +- .../minecraft/world/item/ItemHanging.patch | 4 +- .../net/minecraft/world/item/ItemLeash.patch | 38 +- .../minecraft/world/item/ItemMilkBucket.patch | 6 +- .../world/item/ItemProjectileWeapon.patch | 21 +- .../net/minecraft/world/item/ItemRecord.patch | 10 - .../net/minecraft/world/item/ItemStack.patch | 111 +++-- .../minecraft/world/item/ItemTrident.patch | 72 ++-- .../world/item/crafting/CraftingManager.patch | 54 +-- .../world/item/crafting/IRecipe.patch | 2 +- .../item/crafting/RecipeStonecutting.patch | 4 +- .../world/item/crafting/ShapedRecipes.patch | 4 +- .../item/crafting/ShapelessRecipes.patch | 4 +- .../crafting/SmithingTransformRecipe.patch | 4 +- .../item/crafting/SmithingTrimRecipe.patch | 4 +- .../enchantment/EnchantmentFrostWalker.patch | 16 - .../enchantment/EnchantmentWeaponDamage.patch | 11 - .../enchantment/effects/ApplyMobEffect.patch | 11 + .../item/enchantment/effects/Ignite.patch | 30 ++ .../enchantment/effects/ReplaceBlock.patch | 11 + .../enchantment/effects/ReplaceDisk.patch | 11 + .../effects/SummonEntityEffect.patch | 36 ++ .../net/minecraft/world/level/Explosion.patch | 20 +- .../net/minecraft/world/level/World.patch | 36 +- .../minecraft/world/level/block/Block.patch | 18 +- .../level/block/BlockButtonAbstract.patch | 6 +- .../world/level/block/BlockCake.patch | 2 +- .../world/level/block/BlockCampfire.patch | 10 +- .../world/level/block/BlockDropper.patch | 4 +- .../world/level/block/BlockEndGateway.patch | 22 + .../world/level/block/BlockEnderPortal.patch | 79 +++- .../world/level/block/BlockFireAbstract.patch | 4 +- .../world/level/block/BlockLectern.patch | 2 +- .../world/level/block/BlockLever.patch | 8 +- .../world/level/block/BlockMagma.patch | 4 +- .../world/level/block/BlockPortal.patch | 95 ++++- .../world/level/block/BlockRedstoneOre.patch | 19 +- .../world/level/block/BlockSign.patch | 6 +- .../world/level/block/BlockTNT.patch | 2 +- .../world/level/block/DecoratedPotBlock.patch | 2 +- .../world/level/block/LightningRodBlock.patch | 17 +- .../entity/SculkCatalystBlockEntity.patch | 4 +- .../block/entity/TileEntityBrewingStand.patch | 4 +- .../block/entity/TileEntityCampfire.patch | 10 +- .../block/entity/TileEntityEndGateway.patch | 68 +-- .../block/entity/TileEntityFurnace.patch | 28 +- .../block/entity/TileEntityJukeBox.patch | 27 +- .../trialspawner/TrialSpawnerData.patch | 8 +- .../world/level/block/state/BlockBase.patch | 2 +- .../world/level/border/WorldBorder.patch | 4 +- .../minecraft/world/level/chunk/Chunk.patch | 26 +- .../world/level/chunk/ChunkGenerator.patch | 8 +- .../world/level/chunk/IChunkAccess.patch | 6 +- .../level/chunk/status/ChunkStatusTasks.patch | 27 +- .../chunk/storage/ChunkRegionLoader.patch | 20 +- .../level/chunk/storage/IChunkLoader.patch | 35 +- .../level/levelgen/ChunkProviderFlat.patch | 2 +- .../levelgen/feature/EndPlatformFeature.patch | 60 +++ .../levelgen/structure/StructurePiece.patch | 30 +- .../structure/structures/IglooPieces.patch | 2 +- .../templatesystem/DefinedStructureInfo.patch | 2 +- .../world/level/portal/BlockPortalShape.patch | 34 +- .../level/portal/DimensionTransition.patch | 47 +++ .../level/portal/PortalTravelAgent.patch | 44 +- .../level/portal/ShapeDetectorShape.patch | 29 -- .../world/level/saveddata/maps/WorldMap.patch | 18 +- .../level/storage/loot/LootDataType.patch | 8 +- .../world/level/storage/loot/LootTable.patch | 2 +- .../loot/functions/LootEnchantFunction.patch | 17 - .../parameters/LootContextParameters.patch | 10 - ...ItemConditionRandomChanceWithLooting.patch | 14 - paper-server/pom.xml | 10 +- .../org/bukkit/craftbukkit/CraftChunk.java | 2 +- .../bukkit/craftbukkit/CraftJukeboxSong.java | 65 +++ .../bukkit/craftbukkit/CraftLootTable.java | 16 +- .../craftbukkit/CraftRegionAccessor.java | 3 +- .../org/bukkit/craftbukkit/CraftRegistry.java | 4 + .../org/bukkit/craftbukkit/CraftServer.java | 20 +- .../bukkit/craftbukkit/CraftServerLinks.java | 142 +++++++ .../bukkit/craftbukkit/CraftStatistic.java | 16 +- .../org/bukkit/craftbukkit/CraftWorld.java | 4 +- .../java/org/bukkit/craftbukkit/Main.java | 4 +- .../attribute/CraftAttributeInstance.java | 7 +- .../craftbukkit/block/CraftJukebox.java | 26 +- .../enchantments/CraftEnchantment.java | 31 +- .../entity/CraftAbstractArrow.java | 17 +- .../entity/CraftAbstractWindCharge.java | 2 +- .../entity/CraftBlockAttachedEntity.java | 20 + .../craftbukkit/entity/CraftEntity.java | 21 +- .../craftbukkit/entity/CraftEntityTypes.java | 9 +- .../craftbukkit/entity/CraftFireball.java | 8 +- .../craftbukkit/entity/CraftHanging.java | 2 +- .../craftbukkit/entity/CraftItemFrame.java | 2 +- .../bukkit/craftbukkit/entity/CraftLeash.java | 13 +- .../craftbukkit/entity/CraftLivingEntity.java | 18 +- .../craftbukkit/entity/CraftPlayer.java | 36 +- .../craftbukkit/event/CraftEventFactory.java | 16 +- .../generator/CustomChunkGenerator.java | 5 +- .../inventory/CraftInventoryCrafting.java | 9 +- .../inventory/CraftItemFactory.java | 17 +- .../craftbukkit/inventory/CraftItemStack.java | 6 +- .../craftbukkit/inventory/CraftItemType.java | 3 +- .../craftbukkit/inventory/CraftMetaItem.java | 62 ++- .../components/CraftFoodComponent.java | 30 +- .../components/CraftJukeboxComponent.java | 116 ++++++ .../craftbukkit/legacy/CraftLegacy.java | 4 +- .../craftbukkit/legacy/MethodRerouting.java | 12 + .../CraftBlockProjectileSource.java | 19 +- .../structure/CraftStructureManager.java | 4 +- .../bukkit/craftbukkit/util/ApiVersion.java | 2 +- .../bukkit/craftbukkit/util/Commodore.java | 5 + .../craftbukkit/util/CraftMagicNumbers.java | 2 +- .../craftbukkit/util/CraftNamespacedKey.java | 4 +- .../src/test/java/org/bukkit/ArtTest.java | 14 +- .../test/java/org/bukkit/DyeColorsTest.java | 4 +- .../test/java/org/bukkit/EnchantmentTest.java | 7 +- .../test/java/org/bukkit/PerMaterialTest.java | 13 +- .../inventory/NMSCraftItemStackTest.java | 5 +- .../bukkit/craftbukkit/legacy/LegacyTest.java | 2 + .../craftbukkit/util/ApiVersionTest.java | 9 +- .../provider/RegistriesArgumentProvider.java | 3 + 255 files changed, 3585 insertions(+), 3261 deletions(-) create mode 100644 paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch rename paper-server/nms-patches/net/minecraft/world/entity/decoration/{EntityHanging.patch => BlockAttachedEntity.patch} (57%) create mode 100644 paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/Ignite.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceBlock.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch create mode 100644 paper-server/nms-patches/net/minecraft/world/level/portal/DimensionTransition.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch delete mode 100644 paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/legacy/MethodRerouting.java diff --git a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch index c1a239711a..ff91e67a01 100644 --- a/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch +++ b/paper-server/nms-patches/net/minecraft/commands/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java -@@ -136,6 +136,14 @@ +@@ -135,6 +135,14 @@ import net.minecraft.world.level.GameRules; import org.slf4j.Logger; @@ -15,7 +15,7 @@ public class CommandDispatcher { private static final ThreadLocal> CURRENT_EXECUTION_CONTEXT = new ThreadLocal(); -@@ -148,6 +156,7 @@ +@@ -147,6 +155,7 @@ private final com.mojang.brigadier.CommandDispatcher dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) { @@ -23,7 +23,7 @@ CommandAdvancement.register(this.dispatcher); CommandAttribute.register(this.dispatcher, commandbuildcontext); CommandExecute.register(this.dispatcher, commandbuildcontext); -@@ -249,6 +258,11 @@ +@@ -247,6 +256,11 @@ CommandPublish.register(this.dispatcher); } @@ -35,7 +35,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -259,18 +273,65 @@ +@@ -257,18 +271,65 @@ return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions()); } @@ -103,7 +103,7 @@ try { if (contextchain != null) { -@@ -304,7 +365,7 @@ +@@ -302,7 +363,7 @@ } @Nullable @@ -112,7 +112,7 @@ try { validateParseResults(parseresults); return (ContextChain) ContextChain.tryFlatten(parseresults.getContext().build(s)).orElseThrow(() -> { -@@ -315,7 +376,7 @@ +@@ -313,7 +374,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> { @@ -121,7 +121,7 @@ }); if (i > 10) { -@@ -365,7 +426,7 @@ +@@ -363,7 +424,7 @@ executioncontext1.close(); } finally { @@ -130,7 +130,7 @@ } } else { consumer.accept(executioncontext); -@@ -374,11 +435,36 @@ +@@ -372,11 +433,36 @@ } public void sendCommands(EntityPlayer entityplayer) { @@ -168,7 +168,7 @@ entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); } -@@ -389,7 +475,7 @@ +@@ -387,7 +473,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -177,7 +177,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -412,7 +498,7 @@ +@@ -410,7 +496,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } @@ -186,7 +186,7 @@ map.put(commandnode2, commandnode3); commandnode1.addChild(commandnode3); -@@ -473,7 +559,7 @@ +@@ -471,7 +557,7 @@ } private HolderLookup.b.a createLookup(final HolderLookup.b holderlookup_b) { diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch index e979bd5e4d..09c5306353 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/blocks/ArgumentBlock.patch @@ -7,7 +7,7 @@ - private final Map, Comparable> properties = Maps.newHashMap(); + private final Map, Comparable> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable private final Map vagueProperties = Maps.newHashMap(); - private MinecraftKey id = new MinecraftKey(""); + private MinecraftKey id = MinecraftKey.withDefaultNamespace(""); @Nullable @@ -275,7 +275,7 @@ Iterator iterator = iblockstate.getPossibleValues().iterator(); diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch index 73ff62a169..438808bdf8 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/ArgumentParserSelector.patch @@ -22,7 +22,7 @@ this.suggestions = this::suggestSelector; if (!this.reader.canRead()) { throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader); -@@ -463,6 +465,12 @@ +@@ -494,6 +496,12 @@ } public EntitySelector parse() throws CommandSyntaxException { @@ -35,7 +35,7 @@ this.startPosition = this.reader.getCursor(); this.suggestions = this::suggestNameOrSelector; if (this.reader.canRead() && this.reader.peek() == '@') { -@@ -471,7 +479,7 @@ +@@ -502,7 +510,7 @@ } this.reader.skip(); diff --git a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch index e4633ef40e..144825345e 100644 --- a/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch +++ b/paper-server/nms-patches/net/minecraft/commands/arguments/selector/EntitySelector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -92,7 +92,7 @@ +@@ -93,7 +93,7 @@ } private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { diff --git a/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch b/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch index f6b6beeeaf..4e271a50a5 100644 --- a/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch +++ b/paper-server/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch @@ -118,7 +118,7 @@ world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); } -@@ -227,47 +260,55 @@ +@@ -227,76 +260,89 @@ return ItemInteractionResult.sidedSuccess(world.isClientSide); } @@ -165,7 +165,9 @@ + return ItemInteractionResult.SUCCESS; + } + // CraftBukkit end - entityhuman.setItemInHand(enumhand, itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1)); + ItemStack itemstack1 = itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1); + + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false)); entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX); - LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); + // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit @@ -190,9 +192,7 @@ ItemStack itemstack1 = itemstack.copyWithCount(1); itemstack1.set(DataComponents.BANNER_PATTERNS, bannerpatternlayers.removeLast()); -@@ -281,28 +322,33 @@ - } - + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false)); entityhuman.awardStat(StatisticList.CLEAN_BANNER); - LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); + // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit diff --git a/paper-server/nms-patches/net/minecraft/core/component/DataComponentPatch.patch b/paper-server/nms-patches/net/minecraft/core/component/DataComponentPatch.patch index e7c58e44a1..5e70217b4a 100644 --- a/paper-server/nms-patches/net/minecraft/core/component/DataComponentPatch.patch +++ b/paper-server/nms-patches/net/minecraft/core/component/DataComponentPatch.patch @@ -9,7 +9,7 @@ }); public static final StreamCodec STREAM_CODEC = new StreamCodec() { public DataComponentPatch decode(RegistryFriendlyByteBuf registryfriendlybytebuf) { -@@ -143,7 +143,7 @@ +@@ -144,7 +144,7 @@ } private static void encodeComponent(RegistryFriendlyByteBuf registryfriendlybytebuf, DataComponentType datacomponenttype, Object object) { @@ -18,7 +18,7 @@ } }; private static final String REMOVED_PREFIX = "!"; -@@ -270,6 +270,42 @@ +@@ -271,6 +271,42 @@ a() {} diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch index 35ba36195a..6244b3f3bd 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorItem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorItem.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorItem.java -@@ -7,8 +7,23 @@ +@@ -7,10 +7,25 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.BlockDispenser; @@ -13,6 +13,8 @@ + public class DispenseBehaviorItem implements IDispenseBehavior { + private static final int DEFAULT_ACCURACY = 6; + + // CraftBukkit start + private boolean dropper; + @@ -24,7 +26,7 @@ public DispenseBehaviorItem() {} @Override -@@ -25,11 +40,22 @@ +@@ -27,11 +42,22 @@ IPosition iposition = BlockDispenser.getDispensePosition(sourceblock); ItemStack itemstack1 = itemstack.split(1); @@ -48,7 +50,7 @@ double d0 = iposition.x(); double d1 = iposition.y(); double d2 = iposition.z(); -@@ -44,7 +70,47 @@ +@@ -46,7 +72,47 @@ double d3 = world.random.nextDouble() * 0.1D + 0.2D; entityitem.setDeltaMovement(world.random.triangle((double) enumdirection.getStepX() * d3, 0.0172275D * (double) i), world.random.triangle(0.2D, 0.0172275D * (double) i), world.random.triangle((double) enumdirection.getStepZ() * d3, 0.0172275D * (double) i)); diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch index 74cefdd763..ff8376c910 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch @@ -48,9 +48,9 @@ - this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition)); + this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit if (this.isSuccess()) { - itemstack.hurtAndBreak(1, worldserver.getRandom(), (EntityPlayer) null, () -> { - itemstack.setCount(0); -@@ -65,7 +95,7 @@ + itemstack.hurtAndBreak(1, worldserver, (EntityPlayer) null, (item) -> { + }); +@@ -64,7 +94,7 @@ return false; } @@ -59,7 +59,7 @@ List list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); Iterator iterator = list.iterator(); -@@ -74,6 +104,11 @@ +@@ -73,6 +103,11 @@ if (entityliving instanceof IShearable ishearable) { if (ishearable.readyForShearing()) { diff --git a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch b/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch index 20c555d68a..054da80dbc 100644 --- a/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch +++ b/paper-server/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java -@@ -66,6 +66,22 @@ +@@ -67,6 +67,22 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import org.slf4j.Logger; @@ -23,7 +23,7 @@ public interface IDispenseBehavior { Logger LOGGER = LogUtils.getLogger(); -@@ -93,14 +109,42 @@ +@@ -94,14 +110,42 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack); @@ -68,7 +68,7 @@ sourceblock.level().gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, sourceblock.pos()); return itemstack; } -@@ -119,13 +163,41 @@ +@@ -120,13 +164,41 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); BlockPosition blockposition = sourceblock.pos().relative(enumdirection); WorldServer worldserver = sourceblock.level(); @@ -111,10 +111,11 @@ } return itemstack; -@@ -144,8 +216,35 @@ +@@ -145,7 +217,34 @@ }); if (!list.isEmpty()) { +- ((ISaddleable) list.get(0)).equipSaddle(itemstack.split(1), SoundCategory.BLOCKS); + // CraftBukkit start + ItemStack itemstack1 = itemstack.split(1); + WorldServer world = sourceblock.level(); @@ -141,10 +142,8 @@ + return itemstack; + } + } ++ ((ISaddleable) list.get(0)).equipSaddle(itemstack1, SoundCategory.BLOCKS); + // CraftBukkit end - ((ISaddleable) list.get(0)).equipSaddle(SoundCategory.BLOCKS); -- itemstack.shrink(1); -+ // itemstack.shrink(1); // CraftBukkit - handled above this.setSuccess(true); return itemstack; } else { @@ -223,7 +222,7 @@ this.setSuccess(true); return itemstack; } -@@ -249,9 +402,51 @@ +@@ -249,6 +402,38 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); WorldServer worldserver = sourceblock.level(); @@ -261,22 +260,8 @@ + if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) { dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition); -- return new ItemStack(Items.BUCKET); -+ // CraftBukkit start - Handle stacked buckets -+ Item item = Items.BUCKET; -+ itemstack.shrink(1); -+ if (itemstack.isEmpty()) { -+ itemstack.setItem(Items.BUCKET); -+ itemstack.setCount(1); -+ } else if (sourceblock.blockEntity().addItem(new ItemStack(item)) < 0) { -+ this.defaultDispenseItemBehavior.dispense(sourceblock, new ItemStack(item)); -+ } -+ return itemstack; -+ // CraftBukkit end - } else { - return this.defaultDispenseItemBehavior.dispense(sourceblock, itemstack); - } -@@ -278,7 +473,7 @@ + return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(Items.BUCKET)); +@@ -276,7 +461,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource ifluidsource) { @@ -285,7 +270,7 @@ if (itemstack1.isEmpty()) { return super.execute(sourceblock, itemstack); -@@ -286,6 +481,32 @@ +@@ -284,6 +469,32 @@ worldserver.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); Item item = itemstack1.getItem(); @@ -315,10 +300,10 @@ + itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, worldserver, blockposition, iblockdata); // From above + // CraftBukkit end + - itemstack.shrink(1); - if (itemstack.isEmpty()) { - return new ItemStack(item); -@@ -307,16 +528,44 @@ + return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(item)); + } + } else { +@@ -296,16 +507,44 @@ protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { WorldServer worldserver = sourceblock.level(); @@ -366,7 +351,7 @@ BlockTNT.explode(worldserver, blockposition); worldserver.removeBlock(blockposition, false); } else { -@@ -342,12 +591,62 @@ +@@ -330,12 +569,62 @@ this.setSuccess(true); WorldServer worldserver = sourceblock.level(); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); @@ -429,7 +414,7 @@ return itemstack; } -@@ -357,12 +656,41 @@ +@@ -345,12 +634,41 @@ protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { WorldServer worldserver = sourceblock.level(); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); @@ -473,7 +458,7 @@ return itemstack; } }); -@@ -387,6 +715,30 @@ +@@ -375,6 +693,30 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); BlockPosition blockposition = sourceblock.pos().relative(enumdirection); @@ -504,7 +489,7 @@ if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) { worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3); worldserver.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition); -@@ -412,6 +764,30 @@ +@@ -400,6 +742,30 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; @@ -535,7 +520,7 @@ if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) { if (!worldserver.isClientSide) { worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); -@@ -461,6 +837,30 @@ +@@ -438,6 +804,30 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); IBlockData iblockdata = worldserver.getBlockState(blockposition); @@ -566,7 +551,7 @@ if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> { return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL) && blockbase_blockdata.getBlock() instanceof BlockBeehive; }) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) { -@@ -510,6 +910,31 @@ +@@ -487,6 +877,31 @@ this.setSuccess(false); return itemstack; } else { diff --git a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch index ce47080818..c5e3757727 100644 --- a/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch +++ b/paper-server/nms-patches/net/minecraft/network/NetworkManager.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/network/NetworkManager.java +++ b/net/minecraft/network/NetworkManager.java @@ -114,6 +114,7 @@ - private volatile IChatBaseComponent delayedDisconnect; + private volatile DisconnectionDetails delayedDisconnect; @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; + public String hostname = ""; // CraftBukkit - add field public NetworkManager(EnumProtocolDirection enumprotocoldirection) { this.receiving = enumprotocoldirection; -@@ -197,7 +198,7 @@ +@@ -205,7 +206,7 @@ } private static void genericsFtw(Packet packet, PacketListener packetlistener) { @@ -17,16 +17,16 @@ } private void validateListener(ProtocolInfo protocolinfo, PacketListener packetlistener) { -@@ -457,7 +458,7 @@ +@@ -469,7 +470,7 @@ } if (this.isConnected()) { - this.channel.close().awaitUninterruptibly(); + this.channel.close(); // We can't wait as this may be called from an event loop. - this.disconnectedReason = ichatbasecomponent; + this.disconnectionDetails = disconnectiondetails; } -@@ -525,7 +526,7 @@ +@@ -537,7 +538,7 @@ } public void configurePacketHandler(ChannelPipeline channelpipeline) { diff --git a/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch b/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch index 93751f5b13..95c8733e3c 100644 --- a/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch +++ b/paper-server/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/IChatBaseComponent.java +++ b/net/minecraft/network/chat/IChatBaseComponent.java -@@ -35,7 +35,22 @@ +@@ -36,7 +36,22 @@ import net.minecraft.util.FormattedString; import net.minecraft.world.level.ChunkCoordIntPair; diff --git a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch index 56cd482b40..e909c52997 100644 --- a/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch +++ b/paper-server/nms-patches/net/minecraft/network/protocol/PlayerConnectionUtils.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/PlayerConnectionUtils.java +++ b/net/minecraft/network/protocol/PlayerConnectionUtils.java -@@ -10,6 +10,11 @@ +@@ -11,6 +11,11 @@ import net.minecraft.util.thread.IAsyncTaskHandler; import org.slf4j.Logger; @@ -12,7 +12,7 @@ public class PlayerConnectionUtils { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -23,6 +28,7 @@ +@@ -24,6 +29,7 @@ public static void ensureRunningOnSameThread(Packet packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { if (!iasynctaskhandler.isSameThread()) { iasynctaskhandler.executeIfPossible(() -> { diff --git a/paper-server/nms-patches/net/minecraft/server/AdvancementDataWorld.patch b/paper-server/nms-patches/net/minecraft/server/AdvancementDataWorld.patch index dd67145ad6..be95a05a08 100644 --- a/paper-server/nms-patches/net/minecraft/server/AdvancementDataWorld.patch +++ b/paper-server/nms-patches/net/minecraft/server/AdvancementDataWorld.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/AdvancementDataWorld.java +++ b/net/minecraft/server/AdvancementDataWorld.java -@@ -28,11 +28,15 @@ +@@ -27,11 +27,15 @@ import net.minecraft.util.profiling.GameProfilerFiller; import org.slf4j.Logger; @@ -17,7 +17,7 @@ private AdvancementTree tree = new AdvancementTree(); private final HolderLookup.a registries; -@@ -56,7 +60,7 @@ +@@ -55,7 +59,7 @@ } }); diff --git a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch index 495bec3dbd..723d6d05b8 100644 --- a/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/server/DispenserRegistry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -29,6 +29,12 @@ +@@ -28,6 +28,12 @@ import net.minecraft.world.level.block.BlockFire; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class DispenserRegistry { public static final PrintStream STDOUT = System.out; -@@ -40,6 +46,23 @@ +@@ -39,6 +45,23 @@ public static void bootStrap() { if (!DispenserRegistry.isBootstrapped) { @@ -37,7 +37,7 @@ DispenserRegistry.isBootstrapped = true; Instant instant = Instant.now(); -@@ -59,6 +82,69 @@ +@@ -58,6 +81,69 @@ wrapStreams(); DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } diff --git a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch index 7d289eb047..9aa65086eb 100644 --- a/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -168,13 +168,37 @@ +@@ -173,13 +173,38 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start +import com.mojang.serialization.Dynamic; +import com.mojang.serialization.Lifecycle; ++import java.io.File; +import java.util.Random; +import jline.console.ConsoleReader; +import joptsimple.OptionSet; @@ -28,7 +29,7 @@ +import org.bukkit.event.server.ServerLoadEvent; +// CraftBukkit end + - public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements ServerInfo, ICommandListener, AutoCloseable { + public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements ServerInfo, ChunkIOErrorReporter, ICommandListener, AutoCloseable { public static final Logger LOGGER = LogUtils.getLogger(); public static final String VANILLA_BRAND = "vanilla"; @@ -39,9 +40,9 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeRange.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -260,6 +284,19 @@ - private final PotionBrewer potionBrewing; +@@ -266,6 +291,19 @@ private volatile boolean isSaving; + private static final AtomicReference fatalException = new AtomicReference(); + // CraftBukkit start + public final WorldLoader.a worldLoader; @@ -59,7 +60,7 @@ public static S spin(Function function) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -273,14 +310,14 @@ +@@ -279,14 +317,14 @@ thread.setPriority(8); } @@ -76,7 +77,7 @@ super("Server"); this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.profiler = this.metricsRecorder.getProfiler(); -@@ -303,7 +340,7 @@ +@@ -309,7 +347,7 @@ this.customBossEvents = new BossBattleCustomData(); this.registries = worldstem.registries(); this.worldData = worldstem.worldData(); @@ -85,7 +86,7 @@ throw new IllegalStateException("Missing Overworld dimension data"); } else { this.proxy = proxy; -@@ -328,6 +365,33 @@ +@@ -334,6 +372,33 @@ this.executor = SystemUtils.backgroundExecutor(); this.potionBrewing = PotionBrewer.bootstrap(this.worldData.enabledFeatures()); } @@ -119,7 +120,7 @@ } private void readScoreboard(WorldPersistentData worldpersistentdata) { -@@ -336,7 +400,7 @@ +@@ -342,7 +407,7 @@ protected abstract boolean initServer() throws IOException; @@ -128,7 +129,7 @@ if (!JvmProfiler.INSTANCE.isRunning()) { ; } -@@ -344,12 +408,8 @@ +@@ -350,12 +415,8 @@ boolean flag = false; ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); @@ -142,7 +143,7 @@ if (profiledduration != null) { profiledduration.finish(); } -@@ -366,23 +426,217 @@ +@@ -372,23 +433,217 @@ protected void forceDifficulty() {} @@ -173,7 +174,7 @@ + int dimension = 0; + + if (dimensionKey == WorldDimension.NETHER) { -+ if (isNetherEnabled()) { ++ if (server.getAllowNether()) { + dimension = -1; + } else { + continue; @@ -374,7 +375,7 @@ if (!iworlddataserver.isInitialized()) { try { -@@ -406,30 +660,8 @@ +@@ -412,30 +667,8 @@ iworlddataserver.setInitialized(true); } @@ -406,7 +407,7 @@ private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { if (flag1) { -@@ -437,6 +669,21 @@ +@@ -443,6 +676,21 @@ } else { ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition()); @@ -428,7 +429,7 @@ int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver); if (i < worldserver.getMinBuildHeight()) { -@@ -495,8 +742,11 @@ +@@ -501,8 +749,11 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } @@ -442,7 +443,7 @@ MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); BlockPosition blockposition = worldserver.getSharedSpawnPos(); -@@ -506,20 +756,22 @@ +@@ -512,20 +763,22 @@ this.nextTickTimeNanos = SystemUtils.getNanos(); worldserver.setDefaultSpawnPos(blockposition, worldserver.getSharedSpawnAngle()); @@ -473,7 +474,7 @@ ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks"); if (forcedchunk != null) { -@@ -534,10 +786,17 @@ +@@ -540,10 +793,17 @@ } } @@ -494,7 +495,7 @@ } public EnumGamemode getDefaultGameType() { -@@ -567,12 +826,16 @@ +@@ -573,12 +833,16 @@ worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); } @@ -511,7 +512,7 @@ if (flag1) { Iterator iterator1 = this.getAllLevels().iterator(); -@@ -607,18 +870,40 @@ +@@ -613,18 +877,40 @@ this.stopServer(); } @@ -552,7 +553,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -706,7 +991,7 @@ +@@ -712,7 +998,7 @@ } this.nextTickTimeNanos = SystemUtils.getNanos(); @@ -561,7 +562,7 @@ this.status = this.buildServerStatus(); while (this.running) { -@@ -723,6 +1008,7 @@ +@@ -729,6 +1015,7 @@ if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) { long k = j / i; @@ -569,7 +570,7 @@ MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeRange.NANOSECONDS_PER_MILLISECOND, k); this.nextTickTimeNanos += k * i; this.lastOverloadWarningNanos = this.nextTickTimeNanos; -@@ -736,6 +1022,7 @@ +@@ -742,6 +1029,7 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount); } @@ -577,7 +578,7 @@ this.nextTickTimeNanos += i; this.startMetricsRecordingTick(); this.profiler.push("tick"); -@@ -783,6 +1070,12 @@ +@@ -789,6 +1077,12 @@ this.services.profileCache().clearExecutor(); } @@ -590,7 +591,7 @@ this.onServerExit(); } -@@ -842,7 +1135,14 @@ +@@ -848,7 +1142,14 @@ } private boolean haveTime() { @@ -605,8 +606,17 @@ + // CraftBukkit end } - protected void waitUntilNextTick() { -@@ -901,7 +1201,7 @@ + public static boolean throwIfFatalException() { +@@ -862,7 +1163,7 @@ + } + + public static void setFatalException(RuntimeException runtimeexception) { +- MinecraftServer.fatalException.compareAndSet((Object) null, runtimeexception); ++ MinecraftServer.fatalException.compareAndSet(null, runtimeexception); // CraftBukkit - decompile error + } + + @Override +@@ -928,7 +1229,7 @@ } } @@ -615,7 +625,7 @@ this.getProfiler().incrementCounter("runTask"); super.doRunTask(ticktask); } -@@ -960,8 +1260,10 @@ +@@ -987,8 +1288,10 @@ } --this.ticksUntilAutosave; @@ -628,7 +638,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); this.profiler.push("save"); this.saveEverything(true, false, false); -@@ -1049,11 +1351,26 @@ +@@ -1076,11 +1379,26 @@ this.getPlayerList().getPlayers().forEach((entityplayer) -> { entityplayer.connection.suspendFlushing(); }); @@ -655,7 +665,7 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); -@@ -1062,11 +1379,13 @@ +@@ -1089,11 +1407,13 @@ return s + " " + String.valueOf(worldserver.dimension().location()); }); @@ -669,7 +679,7 @@ this.profiler.push("tick"); -@@ -1156,6 +1475,22 @@ +@@ -1183,6 +1503,22 @@ return (WorldServer) this.levels.get(resourcekey); } @@ -692,7 +702,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1185,7 +1520,7 @@ +@@ -1212,7 +1548,7 @@ @DontObfuscate public String getServerModName() { @@ -701,7 +711,7 @@ } public SystemReport fillSystemReport(SystemReport systemreport) { -@@ -1527,11 +1862,11 @@ +@@ -1554,11 +1890,11 @@ public CompletableFuture reloadResources(Collection collection) { CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { @@ -715,7 +725,7 @@ }, this).thenCompose((immutablelist) -> { ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); -@@ -1546,6 +1881,7 @@ +@@ -1573,6 +1909,7 @@ }).thenAcceptAsync((minecraftserver_reloadableresources) -> { this.resources.close(); this.resources = minecraftserver_reloadableresources; @@ -723,7 +733,7 @@ this.packRepository.setSelected(collection); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures()); -@@ -1846,7 +2182,7 @@ +@@ -1873,7 +2210,7 @@ final List list = Lists.newArrayList(); final GameRules gamerules = this.getGameRules(); @@ -732,7 +742,7 @@ @Override public > void visit(GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { list.add(String.format(Locale.ROOT, "%s=%s\n", gamerules_gamerulekey.getId(), gamerules.getRule(gamerules_gamerulekey))); -@@ -1952,7 +2288,7 @@ +@@ -1979,7 +2316,7 @@ try { label51: { @@ -741,7 +751,7 @@ try { arraylist = Lists.newArrayList(NativeModuleLister.listModules()); -@@ -2002,6 +2338,22 @@ +@@ -2029,6 +2366,22 @@ } @@ -764,7 +774,7 @@ private void startMetricsRecordingTick() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { -@@ -2132,6 +2484,11 @@ +@@ -2159,6 +2512,11 @@ } diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch index ad2881ffa1..2113fa769b 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -58,6 +58,18 @@ +@@ -60,6 +60,18 @@ import net.minecraft.world.level.storage.Convertable; import org.slf4j.Logger; @@ -19,7 +19,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer { static final Logger LOGGER = LogUtils.getLogger(); -@@ -66,7 +78,7 @@ +@@ -68,7 +80,7 @@ private final List consoleInput = Collections.synchronizedList(Lists.newArrayList()); @Nullable private RemoteStatusListener queryThreadGs4; @@ -28,9 +28,9 @@ @Nullable private RemoteControlListener rconThread; public DedicatedServerSettings settings; -@@ -79,10 +91,12 @@ - @Nullable +@@ -82,10 +94,12 @@ private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker; + public ServerLinks serverLinks; - public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) { - super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory); @@ -42,9 +42,9 @@ - this.rconConsoleSource = new RemoteControlCommandListener(this); + // this.rconConsoleSource = new RemoteControlCommandListener(this); // CraftBukkit - remove field this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig); + this.serverLinks = createServerLinks(dedicatedserversettings); } - -@@ -90,13 +104,44 @@ +@@ -94,13 +108,44 @@ public boolean initServer() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { @@ -92,7 +92,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -105,6 +150,29 @@ +@@ -109,6 +154,29 @@ } }; @@ -122,7 +122,7 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -129,7 +197,7 @@ +@@ -133,7 +201,7 @@ this.setMotd(dedicatedserverproperties.motd); super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); @@ -131,7 +131,7 @@ DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); InetAddress inetaddress = null; -@@ -153,6 +221,12 @@ +@@ -157,6 +225,12 @@ return false; } @@ -144,7 +144,7 @@ if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -167,7 +241,7 @@ +@@ -171,7 +245,7 @@ if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) { return false; } else { @@ -153,7 +153,7 @@ this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList()); this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME); long i = SystemUtils.getNanos(); -@@ -175,13 +249,13 @@ +@@ -179,13 +253,13 @@ TileEntitySkull.setup(this.services, this); UserCache.setUsesAuthentication(this.usesAuthentication()); DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); @@ -169,7 +169,7 @@ } if (dedicatedserverproperties.enableQuery) { -@@ -307,6 +381,7 @@ +@@ -311,6 +385,7 @@ this.queryThreadGs4.stop(); } @@ -177,7 +177,7 @@ } @Override -@@ -328,7 +403,15 @@ +@@ -332,7 +407,15 @@ while (!this.consoleInput.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); @@ -194,7 +194,7 @@ } } -@@ -555,16 +638,52 @@ +@@ -559,16 +642,52 @@ @Override public String getPluginNames() { @@ -251,9 +251,9 @@ } public void storeUsingWhiteList(boolean flag) { -@@ -641,4 +760,15 @@ - public boolean acceptsTransfers() { - return this.settings.getProperties().acceptsTransfers; +@@ -673,4 +792,15 @@ + } + } } + + // CraftBukkit start diff --git a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch index 49746df6f7..b14bb65a3c 100644 --- a/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch +++ b/paper-server/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch @@ -17,7 +17,7 @@ public final boolean onlineMode = this.get("online-mode", true); public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); public final String serverIp = this.get("server-ip", ""); -@@ -104,8 +109,10 @@ +@@ -105,8 +110,10 @@ public final WorldOptions worldOptions; public boolean acceptsTransfers; @@ -30,7 +30,7 @@ this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY); this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL); this.levelName = this.get("level-name", "world"); -@@ -164,13 +171,15 @@ +@@ -165,13 +172,15 @@ this.initialDataPackConfiguration = getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled()))); } @@ -50,7 +50,7 @@ } @Nullable -@@ -251,10 +260,10 @@ +@@ -252,10 +261,10 @@ }).orElseThrow(() -> { return new IllegalStateException("Invalid datapack contents: can't find default preset"); }); @@ -63,7 +63,7 @@ }); Objects.requireNonNull(iregistry); -@@ -266,7 +275,7 @@ +@@ -267,7 +276,7 @@ if (holder.is(WorldPresets.FLAT)) { RegistryOps registryops = iregistrycustom.createSerializationContext(JsonOps.INSTANCE); diff --git a/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch b/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch index 3ffbd07a4a..b88b2aebda 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch @@ -1,35 +1,6 @@ --- a/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java -@@ -121,10 +121,25 @@ - } - - if (!this.chunksToUpdateFutures.isEmpty()) { -- this.chunksToUpdateFutures.forEach((playerchunk) -> { -+ // CraftBukkit start -+ // Iterate pending chunk updates with protection against concurrent modification exceptions -+ java.util.Iterator iter = this.chunksToUpdateFutures.iterator(); -+ int expectedSize = this.chunksToUpdateFutures.size(); -+ do { -+ PlayerChunk playerchunk = iter.next(); -+ iter.remove(); -+ expectedSize--; -+ - playerchunk.updateFutures(playerchunkmap, this.mainThreadExecutor); -- }); -- this.chunksToUpdateFutures.clear(); -+ -+ // Reset iterator if set was modified using add() -+ if (this.chunksToUpdateFutures.size() != expectedSize) { -+ expectedSize = this.chunksToUpdateFutures.size(); -+ iter = this.chunksToUpdateFutures.iterator(); -+ } -+ } while (iter.hasNext()); -+ // CraftBukkit end -+ - return true; - } else { - if (!this.ticketsToRelease.isEmpty()) { -@@ -160,7 +175,7 @@ +@@ -163,7 +163,7 @@ } } @@ -38,7 +9,7 @@ ArraySetSorted> arraysetsorted = this.getTickets(i); int j = getTicketLevelAt(arraysetsorted); Ticket ticket1 = (Ticket) arraysetsorted.addOrGet(ticket); -@@ -170,13 +185,15 @@ +@@ -173,13 +173,15 @@ this.ticketTracker.update(i, ticket.getTicketLevel(), true); } @@ -56,7 +27,7 @@ } if (arraysetsorted.isEmpty()) { -@@ -184,6 +201,7 @@ +@@ -187,6 +189,7 @@ } this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false); @@ -64,7 +35,7 @@ } public void addTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -@@ -197,19 +215,33 @@ +@@ -200,19 +203,33 @@ } public void addRegionTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { @@ -100,7 +71,7 @@ } private ArraySetSorted> getTickets(long i) { -@@ -248,6 +280,7 @@ +@@ -251,6 +268,7 @@ ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk(); long i = chunkcoordintpair.toLong(); ObjectSet objectset = (ObjectSet) this.playersPerChunk.get(i); @@ -108,7 +79,7 @@ objectset.remove(entityplayer); if (objectset.isEmpty()) { -@@ -377,6 +410,26 @@ +@@ -380,6 +398,26 @@ return !this.tickets.isEmpty(); } diff --git a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 99e6077793..635078eaa2 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkProviderServer.java +++ b/net/minecraft/server/level/ChunkProviderServer.java -@@ -81,6 +81,16 @@ +@@ -82,6 +82,16 @@ this.clearCache(); } @@ -17,7 +17,7 @@ @Override public LightEngineThreaded getLightEngine() { return this.lightEngine; -@@ -124,7 +134,7 @@ +@@ -125,7 +135,7 @@ if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) { IChunkAccess ichunkaccess = this.lastChunk[l]; @@ -26,7 +26,7 @@ return ichunkaccess; } } -@@ -137,7 +147,7 @@ +@@ -138,7 +148,7 @@ Objects.requireNonNull(completablefuture); chunkproviderserver_b.managedBlock(completablefuture::isDone); ChunkResult chunkresult = (ChunkResult) completablefuture.join(); @@ -35,22 +35,7 @@ if (ichunkaccess1 == null && flag) { throw (IllegalStateException) SystemUtils.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError())); -@@ -170,12 +180,12 @@ - if (playerchunk == null) { - return null; - } else { -- ChunkResult chunkresult = (ChunkResult) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow((Object) null); -+ ChunkResult chunkresult = (ChunkResult) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error - - if (chunkresult == null) { - return null; - } else { -- IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse((Object) null); -+ IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error - - if (ichunkaccess1 != null) { - this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL); -@@ -223,7 +233,15 @@ +@@ -218,7 +228,15 @@ int l = ChunkLevel.byStatus(chunkstatus); PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k); @@ -67,16 +52,7 @@ this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); if (this.chunkAbsent(playerchunk, l)) { GameProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -242,7 +260,7 @@ - } - - private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) { -- return playerchunk == null || playerchunk.getTicketLevel() > i; -+ return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks - } - - @Override -@@ -315,11 +333,31 @@ +@@ -292,11 +310,31 @@ @Override public void close() throws IOException { @@ -109,7 +85,7 @@ @Override public void tick(BooleanSupplier booleansupplier, boolean flag) { this.level.getProfiler().push("purge"); -@@ -369,11 +407,11 @@ +@@ -346,11 +384,11 @@ this.lastSpawnState = spawnercreature_d; gameprofilerfiller.popPush("spawnAndTick"); @@ -123,7 +99,7 @@ Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -576,13 +614,19 @@ +@@ -560,13 +598,19 @@ } @Override diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch index 1e72852441..855ca200db 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/EntityPlayer.java +++ b/net/minecraft/server/level/EntityPlayer.java -@@ -165,6 +165,39 @@ +@@ -166,6 +166,42 @@ import net.minecraft.world.scores.criteria.IScoreboardCriteria; import org.slf4j.Logger; @@ -9,6 +9,7 @@ +import net.minecraft.world.damagesource.CombatTracker; +import net.minecraft.world.food.FoodMetaData; +import net.minecraft.world.inventory.ContainerPlayer; ++import net.minecraft.world.item.enchantment.EnchantmentEffectComponents; +import net.minecraft.world.item.enchantment.EnchantmentManager; +import net.minecraft.world.level.block.BlockChest; +import net.minecraft.world.level.dimension.WorldDimension; @@ -24,12 +25,14 @@ +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.CraftDimensionUtil; +import org.bukkit.craftbukkit.util.CraftLocation; ++import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityExhaustionEvent; +import org.bukkit.event.player.PlayerBedLeaveEvent; +import org.bukkit.event.player.PlayerChangedMainHandEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerLocaleChangeEvent; +import org.bukkit.event.player.PlayerPortalEvent; ++import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerSpawnChangeEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -40,7 +43,7 @@ public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -203,7 +236,7 @@ +@@ -204,7 +240,7 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance; @@ -49,7 +52,7 @@ @Nullable private Vec3D startingToFallPosition; @Nullable -@@ -233,6 +266,21 @@ +@@ -235,6 +271,21 @@ private int containerCounter; public boolean wonGame; @@ -71,8 +74,8 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) { super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -299,12 +347,65 @@ - this.fudgeSpawnLocation(worldserver); +@@ -302,14 +353,67 @@ + this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); this.updateOptions(clientinformation); this.object = null; + @@ -130,15 +133,17 @@ } + // CraftBukkit end - private void fudgeSpawnLocation(WorldServer worldserver) { - BlockPosition blockposition = worldserver.getSharedSpawnPos(); + @Override + public BlockPosition adjustSpawnLocation(WorldServer worldserver, BlockPosition blockposition) { + AxisAlignedBB axisalignedbb = this.getDimensions(EntityPose.STANDING).makeBoundingBox(Vec3D.ZERO); + BlockPosition blockposition1 = blockposition; - if (worldserver.dimensionType().hasSkyLight() && worldserver.getServer().getWorldData().getGameType() != EnumGamemode.ADVENTURE) { + if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { // CraftBukkit int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -359,7 +460,7 @@ +@@ -366,7 +470,7 @@ dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); @@ -147,7 +152,7 @@ this.wardenSpawnTracker = wardenspawntracker; }); } -@@ -374,17 +475,26 @@ +@@ -381,17 +485,26 @@ if (nbttagcompound.contains("recipeBook", 10)) { this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager()); } @@ -175,7 +180,7 @@ Logger logger1 = EntityPlayer.LOGGER; Objects.requireNonNull(logger1); -@@ -399,7 +509,7 @@ +@@ -406,7 +519,7 @@ dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase); logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); @@ -184,7 +189,7 @@ this.raidOmenPosition = blockposition; }); } -@@ -409,7 +519,7 @@ +@@ -416,7 +529,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -193,7 +198,7 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -430,7 +540,20 @@ +@@ -437,7 +550,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -215,7 +220,7 @@ NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -455,6 +578,7 @@ +@@ -462,6 +588,7 @@ nbttagcompound.put("SpawnDimension", nbtbase); }); } @@ -223,7 +228,7 @@ nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); if (this.raidOmenPosition != null) { -@@ -468,6 +592,29 @@ +@@ -475,6 +602,29 @@ } @@ -236,7 +241,7 @@ + if (this.respawnDimension != null) { + world = this.server.getLevel(this.respawnDimension); + if (world != null && this.getRespawnPosition() != null) { -+ position = EntityHuman.findRespawnPositionAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).orElse(null); ++ position = EntityPlayer.findRespawnAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).map(EntityPlayer.RespawnPosAngle::position).orElse(null); + } + } + if (world == null || position == null) { @@ -253,7 +258,7 @@ public void setExperiencePoints(int i) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -526,6 +673,11 @@ +@@ -533,6 +683,11 @@ @Override public void tick() { @@ -265,7 +270,7 @@ this.gameMode.tick(); this.wardenSpawnTracker.tick(); --this.spawnInvulnerableTime; -@@ -606,7 +758,7 @@ +@@ -613,7 +768,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -274,7 +279,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -637,6 +789,12 @@ +@@ -644,6 +799,12 @@ this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } @@ -287,7 +292,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); -@@ -651,6 +809,20 @@ +@@ -658,6 +819,20 @@ CriterionTriggers.LOCATION.trigger(this); } @@ -308,7 +313,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -696,7 +868,8 @@ +@@ -703,7 +878,8 @@ } private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -318,7 +323,7 @@ scoreaccess.set(i); }); } -@@ -705,9 +878,47 @@ +@@ -712,9 +888,47 @@ public void die(DamageSource damagesource) { this.gameEvent(GameEvent.ENTITY_DIE); boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); @@ -333,7 +338,7 @@ - IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage(); + if (!keepInventory) { + for (ItemStack item : this.getInventory().getContents()) { -+ if (!item.isEmpty() && !EnchantmentManager.hasVanishingCurse(item)) { ++ if (!item.isEmpty() && EnchantmentManager.has(item, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { + loot.add(CraftItemStack.asCraftMirror(item)); + } + } @@ -368,15 +373,15 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; -@@ -738,12 +949,18 @@ +@@ -745,12 +959,18 @@ if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } - - if (!this.isSpectator()) { -- this.dropAllDeathLoot(damagesource); +- this.dropAllDeathLoot(this.serverLevel(), damagesource); + // SPIGOT-5478 must be called manually now -+ this.dropExperience(); ++ this.dropExperience(damagesource.getEntity()); + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { + this.getInventory().clearContent(); @@ -391,7 +396,7 @@ EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -778,10 +995,12 @@ +@@ -785,10 +1005,12 @@ if (entity != this) { super.awardKillScore(entity, i, damagesource); this.increaseScore(i); @@ -406,7 +411,7 @@ } else { this.awardStat(StatisticList.MOB_KILLS); } -@@ -799,7 +1018,8 @@ +@@ -806,7 +1028,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -416,7 +421,7 @@ } } -@@ -849,18 +1069,20 @@ +@@ -856,10 +1079,16 @@ } private boolean isPvpAllowed() { @@ -425,111 +430,152 @@ + return this.level().pvpMode; } - @Nullable - @Override - protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { - ShapeDetectorShape shapedetectorshape = super.findDimensionEntryPoint(worldserver); -+ worldserver = (shapedetectorshape == null) ? worldserver : shapedetectorshape.world; // CraftBukkit - -- if (shapedetectorshape != null && this.level().dimension() == World.OVERWORLD && worldserver.dimension() == World.END) { -+ if (shapedetectorshape != null && this.level().getTypeKey() == WorldDimension.OVERWORLD && worldserver != null && worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit - Vec3D vec3d = shapedetectorshape.pos.add(0.0D, -1.0D, 0.0D); - -- return new ShapeDetectorShape(vec3d, Vec3D.ZERO, 90.0F, 0.0F); -+ return new ShapeDetectorShape(vec3d, Vec3D.ZERO, 90.0F, 0.0F, worldserver, shapedetectorshape.portalEventInfo); // CraftBukkit - } else { - return shapedetectorshape; - } -@@ -869,11 +1091,20 @@ - @Nullable - @Override - public Entity changeDimension(WorldServer worldserver) { -- this.isChangingDimension = true; -+ // CraftBukkit start -+ return changeDimension(worldserver, TeleportCause.UNKNOWN); -+ } -+ -+ @Nullable -+ public Entity changeDimension(WorldServer worldserver, PlayerTeleportEvent.TeleportCause cause) { +- public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a) { ++ // CraftBukkit start ++ public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a, PlayerRespawnEvent.RespawnReason reason) { ++ DimensionTransition dimensionTransition; ++ boolean isBedSpawn = false; ++ boolean isAnchorSpawn = false; + // CraftBukkit end -+ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 -+ // this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension - WorldServer worldserver1 = this.serverLevel(); -- ResourceKey resourcekey = worldserver1.dimension(); -+ ResourceKey resourcekey = worldserver1.getTypeKey(); // CraftBukkit + BlockPosition blockposition = this.getRespawnPosition(); + float f = this.getRespawnAngle(); + boolean flag1 = this.isRespawnForced(); +@@ -871,13 +1100,32 @@ + if (optional.isPresent()) { + EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get(); -- if (resourcekey == World.END && worldserver.dimension() == World.OVERWORLD) { -+ if (resourcekey == WorldDimension.END && worldserver != null && worldserver.getTypeKey() == WorldDimension.OVERWORLD) { // CraftBukkit -+ this.isChangingDimension = true; // CraftBukkit - Moved down from above - this.unRide(); - this.serverLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); - if (!this.wonGame) { -@@ -884,6 +1115,8 @@ - - return this; +- return new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a); ++ // CraftBukkit start ++ isBedSpawn = entityplayer_respawnposangle.isBedSpawn(); ++ isAnchorSpawn = entityplayer_respawnposangle.isAnchorSpawn(); ++ dimensionTransition = new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a); ++ // CraftBukkit end + } else { +- return DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a); ++ dimensionTransition = DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit + } } else { +- return new DimensionTransition(this.server.overworld(), this, dimensiontransition_a); ++ dimensionTransition = new DimensionTransition(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit + } ++ // CraftBukkit start ++ if (reason == null) { ++ return dimensionTransition; ++ } ++ ++ Player respawnPlayer = this.getBukkitEntity(); ++ Location location = CraftLocation.toBukkit(dimensionTransition.pos(), dimensionTransition.newLevel().getWorld(), dimensionTransition.yRot(), dimensionTransition.xRot()); ++ ++ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn, isAnchorSpawn, reason); ++ this.level().getCraftServer().getPluginManager().callEvent(respawnEvent); ++ ++ location = respawnEvent.getRespawnLocation(); ++ ++ return new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), dimensionTransition.speed(), location.getYaw(), location.getPitch(), dimensionTransition.missingRespawnBlock(), dimensionTransition.postDimensionTransition(), dimensionTransition.cause()); ++ // CraftBukkit end + } + + public static Optional findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) { +@@ -892,11 +1140,11 @@ + } + + return optional.map((vec3d) -> { +- return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition); ++ return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition, false, true); // CraftBukkit + }); + } else if (block instanceof BlockBed && BlockBed.canSetSpawn(worldserver)) { + return BlockBed.findStandUpPosition(EntityTypes.PLAYER, worldserver, blockposition, (EnumDirection) iblockdata.getValue(BlockBed.FACING), f).map((vec3d) -> { +- return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition); ++ return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition, true, false); // CraftBukkit + }); + } else if (!flag) { + return Optional.empty(); +@@ -905,7 +1153,7 @@ + IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above()); + boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); + +- return flag2 && flag3 ? Optional.of(new EntityPlayer.RespawnPosAngle(new Vec3D((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.1D, (double) blockposition.getZ() + 0.5D), f)) : Optional.empty(); ++ return flag2 && flag3 ? Optional.of(new EntityPlayer.RespawnPosAngle(new Vec3D((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.1D, (double) blockposition.getZ() + 0.5D), f, false, false)) : Optional.empty(); // CraftBukkit + } + } + +@@ -923,6 +1171,7 @@ + @Nullable + @Override + public Entity changeDimension(DimensionTransition dimensiontransition) { ++ if (this.isSleeping()) return null; // CraftBukkit - SPIGOT-3154 + if (this.isRemoved()) { + return null; + } else { +@@ -932,14 +1181,21 @@ + + WorldServer worldserver = dimensiontransition.newLevel(); + WorldServer worldserver1 = this.serverLevel(); +- ResourceKey resourcekey = worldserver1.dimension(); + // CraftBukkit start -+ /* - WorldData worlddata = worldserver.getLevelData(); ++ ResourceKey resourcekey = worldserver1.getTypeKey(); - this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3)); -@@ -893,20 +1126,50 @@ - playerlist.sendPlayerPermissionLevel(this); - worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); - this.unsetRemoved(); -+ */ -+ // CraftBukkit end - ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver); +- if (worldserver.dimension() == resourcekey) { +- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot()); ++ if (worldserver != null && worldserver.dimension() == worldserver1.dimension()) { // CraftBukkit ++ boolean result = this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot(), dimensiontransition.cause()); ++ if (!result) { ++ return null; ++ } ++ // CraftBukkit end + this.connection.resetPosition(); + dimensiontransition.postDimensionTransition().onTransition(this); + return this; + } else { ++ // CraftBukkit start ++ /* + this.isChangingDimension = true; + WorldData worlddata = worldserver.getLevelData(); - if (shapedetectorshape != null) { +@@ -950,15 +1206,40 @@ + playerlist.sendPlayerPermissionLevel(this); + worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); + this.unsetRemoved(); ++ */ ++ // CraftBukkit end worldserver1.getProfiler().push("moving"); - if (resourcekey == World.OVERWORLD && worldserver.dimension() == World.NETHER) { -+ worldserver = shapedetectorshape.world; // CraftBukkit -+ if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event -+ if (resourcekey == WorldDimension.OVERWORLD && worldserver.getTypeKey() == WorldDimension.NETHER) { // CraftBukkit ++ if (worldserver != null && resourcekey == WorldDimension.OVERWORLD && worldserver.getTypeKey() == WorldDimension.NETHER) { // CraftBukkit - empty to fall through to null to event this.enteredNetherPosition = this.position(); -- } else if (worldserver.dimension() == World.END) { -+ } else if (worldserver.getTypeKey() == WorldDimension.END && shapedetectorshape.portalEventInfo != null && shapedetectorshape.portalEventInfo.getCanCreatePortal()) { // CraftBukkit - this.createEndPlatform(worldserver, BlockPosition.containing(shapedetectorshape.pos)); } + // CraftBukkit start -+ } else { -+ return null; -+ } -+ Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(shapedetectorshape.pos, worldserver.getWorld(), shapedetectorshape.yRot, shapedetectorshape.xRot); -+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause); -+ Bukkit.getServer().getPluginManager().callEvent(tpEvent); -+ if (tpEvent.isCancelled() || tpEvent.getTo() == null) { -+ return null; -+ } -+ exit = tpEvent.getTo(); -+ worldserver = ((CraftWorld) exit.getWorld()).getHandle(); -+ // CraftBukkit end ++ Location enter = this.getBukkitEntity().getLocation(); ++ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(dimensiontransition.pos(), worldserver.getWorld(), dimensiontransition.yRot(), dimensiontransition.xRot()); ++ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, dimensiontransition.cause()); ++ Bukkit.getServer().getPluginManager().callEvent(tpEvent); ++ if (tpEvent.isCancelled() || tpEvent.getTo() == null) { ++ return null; ++ } ++ exit = tpEvent.getTo(); ++ worldserver = ((CraftWorld) exit.getWorld()).getHandle(); ++ // CraftBukkit end -- worldserver1.getProfiler().pop(); -- worldserver1.getProfiler().push("placing"); -+ worldserver1.getProfiler().pop(); -+ worldserver1.getProfiler().push("placing"); -+ if (true) { // CraftBukkit + worldserver1.getProfiler().pop(); + worldserver1.getProfiler().push("placing"); ++ // CraftBukkit start + this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds ++ WorldData worlddata = worldserver.getLevelData(); + + this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3)); -+ this.connection.send(new PacketPlayOutServerDifficulty(this.level().getDifficulty(), this.level().getLevelData().isDifficultyLocked())); ++ this.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); + PlayerList playerlist = this.server.getPlayerList(); + + playerlist.sendPlayerPermissionLevel(this); + worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); + this.unsetRemoved(); -+ + // CraftBukkit end this.setServerLevel(worldserver); -- this.connection.teleport(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot); +- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot()); + this.connection.teleport(exit); // CraftBukkit - use internal teleport without event this.connection.resetPosition(); - worldserver.addDuringPortalTeleport(this); + worldserver.addDuringTeleport(this); worldserver1.getProfiler().pop(); -@@ -926,39 +1189,66 @@ +@@ -971,21 +1252,47 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -538,17 +584,15 @@ + PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); + this.level().getCraftServer().getPluginManager().callEvent(changeEvent); + // CraftBukkit end + return this; } - - return this; } } + // CraftBukkit start + @Override -+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Vec3D exitPosition, TeleportCause cause, int searchRadius, int creationRadius) { ++ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, TeleportCause cause, int searchRadius, int creationRadius) { + Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld(), getYRot(), getXRot()); + PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) { @@ -558,51 +602,6 @@ + } + // CraftBukkit end + - private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) { - BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); -+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver); // CraftBukkit - - for (int i = -2; i <= 2; ++i) { - for (int j = -2; j <= 2; ++j) { - for (int k = -1; k < 3; ++k) { - IBlockData iblockdata = k == -1 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); - -- worldserver.setBlockAndUpdate(blockposition_mutableblockposition.set(blockposition).move(j, k, i), iblockdata); -+ blockList.setBlock(blockposition_mutableblockposition.set(blockposition).move(j, k, i), iblockdata, 3); // CraftBukkit - } - } - } -+ // CraftBukkit start - call portal event -+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List) (List) blockList.getList(), worldserver.getWorld(), this.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); -+ worldserver.getCraftServer().getPluginManager().callEvent(portalEvent); -+ if (!portalEvent.isCancelled()) { -+ blockList.updateList(); -+ } -+ // CraftBukkit end - - } - - @Override -- protected Optional getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) { -- Optional optional = super.getExitPortal(worldserver, blockposition, flag, worldborder); -+ protected Optional getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit -+ Optional optional = super.getExitPortal(worldserver, blockposition, flag, worldborder, searchRadius, canCreatePortal, createRadius); // CraftBukkit - -- if (optional.isPresent()) { -+ if (optional.isPresent() || !canCreatePortal) { // CraftBukkit - return optional; - } else { - EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level().getBlockState(this.portalEntrancePos).getOptionalValue(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X); -- Optional optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis); -+ Optional optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit - - if (optional1.isEmpty()) { -- EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); -+ // EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); // CraftBukkit - } - - return optional1; -@@ -968,13 +1258,21 @@ public void triggerDimensionChangeTriggers(WorldServer worldserver) { ResourceKey resourcekey = worldserver.dimension(); ResourceKey resourcekey1 = this.level().dimension(); @@ -627,7 +626,7 @@ this.enteredNetherPosition = null; } -@@ -991,19 +1289,17 @@ +@@ -1002,19 +1309,17 @@ this.containerMenu.broadcastChanges(); } @@ -651,7 +650,7 @@ if (this.level().isDay()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW); } else { -@@ -1020,7 +1316,36 @@ +@@ -1031,7 +1336,36 @@ } } @@ -689,7 +688,7 @@ this.awardStat(StatisticList.SLEEP_IN_BED); CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1033,9 +1358,8 @@ +@@ -1044,9 +1378,8 @@ return either; } } @@ -700,7 +699,7 @@ } @Override -@@ -1062,13 +1386,31 @@ +@@ -1073,13 +1406,31 @@ @Override public void stopSleepInBed(boolean flag, boolean flag1) { @@ -733,7 +732,7 @@ } } -@@ -1135,8 +1477,9 @@ +@@ -1146,8 +1497,9 @@ this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag)); } @@ -744,7 +743,7 @@ } @Override -@@ -1144,13 +1487,35 @@ +@@ -1155,13 +1507,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { @@ -780,7 +779,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); -@@ -1158,9 +1523,11 @@ +@@ -1169,9 +1543,11 @@ return OptionalInt.empty(); } else { @@ -794,13 +793,13 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1173,13 +1540,24 @@ +@@ -1184,15 +1560,26 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { + // CraftBukkit start - Inventory open hook + this.nextContainerCounter(); -+ Container container = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); ++ Container container = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract, entityhorseabstract.getInventoryColumns()); + container.setTitle(entityhorseabstract.getDisplayName()); + container = CraftEventFactory.callInventoryOpenEvent(this, container); + @@ -815,13 +814,15 @@ - this.nextContainerCounter(); + // this.nextContainerCounter(); // CraftBukkit - moved up - this.connection.send(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getContainerSize(), entityhorseabstract.getId())); -- this.containerMenu = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); + int i = entityhorseabstract.getInventoryColumns(); + + this.connection.send(new PacketPlayOutOpenWindowHorse(this.containerCounter, i, entityhorseabstract.getId())); +- this.containerMenu = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract, i); + this.containerMenu = container; // CraftBukkit this.initMenu(this.containerMenu); } -@@ -1202,6 +1580,7 @@ +@@ -1215,6 +1602,7 @@ @Override public void closeContainer() { @@ -829,7 +830,7 @@ this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1224,6 +1603,16 @@ +@@ -1237,6 +1625,16 @@ } this.jumping = flag; @@ -846,7 +847,7 @@ this.setShiftKeyDown(flag1); } -@@ -1257,19 +1646,19 @@ +@@ -1270,19 +1668,19 @@ i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { this.awardStat(StatisticList.SWIM_ONE_CM, i); @@ -869,7 +870,7 @@ } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1280,13 +1669,13 @@ +@@ -1293,13 +1691,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); @@ -886,7 +887,7 @@ } } } else if (this.isFallFlying()) { -@@ -1329,7 +1718,7 @@ +@@ -1342,7 +1740,7 @@ @Override public void awardStat(Statistic statistic, int i) { this.stats.increment(this, statistic, i); @@ -895,7 +896,7 @@ scoreaccess.add(i); }); } -@@ -1337,7 +1726,7 @@ +@@ -1350,7 +1748,7 @@ @Override public void resetStat(Statistic statistic) { this.stats.setValue(this, statistic, 0); @@ -904,7 +905,7 @@ } @Override -@@ -1385,6 +1774,7 @@ +@@ -1398,6 +1796,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -912,7 +913,7 @@ } @Override -@@ -1442,7 +1832,7 @@ +@@ -1465,7 +1864,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -921,7 +922,7 @@ this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.chunkTrackingView = entityplayer.chunkTrackingView; -@@ -1493,6 +1883,12 @@ +@@ -1516,6 +1915,12 @@ @Override public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1) { @@ -934,7 +935,7 @@ ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2)); worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId()); -@@ -1502,9 +1898,9 @@ +@@ -1525,9 +1930,9 @@ } if (worldserver == this.level()) { @@ -946,7 +947,7 @@ } this.setYHeadRot(f); -@@ -1606,6 +2002,16 @@ +@@ -1635,6 +2040,16 @@ } public void updateOptions(ClientInformation clientinformation) { @@ -963,7 +964,7 @@ this.language = clientinformation.language(); this.requestedViewDistance = clientinformation.viewDistance(); this.chatVisibility = clientinformation.chatVisibility(); -@@ -1689,7 +2095,7 @@ +@@ -1718,7 +2133,7 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; @@ -972,7 +973,7 @@ } if (entity != null) { -@@ -1726,7 +2132,7 @@ +@@ -1755,7 +2170,7 @@ @Nullable public IChatBaseComponent getTabListDisplayName() { @@ -981,7 +982,7 @@ } @Override -@@ -1747,9 +2153,16 @@ +@@ -1776,14 +2191,24 @@ return this.advancements; } @@ -998,9 +999,7 @@ if (worldserver == this.level()) { this.connection.teleport(d0, d1, d2, f, f1); } else { -@@ -1769,6 +2182,9 @@ - this.server.getPlayerList().sendLevelInfo(this, worldserver); - this.server.getPlayerList().sendAllPlayerInfo(this); + this.changeDimension(new DimensionTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, DimensionTransition.DO_NOTHING)); } + */ + this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause); @@ -1008,7 +1007,7 @@ } -@@ -1790,6 +2206,32 @@ +@@ -1809,6 +2234,32 @@ } public void setRespawnPosition(ResourceKey resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) { @@ -1041,9 +1040,25 @@ if (blockposition != null) { boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension); -@@ -2011,4 +2453,147 @@ - public BlockPosition getRaidOmenPosition() { - return this.raidOmenPosition; +@@ -2049,10 +2500,12 @@ + this.awardStat(StatisticList.ITEM_BROKEN.get(item)); + } + +- public static record RespawnPosAngle(Vec3D position, float yaw) { ++ // CraftBukkit start ++ public static record RespawnPosAngle(Vec3D position, float yaw, boolean isBedSpawn, boolean isAnchorSpawn) { + +- public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPosition blockposition) { +- return new EntityPlayer.RespawnPosAngle(vec3d, calculateLookAtYaw(vec3d, blockposition)); ++ public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPosition blockposition, boolean isBedSpawn, boolean isAnchorSpawn) { ++ return new EntityPlayer.RespawnPosAngle(vec3d, calculateLookAtYaw(vec3d, blockposition), isBedSpawn, isAnchorSpawn); ++ // CraftBukkit end + } + + private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) { +@@ -2061,4 +2514,147 @@ + return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); + } } + + // CraftBukkit start - Add per-player time and weather. diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index 4a967146ff..f8ac888b35 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch @@ -24,10 +24,10 @@ + public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { + this.trackedPlayers = trackedPlayers; + // CraftBukkit end - this.ap = Vec3D.ZERO; - this.lastPassengers = Collections.emptyList(); this.level = worldserver; -@@ -91,7 +101,7 @@ + this.broadcast = consumer; + this.entity = entity; +@@ -90,7 +100,7 @@ List list = this.entity.getPassengers(); if (!list.equals(this.lastPassengers)) { @@ -36,7 +36,7 @@ removedPassengers(list, this.lastPassengers).forEach((entity) -> { if (entity instanceof EntityPlayer entityplayer) { entityplayer.connection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); -@@ -104,18 +114,18 @@ +@@ -103,18 +113,18 @@ Entity entity = this.entity; if (entity instanceof EntityItemFrame entityitemframe) { @@ -59,11 +59,10 @@ worldmap.tickCarriedBy(entityplayer, itemstack); Packet packet = worldmap.getUpdatePacket(mapid, entityplayer); -@@ -228,7 +238,27 @@ +@@ -232,6 +242,27 @@ ++this.tickCount; if (this.entity.hurtMarked) { -- this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); + // CraftBukkit start - Create PlayerVelocity event + boolean cancelled = false; + @@ -81,14 +80,14 @@ + } + } + -+ if (!cancelled) { -+ this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); ++ if (cancelled) { ++ return; + } + // CraftBukkit end - entity = this.entity; - if (entity instanceof EntityFireball) { - EntityFireball entityfireball = (EntityFireball) entity; -@@ -263,7 +293,10 @@ + this.entity.hurtMarked = false; + this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); + } +@@ -260,7 +291,10 @@ public void sendPairingData(EntityPlayer entityplayer, Consumer> consumer) { if (this.entity.isRemoved()) { @@ -99,8 +98,8 @@ + // CraftBukkit end } - Packet packet = this.entity.getAddEntityPacket(); -@@ -279,6 +312,12 @@ + Packet packet = this.entity.getAddEntityPacket(this); +@@ -275,6 +309,12 @@ if (this.entity instanceof EntityLiving) { Collection collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes(); @@ -113,7 +112,7 @@ if (!collection.isEmpty()) { consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); } -@@ -310,6 +349,7 @@ +@@ -305,6 +345,7 @@ if (!list.isEmpty()) { consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } @@ -121,8 +120,8 @@ } if (!this.entity.getPassengers().isEmpty()) { -@@ -343,6 +383,11 @@ - Set set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes(); +@@ -358,6 +399,11 @@ + Set set = ((EntityLiving) this.entity).getAttributes().getAttributesToSync(); if (!set.isEmpty()) { + // CraftBukkit start - Send scaled max health diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch index ef4371bdc5..939aea8551 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerChunk.java +++ b/net/minecraft/server/level/PlayerChunk.java -@@ -34,6 +34,10 @@ +@@ -28,6 +28,10 @@ import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.lighting.LevelLightEngine; @@ -8,47 +8,40 @@ +import net.minecraft.server.MinecraftServer; +// CraftBukkit end + - public class PlayerChunk { + public class PlayerChunk extends GenerationChunkHolder { - public static final ChunkResult UNLOADED_CHUNK = ChunkResult.error("Unloaded chunk"); -@@ -70,12 +74,12 @@ - this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; - this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; + public static final ChunkResult UNLOADED_LEVEL_CHUNK = ChunkResult.error("Unloaded level chunk"); +@@ -58,9 +62,9 @@ this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE; -- this.chunkToSave = CompletableFuture.completedFuture((Object) null); -+ this.chunkToSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error - this.chunkToSaveHistory = null; this.blockChangedLightSectionFilter = new BitSet(); this.skyChangedLightSectionFilter = new BitSet(); - this.pendingFullStateConfirmation = CompletableFuture.completedFuture((Object) null); - this.sendSync = CompletableFuture.completedFuture((Object) null); +- this.saveSync = CompletableFuture.completedFuture((Object) null); + this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error + this.sendSync = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error - this.pos = chunkcoordintpair; ++ this.saveSync = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error this.levelHeightAccessor = levelheightaccessor; this.lightEngine = levellightengine; -@@ -88,6 +92,20 @@ + this.onLevelChange = playerchunk_a; +@@ -72,6 +76,16 @@ this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()]; } + // CraftBukkit start + public Chunk getFullChunkNow() { -+ // Note: We use the oldTicketLevel for isLoaded checks. -+ if (!ChunkLevel.fullStatus(this.oldTicketLevel).isOrAfter(FullChunkStatus.FULL)) return null; -+ return this.getFullChunkNowUnchecked(); ++ return (Chunk) this.getChunkIfPresent(ChunkStatus.FULL); + } + + public Chunk getFullChunkNowUnchecked() { -+ CompletableFuture> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); -+ ChunkResult either = statusFuture.getNow(null); -+ return (either == null) ? null : (Chunk) either.orElse(null); ++ return (Chunk) this.getChunkIfPresentUnchecked(ChunkStatus.FULL); + } + // CraftBukkit end + - public CompletableFuture> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) { - CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex()); - -@@ -112,7 +130,7 @@ + public CompletableFuture> getTickingChunkFuture() { + return this.tickingChunkFuture; + } +@@ -86,7 +100,7 @@ @Nullable public Chunk getTickingChunk() { @@ -56,8 +49,8 @@ + return (Chunk) ((ChunkResult) this.getTickingChunkFuture().getNow(PlayerChunk.UNLOADED_LEVEL_CHUNK)).orElse(null); // CraftBukkit - decompile error } - public CompletableFuture getChunkSendSyncFuture() { -@@ -166,6 +184,7 @@ + @Nullable +@@ -134,6 +148,7 @@ if (chunk != null) { int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY()); @@ -65,16 +58,7 @@ if (this.changedBlocksPerSection[i] == null) { this.hasChangedSections = true; this.changedBlocksPerSection[i] = new ShortOpenHashSet(); -@@ -176,7 +195,7 @@ - } - - public void sectionLightChanged(EnumSkyBlock enumskyblock, int i) { -- IChunkAccess ichunkaccess = (IChunkAccess) ((ChunkResult) this.getFutureIfPresent(ChunkStatus.INITIALIZE_LIGHT).getNow(PlayerChunk.UNLOADED_CHUNK)).orElse((Object) null); -+ IChunkAccess ichunkaccess = (IChunkAccess) ((ChunkResult) this.getFutureIfPresent(ChunkStatus.INITIALIZE_LIGHT).getNow(PlayerChunk.UNLOADED_CHUNK)).orElse(null); // CraftBukkit - decompile error - - if (ichunkaccess != null) { - ichunkaccess.setUnsaved(true); -@@ -240,8 +259,11 @@ +@@ -208,8 +223,11 @@ PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection); this.broadcast(list, packetplayoutmultiblockchange); @@ -87,7 +71,7 @@ }); } } -@@ -374,7 +396,7 @@ +@@ -275,7 +293,7 @@ this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((chunkresult) -> { chunkresult.ifSuccess((chunk) -> { @@ -96,14 +80,14 @@ }); }); } -@@ -391,6 +413,30 @@ - boolean flag1 = ChunkLevel.isLoaded(this.ticketLevel); - FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel); +@@ -290,6 +308,30 @@ FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel); + boolean flag = fullchunkstatus.isOrAfter(FullChunkStatus.FULL); + boolean flag1 = fullchunkstatus1.isOrAfter(FullChunkStatus.FULL); + // CraftBukkit start + // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. -+ if (fullchunkstatus.isOrAfter(FullChunkStatus.FULL) && !fullchunkstatus1.isOrAfter(FullChunkStatus.FULL)) { -+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { ++ if (flag && !flag1) { ++ this.getFullChunkFuture().thenAccept((either) -> { + Chunk chunk = (Chunk) either.orElse(null); + if (chunk != null) { + playerchunkmap.callbackExecutor.execute(() -> { @@ -125,16 +109,16 @@ + } + // CraftBukkit end - if (flag) { - ChunkResult chunkresult = ChunkResult.error(() -> { -@@ -459,6 +505,26 @@ + this.wasAccessibleSinceLastSave |= flag1; + if (!flag && flag1) { +@@ -341,6 +383,26 @@ this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; + // CraftBukkit start + // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins. + if (!fullchunkstatus.isOrAfter(FullChunkStatus.FULL) && fullchunkstatus1.isOrAfter(FullChunkStatus.FULL)) { -+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { ++ this.getFullChunkFuture().thenAccept((either) -> { + Chunk chunk = (Chunk) either.orElse(null); + if (chunk != null) { + playerchunkmap.callbackExecutor.execute(() -> { diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index a68262db80..f6390c0e39 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -104,6 +104,10 @@ +@@ -102,6 +102,10 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -8,12 +8,12 @@ +import org.bukkit.craftbukkit.generator.CustomChunkGenerator; +// CraftBukkit end + - public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.c { + public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.b, GeneratingChunkMap { - private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -146,6 +150,27 @@ + private static final ChunkResult> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range"); +@@ -145,6 +149,27 @@ public int serverViewDistance; - private WorldGenContext worldGenContext; + private final WorldGenContext worldGenContext; + // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() + public final CallbackExecutor callbackExecutor = new CallbackExecutor(); @@ -39,7 +39,7 @@ public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { super(new RegionStorageInfo(convertable_conversionsession.getLevelId(), worldserver.dimension(), "chunk"), convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -166,7 +191,13 @@ +@@ -164,7 +189,13 @@ IRegistryCustom iregistrycustom = worldserver.registryAccess(); long j = worldserver.getSeed(); @@ -54,21 +54,7 @@ this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); } else { this.randomState = RandomState.create(GeneratorSettingBase.dummy(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); -@@ -332,16 +363,19 @@ - CompletableFuture>> completablefuture1 = SystemUtils.sequence(list); - CompletableFuture>> completablefuture2 = completablefuture1.thenApply((list2) -> { - List list3 = Lists.newArrayList(); -- int l1 = 0; -+ // CraftBukkit start - decompile error -+ int cnt = 0; - -- for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++l1) { -+ for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++cnt) { -+ final int l1 = cnt; -+ // CraftBukkit end - ChunkResult chunkresult = (ChunkResult) iterator.next(); - - if (chunkresult == null) { +@@ -318,7 +349,7 @@ throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); } @@ -76,68 +62,18 @@ + IChunkAccess ichunkaccess = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error if (ichunkaccess == null) { - return ChunkResult.error(() -> { -@@ -538,7 +572,7 @@ - - private void scheduleUnload(long i, PlayerChunk playerchunk) { - CompletableFuture completablefuture = playerchunk.getChunkToSave(); -- Consumer consumer = (ichunkaccess) -> { -+ Consumer consumer = (ichunkaccess) -> { // CraftBukkit - decompile error - CompletableFuture completablefuture1 = playerchunk.getChunkToSave(); - - if (completablefuture1 != completablefuture) { -@@ -708,7 +742,7 @@ - }; - - return completablefuture.thenComposeAsync((chunkresult) -> { -- List list = (List) chunkresult.orElse((Object) null); -+ List list = (List) chunkresult.orElse(null); // CraftBukkit - decompile error - - if (list == null) { - this.releaseLightTicket(chunkcoordintpair); -@@ -773,7 +807,21 @@ - - private static void postLoadProtoChunk(WorldServer worldserver, List list) { - if (!list.isEmpty()) { -- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver)); -+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities -+ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver).filter((entity) -> { -+ boolean needsRemoval = false; -+ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer(); -+ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.NPC) { -+ entity.discard(null); // CraftBukkit - add Bukkit remove cause -+ needsRemoval = true; -+ } -+ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { -+ entity.discard(null); // CraftBukkit - add Bukkit remove cause -+ needsRemoval = true; -+ } -+ return !needsRemoval; -+ })); -+ // CraftBukkit end - } - - } -@@ -879,7 +927,7 @@ - if (!playerchunk.wasAccessibleSinceLastSave()) { - return false; - } else { -- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow((Object) null); -+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow(null); // CraftBukkit - decompile error - - if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) { - return false; -@@ -1040,7 +1088,8 @@ + return PlayerChunkMap.UNLOADED_CHUNK_LIST_RESULT; +@@ -937,7 +968,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); -- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { +- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { + // CraftBukkit - decompile error -+ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { ++ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { return chunk.getBlockEntities().size(); }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -1053,7 +1102,7 @@ +@@ -950,7 +982,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -146,7 +82,7 @@ return chunkresult != null ? (chunkresult.isSuccess() ? "done" : "unloaded") : "not completed"; } catch (CompletionException completionexception) { -@@ -1065,12 +1114,14 @@ +@@ -962,12 +994,14 @@ private CompletableFuture> readChunk(ChunkCoordIntPair chunkcoordintpair) { return this.read(chunkcoordintpair).thenApplyAsync((optional) -> { @@ -156,15 +92,15 @@ } - private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound) { -- return this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer()); +- return this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator().getTypeNameForDataFixer()); + // CraftBukkit start + private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound, ChunkCoordIntPair chunkcoordintpair) { -+ return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level); ++ return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator().getTypeNameForDataFixer(), chunkcoordintpair, level); + // CraftBukkit end } boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { -@@ -1473,7 +1524,7 @@ +@@ -1370,7 +1404,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(final Entity entity, final int i, final int j, final boolean flag) { @@ -173,7 +109,7 @@ this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of((EntityAccess) entity); -@@ -1533,6 +1584,11 @@ +@@ -1430,6 +1464,11 @@ double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z); diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch index c01a3a913c..a82ef80b1a 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/level/PlayerInteractManager.java +++ b/net/minecraft/server/level/PlayerInteractManager.java -@@ -25,6 +25,27 @@ - import net.minecraft.world.phys.MovingObjectPositionBlock; +@@ -28,6 +28,27 @@ + import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start @@ -28,7 +28,7 @@ public class PlayerInteractManager { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -55,9 +76,16 @@ +@@ -58,9 +79,16 @@ if (enumgamemode == this.gameModeForPlayer) { return false; } else { @@ -46,7 +46,7 @@ this.level.updateSleepingPlayerList(); if (enumgamemode == EnumGamemode.CREATIVE) { this.player.resetCurrentImpulseContext(); -@@ -91,7 +119,7 @@ +@@ -94,7 +122,7 @@ } public void tick() { @@ -55,7 +55,7 @@ IBlockData iblockdata; if (this.hasDelayedDestroy) { -@@ -145,11 +173,33 @@ +@@ -148,11 +176,33 @@ if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { if (!this.level.mayInteract(this.player, blockposition)) { @@ -89,7 +89,7 @@ if (this.isCreative()) { this.destroyAndAck(blockposition, j, "creative destroy"); return; -@@ -165,11 +215,43 @@ +@@ -168,7 +218,19 @@ float f = 1.0F; iblockdata = this.level.getBlockState(blockposition); @@ -107,7 +107,10 @@ + this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + } + } else if (!iblockdata.isAir()) { - iblockdata.attack(this.level, blockposition, this.player); + EnchantmentManager.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EnumItemSlot.MAINHAND, Vec3D.atCenterOf(blockposition), iblockdata, (item) -> { + this.player.onEquippedItemBroken(item, EnumItemSlot.MAINHAND); + }); +@@ -176,6 +238,26 @@ f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition); } @@ -134,7 +137,7 @@ if (!iblockdata.isAir() && f >= 1.0F) { this.destroyAndAck(blockposition, j, "insta mine"); } else { -@@ -214,13 +296,15 @@ +@@ -220,13 +302,15 @@ } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; if (!Objects.equals(this.destroyPos, blockposition)) { @@ -151,7 +154,7 @@ } } -@@ -238,10 +322,65 @@ +@@ -244,10 +328,65 @@ public boolean destroyBlock(BlockPosition blockposition) { IBlockData iblockdata = this.level.getBlockState(blockposition); @@ -218,7 +221,7 @@ TileEntity tileentity = this.level.getBlockEntity(blockposition); Block block = iblockdata.getBlock(); -@@ -251,6 +390,10 @@ +@@ -257,6 +396,10 @@ } else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) { return false; } else { @@ -229,7 +232,7 @@ IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player); boolean flag = this.level.removeBlock(blockposition, false); -@@ -259,19 +402,32 @@ +@@ -265,19 +408,32 @@ } if (this.isCreative()) { @@ -265,7 +268,7 @@ } } } -@@ -309,14 +465,53 @@ +@@ -315,14 +471,53 @@ } } @@ -319,7 +322,7 @@ if (itileinventory != null) { entityplayer.openMenu(itileinventory); -@@ -347,7 +542,7 @@ +@@ -353,7 +548,7 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch b/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch index b77319ec9d..de07819628 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/RegionLimitedWorldAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java -@@ -216,7 +216,7 @@ +@@ -217,7 +217,7 @@ if (iblockdata.isAir()) { return false; } else { @@ -9,7 +9,7 @@ TileEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(blockposition) : null; Block.dropResources(iblockdata, this.level, blockposition, tileentity, entity, ItemStack.EMPTY); -@@ -335,6 +335,13 @@ +@@ -336,6 +336,13 @@ @Override public boolean addFreshEntity(Entity entity) { diff --git a/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch b/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch index 24c2b2c7a5..a83c57b303 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/TicketType.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -23,6 +23,8 @@ +@@ -22,6 +22,8 @@ public static final TicketType PORTAL = create("portal", BaseBlockPosition::compareTo, 300); public static final TicketType POST_TELEPORT = create("post_teleport", Integer::compareTo, 5); public static final TicketType UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1); diff --git a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch index 3c7c308512..2327d7de5c 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java -@@ -170,6 +170,23 @@ +@@ -171,6 +171,23 @@ import net.minecraft.world.ticks.TickListServer; import org.slf4j.Logger; @@ -24,7 +24,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -183,7 +200,7 @@ +@@ -184,7 +201,7 @@ final List players; private final ChunkProviderServer chunkSource; private final MinecraftServer server; @@ -33,7 +33,7 @@ private int lastSpawnChunkRadius; final EntityTickList entityTickList; public final PersistentEntitySectionManager entityManager; -@@ -210,12 +227,30 @@ +@@ -211,12 +228,30 @@ private final boolean tickTime; private final RandomSequences randomSequences; @@ -69,7 +69,7 @@ this.players = Lists.newArrayList(); this.entityTickList = new EntityTickList(); this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); -@@ -230,6 +265,22 @@ +@@ -231,6 +266,22 @@ this.customSpawners = list; this.serverLevelData = iworlddataserver; ChunkGenerator chunkgenerator = worlddimension.generator(); @@ -92,7 +92,7 @@ boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); EntityPersistentStorage entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver); -@@ -257,9 +308,9 @@ +@@ -258,9 +309,9 @@ long l = minecraftserver.getWorldData().worldGenOptions().seed(); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); @@ -105,7 +105,7 @@ } else { this.dragonFight = null; } -@@ -269,6 +320,7 @@ +@@ -270,6 +321,7 @@ this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> { return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences"); }); @@ -113,7 +113,7 @@ } /** @deprecated */ -@@ -313,12 +365,20 @@ +@@ -314,12 +366,20 @@ long j; if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -137,7 +137,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -353,7 +413,7 @@ +@@ -354,7 +414,7 @@ this.handlingTick = false; gameprofilerfiller.pop(); @@ -146,7 +146,7 @@ if (flag1) { this.resetEmptyTime(); -@@ -369,7 +429,7 @@ +@@ -370,7 +430,7 @@ this.entityTickList.forEach((entity) -> { if (!entity.isRemoved()) { @@ -155,7 +155,7 @@ entity.discard(); } else if (!tickratemanager.isEntityFrozen(entity)) { gameprofilerfiller.push("checkDespawn"); -@@ -441,7 +501,7 @@ +@@ -442,7 +502,7 @@ private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); @@ -164,7 +164,7 @@ entityplayer.stopSleepInBed(false, false); }); } -@@ -468,7 +528,7 @@ +@@ -469,7 +529,7 @@ entityhorseskeleton.setTrap(true); entityhorseskeleton.setAge(0); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); @@ -173,7 +173,7 @@ } } -@@ -477,7 +537,7 @@ +@@ -478,7 +538,7 @@ if (entitylightning != null) { entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); entitylightning.setVisualOnly(flag1); @@ -182,7 +182,7 @@ } } } -@@ -533,7 +593,7 @@ +@@ -534,7 +594,7 @@ BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value(); if (biomebase.shouldFreeze(this, blockposition2)) { @@ -191,7 +191,7 @@ } if (this.isRaining()) { -@@ -549,10 +609,10 @@ +@@ -550,10 +610,10 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1); @@ -204,7 +204,7 @@ } } -@@ -713,6 +773,7 @@ +@@ -714,6 +774,7 @@ this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -212,7 +212,7 @@ if (this.oRainLevel != this.rainLevel) { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -731,15 +792,48 @@ +@@ -732,15 +793,48 @@ this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -263,7 +263,7 @@ } public void resetEmptyTime() { -@@ -774,6 +868,7 @@ +@@ -775,6 +869,7 @@ }); gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); @@ -271,7 +271,7 @@ this.getProfiler().pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -797,6 +892,7 @@ +@@ -798,6 +893,7 @@ }); gameprofilerfiller.incrementCounter("tickPassenger"); entity1.rideTick(); @@ -279,7 +279,7 @@ gameprofilerfiller.pop(); Iterator iterator = entity1.getPassengers().iterator(); -@@ -821,6 +917,7 @@ +@@ -822,6 +918,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { @@ -287,7 +287,7 @@ if (iprogressupdate != null) { iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); } -@@ -838,11 +935,19 @@ +@@ -839,11 +936,19 @@ } } @@ -308,7 +308,7 @@ } this.getChunkSource().getDataStorage().save(); -@@ -907,15 +1012,37 @@ +@@ -908,18 +1013,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -335,7 +335,6 @@ } public void addDuringTeleport(Entity entity) { -- this.addEntity(entity); + // CraftBukkit start + // SPIGOT-6415: Don't call spawn event for entities which travel trough worlds, + // since it is only an implementation detail, that a new entity is created when @@ -344,12 +343,16 @@ + } + + public void addDuringTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) { -+ this.addEntity(entity, reason); + // CraftBukkit end - } + if (entity instanceof EntityPlayer entityplayer) { + this.addPlayer(entityplayer); + } else { +- this.addEntity(entity); ++ this.addEntity(entity, reason); // CraftBukkit + } - public void addDuringCommandTeleport(EntityPlayer entityplayer) { -@@ -946,24 +1073,37 @@ + } +@@ -944,24 +1071,37 @@ this.entityManager.addNewEntity(entityplayer); } @@ -391,14 +394,14 @@ return true; } } -@@ -974,13 +1114,35 @@ +@@ -972,13 +1112,35 @@ } public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) { - entityplayer.remove(entity_removalreason); + entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause -+ } -+ + } + + // CraftBukkit start + public boolean strikeLightning(Entity entitylightning) { + return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN); @@ -412,9 +415,9 @@ + } + + return this.addFreshEntity(entitylightning); - } ++ } + // CraftBukkit end - ++ @Override public void destroyBlockProgress(int i, BlockPosition blockposition, int j) { Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); @@ -428,7 +431,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -989,6 +1151,12 @@ +@@ -987,6 +1149,12 @@ double d1 = (double) blockposition.getY() - entityplayer.getY(); double d2 = (double) blockposition.getZ() - entityplayer.getZ(); @@ -441,7 +444,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -1049,7 +1217,18 @@ +@@ -1047,7 +1215,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -461,7 +464,7 @@ NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(blockposition)) { -@@ -1111,6 +1290,11 @@ +@@ -1109,6 +1288,11 @@ @Override public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder holder) { Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false, particleparam, particleparam1, holder); @@ -473,7 +476,7 @@ if (!explosion.interactsWithBlocks()) { explosion.clearToBlow(); -@@ -1183,13 +1367,20 @@ +@@ -1181,13 +1365,20 @@ } public int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -496,7 +499,7 @@ ++j; } } -@@ -1240,7 +1431,7 @@ +@@ -1238,7 +1429,7 @@ @Nullable public BlockPosition findNearestMapStructure(TagKey tagkey, BlockPosition blockposition, int i, boolean flag) { @@ -505,7 +508,7 @@ return null; } else { Optional> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey); -@@ -1282,11 +1473,22 @@ +@@ -1280,11 +1471,22 @@ @Nullable @Override public WorldMap getMapData(MapId mapid) { @@ -529,7 +532,7 @@ this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap); } -@@ -1597,6 +1799,11 @@ +@@ -1595,6 +1797,11 @@ @Override public void blockUpdated(BlockPosition blockposition, Block block) { if (!this.isDebug()) { @@ -541,7 +544,7 @@ this.updateNeighborsAt(blockposition, block); } -@@ -1616,12 +1823,12 @@ +@@ -1614,12 +1821,12 @@ } public boolean isFlat() { @@ -556,7 +559,7 @@ } @Nullable -@@ -1644,7 +1851,7 @@ +@@ -1642,7 +1849,7 @@ private static String getTypeCount(Iterable iterable, Function function) { try { Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); @@ -565,7 +568,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1653,7 +1860,7 @@ +@@ -1651,7 +1858,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -574,43 +577,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1664,17 +1871,33 @@ - } - - public static void makeObsidianPlatform(WorldServer worldserver) { -+ // CraftBukkit start -+ WorldServer.makeObsidianPlatform(worldserver, null); -+ } -+ -+ public static void makeObsidianPlatform(WorldServer worldserver, Entity entity) { -+ // CraftBukkit end - BlockPosition blockposition = WorldServer.END_SPAWN_POINT; - int i = blockposition.getX(); - int j = blockposition.getY() - 2; - int k = blockposition.getZ(); - -+ // CraftBukkit start -+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver); - BlockPosition.betweenClosed(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> { -- worldserver.setBlockAndUpdate(blockposition1, Blocks.AIR.defaultBlockState()); -+ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); - }); - BlockPosition.betweenClosed(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> { -- worldserver.setBlockAndUpdate(blockposition1, Blocks.OBSIDIAN.defaultBlockState()); -+ blockList.setBlock(blockposition1, Blocks.OBSIDIAN.defaultBlockState(), 3); - }); -+ org.bukkit.World bworld = worldserver.getWorld(); -+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); -+ -+ worldserver.getCraftServer().getPluginManager().callEvent(portalEvent); -+ if (!portalEvent.isCancelled()) { -+ blockList.updateList(); -+ } -+ // CraftBukkit end - } - - @Override -@@ -1812,6 +2035,8 @@ +@@ -1796,6 +2003,8 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -619,7 +586,7 @@ } public void onTrackingEnd(Entity entity) { -@@ -1843,6 +2068,14 @@ +@@ -1827,6 +2036,14 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); diff --git a/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch b/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch index 8f128db0c0..3b369126f9 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/HandshakeListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/HandshakeListener.java +++ b/net/minecraft/server/network/HandshakeListener.java -@@ -12,8 +12,17 @@ +@@ -13,8 +13,17 @@ import net.minecraft.network.protocol.status.StatusProtocols; import net.minecraft.server.MinecraftServer; @@ -18,7 +18,7 @@ private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.translatable("disconnect.ignoring_status_request"); private final MinecraftServer server; private final NetworkManager connection; -@@ -25,6 +34,7 @@ +@@ -26,6 +35,7 @@ @Override public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) { @@ -26,7 +26,7 @@ switch (packethandshakinginsetprotocol.intention()) { case LOGIN: this.beginLogin(packethandshakinginsetprotocol, false); -@@ -58,6 +68,40 @@ +@@ -59,6 +69,40 @@ private void beginLogin(PacketHandshakingInSetProtocol packethandshakinginsetprotocol, boolean flag) { this.connection.setupOutboundProtocol(LoginProtocols.CLIENTBOUND); diff --git a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch index 221bc4aacd..61bec582f4 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/LoginListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/LoginListener.java +++ b/net/minecraft/server/network/LoginListener.java -@@ -42,8 +42,33 @@ +@@ -44,8 +44,33 @@ import org.apache.commons.lang3.Validate; import org.slf4j.Logger; @@ -35,7 +35,7 @@ private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); static final Logger LOGGER = LogUtils.getLogger(); private static final int MAX_TICKS_BEFORE_LOGIN = 600; -@@ -58,6 +83,7 @@ +@@ -60,6 +85,7 @@ private GameProfile authenticatedProfile; private final String serverId; private final boolean transferred; @@ -43,7 +43,7 @@ public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager, boolean flag) { this.state = LoginListener.EnumProtocolState.HELLO; -@@ -74,6 +100,12 @@ +@@ -76,6 +102,12 @@ this.verifyLoginAndFinishConnectionSetup((GameProfile) Objects.requireNonNull(this.authenticatedProfile)); } @@ -56,7 +56,7 @@ if (this.state == LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT && !this.isPlayerAlreadyInWorld((GameProfile) Objects.requireNonNull(this.authenticatedProfile))) { this.finishLoginAndWaitForClient(this.authenticatedProfile); } -@@ -84,6 +116,13 @@ +@@ -86,6 +118,13 @@ } @@ -70,7 +70,7 @@ @Override public boolean isAcceptingMessages() { return this.connection.isConnected(); -@@ -129,7 +168,27 @@ +@@ -131,7 +170,27 @@ this.state = LoginListener.EnumProtocolState.KEY; this.connection.send(new PacketLoginOutEncryptionBegin("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true)); } else { @@ -99,7 +99,7 @@ } } -@@ -142,10 +201,24 @@ +@@ -144,10 +203,24 @@ private void verifyLoginAndFinishConnectionSetup(GameProfile gameprofile) { PlayerList playerlist = this.server.getPlayerList(); @@ -127,7 +127,7 @@ } else { if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) { this.connection.send(new PacketLoginOutSetCompression(this.server.getCompressionThreshold()), PacketSendListener.thenRun(() -> { -@@ -153,7 +226,7 @@ +@@ -155,7 +228,7 @@ })); } @@ -136,7 +136,7 @@ if (flag) { this.state = LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT; -@@ -203,6 +276,12 @@ +@@ -205,6 +278,12 @@ if (profileresult != null) { GameProfile gameprofile = profileresult.profile(); @@ -149,7 +149,7 @@ LoginListener.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId()); LoginListener.this.startClientVerification(gameprofile); } else if (LoginListener.this.server.isSingleplayer()) { -@@ -220,6 +299,11 @@ +@@ -222,6 +301,11 @@ LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down")); LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable"); } @@ -161,7 +161,7 @@ } } -@@ -236,6 +320,43 @@ +@@ -238,6 +322,43 @@ thread.start(); } @@ -205,7 +205,11 @@ @Override public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket serverboundcustomqueryanswerpacket) { this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); -@@ -246,7 +367,7 @@ +@@ -245,10 +366,11 @@ + + @Override + public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket serverboundloginacknowledgedpacket) { ++ PlayerConnectionUtils.ensureRunningOnSameThread(serverboundloginacknowledgedpacket, this, this.server); // CraftBukkit Validate.validState(this.state == LoginListener.EnumProtocolState.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", new Object[0]); this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); CommonListenerCookie commonlistenercookie = CommonListenerCookie.createInitial((GameProfile) Objects.requireNonNull(this.authenticatedProfile), this.transferred); @@ -214,7 +218,7 @@ this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, serverconfigurationpacketlistenerimpl); serverconfigurationpacketlistenerimpl.startConfiguration(); -@@ -262,12 +383,18 @@ +@@ -264,12 +386,18 @@ @Override public void handleCookieResponse(ServerboundCookieResponsePacket serverboundcookieresponsepacket) { diff --git a/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch b/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch index 49073b4376..5646849f6a 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/PacketStatusListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/PacketStatusListener.java +++ b/net/minecraft/server/network/PacketStatusListener.java -@@ -9,6 +9,21 @@ +@@ -10,6 +10,21 @@ import net.minecraft.network.protocol.status.PacketStatusOutServerInfo; import net.minecraft.network.protocol.status.ServerPing; @@ -22,7 +22,7 @@ public class PacketStatusListener implements PacketStatusInListener { private static final IChatBaseComponent DISCONNECT_REASON = IChatBaseComponent.translatable("multiplayer.status.request_handled"); -@@ -35,7 +50,101 @@ +@@ -36,7 +51,101 @@ this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON); } else { this.hasRequestedStatus = true; diff --git a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch index fe32b0f84a..5373c1dec4 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java -@@ -190,6 +190,67 @@ +@@ -191,6 +191,67 @@ import net.minecraft.world.phys.shapes.VoxelShapes; import org.slf4j.Logger; @@ -68,7 +68,7 @@ public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener { static final Logger LOGGER = LogUtils.getLogger(); -@@ -203,7 +264,9 @@ +@@ -204,7 +265,9 @@ public final PlayerChunkSender chunkSender; private int tickCount; private int ackBlockChangesUpTo = -1; @@ -79,7 +79,7 @@ private int dropSpamTickCount; private double firstGoodX; private double firstGoodY; -@@ -238,7 +301,7 @@ +@@ -239,7 +302,7 @@ private boolean waitingForSwitchToConfig; public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) { @@ -88,7 +88,7 @@ this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection()); this.player = entityplayer; entityplayer.connection = this; -@@ -247,9 +310,25 @@ +@@ -248,9 +311,25 @@ Objects.requireNonNull(minecraftserver); this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile); @@ -115,7 +115,7 @@ @Override public void tick() { if (this.ackBlockChangesUpTo > -1) { -@@ -301,15 +380,21 @@ +@@ -302,15 +381,21 @@ } this.keepConnectionAlive(); @@ -134,10 +134,10 @@ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { + this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 - this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling")); + this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling")); } -@@ -398,6 +483,13 @@ +@@ -399,6 +484,13 @@ if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { WorldServer worldserver = this.player.serverLevel(); @@ -151,7 +151,7 @@ double d0 = entity.getX(); double d1 = entity.getY(); double d2 = entity.getZ(); -@@ -412,7 +504,33 @@ +@@ -413,7 +505,33 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -186,7 +186,7 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -452,14 +570,76 @@ +@@ -453,14 +571,76 @@ } entity.absMoveTo(d3, d4, d5, f, f1); @@ -261,9 +261,9 @@ + // CraftBukkit end + this.player.serverLevel().getChunkSource().move(this.player); - this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); - this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); -@@ -493,6 +673,7 @@ + Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2); + +@@ -497,6 +677,7 @@ } this.awaitingPositionFromClient = null; @@ -271,7 +271,7 @@ } } -@@ -500,7 +681,7 @@ +@@ -504,7 +685,7 @@ @Override public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel()); @@ -280,7 +280,7 @@ RecipeBookServer recipebookserver = this.player.getRecipeBook(); Objects.requireNonNull(recipebookserver); -@@ -510,6 +691,7 @@ +@@ -514,6 +695,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel()); @@ -288,7 +288,7 @@ this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering()); } -@@ -530,6 +712,12 @@ +@@ -534,6 +716,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel()); @@ -301,7 +301,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -539,6 +727,7 @@ +@@ -543,6 +731,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -309,7 +309,7 @@ Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000)); this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1)); -@@ -783,6 +972,13 @@ +@@ -787,6 +976,13 @@ Container container = this.player.containerMenu; if (container instanceof ContainerMerchant containermerchant) { @@ -323,13 +323,13 @@ if (!containermerchant.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); return; -@@ -796,6 +992,13 @@ +@@ -800,6 +996,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { + // CraftBukkit start + if (this.lastBookTick + 20 > MinecraftServer.currentTick) { -+ this.disconnect("Book edited too quickly!"); ++ this.disconnect(IChatBaseComponent.literal("Book edited too quickly!")); + return; + } + this.lastBookTick = MinecraftServer.currentTick; @@ -337,7 +337,7 @@ int i = packetplayinbedit.slot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -804,7 +1007,7 @@ +@@ -808,7 +1011,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); @@ -346,7 +346,7 @@ Objects.requireNonNull(list); stream.forEach(list::add); -@@ -819,12 +1022,16 @@ +@@ -823,12 +1026,16 @@ } private void updateBookContents(List list, int i) { @@ -364,8 +364,8 @@ } } -@@ -835,12 +1042,13 @@ - ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK, 1); +@@ -839,12 +1046,13 @@ + ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK); itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT); - List> list1 = list.stream().map((filteredtext1) -> { @@ -380,7 +380,7 @@ } } -@@ -902,7 +1110,7 @@ +@@ -906,7 +1114,7 @@ } else { WorldServer worldserver = this.player.serverLevel(); @@ -389,15 +389,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -912,6 +1120,7 @@ - this.awaitingTeleportTime = this.tickCount; - this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); - } -+ this.allowedPlayerTicks = 20; // CraftBukkit - - } else { - this.awaitingTeleportTime = this.tickCount; -@@ -924,7 +1133,15 @@ +@@ -921,7 +1129,15 @@ if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.serverLevel().getChunkSource().move(this.player); @@ -413,7 +405,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -946,15 +1163,33 @@ +@@ -943,15 +1159,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -449,7 +441,7 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -976,6 +1211,7 @@ +@@ -973,6 +1207,7 @@ boolean flag2 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8)); @@ -457,7 +449,7 @@ double d11 = d7; d6 = d0 - this.player.getX(); -@@ -994,9 +1230,75 @@ +@@ -991,9 +1226,75 @@ } if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { @@ -534,7 +526,15 @@ this.player.absMoveTo(d0, d1, d2, f, f1); boolean flag4 = this.player.isAutoSpinAttack(); -@@ -1043,11 +1345,68 @@ +@@ -1030,6 +1331,7 @@ + this.awaitingTeleportTime = this.tickCount; + this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); + } ++ this.allowedPlayerTicks = 20; // CraftBukkit + + return true; + } else { +@@ -1057,11 +1359,68 @@ return true; } @@ -544,8 +544,8 @@ + this.teleport(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + -+ public void teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { -+ this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause); ++ public boolean teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { ++ return this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause); } public void teleport(double d0, double d1, double d2, float f, float f1, Set set) { @@ -604,7 +604,7 @@ double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D; double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D; double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D; -@@ -1059,6 +1418,14 @@ +@@ -1073,6 +1432,14 @@ this.awaitingTeleport = 0; } @@ -617,9 +617,9 @@ + // CraftBukkit end + this.awaitingTeleportTime = this.tickCount; - this.player.resetCurrentImpulseContext(); this.player.absMoveTo(d0, d1, d2, f, f1); -@@ -1068,6 +1435,7 @@ + this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport)); +@@ -1081,6 +1448,7 @@ @Override public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel()); @@ -627,7 +627,7 @@ BlockPosition blockposition = packetplayinblockdig.getPos(); this.player.resetLastActionTime(); -@@ -1078,14 +1446,46 @@ +@@ -1091,14 +1459,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -668,7 +668,7 @@ + this.dropCount++; + if (this.dropCount >= 20) { + LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!"); -+ this.disconnect("You dropped your items too quickly (Hacking?)"); ++ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)")); + return; + } + } @@ -676,7 +676,7 @@ this.player.drop(false); } -@@ -1123,6 +1523,7 @@ +@@ -1136,6 +1536,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel()); @@ -684,7 +684,7 @@ this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); WorldServer worldserver = this.player.serverLevel(); EnumHand enumhand = packetplayinuseitem.getHand(); -@@ -1145,6 +1546,7 @@ +@@ -1158,6 +1559,7 @@ if (blockposition.getY() < i) { if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) { @@ -692,7 +692,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); if (enuminteractionresult.consumesAction()) { -@@ -1177,6 +1579,7 @@ +@@ -1190,6 +1592,7 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel()); @@ -700,21 +700,19 @@ this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); WorldServer worldserver = this.player.serverLevel(); EnumHand enumhand = packetplayinblockplace.getHand(); -@@ -1184,6 +1587,49 @@ +@@ -1204,6 +1607,47 @@ + this.player.absRotateTo(f, f1); + } - this.player.resetLastActionTime(); - if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) { + // CraftBukkit start + // Raytrace to look for 'rogue armswings' -+ float f1 = this.player.getXRot(); -+ float f2 = this.player.getYRot(); + double d0 = this.player.getX(); + double d1 = this.player.getY() + (double) this.player.getEyeHeight(); + double d2 = this.player.getZ(); + Vec3D vec3d = new Vec3D(d0, d1, d2); + -+ float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); -+ float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); ++ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F); ++ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; @@ -750,7 +748,7 @@ EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.shouldSwing()) { -@@ -1204,7 +1650,7 @@ +@@ -1224,7 +1668,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { @@ -759,10 +757,10 @@ return; } } -@@ -1225,6 +1671,13 @@ +@@ -1245,6 +1689,13 @@ @Override - public void onDisconnect(IChatBaseComponent ichatbasecomponent) { + public void onDisconnect(DisconnectionDetails disconnectiondetails) { + // CraftBukkit start - Rarely it would send a disconnect line twice + if (this.processedDisconnect) { + return; @@ -770,10 +768,10 @@ + this.processedDisconnect = true; + } + // CraftBukkit end - PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), ichatbasecomponent.getString()); + PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString()); this.removePlayerFromWorld(); - super.onDisconnect(ichatbasecomponent); -@@ -1232,10 +1685,18 @@ + super.onDisconnect(disconnectiondetails); +@@ -1252,10 +1703,18 @@ private void removePlayerFromWorld() { this.chatMessageChain.close(); @@ -793,7 +791,7 @@ this.player.getTextFilter().leave(); } -@@ -1250,7 +1711,16 @@ +@@ -1270,7 +1729,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel()); @@ -810,11 +808,11 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1259,11 +1729,18 @@ +@@ -1279,11 +1747,18 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); -+ this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit ++ this.disconnect(IChatBaseComponent.literal("Invalid hotbar selection (Hacking?)")); // CraftBukkit } } @@ -829,7 +827,7 @@ Optional optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages()); if (!optional.isEmpty()) { -@@ -1277,7 +1754,7 @@ +@@ -1297,7 +1772,7 @@ return; } @@ -838,7 +836,7 @@ IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent()); this.chatMessageChain.append(completablefuture, (filteredtext) -> { -@@ -1285,19 +1762,36 @@ +@@ -1305,19 +1780,36 @@ this.broadcastChatMessage(playerchatmessage1); }); @@ -877,7 +875,7 @@ ParseResults parseresults = this.parseCommand(s); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) { -@@ -1314,19 +1808,37 @@ +@@ -1334,19 +1826,37 @@ if (!optional.isEmpty()) { this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> { @@ -918,7 +916,7 @@ } catch (SignedMessageChain.a signedmessagechain_a) { this.handleMessageDecodeFailure(signedmessagechain_a); return; -@@ -1334,10 +1846,10 @@ +@@ -1354,10 +1864,10 @@ CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); @@ -931,14 +929,14 @@ } private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { -@@ -1413,14 +1925,20 @@ +@@ -1433,14 +1943,20 @@ return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack()); } - private void tryHandleChat(String s, Runnable runnable) { + private void tryHandleChat(String s, Runnable runnable, boolean sync) { // CraftBukkit if (isChatMessageIllegal(s)) { - this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters")); + this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters")); - } else if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { + } else if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false)); @@ -955,7 +953,7 @@ } } -@@ -1449,6 +1967,116 @@ +@@ -1469,6 +1985,116 @@ return false; } @@ -1072,7 +1070,7 @@ private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); -@@ -1456,13 +2084,33 @@ +@@ -1476,13 +2102,33 @@ } private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { @@ -1101,15 +1099,15 @@ private void detectRateSpam() { - this.chatSpamTickCount += 20; -- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { +- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { + // CraftBukkit start - replaced with thread safe throttle + // this.chatSpamTickCount += 20; -+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { ++ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { + // CraftBukkit end - this.disconnect(IChatBaseComponent.translatable("disconnect.spam")); + this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam")); } -@@ -1484,13 +2132,62 @@ +@@ -1504,13 +2150,62 @@ @Override public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel()); @@ -1172,7 +1170,7 @@ this.player.resetLastActionTime(); Entity entity; -@@ -1567,6 +2264,12 @@ +@@ -1587,6 +2282,12 @@ } public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) { @@ -1185,7 +1183,7 @@ this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a)); this.addPendingMessage(playerchatmessage); } -@@ -1594,6 +2297,7 @@ +@@ -1614,6 +2315,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel()); @@ -1193,7 +1191,7 @@ final WorldServer worldserver = this.player.serverLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1608,13 +2312,51 @@ +@@ -1628,13 +2330,51 @@ if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { @@ -1212,7 +1210,7 @@ + + // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a + if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { -+ send(new PacketPlayOutSpawnEntity(entity)); ++ entity.getBukkitEntity().update(player); + player.containerMenu.sendAllDataToRemote(); + } + @@ -1246,7 +1244,7 @@ if (enuminteractionresult.consumesAction()) { CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, enuminteractionresult.indicateItemUse() ? itemstack1 : ItemStack.EMPTY, entity); if (enuminteractionresult.shouldSwing()) { -@@ -1627,19 +2369,20 @@ +@@ -1647,19 +2387,20 @@ @Override public void onInteraction(EnumHand enumhand) { @@ -1270,7 +1268,7 @@ label23: { if (entity instanceof EntityArrow) { -@@ -1657,6 +2400,11 @@ +@@ -1677,6 +2418,11 @@ } PlayerConnection.this.player.attack(entity); @@ -1282,20 +1280,20 @@ return; } } -@@ -1680,17 +2428,17 @@ +@@ -1700,17 +2446,17 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; -- this.player = this.server.getPlayerList().respawn(this.player, true); -+ this.player = this.server.getPlayerList().respawn(this.player, true, RespawnReason.END_PORTAL); +- 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 CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD); } else { if (this.player.getHealth() > 0.0F) { return; } -- this.player = this.server.getPlayerList().respawn(this.player, false); -+ this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH); +- 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 if (this.server.isHardcore()) { this.player.setGameMode(EnumGamemode.SPECTATOR); - ((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); @@ -1303,7 +1301,7 @@ } } break; -@@ -1703,15 +2451,21 @@ +@@ -1723,15 +2469,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel()); @@ -1327,7 +1325,7 @@ this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1724,7 +2478,284 @@ +@@ -1744,7 +2496,284 @@ boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -1613,7 +1611,7 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1754,9 +2785,18 @@ +@@ -1774,9 +2803,18 @@ if (!this.player.containerMenu.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); } else { @@ -1634,7 +1632,7 @@ } } } -@@ -1764,6 +2804,7 @@ +@@ -1784,6 +2822,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel()); @@ -1642,7 +1640,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1806,6 +2847,43 @@ +@@ -1826,6 +2865,43 @@ boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); @@ -1686,7 +1684,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack); -@@ -1828,6 +2906,7 @@ +@@ -1848,6 +2924,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1694,7 +1692,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.serverLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1849,7 +2928,17 @@ +@@ -1869,7 +2946,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel()); @@ -1713,7 +1711,7 @@ } @Override -@@ -1908,7 +2997,7 @@ +@@ -1928,7 +3015,7 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -1722,7 +1720,7 @@ } } -@@ -1933,8 +3022,10 @@ +@@ -1953,8 +3040,10 @@ }); } diff --git a/paper-server/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch b/paper-server/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch index b48df01115..68f3427397 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -27,8 +27,39 @@ +@@ -28,8 +28,39 @@ import net.minecraft.util.thread.IAsyncTaskHandler; import org.slf4j.Logger; @@ -20,14 +20,14 @@ +import org.bukkit.craftbukkit.util.Waitable; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent; -+ + +public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection { + + @Override + public boolean isTransferred() { + return this.transferred; + } - ++ + @Override + public EnumProtocol getProtocol() { + return protocol(); @@ -41,7 +41,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final int LATENCY_CHECK_INTERVAL = 15000; private static final int CLOSED_LISTENER_TIMEOUT = 15000; -@@ -45,12 +76,24 @@ +@@ -46,12 +77,24 @@ private int latency; private volatile boolean suspendFlushingOnServerThread = false; @@ -67,7 +67,7 @@ } private void close() { -@@ -72,6 +115,7 @@ +@@ -73,6 +116,7 @@ @Override public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) { @@ -75,13 +75,13 @@ if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) { int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); -@@ -86,8 +130,56 @@ +@@ -87,8 +131,56 @@ @Override public void handlePong(ServerboundPongPacket serverboundpongpacket) {} + // CraftBukkit start -+ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register"); -+ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister"); ++ private static final MinecraftKey CUSTOM_REGISTER = MinecraftKey.withDefaultNamespace("register"); ++ private static final MinecraftKey CUSTOM_UNREGISTER = MinecraftKey.withDefaultNamespace("unregister"); + @Override - public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {} @@ -101,7 +101,7 @@ + } + } catch (Exception ex) { + PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex); -+ this.disconnect("Invalid payload REGISTER!"); ++ this.disconnect(IChatBaseComponent.literal("Invalid payload REGISTER!")); + } + } else if (identifier.equals(CUSTOM_UNREGISTER)) { + try { @@ -111,7 +111,7 @@ + } + } catch (Exception ex) { + PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex); -+ this.disconnect("Invalid payload UNREGISTER!"); ++ this.disconnect(IChatBaseComponent.literal("Invalid payload UNREGISTER!")); + } + } else { + try { @@ -120,7 +120,7 @@ + cserver.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), identifier.toString(), data); + } catch (Exception ex) { + PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex); -+ this.disconnect("Invalid custom payload!"); ++ this.disconnect(IChatBaseComponent.literal("Invalid custom payload!")); + } + } + @@ -133,9 +133,9 @@ @Override public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) { -@@ -96,11 +188,18 @@ +@@ -97,11 +189,18 @@ ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), serverboundresourcepackpacket.id()); - this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect")); + this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect")); } + this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), serverboundresourcepackpacket.id(), PlayerResourcePackStatusEvent.Status.values()[serverboundresourcepackpacket.action().ordinal()])); // CraftBukkit @@ -152,7 +152,7 @@ this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); } -@@ -108,7 +207,7 @@ +@@ -109,7 +208,7 @@ this.server.getProfiler().push("keepAlive"); long i = SystemUtils.getMillis(); @@ -161,7 +161,7 @@ if (this.keepAlivePending) { this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE); } else if (this.checkIfClosed(i)) { -@@ -148,6 +247,14 @@ +@@ -149,6 +248,14 @@ } public void send(Packet packet, @Nullable PacketSendListener packetsendlistener) { @@ -176,18 +176,10 @@ if (packet.isTerminal()) { this.close(); } -@@ -167,16 +274,67 @@ - } +@@ -173,15 +280,61 @@ } -+ // CraftBukkit start -+ @Deprecated - public void disconnect(IChatBaseComponent ichatbasecomponent) { -+ disconnect(CraftChatMessage.fromComponent(ichatbasecomponent)); -+ } -+ // CraftBukkit end -+ -+ public void disconnect(String s) { + public void disconnect(DisconnectionDetails disconnectiondetails) { + // CraftBukkit start - fire PlayerKickEvent + if (this.processedDisconnect) { + return; @@ -196,7 +188,7 @@ + Waitable waitable = new Waitable() { + @Override + protected Object evaluate() { -+ ServerCommonPacketListenerImpl.this.disconnect(s); ++ ServerCommonPacketListenerImpl.this.disconnect(disconnectiondetails); + return null; + } + }; @@ -215,7 +207,7 @@ + + String leaveMessage = EnumChatFormat.YELLOW + this.player.getScoreboardName() + " left the game."; + -+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage); ++ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), CraftChatMessage.fromComponent(disconnectiondetails.reason()), leaveMessage); + + if (this.cserver.getServer().isRunning()) { + this.cserver.getPluginManager().callEvent(event); @@ -227,13 +219,15 @@ + } + this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent + // Send the possibly modified leave message -+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0]; -+ // CraftBukkit end ++ disconnect0(new DisconnectionDetails(CraftChatMessage.fromString(event.getReason(), true)[0], disconnectiondetails.report(), disconnectiondetails.bugReportLink())); ++ } + - this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), PacketSendListener.thenRun(() -> { - this.connection.disconnect(ichatbasecomponent); ++ private void disconnect0(DisconnectionDetails disconnectiondetails) { ++ // CraftBukkit end + this.connection.send(new ClientboundDisconnectPacket(disconnectiondetails.reason()), PacketSendListener.thenRun(() -> { + this.connection.disconnect(disconnectiondetails); })); -+ this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly ++ this.onDisconnect(disconnectiondetails); // CraftBukkit - fire quit instantly this.connection.setReadOnly(); MinecraftServer minecraftserver = this.server; NetworkManager networkmanager = this.connection; diff --git a/paper-server/nms-patches/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.patch b/paper-server/nms-patches/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.patch index 0764b9370f..07e664c9eb 100644 --- a/paper-server/nms-patches/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.patch +++ b/paper-server/nms-patches/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.patch @@ -1,6 +1,18 @@ --- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -47,8 +47,10 @@ +@@ -38,6 +38,11 @@ + import net.minecraft.world.flag.FeatureFlags; + import org.slf4j.Logger; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.CraftServerLinks; ++import org.bukkit.event.player.PlayerLinksSendEvent; ++// CraftBukkit end ++ + public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerConfigurationPacketListener, TickablePacketListener { + + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -50,8 +55,10 @@ @Nullable private SynchronizeRegistriesTask synchronizeRegistriesTask; @@ -13,7 +25,20 @@ this.gameProfile = commonlistenercookie.gameProfile(); this.clientInformation = commonlistenercookie.clientInformation(); } -@@ -134,14 +136,14 @@ +@@ -75,6 +82,12 @@ + public void startConfiguration() { + this.send(new ClientboundCustomPayloadPacket(new BrandPayload(this.server.getServerModName()))); + ServerLinks serverlinks = this.server.serverLinks(); ++ // CraftBukkit start ++ CraftServerLinks wrapper = new CraftServerLinks(serverlinks); ++ PlayerLinksSendEvent event = new PlayerLinksSendEvent(player.getBukkitEntity(), wrapper); ++ player.getBukkitEntity().getServer().getPluginManager().callEvent(event); ++ serverlinks = wrapper.getServerLinks(); ++ // CraftBukkit end + + if (!serverlinks.isEmpty()) { + this.send(new ClientboundServerLinksPacket(serverlinks.untrust())); +@@ -143,14 +156,14 @@ return; } diff --git a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch index fa5b7652ed..da2910eb70 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -127,7 +127,7 @@ + entityplayer.loadGameTypes((NBTTagCompound) optional.orElse(null)); // CraftBukkit - decompile error PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer, commonlistenercookie); - networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection); + networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection); @@ -194,6 +237,7 @@ boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING); @@ -148,7 +148,7 @@ playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); ServerPing serverping = this.server.getStatus(); -@@ -219,13 +265,64 @@ +@@ -219,18 +265,70 @@ entityplayer.sendServerStatus(serverping); } @@ -214,11 +214,7 @@ + + worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it + // CraftBukkit end - Iterator iterator = entityplayer.getActiveEffects().iterator(); - - while (iterator.hasNext()) { -@@ -236,8 +333,9 @@ - + this.sendActivePlayerEffects(entityplayer); if (optional.isPresent() && ((NBTTagCompound) optional.get()).contains("RootVehicle", 10)) { NBTTagCompound nbttagcompound = ((NBTTagCompound) optional.get()).getCompound("RootVehicle"); + WorldServer finalWorldServer = worldserver1; // CraftBukkit - decompile error @@ -228,16 +224,16 @@ }); if (entity != null) { -@@ -268,18 +366,20 @@ +@@ -261,18 +359,20 @@ if (!entityplayer.isPassenger()) { PlayerList.LOGGER.warn("Couldn't reattach entity to player"); - entity.discard(); + entity.discard(null); // CraftBukkit - add Bukkit remove cause - iterator1 = entity.getIndirectPassengers().iterator(); + iterator = entity.getIndirectPassengers().iterator(); - while (iterator1.hasNext()) { - entity1 = (Entity) iterator1.next(); + while (iterator.hasNext()) { + entity1 = (Entity) iterator.next(); - entity1.discard(); + entity1.discard(null); // CraftBukkit - add Bukkit remove cause } @@ -251,7 +247,7 @@ } public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -316,30 +416,31 @@ +@@ -309,30 +409,31 @@ } public void addWorldborderListener(WorldServer worldserver) { @@ -288,7 +284,7 @@ } @Override -@@ -366,14 +467,15 @@ +@@ -359,14 +460,15 @@ } protected void save(EntityPlayer entityplayer) { @@ -306,7 +302,7 @@ if (advancementdataplayer != null) { advancementdataplayer.save(); -@@ -381,10 +483,24 @@ +@@ -374,10 +476,24 @@ } @@ -332,7 +328,7 @@ this.save(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -393,7 +509,7 @@ +@@ -386,7 +502,7 @@ PlayerList.LOGGER.debug("Removing player mount"); entityplayer.stopRiding(); entity.getPassengersAndSelf().forEach((entity1) -> { @@ -341,7 +337,7 @@ }); } } -@@ -408,17 +524,66 @@ +@@ -401,17 +517,66 @@ if (entityplayer1 == entityplayer) { this.playersByUUID.remove(uuid); @@ -413,7 +409,7 @@ if (this.bans.isBanned(gameprofile)) { GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); -@@ -427,9 +592,11 @@ +@@ -420,9 +585,11 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires()))); } @@ -427,7 +423,7 @@ } else if (this.ipBans.isBanned(socketaddress)) { IpBanEntry ipbanentry = this.ipBans.get(socketaddress); -@@ -438,17 +605,32 @@ +@@ -431,17 +598,32 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires()))); } @@ -465,7 +461,7 @@ UUID uuid = gameprofile.getId(); Set set = Sets.newIdentityHashSet(); Iterator iterator = this.players.iterator(); -@@ -476,14 +658,24 @@ +@@ -469,22 +651,41 @@ } return !set.isEmpty(); @@ -474,142 +470,96 @@ + // CraftBukkit end } -- public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag) { +- public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason) { + // CraftBukkit start -+ public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, RespawnReason reason) { -+ return this.respawn(entityplayer, this.server.getLevel(entityplayer.getRespawnDimension()), flag, null, true, reason); ++ public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason, RespawnReason reason) { ++ return this.respawn(entityplayer, flag, entity_removalreason, reason, null); + } + -+ public EntityPlayer respawn(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason) { ++ public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason, RespawnReason reason, Location location) { + entityplayer.stopRiding(); // CraftBukkit this.players.remove(entityplayer); - entityplayer.serverLevel().removePlayerImmediately(entityplayer, Entity.RemovalReason.DISCARDED); - BlockPosition blockposition = entityplayer.getRespawnPosition(); - float f = entityplayer.getRespawnAngle(); - boolean flag1 = entityplayer.isRespawnForced(); + entityplayer.serverLevel().removePlayerImmediately(entityplayer, entity_removalreason); + /* CraftBukkit start - WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension()); - Optional optional; - -@@ -495,6 +687,11 @@ - - WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld(); - EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile(), entityplayer.clientInformation()); + DimensionTransition dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING); + WorldServer worldserver = dimensiontransition.newLevel(); + EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver, entityplayer.getGameProfile(), entityplayer.clientInformation()); + // */ + EntityPlayer entityplayer1 = entityplayer; -+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld(); ++ World fromWorld = entityplayer.level(); + entityplayer.wonGame = false; + // CraftBukkit end entityplayer1.connection = entityplayer.connection; entityplayer1.restoreFrom(entityplayer, flag); -@@ -510,28 +707,66 @@ + entityplayer1.setId(entityplayer.getId()); + entityplayer1.setMainArm(entityplayer.getMainArm()); ++ // CraftBukkit - not required, just copies old location into reused entity ++ /* + if (!dimensiontransition.missingRespawnBlock()) { + entityplayer1.copyRespawnPosition(entityplayer); + } ++ */ ++ // CraftBukkit end - boolean flag2 = false; + Iterator iterator = entityplayer.getTags().iterator(); + +@@ -494,11 +695,26 @@ + entityplayer1.addTag(s); + } -- if (optional.isPresent()) { -- IBlockData iblockdata = worldserver1.getBlockState(blockposition); -- boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR); -- Vec3D vec3d = (Vec3D) optional.get(); -- float f1; + // CraftBukkit start - fire PlayerRespawnEvent ++ DimensionTransition dimensiontransition; + if (location == null) { -+ boolean isBedSpawn = false; -+ WorldServer worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension()); -+ if (worldserver1 != null) { -+ Optional optional; - -- if (!iblockdata.is(TagsBlock.BEDS) && !flag3) { -- f1 = f; -- } else { -- Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); -+ if (blockposition != null) { -+ optional = EntityHuman.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, flag); -+ } else { -+ optional = Optional.empty(); -+ } - -- f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); -+ if (optional.isPresent()) { -+ IBlockData iblockdata = worldserver1.getBlockState(blockposition); -+ boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR); -+ Vec3D vec3d = (Vec3D) optional.get(); -+ float f1; ++ dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING, reason); + -+ if (!iblockdata.is(TagsBlock.BEDS) && !flag3) { -+ f1 = f; -+ } else { -+ Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); -+ -+ f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); -+ } -+ -+ // entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false); // CraftBukkit - not required, just copies old location into reused entity -+ flag2 = !flag && flag3; -+ isBedSpawn = true; -+ location = CraftLocation.toBukkit(vec3d, worldserver1.getWorld(), f1, 0.0F); -+ } else if (blockposition != null) { -+ entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); -+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed -+ } - } - -- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); -- entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false); -- flag2 = !flag && flag3; -- } else if (blockposition != null) { -- entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); -+ if (location == null) { -+ worldserver1 = this.server.getLevel(World.OVERWORLD); -+ blockposition = entityplayer1.getSpawnPoint(worldserver1); -+ location = CraftLocation.toBukkit(blockposition, worldserver1.getWorld()).add(0.5F, 0.1F, 0.5F); -+ } -+ -+ Player respawnPlayer = entityplayer1.getBukkitEntity(); -+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2, reason); -+ cserver.getPluginManager().callEvent(respawnEvent); -+ -+ location = respawnEvent.getRespawnLocation(); + if (!flag) entityplayer.reset(); // SPIGOT-4785 + } else { -+ location.setWorld(worldserver.getWorld()); - } -+ WorldServer worldserver1 = ((CraftWorld) location.getWorld()).getHandle(); -+ entityplayer1.spawnIn(worldserver1); ++ dimensiontransition = new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), DimensionTransition.DO_NOTHING); ++ } ++ WorldServer worldserver = dimensiontransition.newLevel(); ++ entityplayer1.spawnIn(worldserver); + entityplayer1.unsetRemoved(); + entityplayer1.setShiftKeyDown(false); -+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + Vec3D vec3d = dimensiontransition.pos(); -- while (!worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { -+ while (avoidSuffocation && !worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) { -+ // CraftBukkit end - entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ()); +- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot()); ++ entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot()); ++ // CraftBukkit end + if (dimensiontransition.missingRespawnBlock()) { + entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); ++ entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed } -@@ -540,21 +775,43 @@ - WorldData worlddata = worldserver2.getLevelData(); + int i = flag ? 1 : 0; +@@ -506,17 +722,19 @@ + WorldData worlddata = worldserver1.getLevelData(); - entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver2), (byte) i)); + entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i)); - entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); -+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver2.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit - entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle())); ++ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit + entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle())); entityplayer1.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); entityplayer1.connection.send(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel)); - this.sendLevelInfo(entityplayer1, worldserver1); + this.sendActivePlayerEffects(entityplayer1); + this.sendLevelInfo(entityplayer1, worldserver); this.sendPlayerPermissionLevel(entityplayer1); -- worldserver1.addRespawnedPlayer(entityplayer1); +- worldserver.addRespawnedPlayer(entityplayer1); - this.players.add(entityplayer1); - this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1); - entityplayer1.initInventoryMenu(); + if (!entityplayer.connection.isDisconnected()) { -+ worldserver1.addRespawnedPlayer(entityplayer1); ++ worldserver.addRespawnedPlayer(entityplayer1); + this.players.add(entityplayer1); + this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1); + } + // entityplayer1.initInventoryMenu(); entityplayer1.setHealth(entityplayer1.getHealth()); - if (flag2) { - entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver1.getRandom().nextLong())); + if (!flag) { + BlockPosition blockposition = BlockPosition.containing(dimensiontransition.pos()); +@@ -526,6 +744,27 @@ + entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong())); + } } + // Added from changeDimension + sendAllPlayerInfo(entityplayer); // Update health, etc... @@ -619,23 +569,23 @@ + } + + // Fire advancement trigger -+ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle()); ++ entityplayer.triggerDimensionChangeTriggers(worldserver); + + // Don't fire on respawn -+ if (fromWorld != location.getWorld()) { -+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld); ++ if (fromWorld != worldserver) { ++ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld.getWorld()); + server.server.getPluginManager().callEvent(event); + } - ++ + // Save player file again if they were disconnected + if (entityplayer.connection.isDisconnected()) { + this.save(entityplayer); + } + // CraftBukkit end + return entityplayer1; } - -@@ -567,7 +824,18 @@ +@@ -554,7 +793,18 @@ public void tick() { if (++this.sendAllPlayerInfoIn > 600) { @@ -655,7 +605,7 @@ this.sendAllPlayerInfoIn = 0; } -@@ -584,6 +852,25 @@ +@@ -571,6 +821,25 @@ } @@ -681,7 +631,7 @@ public void broadcastAll(Packet packet, ResourceKey resourcekey) { Iterator iterator = this.players.iterator(); -@@ -662,7 +949,7 @@ +@@ -649,7 +918,7 @@ } public void deop(GameProfile gameprofile) { @@ -690,7 +640,7 @@ EntityPlayer entityplayer = this.getPlayer(gameprofile.getId()); if (entityplayer != null) { -@@ -686,6 +973,7 @@ +@@ -673,6 +942,7 @@ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -698,7 +648,7 @@ this.server.getCommands().sendCommands(entityplayer); } -@@ -716,6 +1004,12 @@ +@@ -703,6 +973,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -711,7 +661,7 @@ if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) { double d4 = d0 - entityplayer.getX(); double d5 = d1 - entityplayer.getY(); -@@ -755,15 +1049,19 @@ +@@ -742,15 +1018,19 @@ public void reloadWhiteList() {} public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) { @@ -735,7 +685,7 @@ } entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -772,8 +1070,16 @@ +@@ -759,8 +1039,16 @@ public void sendAllPlayerInfo(EntityPlayer entityplayer) { entityplayer.inventoryMenu.sendAllDataToRemote(); @@ -753,15 +703,15 @@ } public int getPlayerCount() { -@@ -829,12 +1135,22 @@ +@@ -816,12 +1104,22 @@ } public void removeAll() { - for (int i = 0; i < this.players.size(); ++i) { -- ((EntityPlayer) this.players.get(i)).connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.server_shutdown")); +- ((EntityPlayer) this.players.get(i)).connection.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.server_shutdown")); + // CraftBukkit start - disconnect safely + for (EntityPlayer player : this.players) { -+ player.connection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message ++ player.connection.disconnect(CraftChatMessage.fromStringOrEmpty(this.server.server.getShutdownMessage())); // CraftBukkit - add custom shutdown message } + // CraftBukkit end @@ -778,7 +728,7 @@ public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> { return ichatbasecomponent; -@@ -892,16 +1208,23 @@ +@@ -879,16 +1177,23 @@ return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now()); } @@ -806,7 +756,7 @@ Path path = file2.toPath(); if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { -@@ -910,7 +1233,7 @@ +@@ -897,7 +1202,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -815,7 +765,7 @@ } return serverstatisticmanager; -@@ -918,13 +1241,13 @@ +@@ -905,13 +1210,13 @@ public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUUID(); @@ -831,7 +781,7 @@ } advancementdataplayer.setPlayer(entityplayer); -@@ -975,13 +1298,20 @@ +@@ -962,13 +1267,20 @@ } public void reloadResources() { diff --git a/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch b/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch index 5d9ea41c07..ebbba19e01 100644 --- a/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch +++ b/paper-server/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java -@@ -484,6 +484,18 @@ +@@ -495,6 +495,18 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false)); Schema schema45 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); @@ -19,7 +19,7 @@ datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45, false)); -@@ -742,7 +754,8 @@ +@@ -753,7 +765,8 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema110, "Added Zoglin", DataConverterTypes.ENTITY)); Schema schema111 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED); @@ -29,7 +29,7 @@ Schema schema112 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED); datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema112)); -@@ -805,12 +818,14 @@ +@@ -816,12 +829,14 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Squid", DataConverterTypes.ENTITY)); datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Item Frame", DataConverterTypes.ENTITY)); Schema schema131 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); @@ -46,7 +46,7 @@ datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1))); datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1))); -@@ -818,7 +833,8 @@ +@@ -829,7 +844,8 @@ datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); @@ -56,7 +56,7 @@ datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); datafixerbuilder.addFixer(DataConverterBlockRename.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); -@@ -905,10 +921,11 @@ +@@ -916,10 +932,11 @@ datafixerbuilder.addFixer(new DataConverterAddChoices(schema159, "Added Allay", DataConverterTypes.ENTITY)); Schema schema160 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); @@ -70,7 +70,7 @@ int2objectopenhashmap1.defaultReturnValue("minecraft:tabby"); int2objectopenhashmap1.put(0, "minecraft:tabby"); int2objectopenhashmap1.put(1, "minecraft:black"); -@@ -925,7 +942,8 @@ +@@ -936,7 +953,8 @@ Objects.requireNonNull(int2objectopenhashmap); datafixerbuilder.addFixer(new EntityVariantFix(schema161, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); diff --git a/paper-server/nms-patches/net/minecraft/world/IInventory.patch b/paper-server/nms-patches/net/minecraft/world/IInventory.patch index f405332f8b..90d9dcf5a2 100644 --- a/paper-server/nms-patches/net/minecraft/world/IInventory.patch +++ b/paper-server/nms-patches/net/minecraft/world/IInventory.patch @@ -23,7 +23,7 @@ default int getMaxStackSize(ItemStack itemstack) { return Math.min(this.getMaxStackSize(), itemstack.getMaxStackSize()); -@@ -91,4 +94,29 @@ +@@ -91,4 +94,22 @@ return world == null ? false : (world.getBlockEntity(blockposition) != tileentity ? false : entityhuman.canInteractWithBlock(blockposition, (double) f)); } @@ -43,13 +43,6 @@ + + org.bukkit.Location getLocation(); + -+ default RecipeHolder getCurrentRecipe() { -+ return null; -+ } -+ -+ default void setCurrentRecipe(RecipeHolder recipe) { -+ } -+ + int MAX_STACK = 99; + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch index 104e23c4ea..86fc05e293 100644 --- a/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch +++ b/paper-server/nms-patches/net/minecraft/world/damagesource/DamageSources.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/damagesource/DamageSources.java +++ b/net/minecraft/world/damagesource/DamageSources.java -@@ -41,9 +41,15 @@ +@@ -42,9 +42,15 @@ private final DamageSource stalagmite; private final DamageSource outsideBorder; private final DamageSource genericKill; @@ -14,9 +14,9 @@ + this.poison = this.source(DamageTypes.MAGIC).poison(); + // CraftBukkit end this.inFire = this.source(DamageTypes.IN_FIRE); + this.campfire = this.source(DamageTypes.CAMPFIRE); this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT); - this.onFire = this.source(DamageTypes.ON_FIRE); -@@ -81,6 +87,16 @@ +@@ -83,6 +89,16 @@ return new DamageSource(this.damageTypes.getHolderOrThrow(resourcekey), entity, entity1); } @@ -33,7 +33,7 @@ public DamageSource inFire() { return this.inFire; } -@@ -242,7 +258,13 @@ +@@ -248,7 +264,13 @@ } public DamageSource explosion(@Nullable Entity entity, @Nullable Entity entity1) { @@ -48,7 +48,7 @@ } public DamageSource sonicBoom(Entity entity) { -@@ -250,7 +272,13 @@ +@@ -256,7 +278,13 @@ } public DamageSource badRespawnPointExplosion(Vec3D vec3d) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch index f09c987e3d..76cf023a33 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -128,8 +128,69 @@ +@@ -131,8 +131,72 @@ import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; +// CraftBukkit start ++import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; +import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -+import net.minecraft.world.level.dimension.WorldDimension; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Server; +import org.bukkit.block.BlockFace; +import org.bukkit.command.CommandSender; -+import org.bukkit.craftbukkit.event.CraftPortalEvent; +import org.bukkit.entity.Hanging; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Vehicle; @@ -25,6 +24,7 @@ +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.event.CraftPortalEvent; +import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.entity.Pose; +import org.bukkit.event.entity.EntityAirChangeEvent; @@ -35,6 +35,9 @@ +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.entity.EntityPoseChangeEvent; +import org.bukkit.event.entity.EntityRemoveEvent; ++import org.bukkit.event.entity.EntityTeleportEvent; ++import org.bukkit.event.entity.EntityUnleashEvent; ++import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.plugin.PluginManager; +// CraftBukkit end @@ -70,11 +73,12 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -243,6 +304,29 @@ +@@ -245,6 +309,30 @@ public boolean hasVisualFire; @Nullable private IBlockData inBlockState; + // CraftBukkit start ++ public boolean forceDrops; + public boolean persist = true; + public boolean visibleByDefault = true; + public boolean valid; @@ -100,7 +104,7 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -349,12 +433,18 @@ +@@ -351,12 +439,18 @@ } public void kill() { @@ -121,7 +125,7 @@ } protected abstract void defineSynchedData(DataWatcher.a datawatcher_a); -@@ -363,6 +453,16 @@ +@@ -365,6 +459,16 @@ return this.entityData; } @@ -138,7 +142,7 @@ public boolean equals(Object object) { return object instanceof Entity ? ((Entity) object).id == this.id : false; } -@@ -372,12 +472,24 @@ +@@ -374,12 +478,24 @@ } public void remove(Entity.RemovalReason entity_removalreason) { @@ -164,7 +168,7 @@ this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -402,6 +514,33 @@ +@@ -404,6 +520,33 @@ } protected void setRot(float f, float f1) { @@ -198,7 +202,7 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -443,6 +582,15 @@ +@@ -445,6 +588,15 @@ this.baseTick(); } @@ -206,7 +210,7 @@ + public void postTick() { + // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle + if (!(this instanceof EntityPlayer)) { -+ this.handleNetherPortal(); ++ this.handlePortal(); + } + } + // CraftBukkit end @@ -214,16 +218,16 @@ public void baseTick() { this.level().getProfiler().push("entityBaseTick"); this.inBlockState = null; -@@ -457,7 +605,7 @@ +@@ -459,7 +611,7 @@ this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); -- this.handleNetherPortal(); -+ if (this instanceof EntityPlayer) this.handleNetherPortal(); // CraftBukkit - // Moved up to postTick +- this.handlePortal(); ++ if (this instanceof EntityPlayer) this.handlePortal(); // CraftBukkit - // Moved up to postTick if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -492,6 +640,10 @@ +@@ -494,6 +646,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -234,11 +238,20 @@ } this.checkBelowWorld(); -@@ -543,15 +695,47 @@ +@@ -503,7 +659,7 @@ + + this.firstTick = false; + if (!this.level().isClientSide && this instanceof Leashable) { +- Leashable.tickLeash((Entity) ((Leashable) this)); ++ Leashable.tickLeash((Entity & Leashable) this); // CraftBukkit - decompile error + } + + this.level().getProfiler().pop(); +@@ -545,15 +701,47 @@ public void lavaHurt() { if (!this.fireImmune()) { -- this.igniteForSeconds(15); +- this.igniteForSeconds(15.0F); - if (this.hurt(this.damageSources().lava(), 4.0F)) { + // CraftBukkit start - Fallen in lava TODO: this event spams! + if (this instanceof EntityLiving && remainingFireTicks <= 0) { @@ -253,7 +266,7 @@ + } + } else { + // This will be called every single tick the entity is in lava, so don't throw an event -+ this.igniteForSeconds(15, false); ++ this.igniteForSeconds(15.0F, false); + } + + if (this.hurt(this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F)) { @@ -264,27 +277,27 @@ } } - public final void igniteForSeconds(int i) { + public final void igniteForSeconds(float f) { + // CraftBukkit start -+ this.igniteForSeconds(i, true); ++ this.igniteForSeconds(f, true); + } + -+ public final void igniteForSeconds(int i, boolean callEvent) { ++ public final void igniteForSeconds(float f, boolean callEvent) { + if (callEvent) { -+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i); ++ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), f); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + -+ i = event.getDuration(); ++ f = event.getDuration(); + } + // CraftBukkit end - this.igniteForTicks(i * 20); + this.igniteForTicks(MathHelper.floor(f * 20.0F)); } -@@ -575,7 +759,7 @@ +@@ -577,7 +765,7 @@ } protected void onBelowWorld() { @@ -293,7 +306,7 @@ } public boolean isFree(double d0, double d1, double d2) { -@@ -700,6 +884,28 @@ +@@ -702,6 +890,28 @@ block.updateEntityAfterFallOn(this.level(), this); } @@ -322,7 +335,7 @@ if (this.onGround()) { block.stepOn(this.level(), blockposition, iblockdata, this); } -@@ -1027,6 +1233,20 @@ +@@ -1073,6 +1283,20 @@ return SoundEffects.GENERIC_SPLASH; } @@ -343,7 +356,7 @@ protected void checkInsideBlocks() { AxisAlignedBB axisalignedbb = this.getBoundingBox(); BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); -@@ -1454,6 +1674,7 @@ +@@ -1512,6 +1736,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -351,7 +364,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1652,6 +1873,12 @@ +@@ -1718,6 +1943,12 @@ return false; } @@ -364,7 +377,7 @@ public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1680,16 +1907,22 @@ +@@ -1746,16 +1977,22 @@ } public boolean saveAsPassenger(NBTTagCompound nbttagcompound) { @@ -389,7 +402,7 @@ return true; } } -@@ -1700,16 +1933,38 @@ +@@ -1766,16 +2003,38 @@ } public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) { @@ -432,7 +445,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1717,7 +1972,28 @@ +@@ -1783,7 +2042,28 @@ nbttagcompound.putBoolean("OnGround", this.onGround()); nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); @@ -462,7 +475,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1766,7 +2042,7 @@ +@@ -1832,7 +2112,7 @@ nbttagcompound.put("Tags", nbttaglist); } @@ -471,7 +484,7 @@ if (this.isVehicle()) { nbttaglist = new NBTTagList(); iterator = this.getPassengers().iterator(); -@@ -1775,7 +2051,7 @@ +@@ -1841,7 +2121,7 @@ Entity entity = (Entity) iterator.next(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); @@ -480,7 +493,7 @@ nbttaglist.add(nbttagcompound1); } } -@@ -1785,6 +2061,11 @@ +@@ -1851,6 +2131,11 @@ } } @@ -492,7 +505,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -1868,6 +2149,45 @@ +@@ -1934,6 +2219,45 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -538,7 +551,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -1889,6 +2209,12 @@ +@@ -1955,6 +2279,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -551,7 +564,7 @@ protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound); -@@ -1943,9 +2269,22 @@ +@@ -2009,9 +2339,22 @@ } else if (this.level().isClientSide) { return null; } else { @@ -574,7 +587,34 @@ this.level().addFreshEntity(entityitem); return entityitem; } -@@ -2046,6 +2385,27 @@ +@@ -2040,6 +2383,12 @@ + if (this.isAlive() && this instanceof Leashable leashable) { + if (leashable.getLeashHolder() == entityhuman) { + if (!this.level().isClientSide()) { ++ // CraftBukkit start - fire PlayerUnleashEntityEvent ++ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman, enumhand).isCancelled()) { ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, leashable.getLeashHolder())); ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + leashable.dropLeash(true, !entityhuman.hasInfiniteMaterials()); + this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman); + } +@@ -2051,6 +2400,13 @@ + + if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { + if (!this.level().isClientSide()) { ++ // CraftBukkit start - fire PlayerLeashEntityEvent ++ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman, enumhand).isCancelled()) { ++ ((EntityPlayer) entityhuman).resendItemInHands(); // SPIGOT-7615: Resend to fix client desync with used item ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, leashable.getLeashHolder())); ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + leashable.setLeashedTo(entityhuman, true); + } + +@@ -2134,6 +2490,27 @@ if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -602,7 +642,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2079,7 +2439,7 @@ +@@ -2167,7 +2544,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -611,7 +651,7 @@ } } -@@ -2110,10 +2470,38 @@ +@@ -2198,10 +2575,38 @@ } } @@ -651,7 +691,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -2125,6 +2513,7 @@ +@@ -2213,6 +2618,7 @@ entity.boardingCooldown = 60; this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); } @@ -659,31 +699,16 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -2210,14 +2599,20 @@ +@@ -2307,7 +2713,7 @@ + if (dimensiontransition != null) { + WorldServer worldserver1 = dimensiontransition.newLevel(); - if (this.isInsidePortal) { - MinecraftServer minecraftserver = worldserver.getServer(); -- ResourceKey resourcekey = this.level().dimension() == World.NETHER ? World.OVERWORLD : World.NETHER; -+ ResourceKey resourcekey = this.level().getTypeKey() == WorldDimension.NETHER ? World.OVERWORLD : World.NETHER; // CraftBukkit - WorldServer worldserver1 = minecraftserver.getLevel(resourcekey); - -- if (worldserver1 != null && minecraftserver.isNetherEnabled() && !this.isPassenger() && this.portalTime++ >= i) { -+ if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit - this.level().getProfiler().push("portal"); - this.portalTime = i; - this.setPortalCooldown(); -- this.changeDimension(worldserver1); -+ // CraftBukkit start -+ if (this instanceof EntityPlayer) { -+ ((EntityPlayer) this).changeDimension(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); -+ } else { -+ this.changeDimension(worldserver1); -+ } -+ // CraftBukkit end - this.level().getProfiler().pop(); - } - -@@ -2327,6 +2722,13 @@ +- if (worldserver.getServer().isLevelEnabled(worldserver1) && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1))) { ++ if (this instanceof EntityPlayer || (worldserver1 != null && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1)))) { // CraftBukkit - always call event for players + this.changeDimension(dimensiontransition); + } + } +@@ -2414,6 +2820,13 @@ } public void setSwimming(boolean flag) { @@ -697,7 +722,7 @@ this.setSharedFlag(4, flag); } -@@ -2376,8 +2778,12 @@ +@@ -2463,8 +2876,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -711,7 +736,7 @@ } public boolean getSharedFlag(int i) { -@@ -2396,7 +2802,7 @@ +@@ -2483,7 +2900,7 @@ } public int getMaxAirSupply() { @@ -720,7 +745,7 @@ } public int getAirSupply() { -@@ -2404,7 +2810,18 @@ +@@ -2491,7 +2908,18 @@ } public void setAirSupply(int i) { @@ -740,7 +765,7 @@ } public int getTicksFrozen() { -@@ -2431,11 +2848,40 @@ +@@ -2518,11 +2946,40 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -751,9 +776,9 @@ + // CraftBukkit end + if (this.remainingFireTicks == 0) { -- this.igniteForSeconds(8); +- this.igniteForSeconds(8.0F); + // CraftBukkit start - Call a combust event when lightning strikes -+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); ++ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8.0F); + pluginManager.callEvent(entityCombustEvent); + if (!entityCombustEvent.isCancelled()) { + this.igniteForSeconds(entityCombustEvent.getDuration(), false); @@ -783,157 +808,58 @@ } public void onAboveBubbleCol(boolean flag) { -@@ -2600,15 +3046,38 @@ +@@ -2691,6 +3148,15 @@ - @Nullable - public Entity changeDimension(WorldServer worldserver) { -+ // CraftBukkit start -+ return teleportTo(worldserver, null); -+ } -+ -+ @Nullable -+ public Entity teleportTo(WorldServer worldserver, Vec3D location) { -+ // CraftBukkit end - if (this.level() instanceof WorldServer && !this.isRemoved()) { - this.level().getProfiler().push("changeDimension"); -- this.unRide(); -+ // CraftBukkit start -+ // this.unRide(); -+ if (worldserver == null) { -+ return null; -+ } -+ // CraftBukkit end - this.level().getProfiler().push("reposition"); -- ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver); -+ ShapeDetectorShape shapedetectorshape = (location == null) ? this.findDimensionEntryPoint(worldserver) : new ShapeDetectorShape(new Vec3D(location.x(), location.y(), location.z()), Vec3D.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit - - if (shapedetectorshape == null) { - return null; - } else { + if (world instanceof WorldServer worldserver) { + if (!this.isRemoved()) { + // CraftBukkit start -+ worldserver = shapedetectorshape.world; -+ if (worldserver == level) { -+ // SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in -+ moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot); -+ setDeltaMovement(shapedetectorshape.speed); -+ return this; ++ Location to = new Location(dimensiontransition.newLevel().getWorld(), dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot()); ++ EntityTeleportEvent teleEvent = CraftEventFactory.callEntityTeleportEvent(this, to); ++ if (teleEvent.isCancelled()) { ++ return null; + } -+ this.unRide(); ++ to = teleEvent.getTo(); ++ dimensiontransition = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), dimensiontransition.speed(), to.getYaw(), to.getPitch(), dimensiontransition.missingRespawnBlock(), dimensiontransition.postDimensionTransition(), dimensiontransition.cause()); + // CraftBukkit end -+ - this.level().getProfiler().popPush("reloading"); - Entity entity = this.getType().create(worldserver); + WorldServer worldserver1 = dimensiontransition.newLevel(); + List list = this.getPassengers(); -@@ -2616,10 +3085,22 @@ - entity.restoreFrom(this); - entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); - entity.setDeltaMovement(shapedetectorshape.speed); -- worldserver.addDuringTeleport(entity); -- if (worldserver.dimension() == World.END) { -- WorldServer.makeObsidianPlatform(worldserver); -+ // CraftBukkit start - Don't spawn the new entity if the current entity isn't spawned -+ if (this.inWorld) { -+ worldserver.addDuringTeleport(entity); -+ if (worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit -+ WorldServer.makeObsidianPlatform(worldserver, this); // CraftBukkit -+ } -+ } -+ // CraftBukkit end -+ // CraftBukkit start - Forward the CraftEntity to the new entity -+ this.getBukkitEntity().setHandle(entity); -+ entity.bukkitEntity = this.getBukkitEntity(); -+ -+ if (this instanceof EntityInsentient) { -+ ((EntityInsentient) this).dropLeash(true, false); // Unleash to prevent duping of leads. +@@ -2716,11 +3182,15 @@ + if (this != entity2) { + entity2.restoreFrom(this); + this.removeAfterChangingDimensions(); ++ // CraftBukkit start - Forward the CraftEntity to the new entity ++ this.getBukkitEntity().setHandle(entity2); ++ entity2.bukkitEntity = this.getBukkitEntity(); ++ // CraftBukkit end } -+ // CraftBukkit end - } - this.removeAfterChangingDimensions(); -@@ -2635,25 +3116,39 @@ + entity2.moveTo(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), entity2.getXRot()); + entity2.setDeltaMovement(dimensiontransition.speed()); +- if (this != entity2) { ++ if (this != entity2 && this.inWorld) { // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned + worldserver1.addDuringTeleport(entity2); + } + +@@ -2754,8 +3224,9 @@ } protected void removeAfterChangingDimensions() { - this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION); + this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause - } - - @Nullable - protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { -- boolean flag = this.level().dimension() == World.END && worldserver.dimension() == World.OVERWORLD; -- boolean flag1 = worldserver.dimension() == World.END; -+ // CraftBukkit start -+ if (worldserver == null) { -+ return null; -+ } -+ boolean flag = this.level().getTypeKey() == WorldDimension.END && worldserver.getTypeKey() == WorldDimension.OVERWORLD; // fromEndToOverworld -+ boolean flag1 = worldserver.getTypeKey() == WorldDimension.END; // targetIsEnd -+ // CraftBukkit end - - if (!flag && !flag1) { -- boolean flag2 = worldserver.dimension() == World.NETHER; -+ boolean flag2 = worldserver.getTypeKey() == WorldDimension.NETHER; // CraftBukkit - -- if (this.level().dimension() != World.NETHER && !flag2) { -+ if (this.level().getTypeKey() != WorldDimension.NETHER && !flag2) { // CraftBukkit - return null; - } else { - WorldBorder worldborder = worldserver.getWorldBorder(); - double d0 = DimensionManager.getTeleportationScale(this.level().dimensionType(), worldserver.dimensionType()); - BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0); -+ // CraftBukkit start -+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Vec3D(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); -+ if (event == null) { -+ return null; -+ } -+ final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); -+ worldborder = worldserverFinal.getWorldBorder(); -+ blockposition = worldborder.clampToBounds(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); - -- return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder).map((blockutil_rectangle) -> { -+ return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> { -+ // CraftBukkit end - IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos); - EnumDirection.EnumAxis enumdirection_enumaxis; - Vec3D vec3d; -@@ -2670,8 +3165,8 @@ - vec3d = new Vec3D(0.5D, 0.0D, 0.0D); - } - -- return BlockPortalShape.createPortalInfo(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this, this.getDeltaMovement(), this.getYRot(), this.getXRot()); -- }).orElse((Object) null); -+ return BlockPortalShape.createPortalInfo(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this, this.getDeltaMovement(), this.getYRot(), this.getXRot(), event); // CraftBukkit -+ }).orElse(null); // CraftBukkit - decompile error - } - } else { - BlockPosition blockposition1 = flag1 ? WorldServer.END_SPAWN_POINT : worldserver.getSharedSpawnPos(); -@@ -2684,8 +3179,14 @@ - } else { - i = worldserver.getChunkAt(blockposition1).getHeight(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, blockposition1.getX(), blockposition1.getZ()) + 1; - } -+ // CraftBukkit start -+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Vec3D(blockposition1.getX() + 0.5D, i, blockposition1.getZ() + 0.5D), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0); -+ if (event == null) { -+ return null; -+ } - -- return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) i, (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot()); -+ return new ShapeDetectorShape(new Vec3D(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()), this.getDeltaMovement(), this.getYRot(), this.getXRot(), ((CraftWorld) event.getTo().getWorld()).getHandle(), event); -+ // CraftBukkit end + if (this instanceof Leashable leashable) { ++ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit + leashable.dropLeash(true, false); } - } -@@ -2693,8 +3194,23 @@ +@@ -2765,6 +3236,20 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } -- protected Optional getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) { -- return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder); + // CraftBukkit start -+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Vec3D exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { ++ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); + Location enter = bukkitEntity.getLocation(); -+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld()); + + EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius); + event.getEntity().getServer().getPluginManager().callEvent(event); @@ -942,15 +868,13 @@ + } + return new CraftPortalEvent(event); + } ++ // CraftBukkit end + -+ protected Optional getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { -+ return worldserver.getPortalForcer().findPortalAround(blockposition, worldborder, searchRadius); -+ // CraftBukkit end + public boolean canUsePortal(boolean flag) { + return (flag || !this.isPassenger()) && this.isAlive(); } - - public boolean canChangeDimensions() { -@@ -2815,6 +3331,12 @@ - } +@@ -2877,6 +3362,12 @@ + return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } + // CraftBukkit start @@ -962,7 +886,7 @@ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1) { float f2 = MathHelper.clamp(f1, -90.0F, 90.0F); -@@ -2833,8 +3355,12 @@ +@@ -2895,8 +3386,12 @@ entity.restoreFrom(this); entity.moveTo(d0, d1, d2, f, f2); entity.setYHeadRot(f); @@ -977,7 +901,7 @@ } return true; -@@ -2942,7 +3468,26 @@ +@@ -3023,7 +3518,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -1005,7 +929,7 @@ } public final float getEyeHeight(EntityPose entitypose) { -@@ -3263,6 +3808,11 @@ +@@ -3332,6 +3846,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } @@ -1017,7 +941,7 @@ } } } -@@ -3532,6 +4082,14 @@ +@@ -3601,6 +4120,14 @@ @Override public final void setRemoved(Entity.RemovalReason entity_removalreason) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index 58a58725a9..ee7c730663 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java -@@ -30,6 +30,12 @@ +@@ -32,6 +32,12 @@ import net.minecraft.world.level.material.EnumPistonReaction; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class EntityAreaEffectCloud extends Entity implements TraceableEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -186,7 +192,7 @@ +@@ -188,7 +194,7 @@ } } else { if (this.tickCount >= this.waitTime + this.duration) { @@ -22,7 +22,7 @@ return; } -@@ -203,7 +209,7 @@ +@@ -205,7 +211,7 @@ if (this.radiusPerTick != 0.0F) { f += this.radiusPerTick; if (f < 0.5F) { @@ -31,7 +31,7 @@ return; } -@@ -237,6 +243,7 @@ +@@ -239,11 +245,12 @@ if (!list1.isEmpty()) { Iterator iterator1 = list1.iterator(); @@ -39,47 +39,55 @@ while (iterator1.hasNext()) { EntityLiving entityliving = (EntityLiving) iterator1.next(); -@@ -246,6 +253,17 @@ - double d5 = d3 * d3 + d4 * d4; + if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) { +- Stream stream = list.stream(); ++ Stream stream = list.stream(); // CraftBukkit - decompile error - if (d5 <= (double) (f * f)) { -+ // CraftBukkit start -+ entities.add((LivingEntity) entityliving.getBukkitEntity()); + Objects.requireNonNull(entityliving); + if (!stream.noneMatch(entityliving::canBeAffected)) { +@@ -252,6 +259,19 @@ + double d5 = d3 * d3 + d4 * d4; + + if (d5 <= (double) (f * f)) { ++ // CraftBukkit start ++ entities.add((LivingEntity) entityliving.getBukkitEntity()); ++ } + } + } + } -+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities); -+ if (!event.isCancelled()) { -+ for (LivingEntity entity : event.getAffectedEntities()) { -+ if (entity instanceof CraftLivingEntity) { -+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); -+ // CraftBukkit end - this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); - Iterator iterator2 = list.iterator(); ++ { ++ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities); ++ if (!event.isCancelled()) { ++ for (LivingEntity entity : event.getAffectedEntities()) { ++ if (entity instanceof CraftLivingEntity) { ++ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); ++ // CraftBukkit end + this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); + Iterator iterator2 = list.iterator(); -@@ -255,14 +273,14 @@ - if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) { - ((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); - } else { -- entityliving.addEffect(new MobEffect(mobeffect1), this); -+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit - } - } - - if (this.radiusOnUse != 0.0F) { - f += this.radiusOnUse; - if (f < 0.5F) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; +@@ -261,14 +281,14 @@ + if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) { + ((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); + } else { +- entityliving.addEffect(new MobEffect(mobeffect1), this); ++ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit + } } -@@ -272,7 +290,7 @@ - if (this.durationOnUse != 0) { - this.duration += this.durationOnUse; - if (this.duration <= 0) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; + if (this.radiusOnUse != 0.0F) { + f += this.radiusOnUse; + if (f < 0.5F) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } + +@@ -278,7 +298,7 @@ + if (this.durationOnUse != 0) { + this.duration += this.durationOnUse; + if (this.duration <= 0) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } } - } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch index 2d506ce6f9..9834a2c814 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityCreature.patch @@ -11,19 +11,3 @@ public abstract class EntityCreature extends EntityInsentient { protected static final float DEFAULT_WALK_TARGET_VALUE = 0.0F; -@@ -67,6 +71,7 @@ - - if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isInSittingPose()) { - if (f > 10.0F) { -+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.dropLeash(true, true); - } - -@@ -75,6 +80,7 @@ - - this.onLeashDistance(f); - if (f > 10.0F) { -+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.dropLeash(true, true); - this.goalSelector.disableControlFlag(PathfinderGoal.Type.MOVE); - } else if (f > 6.0F) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch index 904aa64996..4ada992e8c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityExperienceOrb.java +++ b/net/minecraft/world/entity/EntityExperienceOrb.java -@@ -22,6 +22,14 @@ +@@ -25,6 +25,14 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -15,7 +15,7 @@ public class EntityExperienceOrb extends Entity { private static final int LIFETIME = 6000; -@@ -65,6 +73,7 @@ +@@ -68,6 +76,7 @@ @Override public void tick() { super.tick(); @@ -23,7 +23,7 @@ this.xo = this.getX(); this.yo = this.getY(); this.zo = this.getZ(); -@@ -90,7 +99,22 @@ +@@ -93,7 +102,22 @@ this.followingPlayer = null; } @@ -47,7 +47,7 @@ Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); double d0 = vec3d.lengthSqr(); -@@ -115,7 +139,7 @@ +@@ -118,7 +142,7 @@ ++this.age; if (this.age >= 6000) { @@ -56,7 +56,7 @@ } } -@@ -184,7 +208,7 @@ +@@ -187,7 +211,7 @@ private void merge(EntityExperienceOrb entityexperienceorb) { this.count += entityexperienceorb.count; this.age = Math.min(this.age, entityexperienceorb.age); @@ -65,7 +65,7 @@ } private void setUnderwaterMovement() { -@@ -206,7 +230,7 @@ +@@ -209,7 +233,7 @@ this.markHurt(); this.health = (int) ((float) this.health - f); if (this.health <= 0) { @@ -74,14 +74,14 @@ } return true; -@@ -233,17 +257,17 @@ +@@ -236,17 +260,17 @@ public void playerTouch(EntityHuman entityhuman) { - if (!this.level().isClientSide) { + if (entityhuman instanceof EntityPlayer entityplayer) { if (entityhuman.takeXpDelay == 0) { - entityhuman.takeXpDelay = 2; + entityhuman.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(entityhuman, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2; entityhuman.take(this, 1); - int i = this.repairPlayerItems(entityhuman, this.value); + int i = this.repairPlayerItems(entityplayer, this.value); if (i > 0) { - entityhuman.giveExperiencePoints(i); @@ -95,25 +95,28 @@ } } -@@ -256,9 +280,17 @@ - if (entry != null) { - ItemStack itemstack = (ItemStack) entry.getValue(); - int j = Math.min(this.xpToDurability(i), itemstack.getDamageValue()); +@@ -260,12 +284,20 @@ + ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack(); + int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i); + int k = Math.min(j, itemstack.getDamageValue()); + // CraftBukkit start -+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, entry.getKey(), j); -+ j = event.getRepairAmount(); ++ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityplayer, this, itemstack, optional.get().inSlot(), k); ++ k = event.getRepairAmount(); + if (event.isCancelled()) { + return i; + } + // CraftBukkit end - itemstack.setDamageValue(itemstack.getDamageValue() - j); - int k = i - this.durabilityToXp(j); -+ this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls + itemstack.setDamageValue(itemstack.getDamageValue() - k); + if (k > 0) { + int l = i - k * i / j; - return k > 0 ? this.repairPlayerItems(entityhuman, k) : 0; - } else { -@@ -283,6 +315,24 @@ + if (l > 0) { ++ this.value = l; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls + return this.repairPlayerItems(entityplayer, l); + } + } +@@ -285,6 +317,24 @@ } public static int getExperienceValue(int i) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch index a1d0bd8a51..54e16c0d86 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityInsentient.java +++ b/net/minecraft/world/entity/EntityInsentient.java -@@ -89,6 +89,20 @@ +@@ -87,6 +87,20 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.AxisAlignedBB; @@ -18,10 +18,10 @@ +import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; +// CraftBukkit end + - public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Targeting { + public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Leashable, Targeting { private static final DataWatcherObject DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); -@@ -138,6 +152,8 @@ +@@ -134,6 +148,8 @@ private BlockPosition restrictCenter; private float restrictRadius; @@ -30,7 +30,7 @@ protected EntityInsentient(EntityTypes entitytypes, World world) { super(entitytypes, world); this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); -@@ -165,6 +181,12 @@ +@@ -161,6 +177,12 @@ } @@ -43,7 +43,7 @@ protected void registerGoals() {} public static AttributeProvider.Builder createMobAttributes() { -@@ -269,11 +291,42 @@ +@@ -265,11 +287,42 @@ @Nullable protected final EntityLiving getTargetFromBrain() { @@ -87,7 +87,7 @@ } @Override -@@ -412,6 +465,12 @@ +@@ -405,6 +458,12 @@ return null; } @@ -100,19 +100,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); -@@ -486,7 +545,10 @@ - } - } - -- if (either != null) { -+ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin -+ Entity leashHolder = this.leashHolder; -+ if (either != null && (leashHolder == null || !leashHolder.pluginRemoved)) { -+ // CraftBukkit end - nbttagcompound.put("leash", (NBTBase) either.map((uuid) -> { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - -@@ -507,16 +569,26 @@ +@@ -478,16 +537,26 @@ nbttagcompound.putBoolean("NoAI", this.isNoAi()); } @@ -141,16 +129,7 @@ NBTTagList nbttaglist; NBTTagCompound nbttagcompound1; int i; -@@ -565,7 +637,7 @@ - if (nbttagcompound.contains("leash", 10)) { - this.delayedLeashInfo = Either.left(nbttagcompound.getCompound("leash").getUUID("UUID")); - } else if (nbttagcompound.contains("leash", 11)) { -- this.delayedLeashInfo = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse((Object) null); -+ this.delayedLeashInfo = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse(null); // CraftBukkit - decompile error - } else { - this.delayedLeashInfo = null; - } -@@ -577,6 +649,11 @@ +@@ -541,6 +610,11 @@ } this.setNoAi(nbttagcompound.getBoolean("NoAI")); @@ -162,7 +141,7 @@ } @Override -@@ -651,20 +728,26 @@ +@@ -615,20 +689,26 @@ protected void pickUpItem(EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -188,10 +167,10 @@ + + public ItemStack equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) { + // CraftBukkit end - EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack); + EnumItemSlot enumitemslot = this.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = this.getItemBySlot(enumitemslot); boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1); -@@ -675,11 +758,19 @@ +@@ -639,11 +719,19 @@ flag = itemstack1.isEmpty(); } @@ -211,8 +190,8 @@ + this.forceDrops = false; // CraftBukkit } - if (enumitemslot.isArmor() && itemstack.getCount() > 1) { -@@ -813,7 +904,7 @@ + ItemStack itemstack2 = enumitemslot.limit(itemstack); +@@ -772,7 +860,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { @@ -221,7 +200,7 @@ } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D); -@@ -823,14 +914,14 @@ +@@ -782,14 +870,14 @@ int j = i * i; if (d0 > (double) j && this.removeWhenFarAway(d0)) { @@ -238,7 +217,7 @@ } else if (d0 < (double) l) { this.noActionTime = 0; } -@@ -844,6 +935,7 @@ +@@ -803,6 +891,7 @@ @Override protected final void serverAiStep() { ++this.noActionTime; @@ -246,43 +225,16 @@ GameProfilerFiller gameprofilerfiller = this.level().getProfiler(); gameprofilerfiller.push("sensing"); -@@ -1311,6 +1403,12 @@ - if (!this.isAlive()) { - return EnumInteractionResult.PASS; - } else if (this.getLeashHolder() == entityhuman) { -+ // CraftBukkit start - fire PlayerUnleashEntityEvent -+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman, enumhand).isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - this.dropLeash(true, !entityhuman.hasInfiniteMaterials()); - this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman); - return EnumInteractionResult.sidedSuccess(this.level().isClientSide); -@@ -1336,6 +1434,13 @@ - ItemStack itemstack = entityhuman.getItemInHand(enumhand); +@@ -1354,7 +1443,7 @@ + if (itemstack.getItem() instanceof ItemMonsterEgg) { + if (this.level() instanceof WorldServer) { + ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); +- Optional optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, this.getType(), (WorldServer) this.level(), this.position(), itemstack); ++ Optional optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, (EntityTypes) this.getType(), (WorldServer) this.level(), this.position(), itemstack); // CraftBukkit - decompile error - if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) { -+ // CraftBukkit start - fire PlayerLeashEntityEvent -+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman, enumhand).isCancelled()) { -+ ((EntityPlayer) entityhuman).resendItemInHands(); // SPIGOT-7615: Resend to fix client desync with used item -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - this.setLeashedTo(entityhuman, true); - itemstack.shrink(1); - return EnumInteractionResult.sidedSuccess(this.level().isClientSide); -@@ -1351,7 +1456,7 @@ - if (itemstack.getItem() instanceof ItemMonsterEgg) { - if (this.level() instanceof WorldServer) { - ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); -- Optional optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, this.getType(), (WorldServer) this.level(), this.position(), itemstack); -+ Optional optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, (EntityTypes) this.getType(), (WorldServer) this.level(), this.position(), itemstack); // CraftBukkit - decompile error - - optional.ifPresent((entityinsentient) -> { - this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); -@@ -1401,12 +1506,19 @@ + optional.ifPresent((entityinsentient) -> { + this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); +@@ -1403,12 +1492,19 @@ return this.restrictRadius != -1.0F; } @@ -303,7 +255,7 @@ if (t0 == null) { return null; -@@ -1440,7 +1552,12 @@ +@@ -1442,7 +1538,12 @@ } } @@ -317,7 +269,7 @@ if (this.isPassenger()) { Entity entity = this.getVehicle(); -@@ -1448,7 +1565,7 @@ +@@ -1450,7 +1551,7 @@ t0.startRiding(entity, true); } @@ -326,27 +278,7 @@ return t0; } } -@@ -1461,7 +1578,8 @@ - - if (this.leashHolder != null) { - if (!this.isAlive() || !this.leashHolder.isAlive()) { -- this.dropLeash(true, true); -+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit -+ this.dropLeash(true, !this.leashHolder.pluginRemoved);// CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin - } - - } -@@ -1473,7 +1591,9 @@ - this.delayedLeashInfo = null; - this.clearRestriction(); - if (!this.level().isClientSide && flag1) { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation((IMaterial) Items.LEAD); -+ this.forceDrops = false; // CraftBukkit - } - - if (!this.level().isClientSide && flag && this.level() instanceof WorldServer) { -@@ -1527,6 +1647,7 @@ +@@ -1492,6 +1593,7 @@ boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { @@ -354,45 +286,12 @@ this.dropLeash(true, true); } -@@ -1555,7 +1676,9 @@ - } - - if (this.tickCount > 100) { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation((IMaterial) Items.LEAD); -+ this.forceDrops = false; // CraftBukkit - this.delayedLeashInfo = null; - } - } -@@ -1638,14 +1761,21 @@ - int i = EnchantmentManager.getFireAspect(this); - - if (i > 0) { -- entity.igniteForSeconds(i * 4); -+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item -+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), i * 4); -+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); -+ -+ if (!combustEvent.isCancelled()) { -+ entity.igniteForSeconds(combustEvent.getDuration(), false); -+ } -+ // CraftBukkit end - } - - boolean flag = entity.hurt(this.damageSources().mobAttack(this), f); - - if (flag) { +@@ -1578,7 +1680,7 @@ if (f1 > 0.0F && entity instanceof EntityLiving) { -- ((EntityLiving) entity).knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); -+ ((EntityLiving) entity).knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot())) * 0.017453292F, this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit + EntityLiving entityliving = (EntityLiving) entity; + +- entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); ++ entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); } -@@ -1695,6 +1825,7 @@ - @Override - protected void removeAfterChangingDimensions() { - super.removeAfterChangingDimensions(); -+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - this.dropLeash(true, false); - this.getAllSlots().forEach((itemstack) -> { - if (!itemstack.isEmpty()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch index d7a060efd5..fb794de497 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java -@@ -126,6 +126,32 @@ +@@ -132,6 +132,32 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -9,9 +9,9 @@ +import java.util.HashSet; +import java.util.Set; +import com.google.common.base.Function; ++import java.util.UUID; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagInt; -+import net.minecraft.world.entity.animal.EntityAnimal; +import org.bukkit.Location; +import org.bukkit.craftbukkit.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -33,13 +33,12 @@ public abstract class EntityLiving extends Entity implements Attackable { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -237,6 +263,20 @@ - protected BehaviorController brain; +@@ -249,6 +275,19 @@ protected boolean skipDropExperience; + private final Reference2ObjectMap> activeLocationDependentEnchantments; protected float appliedScale; + // CraftBukkit start + public int expToDrop; -+ public boolean forceDrops; + public ArrayList drops = new ArrayList(); + public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; + public boolean collides = true; @@ -54,8 +53,8 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -251,7 +291,9 @@ - this.lastClimbablePos = Optional.empty(); +@@ -264,7 +303,9 @@ + this.activeLocationDependentEnchantments = new Reference2ObjectArrayMap(); this.appliedScale = 1.0F; this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes)); - this.setHealth(this.getMaxHealth()); @@ -65,22 +64,22 @@ this.blocksBuilding = true; this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.reapplyPosition(); -@@ -329,7 +371,13 @@ - double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D); - int i = (int) (150.0D * d8); +@@ -344,7 +385,13 @@ + double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D); + int i = (int) (150.0D * d8); -- ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); -+ // CraftBukkit start - visiblity api -+ if (this instanceof EntityPlayer) { -+ ((WorldServer) this.level()).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); -+ } else { -+ ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); -+ } -+ // CraftBukkit end +- ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ // CraftBukkit start - visiblity api ++ if (this instanceof EntityPlayer) { ++ ((WorldServer) this.level()).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); ++ } else { ++ ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ } ++ // CraftBukkit end + } } } - -@@ -594,7 +642,7 @@ +@@ -555,7 +602,7 @@ ++this.deathTime; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, (byte) 60); @@ -89,7 +88,7 @@ } } -@@ -693,13 +741,19 @@ +@@ -661,13 +708,19 @@ } public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) { @@ -110,7 +109,7 @@ this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong()); } -@@ -713,6 +767,13 @@ +@@ -681,11 +734,18 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -122,10 +121,7 @@ + public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { + // CraftBukkit end if (entity_removalreason == Entity.RemovalReason.KILLED || entity_removalreason == Entity.RemovalReason.DISCARDED) { - Iterator iterator = this.getActiveEffects().iterator(); - -@@ -723,7 +784,7 @@ - } + this.triggerOnDeathMobEffects(entity_removalreason); } - super.remove(entity_removalreason); @@ -133,7 +129,7 @@ this.brain.clearMemories(); } -@@ -783,6 +844,17 @@ +@@ -757,6 +817,17 @@ } } @@ -151,7 +147,7 @@ if (nbttagcompound.contains("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -821,9 +893,32 @@ +@@ -795,9 +866,32 @@ } @@ -184,7 +180,7 @@ try { while (iterator.hasNext()) { Holder holder = (Holder) iterator.next(); -@@ -833,6 +928,12 @@ +@@ -807,6 +901,12 @@ this.onEffectUpdated(mobeffect, true, (Entity) null); })) { if (!this.level().isClientSide) { @@ -197,7 +193,7 @@ iterator.remove(); this.onEffectRemoved(mobeffect); } -@@ -843,6 +944,17 @@ +@@ -817,6 +917,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -215,7 +211,7 @@ if (this.effectsDirty) { if (!this.level().isClientSide) { -@@ -958,7 +1070,13 @@ +@@ -932,7 +1043,13 @@ this.entityData.set(EntityLiving.DATA_EFFECT_PARTICLES, List.of()); } @@ -229,7 +225,7 @@ if (this.level().isClientSide) { return false; } else { -@@ -967,7 +1085,14 @@ +@@ -941,7 +1058,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { @@ -245,7 +241,7 @@ iterator.remove(); } -@@ -996,20 +1121,50 @@ +@@ -970,20 +1094,50 @@ return this.addEffect(mobeffect, (Entity) null); } @@ -297,7 +293,7 @@ flag = true; } -@@ -1040,13 +1195,39 @@ +@@ -1014,13 +1168,39 @@ return this.getType().is(TagsEntity.INVERTED_HEALING_AND_HARM); } @@ -338,7 +334,7 @@ if (mobeffect != null) { this.onEffectRemoved(mobeffect); -@@ -1142,20 +1323,55 @@ +@@ -1118,20 +1298,55 @@ } @@ -395,7 +391,7 @@ this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); } -@@ -1169,7 +1385,7 @@ +@@ -1145,7 +1360,7 @@ return false; } else if (this.level().isClientSide) { return false; @@ -404,7 +400,7 @@ return false; } else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1180,10 +1396,11 @@ +@@ -1156,10 +1371,11 @@ this.noActionTime = 0; float f1 = f; @@ -418,7 +414,7 @@ this.hurtCurrentlyUsedShield(f); f2 = f; f = 0.0F; -@@ -1204,7 +1421,8 @@ +@@ -1180,7 +1396,8 @@ f *= 5.0F; } @@ -428,7 +424,7 @@ this.hurtHelmet(damagesource, f); f *= 0.75F; } -@@ -1212,18 +1430,27 @@ +@@ -1188,18 +1405,27 @@ this.walkAnimation.setSpeed(1.5F); boolean flag1 = true; @@ -460,7 +456,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1269,7 +1496,7 @@ +@@ -1245,7 +1471,7 @@ this.level().broadcastDamageEvent(this, damagesource); } @@ -469,8 +465,8 @@ this.markHurt(); } -@@ -1282,7 +1509,7 @@ - d0 = (Math.random() - Math.random()) * 0.01D; +@@ -1265,7 +1491,7 @@ + d1 = damagesource.getSourcePosition().z() - this.getZ(); } - this.knockback(0.4000000059604645D, d0, d1); @@ -478,7 +474,7 @@ if (!flag) { this.indicateDamage(d0, d1); } -@@ -1301,7 +1528,7 @@ +@@ -1284,7 +1510,7 @@ this.playHurtSound(damagesource); } @@ -487,7 +483,7 @@ if (flag2) { this.lastDamageSource = damagesource; -@@ -1335,7 +1562,7 @@ +@@ -1318,7 +1544,7 @@ } protected void blockedByShield(EntityLiving entityliving) { @@ -496,7 +492,7 @@ } private boolean checkTotemDeathProtection(DamageSource damagesource) { -@@ -1346,19 +1573,32 @@ +@@ -1329,19 +1555,32 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -533,7 +529,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); -@@ -1367,14 +1607,16 @@ +@@ -1350,14 +1589,16 @@ } this.setHealth(1.0F); @@ -555,7 +551,7 @@ } } -@@ -1481,14 +1723,22 @@ +@@ -1464,14 +1705,22 @@ IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { @@ -580,14 +576,14 @@ this.level().addFreshEntity(entityitem); } } -@@ -1508,21 +1758,40 @@ - +@@ -1482,26 +1731,41 @@ + protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) { boolean flag = this.lastHurtByPlayerTime > 0; + this.dropEquipment(); // CraftBukkit - from below - if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (this.shouldDropLoot() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { this.dropFromLootTable(damagesource, flag); - this.dropCustomDeathLoot(damagesource, i, flag); + this.dropCustomDeathLoot(worldserver, damagesource, flag); } + // CraftBukkit start - Call death event + CraftEventFactory.callEntityDeathEvent(this, damagesource, this.drops); @@ -595,36 +591,37 @@ + // CraftBukkit end - this.dropEquipment(); -+ // this.dropInventory();// CraftBukkit - moved up - this.dropExperience(); ++ // this.dropEquipment();// CraftBukkit - moved up + this.dropExperience(damagesource.getEntity()); } protected void dropEquipment() {} -- protected void dropExperience() { -+ // CraftBukkit start -+ public int getExpReward() { - if (this.level() instanceof WorldServer && !this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { -- EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.getExperienceReward()); -+ int i = this.getExperienceReward(); -+ return i; -+ } else { -+ return 0; +- protected void dropExperience(@Nullable Entity entity) { ++ public int getExpReward(@Nullable Entity entity) { // CraftBukkit + World world = this.level(); + + if (world instanceof WorldServer worldserver) { + if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { +- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity)); ++ return this.getExperienceReward(worldserver, entity); // CraftBukkit + } } + ++ return 0; // CraftBukkit + } -+ // CraftBukkit end + -+ protected void dropExperience() { ++ protected void dropExperience(@Nullable Entity entity) { + // CraftBukkit start - Update getExpReward() above if the removed if() changes! -+ if (true && !(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time ++ if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time + EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.expToDrop); + this.expToDrop = 0; + } + // CraftBukkit end - } -@@ -1551,13 +1820,25 @@ + protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {} +@@ -1540,9 +1804,14 @@ } public void knockback(double d0, double d1, double d2) { @@ -638,7 +635,11 @@ - this.hasImpulse = true; + if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0 + //this.hasImpulse = true; // CraftBukkit - Move down - Vec3D vec3d = this.getDeltaMovement(); + + Vec3D vec3d; + +@@ -1552,7 +1821,14 @@ + Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0); - this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y, vec3d.z / 2.0D - vec3d1.z); @@ -653,7 +654,7 @@ } } -@@ -1614,6 +1895,28 @@ +@@ -1613,6 +1889,28 @@ return itemstack.getEatingSound(); } @@ -682,7 +683,7 @@ public Optional getLastClimbablePos() { return this.lastClimbablePos; } -@@ -1669,9 +1972,14 @@ +@@ -1666,9 +1964,14 @@ int i = this.calculateFallDamage(f, f1); if (i > 0) { @@ -698,26 +699,26 @@ return true; } else { return flag; -@@ -1741,7 +2049,7 @@ +@@ -1738,7 +2041,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { - this.hurtArmor(damagesource, f); + // this.hurtArmor(damagesource, f); // CraftBukkit - Moved into actuallyHurt(DamageSource, float) - f = CombatMath.getDamageAfterAbsorb(f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); + f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1754,7 +2062,8 @@ +@@ -1749,7 +2052,8 @@ + if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) { + return f; } else { - int i; - - if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + // CraftBukkit - Moved to actuallyHurt(DamageSource, float) + if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { - i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; + int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1787,16 +2096,125 @@ +@@ -1792,16 +2096,125 @@ } } @@ -764,7 +765,7 @@ + }; + float armorModifier = armor.apply((double) f).floatValue(); + f += armorModifier; -+ + + Function resistance = new Function() { + @Override + public Double apply(Double f) { @@ -823,7 +824,7 @@ + if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + this.hurtHelmet(damagesource, f); + } - ++ + // Apply damage to armor + if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); @@ -851,7 +852,7 @@ if (f2 > 0.0F && f2 < 3.4028235E37F) { Entity entity = damagesource.getEntity(); -@@ -1807,13 +2225,47 @@ +@@ -1812,13 +2225,47 @@ } } @@ -901,7 +902,7 @@ } public CombatTracker getCombatTracker() { -@@ -1838,8 +2290,18 @@ +@@ -1843,8 +2290,18 @@ } public final void setArrowCount(int i) { @@ -921,7 +922,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); -@@ -2075,6 +2537,12 @@ +@@ -2086,6 +2543,12 @@ public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); @@ -934,7 +935,7 @@ public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); public Iterable getHandSlots() { -@@ -2328,6 +2796,7 @@ +@@ -2336,6 +2799,7 @@ } if (this.onGround() && !this.level().isClientSide) { @@ -942,7 +943,7 @@ this.setSharedFlag(7, false); } } else { -@@ -2498,7 +2967,7 @@ +@@ -2506,7 +2970,7 @@ } } @@ -951,7 +952,7 @@ if (this.tickCount % 20 == 0) { this.getCombatTracker().recheckStatus(); } -@@ -2602,7 +3071,7 @@ +@@ -2610,7 +3074,7 @@ } @@ -960,7 +961,7 @@ Map map = this.collectEquipmentChanges(); if (map != null) { -@@ -2924,6 +3393,7 @@ +@@ -2949,6 +3413,7 @@ } if (!this.level().isClientSide) { @@ -968,7 +969,7 @@ this.setSharedFlag(7, flag); } -@@ -3114,14 +3584,21 @@ +@@ -3141,14 +3606,21 @@ @Override public boolean isPickable() { @@ -992,7 +993,7 @@ @Override public float getYHeadRot() { return this.yHeadRot; -@@ -3314,7 +3791,26 @@ +@@ -3346,7 +3818,26 @@ } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { this.triggerItemUseEffects(this.useItem, 16); @@ -1020,7 +1021,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3392,6 +3888,12 @@ +@@ -3424,6 +3915,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -1033,7 +1034,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3416,16 +3918,41 @@ +@@ -3448,16 +3945,41 @@ } if (flag2) { @@ -1078,7 +1079,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3437,7 +3964,7 @@ +@@ -3469,7 +3991,7 @@ entitycreature.getNavigation().stop(); } @@ -1087,7 +1088,7 @@ } } -@@ -3530,7 +4057,7 @@ +@@ -3562,7 +4084,7 @@ } public void stopSleeping() { @@ -1096,7 +1097,7 @@ World world = this.level(); java.util.Objects.requireNonNull(world); -@@ -3564,7 +4091,7 @@ +@@ -3596,7 +4118,7 @@ @Nullable public EnumDirection getBedOrientation() { @@ -1105,7 +1106,7 @@ return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null; } -@@ -3600,7 +4127,7 @@ +@@ -3633,7 +4155,7 @@ FoodInfo.b foodinfo_b = (FoodInfo.b) iterator.next(); if (this.random.nextFloat() < foodinfo_b.probability()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch new file mode 100644 index 0000000000..cd568c2985 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/world/entity/EntityTameableAnimal.java ++++ b/net/minecraft/world/entity/EntityTameableAnimal.java +@@ -27,6 +27,12 @@ + import net.minecraft.world.level.pathfinder.PathfinderNormal; + import net.minecraft.world.scores.ScoreboardTeam; + ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.event.entity.EntityTeleportEvent; ++// CraftBukkit end ++ + public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity { + + public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144; +@@ -281,7 +287,14 @@ + if (!this.canTeleportTo(new BlockPosition(i, j, k))) { + return false; + } else { +- this.moveTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.getYRot(), this.getXRot()); ++ // CraftBukkit start ++ EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this, (double) i + 0.5D, (double) j, (double) k + 0.5D); ++ if (event.isCancelled()) { ++ return false; ++ } ++ Location to = event.getTo(); ++ this.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ // CraftBukkit end + this.navigation.stop(); + return true; + } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch b/paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch new file mode 100644 index 0000000000..16295d0a0f --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/entity/Leashable.patch @@ -0,0 +1,121 @@ +--- a/net/minecraft/world/entity/Leashable.java ++++ b/net/minecraft/world/entity/Leashable.java +@@ -15,6 +15,11 @@ + import net.minecraft.world.level.IMaterial; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityUnleashEvent; ++import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; ++// CraftBukkit end ++ + public interface Leashable { + + String LEASH_TAG = "leash"; +@@ -44,7 +49,7 @@ + + default void setDelayedLeashHolderId(int i) { + this.setLeashData(new Leashable.a(i)); +- dropLeash((Entity) this, false, false); ++ dropLeash((Entity & Leashable) this, false, false); // CraftBukkit - decompile error + } + + @Nullable +@@ -53,7 +58,7 @@ + return new Leashable.a(Either.left(nbttagcompound.getCompound("leash").getUUID("UUID"))); + } else { + if (nbttagcompound.contains("leash", 11)) { +- Either either = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse((Object) null); ++ Either either = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse(null); // CraftBukkit - decompile error + + if (either != null) { + return new Leashable.a(either); +@@ -68,6 +73,11 @@ + if (leashable_a != null) { + Either either = leashable_a.delayedLeashInfo; + Entity entity = leashable_a.leashHolder; ++ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin ++ if (entity != null && entity.pluginRemoved) { ++ return; ++ } ++ // CraftBukkit end + + if (entity instanceof EntityLeash) { + EntityLeash entityleash = (EntityLeash) entity; +@@ -110,7 +120,9 @@ + } + + if (e0.tickCount > 100) { ++ e0.forceDrops = true; // CraftBukkit + e0.spawnAtLocation((IMaterial) Items.LEAD); ++ e0.forceDrops = false; // CraftBukkit + ((Leashable) e0).setLeashData((Leashable.a) null); + } + } +@@ -119,7 +131,7 @@ + } + + default void dropLeash(boolean flag, boolean flag1) { +- dropLeash((Entity) this, flag, flag1); ++ dropLeash((Entity & Leashable) this, flag, flag1); // CraftBukkit - decompile error + } + + private static void dropLeash(E e0, boolean flag, boolean flag1) { +@@ -128,7 +140,9 @@ + if (leashable_a != null && leashable_a.leashHolder != null) { + ((Leashable) e0).setLeashData((Leashable.a) null); + if (!e0.level().isClientSide && flag1) { ++ e0.forceDrops = true; // CraftBukkit + e0.spawnAtLocation((IMaterial) Items.LEAD); ++ e0.forceDrops = false; // CraftBukkit + } + + if (flag) { +@@ -153,7 +167,8 @@ + + if (leashable_a != null && leashable_a.leashHolder != null) { + if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) { +- dropLeash(e0, true, true); ++ e0.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit ++ dropLeash(e0, true, !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin + } + + Entity entity = ((Leashable) e0).getLeashHolder(); +@@ -183,13 +198,18 @@ + } + + default void leashTooFarBehaviour() { ++ // CraftBukkit start ++ if (this instanceof Entity entity) { ++ entity.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(entity.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); ++ } ++ // CraftBukkit end + this.dropLeash(true, true); + } + + default void closeRangeLeashBehaviour(Entity entity) {} + + default void elasticRangeLeashBehaviour(Entity entity, float f) { +- legacyElasticRangeLeashBehaviour((Entity) this, entity, f); ++ legacyElasticRangeLeashBehaviour((Entity & Leashable) this, entity, f); // CraftBukkit - decompile error + } + + private static void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) { +@@ -201,7 +221,7 @@ + } + + default void setLeashedTo(Entity entity, boolean flag) { +- setLeashedTo((Entity) this, entity, flag); ++ setLeashedTo((Entity & Leashable) this, entity, flag); // CraftBukkit - decompile error + } + + private static void setLeashedTo(E e0, Entity entity, boolean flag) { +@@ -232,7 +252,7 @@ + + @Nullable + default Entity getLeashHolder() { +- return getLeashHolder((Entity) this); ++ return getLeashHolder((Entity & Leashable) this); // CraftBukkit - decompile error + } + + @Nullable diff --git a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch b/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch deleted file mode 100644 index b27e8ae157..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.java -+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalFollowOwner.java -@@ -15,6 +15,12 @@ - import net.minecraft.world.level.pathfinder.PathType; - import net.minecraft.world.level.pathfinder.PathfinderNormal; - -+// CraftBukkit start -+import org.bukkit.Location; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityTeleportEvent; -+// CraftBukkit end -+ - public class PathfinderGoalFollowOwner extends PathfinderGoal { - - public static final int TELEPORT_WHEN_DISTANCE_IS = 12; -@@ -123,7 +129,14 @@ - } else if (!this.canTeleportTo(new BlockPosition(i, j, k))) { - return false; - } else { -- this.tamable.moveTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot()); -+ // CraftBukkit start -+ EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this.tamable, (double) i + 0.5D, (double) j, (double) k + 0.5D); -+ if (event.isCancelled()) { -+ return false; -+ } -+ Location to = event.getTo(); -+ this.tamable.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); -+ // CraftBukkit end - this.navigation.stop(); - return true; - } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch index 8857dec070..77ebdc3f32 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch @@ -1,11 +1,10 @@ --- a/net/minecraft/world/entity/animal/Bucketable.java +++ b/net/minecraft/world/entity/animal/Bucketable.java -@@ -17,6 +17,15 @@ +@@ -17,6 +17,14 @@ import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.World; +// CraftBukkit start -+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; +import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -16,7 +15,7 @@ public interface Bucketable { boolean fromBucket(); -@@ -93,10 +102,22 @@ +@@ -93,10 +101,22 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) { @@ -31,7 +30,7 @@ + itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket()); + if (playerBucketFishEvent.isCancelled()) { + ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSpawnEntity(t0)); // We need to play out these packets as the client assumes the fish is gone ++ t0.getBukkitEntity().update((EntityPlayer) entityhuman); // We need to play out these packets as the client assumes the fish is gone + t0.refreshEntityData((EntityPlayer) entityhuman); // Need to send data such as the display name to client + return Optional.of(EnumInteractionResult.FAIL); + } @@ -40,7 +39,7 @@ ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false); entityhuman.setItemInHand(enumhand, itemstack2); -@@ -106,7 +127,7 @@ +@@ -106,7 +126,7 @@ CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch index 0aff7f7538..b3940b512e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityBee.java +++ b/net/minecraft/world/entity/animal/EntityBee.java -@@ -86,6 +86,12 @@ +@@ -87,6 +87,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird { public static final float FLAP_DEGREES_PER_TICK = 120.32113F; -@@ -185,12 +191,19 @@ +@@ -186,12 +192,19 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { @@ -35,7 +35,7 @@ nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos())); } -@@ -204,8 +217,8 @@ +@@ -205,8 +218,8 @@ @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { @@ -46,16 +46,16 @@ super.readAdditionalSaveData(nbttagcompound); this.setHasNectar(nbttagcompound.getBoolean("HasNectar")); this.setHasStung(nbttagcompound.getBoolean("HasStung")); -@@ -232,7 +245,7 @@ +@@ -243,7 +256,7 @@ } if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this); ++ entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } -@@ -625,11 +638,14 @@ +@@ -636,11 +649,14 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { @@ -72,7 +72,7 @@ } } -@@ -981,7 +997,7 @@ +@@ -992,7 +1008,7 @@ e() { super(); @@ -81,7 +81,7 @@ this.blacklistedTargets = Lists.newArrayList(); this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -1098,7 +1114,7 @@ +@@ -1109,7 +1125,7 @@ f() { super(); @@ -90,7 +90,7 @@ this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -1198,7 +1214,7 @@ +@@ -1209,7 +1225,7 @@ } } @@ -99,7 +99,7 @@ EntityBee.this.level().levelEvent(2011, blockposition, 15); EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1); EntityBee.this.incrementNumCropsGrownSincePollination(); -@@ -1271,7 +1287,7 @@ +@@ -1282,7 +1298,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { @@ -108,7 +108,7 @@ } } -@@ -1280,7 +1296,7 @@ +@@ -1291,7 +1307,7 @@ private static class c extends PathfinderGoalNearestAttackableTarget { c(EntityBee entitybee) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch index 0c0c7414ac..334d99b6a8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityCat.java +++ b/net/minecraft/world/entity/animal/EntityCat.java -@@ -182,10 +182,10 @@ +@@ -181,10 +181,10 @@ @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); @@ -13,7 +13,7 @@ Objects.requireNonNull(iregistry); optional.flatMap(iregistry::getHolder).ifPresent(this::setVariant); -@@ -462,7 +462,7 @@ +@@ -452,7 +452,7 @@ } private void tryToTame(EntityHuman entityhuman) { @@ -22,7 +22,7 @@ this.tame(entityhuman); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte) 7); -@@ -480,7 +480,7 @@ +@@ -470,7 +470,7 @@ private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { @Nullable @@ -31,7 +31,7 @@ private final EntityCat cat; public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate predicate, boolean flag) { -@@ -621,7 +621,15 @@ +@@ -611,7 +611,15 @@ while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); @@ -48,7 +48,7 @@ } } -@@ -653,10 +661,10 @@ +@@ -643,10 +651,10 @@ private final EntityCat cat; public a(EntityCat entitycat, Class oclass, float f, double d0, double d1) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch index 2ecffe142a..932c266ec9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch @@ -21,7 +21,7 @@ private static final DataWatcherObject TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS); private static final DataWatcherObject GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN); private static final DataWatcherObject MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT); -@@ -183,7 +195,7 @@ +@@ -176,7 +188,7 @@ @Override public int getMaxAirSupply() { @@ -30,7 +30,7 @@ } @Override -@@ -219,11 +231,17 @@ +@@ -212,11 +224,17 @@ ItemStack itemstack = entityitem.getItem(); if (this.canHoldItem(itemstack)) { @@ -49,7 +49,7 @@ } } -@@ -474,7 +492,7 @@ +@@ -467,7 +485,7 @@ @Override public void start() { @@ -58,7 +58,7 @@ } @Override -@@ -493,7 +511,7 @@ +@@ -486,7 +504,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch index da5d876378..0477fb5526 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityIronGolem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityIronGolem.java +++ b/net/minecraft/world/entity/animal/EntityIronGolem.java -@@ -97,7 +97,7 @@ +@@ -98,7 +98,7 @@ @Override protected void doPush(Entity entity) { if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index fd9f79c2e2..adaf9451c4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityOcelot.java +++ b/net/minecraft/world/entity/animal/EntityOcelot.java -@@ -177,7 +177,7 @@ +@@ -168,7 +168,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) { this.usePlayerItem(entityhuman, enumhand, itemstack); if (!this.level().isClientSide) { @@ -9,7 +9,7 @@ this.setTrusting(true); this.spawnTrustingParticles(true); this.level().broadcastEntityEvent(this, (byte) 41); -@@ -308,10 +308,10 @@ +@@ -299,10 +299,10 @@ private final EntityOcelot ocelot; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch index 12a479cc3b..fc566a8393 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityPanda.java +++ b/net/minecraft/world/entity/animal/EntityPanda.java -@@ -72,6 +72,12 @@ +@@ -73,6 +73,12 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityPanda extends EntityAnimal { private static final DataWatcherObject UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT); -@@ -553,14 +559,14 @@ +@@ -558,14 +564,14 @@ @Override protected void pickUpItem(EntityItem entityitem) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch index 3f9c65d1c2..6087b83e9c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityParrot.patch @@ -18,7 +18,7 @@ if (entityhuman.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -368,7 +368,7 @@ +@@ -363,7 +363,7 @@ @Override public boolean isPushable() { @@ -27,7 +27,7 @@ } @Override -@@ -383,11 +383,14 @@ +@@ -378,11 +378,14 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch index 076aef7fc3..242b724f75 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityRabbit.java +++ b/net/minecraft/world/entity/animal/EntityRabbit.java -@@ -66,6 +66,10 @@ +@@ -67,6 +67,10 @@ import net.minecraft.world.level.pathfinder.PathEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityRabbit extends EntityAnimal implements VariantHolder { public static final double STROLL_SPEED_MOD = 0.6D; -@@ -88,7 +92,6 @@ +@@ -91,7 +95,6 @@ super(entitytypes, world); this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this); this.moveControl = new EntityRabbit.ControllerMoveRabbit(this); @@ -19,7 +19,7 @@ } @Override -@@ -574,9 +577,19 @@ +@@ -578,9 +581,19 @@ int i = (Integer) iblockdata.getValue(BlockCarrots.AGE); if (i == 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch index b18db46cec..8bc4c6cefe 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch @@ -1,21 +1,19 @@ --- a/net/minecraft/world/entity/animal/EntitySheep.java +++ b/net/minecraft/world/entity/animal/EntitySheep.java -@@ -64,6 +64,14 @@ +@@ -63,6 +63,12 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.LootTables; +// CraftBukkit start -+import net.minecraft.world.inventory.InventoryCraftResult; +import net.minecraft.world.item.Item; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.SheepRegrowWoolEvent; -+import org.bukkit.inventory.InventoryView; +// CraftBukkit end + public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; -@@ -251,6 +259,11 @@ +@@ -250,6 +256,11 @@ if (itemstack.is(Items.SHEARS)) { if (!this.level().isClientSide && this.readyForShearing()) { @@ -27,7 +25,7 @@ this.shear(SoundCategory.PLAYERS); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -270,7 +283,9 @@ +@@ -269,7 +280,9 @@ int i = 1 + this.random.nextInt(3); for (int j = 0; j < i; ++j) { @@ -37,7 +35,7 @@ if (entityitem != null) { entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); -@@ -363,6 +378,12 @@ +@@ -362,6 +375,12 @@ @Override public void ate() { @@ -50,31 +48,12 @@ super.ate(); this.setSheared(false); if (this.isBaby()) { -@@ -382,7 +403,7 @@ +@@ -381,7 +400,7 @@ EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); - InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1); -- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { -+ Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error - return ((RecipeCrafting) recipeholder.value()).assemble(inventorycrafting, this.level().registryAccess()); + CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1); +- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { ++ Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error + return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, this.level().registryAccess()); }).map(ItemStack::getItem); -@@ -405,10 +426,18 @@ - public boolean stillValid(EntityHuman entityhuman) { - return false; - } -+ -+ // CraftBukkit start -+ @Override -+ public InventoryView getBukkitView() { -+ return null; // TODO: O.O -+ } -+ // CraftBukkit end - }, 2, 1); - - transientcraftingcontainer.setItem(0, new ItemStack(ItemDye.byColor(enumcolor))); - transientcraftingcontainer.setItem(1, new ItemStack(ItemDye.byColor(enumcolor1))); -+ transientcraftingcontainer.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event - return transientcraftingcontainer; - } - } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch index 27c94ca38b..b12d004577 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityWolf.java +++ b/net/minecraft/world/entity/animal/EntityWolf.java -@@ -88,6 +88,12 @@ +@@ -90,6 +90,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder> { private static final DataWatcherObject DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); -@@ -350,18 +356,21 @@ +@@ -360,11 +366,14 @@ if (this.isInvulnerableTo(damagesource)) { return false; } else { @@ -30,6 +30,9 @@ } } +@@ -374,9 +383,9 @@ + } + @Override - protected void actuallyHurt(DamageSource damagesource, float f) { + public boolean actuallyHurt(DamageSource damagesource, float f) { // CraftBukkit - void -> boolean @@ -39,7 +42,7 @@ } else { ItemStack itemstack = this.getBodyArmorItem(); int i = itemstack.getDamageValue(); -@@ -380,6 +389,7 @@ +@@ -395,6 +404,7 @@ } } @@ -47,7 +50,7 @@ } private boolean canArmorAbsorb(DamageSource damagesource) { -@@ -401,7 +411,7 @@ +@@ -405,7 +415,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D); @@ -56,7 +59,7 @@ } else { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D); } -@@ -428,7 +438,7 @@ +@@ -432,7 +442,7 @@ FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD); float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F; @@ -65,7 +68,7 @@ return EnumInteractionResult.sidedSuccess(this.level().isClientSide()); } else { if (item instanceof ItemDye) { -@@ -476,7 +486,7 @@ +@@ -480,7 +490,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); @@ -74,7 +77,7 @@ return EnumInteractionResult.SUCCESS_NO_ITEM_USED; } else { return enuminteractionresult; -@@ -494,7 +504,8 @@ +@@ -498,7 +508,8 @@ } private void tryToTame(EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch index 6572fd5ee2..5ffafed7f8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -99,6 +99,7 @@ +@@ -101,6 +101,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,7 +8,7 @@ public Allay(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -110,6 +111,12 @@ +@@ -112,6 +113,12 @@ this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius())); } @@ -21,7 +21,7 @@ @Override protected BehaviorController.b brainProvider() { return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES); -@@ -122,7 +129,7 @@ +@@ -124,7 +131,7 @@ @Override public BehaviorController getBrain() { @@ -30,7 +30,7 @@ } public static AttributeProvider.Builder createAttributes() { -@@ -223,7 +230,7 @@ +@@ -225,7 +232,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) { @@ -39,7 +39,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -293,7 +300,12 @@ +@@ -295,7 +302,12 @@ ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND); if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) { @@ -53,7 +53,7 @@ this.level().broadcastEntityEvent(this, (byte) 18); this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(entityhuman, itemstack); -@@ -304,7 +316,7 @@ +@@ -306,7 +318,7 @@ this.setItemInHand(EnumHand.MAIN_HAND, itemstack2); this.removeInteractionItem(entityhuman, itemstack); this.level().playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F); @@ -62,7 +62,7 @@ return EnumInteractionResult.SUCCESS; } else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) { this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY); -@@ -405,6 +417,7 @@ +@@ -407,6 +419,7 @@ } private boolean shouldStopDancing() { @@ -70,25 +70,7 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); } -@@ -449,7 +462,7 @@ - public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.addAdditionalSaveData(nbttagcompound); - this.writeInventoryToTag(nbttagcompound, this.registryAccess()); -- DataResult dataresult = VibrationSystem.a.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.vibrationData); -+ DataResult dataresult = VibrationSystem.a.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.vibrationData); // CraftBukkit - decompile error - Logger logger = Allay.LOGGER; - - Objects.requireNonNull(logger); -@@ -465,7 +478,7 @@ - super.readAdditionalSaveData(nbttagcompound); - this.readInventoryFromTag(nbttagcompound, this.registryAccess()); - if (nbttagcompound.contains("listener", 10)) { -- DataResult dataresult = VibrationSystem.a.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); -+ DataResult dataresult = VibrationSystem.a.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); // CraftBukkit - decompile error - Logger logger = Allay.LOGGER; - - Objects.requireNonNull(logger); -@@ -498,7 +511,7 @@ +@@ -500,7 +513,7 @@ return Allay.DUPLICATION_ITEM.test(itemstack); } @@ -97,7 +79,7 @@ Allay allay = (Allay) EntityTypes.ALLAY.create(this.level()); if (allay != null) { -@@ -506,9 +519,9 @@ +@@ -508,9 +521,9 @@ allay.setPersistenceRequired(); allay.resetDuplicationCooldown(); this.resetDuplicationCooldown(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch index c526525d72..f779c3a422 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -131,14 +131,16 @@ +@@ -132,14 +132,16 @@ @Override protected void customServerAiStep() { this.level().getProfiler().push("armadilloBrain"); @@ -18,7 +18,7 @@ this.gameEvent(GameEvent.ENTITY_PLACE); this.scuteTime = this.pickNextScuteDropTime(); } -@@ -285,8 +287,13 @@ +@@ -286,8 +288,13 @@ } @Override @@ -34,15 +34,15 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (damagesource.getEntity() instanceof EntityLiving) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -298,6 +305,7 @@ +@@ -299,6 +306,7 @@ } } + return hurt; // CraftBukkit } - public boolean shouldPanic() { -@@ -329,7 +337,9 @@ + @Override +@@ -326,7 +334,9 @@ if (this.isBaby()) { return false; } else { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch index 90f6fdcf38..f8aec072ea 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/axolotl/Axolotl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -67,9 +67,16 @@ +@@ -68,9 +68,16 @@ public class Axolotl extends EntityAnimal implements LerpingModel, VariantHolder, Bucketable { @@ -18,7 +18,7 @@ private static final DataWatcherObject DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT); private static final DataWatcherObject DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); private static final DataWatcherObject FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); -@@ -186,7 +193,7 @@ +@@ -187,7 +194,7 @@ @Override public int getMaxAirSupply() { @@ -27,7 +27,7 @@ } @Override -@@ -397,7 +404,7 @@ +@@ -391,7 +398,7 @@ int i = mobeffect != null ? mobeffect.getDuration() : 0; int j = Math.min(2400, 100 + i); @@ -36,7 +36,7 @@ } entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); -@@ -447,7 +454,7 @@ +@@ -441,7 +448,7 @@ @Override public BehaviorController getBrain() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch index 453c03db02..0439fa3ae0 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch @@ -9,7 +9,7 @@ behaviorcontroller.tick((WorldServer) this.level(), this); this.level().getProfiler().pop(); -@@ -451,9 +451,15 @@ +@@ -452,9 +452,15 @@ } @Override diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch index ad9b3e3723..0903590a82 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch @@ -20,7 +20,7 @@ } @Override -@@ -232,9 +236,15 @@ +@@ -232,10 +236,16 @@ } frog.setPersistenceRequired(); @@ -30,6 +30,7 @@ + return; + } + // CraftBukkit end + frog.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); this.playSound(SoundEffects.TADPOLE_GROW_UP, 0.15F, 1.0F); - worldserver.addFreshEntityWithPassengers(frog); - this.discard(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch index 0109a6838a..cf3814014b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java +++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java -@@ -79,6 +79,18 @@ +@@ -81,6 +81,18 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.ticks.ContainerSingleItem; @@ -19,7 +19,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable { public static final int EQUIPMENT_SLOT_OFFSET = 400; -@@ -156,7 +168,53 @@ +@@ -158,7 +170,53 @@ public boolean stillValid(EntityHuman entityhuman) { return entityhuman.getVehicle() == EntityHorseAbstract.this || entityhuman.canInteractWithEntity((Entity) EntityHorseAbstract.this, 4.0D); } @@ -73,7 +73,7 @@ protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -346,7 +404,7 @@ +@@ -353,7 +411,7 @@ public void createInventory() { InventorySubcontainer inventorysubcontainer = this.inventory; @@ -82,7 +82,7 @@ if (inventorysubcontainer != null) { inventorysubcontainer.removeListener(this); int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -450,7 +508,7 @@ +@@ -457,7 +515,7 @@ } public int getMaxTemper() { @@ -91,7 +91,7 @@ } @Override -@@ -521,7 +579,7 @@ +@@ -528,7 +586,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -100,7 +100,7 @@ flag = true; } -@@ -595,7 +653,7 @@ +@@ -602,7 +660,7 @@ super.aiStep(); if (!this.level().isClientSide && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { @@ -109,7 +109,7 @@ } if (this.canEatGrass()) { -@@ -857,6 +915,7 @@ +@@ -864,6 +922,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.putUUID("Owner", this.getOwnerUUID()); } @@ -117,7 +117,7 @@ if (!this.inventory.getItem(0).isEmpty()) { nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess())); -@@ -884,6 +943,11 @@ +@@ -891,6 +950,11 @@ if (uuid != null) { this.setOwnerUUID(uuid); } @@ -129,7 +129,7 @@ if (nbttagcompound.contains("SaddleItem", 10)) { ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY); -@@ -986,6 +1050,17 @@ +@@ -993,6 +1057,17 @@ @Override public void handleStartJump(int i) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch index 0f6fe4303f..19695c4495 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch @@ -13,7 +13,7 @@ public class EntityEnderCrystal extends Entity { private static final DataWatcherObject> DATA_BEAM_TARGET = DataWatcher.defineId(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS); -@@ -55,7 +61,11 @@ +@@ -57,7 +63,11 @@ BlockPosition blockposition = this.blockPosition(); if (((WorldServer) this.level()).getDragonFight() != null && this.level().getBlockState(blockposition).isAir()) { @@ -26,7 +26,7 @@ } } -@@ -92,12 +102,26 @@ +@@ -94,12 +104,26 @@ return false; } else { if (!this.isRemoved() && !this.level().isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch index 31fab595ef..8d68b5bffd 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java -@@ -51,6 +51,20 @@ +@@ -52,6 +52,20 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -21,7 +21,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -88,6 +102,7 @@ +@@ -89,6 +103,7 @@ private final PathPoint[] nodes; private final int[] nodeAdjacency; private final Path openSet; @@ -29,7 +29,7 @@ public EntityEnderDragon(EntityTypes entitytypes, World world) { super(EntityTypes.ENDER_DRAGON, world); -@@ -109,6 +124,7 @@ +@@ -110,6 +125,7 @@ this.noPhysics = true; this.noCulling = true; this.phaseManager = new DragonControllerManager(this); @@ -37,7 +37,7 @@ } public void setDragonFight(EnderDragonBattle enderdragonbattle) { -@@ -256,7 +272,7 @@ +@@ -257,7 +273,7 @@ Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation(); @@ -46,7 +46,7 @@ double d0 = vec3d1.x - this.getX(); double d1 = vec3d1.y - this.getY(); double d2 = vec3d1.z - this.getZ(); -@@ -397,7 +413,14 @@ +@@ -404,7 +420,14 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -62,7 +62,7 @@ } } -@@ -472,6 +495,9 @@ +@@ -489,6 +512,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; @@ -72,7 +72,7 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -481,7 +507,11 @@ +@@ -498,7 +524,11 @@ if (!iblockdata.isAir() && !iblockdata.is(TagsBlock.DRAGON_TRANSPARENT)) { if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) { @@ -85,7 +85,7 @@ } else { flag = true; } -@@ -490,6 +520,51 @@ +@@ -507,6 +537,51 @@ } } @@ -137,7 +137,7 @@ if (flag1) { BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1)); -@@ -545,7 +620,7 @@ +@@ -562,7 +637,7 @@ @Override public void kill() { @@ -146,13 +146,13 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -554,6 +629,21 @@ +@@ -571,6 +646,21 @@ } + // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time. + @Override -+ public int getExpReward() { ++ public int getExpReward(Entity entity) { + // CraftBukkit - Moved from #tickDeath method + boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); + short short0 = 500; @@ -168,7 +168,7 @@ @Override protected void tickDeath() { if (this.dragonFight != null) { -@@ -569,15 +659,20 @@ +@@ -586,15 +676,20 @@ this.level().addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D); } @@ -190,7 +190,7 @@ EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.08F)); } -@@ -588,7 +683,7 @@ +@@ -605,7 +700,7 @@ this.move(EnumMoveType.SELF, new Vec3D(0.0D, 0.10000000149011612D, 0.0D)); if (this.dragonDeathTime == 200 && this.level() instanceof WorldServer) { @@ -199,7 +199,7 @@ EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.2F)); } -@@ -596,7 +691,7 @@ +@@ -613,7 +708,7 @@ this.dragonFight.setDragonKilled(this); } @@ -208,7 +208,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -809,6 +904,7 @@ +@@ -826,6 +921,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime); @@ -216,7 +216,7 @@ } @Override -@@ -822,6 +918,11 @@ +@@ -839,6 +935,11 @@ this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime"); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch b/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch index daff9e28a6..e27efc7a79 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/boss/wither/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/EntityWither.java +++ b/net/minecraft/world/entity/boss/wither/EntityWither.java -@@ -58,6 +58,18 @@ +@@ -59,6 +59,18 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -19,7 +19,7 @@ public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity { private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); -@@ -254,15 +266,40 @@ +@@ -255,15 +267,40 @@ i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { @@ -63,7 +63,7 @@ } } else { -@@ -307,6 +344,7 @@ +@@ -308,6 +345,7 @@ if (!list.isEmpty()) { EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size())); @@ -71,7 +71,7 @@ this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -333,6 +371,11 @@ +@@ -334,6 +372,11 @@ IBlockData iblockdata = this.level().getBlockState(blockposition); if (canDestroy(iblockdata)) { @@ -83,7 +83,7 @@ flag = this.level().destroyBlock(blockposition, true, this) || flag; } } -@@ -344,7 +387,7 @@ +@@ -345,7 +388,7 @@ } if (this.tickCount % 20 == 0) { @@ -92,7 +92,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -500,7 +543,7 @@ +@@ -502,7 +545,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch similarity index 57% rename from paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch rename to paper-server/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch index ac14195543..5a159a32fd 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityHanging.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch @@ -1,87 +1,22 @@ ---- a/net/minecraft/world/entity/decoration/EntityHanging.java -+++ b/net/minecraft/world/entity/decoration/EntityHanging.java -@@ -27,6 +27,14 @@ - import org.apache.commons.lang3.Validate; +--- a/net/minecraft/world/entity/decoration/BlockAttachedEntity.java ++++ b/net/minecraft/world/entity/decoration/BlockAttachedEntity.java +@@ -15,6 +15,15 @@ + import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.tags.DamageTypeTags; ++import net.minecraft.world.level.block.state.IBlockData; +import org.bukkit.entity.Hanging; +import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +// CraftBukkit end + - public abstract class EntityHanging extends Entity { + public abstract class BlockAttachedEntity extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -61,26 +69,37 @@ - - protected void recalculateBoundingBox() { - if (this.direction != null) { -- double d0 = (double) this.pos.getX() + 0.5D; -- double d1 = (double) this.pos.getY() + 0.5D; -- double d2 = (double) this.pos.getZ() + 0.5D; -+ // CraftBukkit start code moved in to calculateBoundingBox -+ this.setBoundingBox(calculateBoundingBox(this, this.pos, this.direction, this.getWidth(), this.getHeight())); -+ // CraftBukkit end -+ } -+ } -+ -+ // CraftBukkit start - break out BB calc into own method -+ public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) { -+ { -+ double d0 = (double) blockPosition.getX() + 0.5D; -+ double d1 = (double) blockPosition.getY() + 0.5D; -+ double d2 = (double) blockPosition.getZ() + 0.5D; - double d3 = 0.46875D; -- double d4 = this.offs(this.getWidth()); -- double d5 = this.offs(this.getHeight()); -+ double d4 = offs(width); -+ double d5 = offs(height); - -- d0 -= (double) this.direction.getStepX() * 0.46875D; -- d2 -= (double) this.direction.getStepZ() * 0.46875D; -+ d0 -= (double) direction.getStepX() * 0.46875D; -+ d2 -= (double) direction.getStepZ() * 0.46875D; - d1 += d5; -- EnumDirection enumdirection = this.direction.getCounterClockWise(); -+ EnumDirection enumdirection = direction.getCounterClockWise(); - - d0 += d4 * (double) enumdirection.getStepX(); - d2 += d4 * (double) enumdirection.getStepZ(); -- this.setPosRaw(d0, d1, d2); -- double d6 = (double) this.getWidth(); -- double d7 = (double) this.getHeight(); -- double d8 = (double) this.getWidth(); -+ if (entity != null) { -+ entity.setPosRaw(d0, d1, d2); -+ } -+ double d6 = (double) width; -+ double d7 = (double) height; -+ double d8 = (double) width; - -- if (this.direction.getAxis() == EnumDirection.EnumAxis.Z) { -+ if (direction.getAxis() == EnumDirection.EnumAxis.Z) { - d8 = 1.0D; - } else { - d6 = 1.0D; -@@ -89,11 +108,12 @@ - d6 /= 32.0D; - d7 /= 32.0D; - d8 /= 32.0D; -- this.setBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); -+ return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8); - } - } -+ // CraftBukkit end - -- private double offs(int i) { -+ private static double offs(int i) { // CraftBukkit - static - return i % 32 == 0 ? 0.5D : 0.0D; - } - -@@ -104,7 +124,25 @@ +@@ -39,7 +48,25 @@ if (this.checkInterval++ == 100) { this.checkInterval = 0; if (!this.isRemoved() && !this.survives()) { @@ -108,12 +43,12 @@ this.dropItem((Entity) null); } } -@@ -165,6 +203,22 @@ +@@ -69,6 +96,22 @@ return false; } else { if (!this.isRemoved() && !this.level().isClientSide) { + // CraftBukkit start - fire break events -+ Entity damager = (damagesource.isIndirect()) ? damagesource.getEntity() : damagesource.getDirectEntity(); ++ Entity damager = (damagesource.isDirect()) ? damagesource.getDirectEntity() : damagesource.getEntity(); + HangingBreakEvent event; + if (damager != null) { + event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), damagesource.is(DamageTypeTags.IS_EXPLOSION) ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY); @@ -131,7 +66,7 @@ this.kill(); this.markHurt(); this.dropItem(damagesource.getEntity()); -@@ -177,6 +231,18 @@ +@@ -81,6 +124,18 @@ @Override public void move(EnumMoveType enummovetype, Vec3D vec3d) { if (!this.level().isClientSide && !this.isRemoved() && vec3d.lengthSqr() > 0.0D) { @@ -150,7 +85,7 @@ this.kill(); this.dropItem((Entity) null); } -@@ -185,13 +251,22 @@ +@@ -89,13 +144,22 @@ @Override public void push(double d0, double d1, double d2) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch index 2b0a1644be..7770160f77 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityArmorStand.java +++ b/net/minecraft/world/entity/decoration/EntityArmorStand.java -@@ -47,6 +47,16 @@ +@@ -46,6 +46,16 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -17,7 +17,7 @@ public class EntityArmorStand extends EntityLiving { public static final int WOBBLE_TIME = 5; -@@ -112,6 +122,13 @@ +@@ -111,6 +121,13 @@ return createLivingAttributes().add(GenericAttributes.STEP_HEIGHT, 0.0D); } @@ -31,7 +31,7 @@ @Override public void refreshDimensions() { double d0 = this.getX(); -@@ -172,13 +189,20 @@ +@@ -171,13 +188,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -48,13 +48,13 @@ - this.onEquipItem(enumitemslot, (ItemStack) this.handItems.set(enumitemslot.getIndex(), itemstack), itemstack); + this.onEquipItem(enumitemslot, (ItemStack) this.handItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit break; - case ARMOR: + case HUMANOID_ARMOR: - this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack); + this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit } } -@@ -408,7 +432,25 @@ +@@ -407,7 +431,25 @@ return false; } else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterFlag() + 16) != 0) { return false; @@ -81,7 +81,7 @@ this.setItemSlot(enumitemslot, itemstack.copyWithCount(1)); return true; } else if (!itemstack.isEmpty() && itemstack.getCount() > 1) { -@@ -423,18 +465,29 @@ +@@ -422,6 +464,7 @@ entityhuman.setItemInHand(enumhand, itemstack1); return true; } @@ -89,75 +89,76 @@ } @Override - public boolean hurt(DamageSource damagesource, float f) { - if (!this.level().isClientSide && !this.isRemoved()) { - if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { -- this.kill(); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { -+ return false; -+ } -+ this.kill(damagesource); // CraftBukkit -+ // CraftBukkit end - return false; -- } else if (!this.isInvulnerableTo(damagesource) && !this.invisible && !this.isMarker()) { -+ } else if (!this.isInvulnerableTo(damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) { -+ return false; -+ } -+ // CraftBukkit end - if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) { - this.brokenByAnything(damagesource); +@@ -435,12 +478,22 @@ + WorldServer worldserver = (WorldServer) world; + + if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { - this.kill(); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { ++ return false; ++ } + this.kill(damagesource); // CraftBukkit ++ // CraftBukkit end return false; - } else if (damagesource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { - if (this.isOnFire()) { -@@ -467,7 +520,7 @@ - if (damagesource.isCreativePlayer()) { - this.playBrokenSound(); - this.showBreakingParticles(); -- this.kill(); -+ this.kill(damagesource); // CraftBukkit - return true; - } else { - long i = this.level().getGameTime(); -@@ -479,7 +532,7 @@ - } else { - this.brokenByPlayer(damagesource); +- } else if (!this.isInvulnerableTo(damagesource) && !this.invisible && !this.isMarker()) { ++ } else if (!this.isInvulnerableTo(damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) { ++ return false; ++ } ++ // CraftBukkit end + if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) { + this.brokenByAnything(worldserver, damagesource); +- this.kill(); ++ this.kill(damagesource); // CraftBukkit + return false; + } else if (damagesource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { + if (this.isOnFire()) { +@@ -473,7 +526,7 @@ + if (damagesource.isCreativePlayer()) { + this.playBrokenSound(); this.showBreakingParticles(); - this.kill(); -+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event - } ++ this.kill(damagesource); // CraftBukkit + return true; + } else { + long i = worldserver.getGameTime(); +@@ -485,7 +538,7 @@ + } else { + this.brokenByPlayer(worldserver, damagesource); + this.showBreakingParticles(); +- this.kill(); ++ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event + } - return true; -@@ -532,7 +585,7 @@ + return true; +@@ -539,7 +592,7 @@ f1 -= f; if (f1 <= 0.5F) { - this.brokenByAnything(damagesource); + this.brokenByAnything(worldserver, damagesource); - this.kill(); + this.kill(damagesource); // CraftBukkit } else { this.setHealth(f1); this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity()); -@@ -544,13 +597,13 @@ +@@ -551,13 +604,13 @@ ItemStack itemstack = new ItemStack(Items.ARMOR_STAND); itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName()); - Block.popResource(this.level(), this.blockPosition(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.brokenByAnything(damagesource); + this.brokenByAnything(worldserver, damagesource); } - private void brokenByAnything(DamageSource damagesource) { + private void brokenByAnything(WorldServer worldserver, DamageSource damagesource) { this.playBrokenSound(); -- this.dropAllDeathLoot(damagesource); -+ // this.dropAllDeathLoot(damagesource); // CraftBukkit - moved down +- this.dropAllDeathLoot(worldserver, damagesource); ++ // this.dropAllDeathLoot(worldserver, damagesource); // CraftBukkit - moved down ItemStack itemstack; int i; -@@ -558,7 +611,7 @@ +@@ -565,7 +618,7 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { @@ -166,7 +167,7 @@ this.handItems.set(i, ItemStack.EMPTY); } } -@@ -566,10 +619,11 @@ +@@ -573,10 +626,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { @@ -175,11 +176,11 @@ this.armorItems.set(i, ItemStack.EMPTY); } } -+ this.dropAllDeathLoot(damagesource); // CraftBukkit - moved from above ++ this.dropAllDeathLoot(worldserver, damagesource); // CraftBukkit - moved from above } -@@ -660,9 +714,23 @@ +@@ -667,9 +721,23 @@ return this.isSmall(); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch index 54cf44902a..1be425e0ee 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch @@ -1,54 +1,19 @@ --- a/net/minecraft/world/entity/decoration/EntityItemFrame.java +++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java -@@ -90,16 +90,27 @@ +@@ -90,6 +90,12 @@ + @Override - protected void recalculateBoundingBox() { - if (this.direction != null) { -+ // CraftBukkit start code moved in to calculateBoundingBox -+ this.setBoundingBox(calculateBoundingBox(this, this.pos, this.direction, this.getWidth(), this.getHeight())); -+ // CraftBukkit end -+ } + protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) { ++ // CraftBukkit start - break out BB calc into own method ++ return calculateBoundingBoxStatic(blockposition, enumdirection); + } + -+ // CraftBukkit start - break out BB calc into own method -+ public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) { -+ { - double d0 = 0.46875D; -- double d1 = (double) this.pos.getX() + 0.5D - (double) this.direction.getStepX() * 0.46875D; -- double d2 = (double) this.pos.getY() + 0.5D - (double) this.direction.getStepY() * 0.46875D; -- double d3 = (double) this.pos.getZ() + 0.5D - (double) this.direction.getStepZ() * 0.46875D; -+ double d1 = (double) blockPosition.getX() + 0.5D - (double) direction.getStepX() * 0.46875D; -+ double d2 = (double) blockPosition.getY() + 0.5D - (double) direction.getStepY() * 0.46875D; -+ double d3 = (double) blockPosition.getZ() + 0.5D - (double) direction.getStepZ() * 0.46875D; - -- this.setPosRaw(d1, d2, d3); -- double d4 = (double) this.getWidth(); -- double d5 = (double) this.getHeight(); -- double d6 = (double) this.getWidth(); -- EnumDirection.EnumAxis enumdirection_enumaxis = this.direction.getAxis(); -+ if (entity != null) { -+ entity.setPosRaw(d1, d2, d3); -+ } -+ double d4 = (double) width; -+ double d5 = (double) height; -+ double d6 = (double) width; -+ EnumDirection.EnumAxis enumdirection_enumaxis = direction.getAxis(); - - switch (enumdirection_enumaxis) { - case X: -@@ -115,9 +126,10 @@ - d4 /= 32.0D; - d5 /= 32.0D; - d6 /= 32.0D; -- this.setBoundingBox(new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6)); -+ return new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6); - } - } -+ // CraftBukkit end - - @Override - public boolean survives() { -@@ -162,6 +174,11 @@ ++ public static AxisAlignedBB calculateBoundingBoxStatic(BlockPosition blockposition, EnumDirection enumdirection) { ++ // CraftBukkit end + float f = 0.46875F; + Vec3D vec3d = Vec3D.atCenterOf(blockposition).relative(enumdirection, -0.46875D); + EnumDirection.EnumAxis enumdirection_enumaxis = enumdirection.getAxis(); +@@ -143,6 +149,11 @@ return false; } else if (!damagesource.is(DamageTypeTags.IS_EXPLOSION) && !this.getItem().isEmpty()) { if (!this.level().isClientSide) { @@ -60,7 +25,7 @@ this.dropItem(damagesource.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, damagesource.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -284,13 +301,19 @@ +@@ -255,13 +266,19 @@ } public void setItem(ItemStack itemstack, boolean flag) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch index 23a7bb576c..2b0db10d68 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityLeash.java +++ b/net/minecraft/world/entity/decoration/EntityLeash.java -@@ -24,6 +24,13 @@ +@@ -26,6 +26,13 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -11,24 +11,26 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + - public class EntityLeash extends EntityHanging { + public class EntityLeash extends BlockAttachedEntity { public static final double OFFSET_Y = 0.375D; -@@ -89,6 +96,13 @@ - EntityInsentient entityinsentient = (EntityInsentient) iterator.next(); +@@ -84,6 +91,15 @@ + Leashable leashable = (Leashable) iterator.next(); - if (entityinsentient.getLeashHolder() == entityhuman) { + if (leashable.getLeashHolder() == entityhuman) { + // CraftBukkit start -+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman, enumhand).isCancelled()) { -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); -+ flag = true; // Also set true when the event is cancelled otherwise it tries to unleash the entities -+ continue; ++ if (leashable instanceof Entity leashed) { ++ if (CraftEventFactory.callPlayerLeashEntityEvent(leashed, this, entityhuman, enumhand).isCancelled()) { ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(leashed, leashable.getLeashHolder())); ++ flag = true; // Also set true when the event is cancelled otherwise it tries to unleash the entities ++ continue; ++ } + } + // CraftBukkit end - entityinsentient.setLeashedTo(this, true); + leashable.setLeashedTo(this, true); flag = true; } -@@ -97,18 +111,32 @@ +@@ -92,18 +108,34 @@ boolean flag1 = false; if (!flag) { @@ -42,16 +44,18 @@ Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { - EntityInsentient entityinsentient1 = (EntityInsentient) iterator1.next(); + Leashable leashable1 = (Leashable) iterator1.next(); - if (entityinsentient1.isLeashed() && entityinsentient1.getLeashHolder() == this) { -- entityinsentient1.dropLeash(true, false); + if (leashable1.isLeashed() && leashable1.getLeashHolder() == this) { +- leashable1.dropLeash(true, false); + // CraftBukkit start -+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient1, entityhuman, enumhand).isCancelled()) { -+ die = false; -+ continue; ++ if (leashable1 instanceof Entity leashed) { ++ if (CraftEventFactory.callPlayerUnleashEntityEvent(leashed, entityhuman, enumhand).isCancelled()) { ++ die = false; ++ continue; ++ } + } -+ entityinsentient1.dropLeash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean ++ leashable1.dropLeash(true, !entityhuman.getAbilities().instabuild); // false -> survival mode boolean + // CraftBukkit end flag1 = true; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch new file mode 100644 index 0000000000..bfdd9a1782 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch @@ -0,0 +1,51 @@ +--- a/net/minecraft/world/entity/decoration/EntityPainting.java ++++ b/net/minecraft/world/entity/decoration/EntityPainting.java +@@ -71,7 +71,7 @@ + public static Optional create(World world, BlockPosition blockposition, EnumDirection enumdirection) { + EntityPainting entitypainting = new EntityPainting(world, blockposition); + List> list = new ArrayList(); +- Iterable iterable = world.registryAccess().registryOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); ++ Iterable> iterable = world.registryAccess().registryOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); // CraftBukkit - decompile error + + Objects.requireNonNull(list); + iterable.forEach(list::add); +@@ -137,22 +137,32 @@ + + @Override + protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) { ++ // CraftBukkit start ++ PaintingVariant paintingvariant = (PaintingVariant) this.getVariant().value(); ++ return calculateBoundingBoxStatic(blockposition, enumdirection, paintingvariant.width(), paintingvariant.height()); ++ } ++ ++ public static AxisAlignedBB calculateBoundingBoxStatic(BlockPosition blockposition, EnumDirection enumdirection, int width, int height) { ++ // CraftBukkit end + float f = 0.46875F; + Vec3D vec3d = Vec3D.atCenterOf(blockposition).relative(enumdirection, -0.46875D); +- PaintingVariant paintingvariant = (PaintingVariant) this.getVariant().value(); +- double d0 = this.offsetForPaintingSize(paintingvariant.width()); +- double d1 = this.offsetForPaintingSize(paintingvariant.height()); ++ // CraftBukkit start ++ double d0 = offsetForPaintingSize(width); ++ double d1 = offsetForPaintingSize(height); ++ // CraftBukkit end + EnumDirection enumdirection1 = enumdirection.getCounterClockWise(); + Vec3D vec3d1 = vec3d.relative(enumdirection1, d0).relative(EnumDirection.UP, d1); + EnumDirection.EnumAxis enumdirection_enumaxis = enumdirection.getAxis(); +- double d2 = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? 0.0625D : (double) paintingvariant.width(); +- double d3 = (double) paintingvariant.height(); +- double d4 = enumdirection_enumaxis == EnumDirection.EnumAxis.Z ? 0.0625D : (double) paintingvariant.width(); ++ // CraftBukkit start ++ double d2 = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? 0.0625D : (double) width; ++ double d3 = (double) height; ++ double d4 = enumdirection_enumaxis == EnumDirection.EnumAxis.Z ? 0.0625D : (double) width; ++ // CraftBukkit end + + return AxisAlignedBB.ofSize(vec3d1, d2, d3, d4); + } + +- private double offsetForPaintingSize(int i) { ++ private static double offsetForPaintingSize(int i) { // CraftBukkit - static + return i % 2 == 0 ? 0.5D : 0.0D; + } + diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index 106011ca4e..1c8bbcb541 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/EntityFallingBlock.java +++ b/net/minecraft/world/entity/item/EntityFallingBlock.java -@@ -49,6 +49,11 @@ +@@ -52,6 +52,11 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -12,7 +12,7 @@ public class EntityFallingBlock extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -83,10 +88,17 @@ +@@ -87,10 +92,17 @@ } public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -31,7 +31,7 @@ return entityfallingblock; } -@@ -126,7 +138,7 @@ +@@ -130,7 +142,7 @@ @Override public void tick() { if (this.blockState.isAir()) { @@ -40,7 +40,7 @@ } else { Block block = this.blockState.getBlock(); -@@ -154,7 +166,7 @@ +@@ -159,7 +171,7 @@ this.spawnAtLocation((IMaterial) block); } @@ -49,7 +49,7 @@ } } else { IBlockData iblockdata = this.level().getBlockState(blockposition); -@@ -171,9 +183,15 @@ +@@ -176,9 +188,15 @@ this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); } @@ -66,7 +66,7 @@ if (block instanceof Fallable) { ((Fallable) block).onLand(this.level(), blockposition, this.blockState, iblockdata, this); } -@@ -201,19 +219,19 @@ +@@ -206,19 +224,19 @@ } } } else if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index 013cd88e03..1613016c17 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityItem.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/EntityItem.java +++ b/net/minecraft/world/entity/item/EntityItem.java -@@ -33,6 +33,15 @@ - import net.minecraft.world.level.gameevent.GameEvent; +@@ -34,6 +34,15 @@ + import net.minecraft.world.level.portal.DimensionTransition; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -16,7 +16,7 @@ public class EntityItem extends Entity implements TraceableEntity { private static final DataWatcherObject DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK); -@@ -51,6 +60,7 @@ +@@ -52,6 +61,7 @@ @Nullable public UUID target; public final float bobOffs; @@ -24,7 +24,7 @@ public EntityItem(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -132,12 +142,15 @@ +@@ -133,12 +143,15 @@ @Override public void tick() { if (this.getItem().isEmpty()) { @@ -44,7 +44,7 @@ this.xo = this.getX(); this.yo = this.getY(); -@@ -186,9 +199,11 @@ +@@ -187,9 +200,11 @@ this.mergeWithNeighbours(); } @@ -56,7 +56,7 @@ this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); if (!this.level().isClientSide) { -@@ -200,7 +215,13 @@ +@@ -201,7 +216,13 @@ } if (!this.level().isClientSide && this.age >= 6000) { @@ -71,7 +71,7 @@ } } -@@ -283,11 +304,16 @@ +@@ -284,11 +305,16 @@ } private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) { @@ -89,7 +89,7 @@ } } -@@ -308,12 +334,17 @@ +@@ -309,12 +335,17 @@ } else if (this.level().isClientSide) { return true; } else { @@ -108,7 +108,7 @@ } return true; -@@ -365,7 +396,7 @@ +@@ -366,7 +397,7 @@ } if (this.getItem().isEmpty()) { @@ -117,7 +117,7 @@ } } -@@ -377,10 +408,50 @@ +@@ -378,10 +409,50 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch index 9bc59fc25b..75d2442861 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/item/EntityTNTPrimed.java +++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java -@@ -17,6 +17,12 @@ - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.state.IBlockData; +@@ -24,6 +24,12 @@ + import net.minecraft.world.level.material.Fluid; + import net.minecraft.world.level.portal.DimensionTransition; +// CraftBukkit start; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -13,16 +13,16 @@ public class EntityTNTPrimed extends Entity implements TraceableEntity { private static final DataWatcherObject DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT); -@@ -26,6 +32,8 @@ - public static final String TAG_FUSE = "fuse"; +@@ -45,6 +51,8 @@ @Nullable public EntityLiving owner; + private boolean usedPortal; + public float yield = 4; // CraftBukkit - add field + public boolean isIncendiary = false; // CraftBukkit - add field public EntityTNTPrimed(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -79,10 +87,13 @@ +@@ -99,10 +107,13 @@ this.setFuse(i); if (i <= 0) { @@ -37,7 +37,7 @@ } else { this.updateInWaterStateAndDoFluidPushing(); if (this.level().isClientSide) { -@@ -93,9 +104,14 @@ +@@ -113,9 +124,14 @@ } private void explode() { @@ -46,9 +46,9 @@ + // float f = 4.0F; + ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity()); -- this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, World.a.TNT); +- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, false, World.a.TNT); + if (!event.isCancelled()) { -+ this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); ++ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch index e8d0f71fdb..000f3ada69 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch @@ -54,7 +54,7 @@ itemstack.shrink(1); } else { itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -246,10 +266,19 @@ +@@ -246,11 +266,20 @@ if (!this.level().isClientSide) { float f = this.isPowered() ? 2.0F : 1.0F; @@ -64,10 +64,11 @@ + // CraftBukkit end this.dead = true; - this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB); -- this.discard(); + this.level().explode(this, this.level().damageSources().explosion(this, this.entityIgniter, net.minecraft.world.damagesource.DamageTypes.EXPLOSION), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit -+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause this.spawnLingeringCloud(); + this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED); +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + // CraftBukkit start + } else { + swell = 0; @@ -76,7 +77,7 @@ } } -@@ -260,6 +289,7 @@ +@@ -261,6 +290,7 @@ if (!collection.isEmpty()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); @@ -84,7 +85,7 @@ entityareaeffectcloud.setRadius(2.5F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); -@@ -273,7 +303,7 @@ +@@ -274,7 +304,7 @@ entityareaeffectcloud.addEffect(new MobEffect(mobeffect)); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch index 9463915bdb..b210296b1b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityEnderman.java +++ b/net/minecraft/world/entity/monster/EntityEnderman.java -@@ -68,6 +68,11 @@ +@@ -70,6 +70,11 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -11,8 +11,8 @@ + public class EntityEnderman extends EntityMonster implements IEntityAngerable { - private static final UUID SPEED_MODIFIER_ATTACKING_UUID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0"); -@@ -111,7 +116,17 @@ + private static final MinecraftKey SPEED_MODIFIER_ATTACKING_ID = MinecraftKey.withDefaultNamespace("attacking"); +@@ -113,7 +118,17 @@ @Override public void setTarget(@Nullable EntityLiving entityliving) { @@ -31,7 +31,7 @@ AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -126,6 +141,7 @@ +@@ -128,6 +143,7 @@ attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING); } } @@ -39,7 +39,7 @@ } -@@ -477,9 +493,11 @@ +@@ -479,9 +495,11 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { @@ -51,7 +51,7 @@ } } -@@ -518,9 +536,11 @@ +@@ -520,9 +538,11 @@ boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition); if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch index cb043c6e75..9fde325519 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntityGhast.java +++ b/net/minecraft/world/entity/monster/EntityGhast.java -@@ -331,6 +331,8 @@ +@@ -332,6 +332,8 @@ - EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4, this.ghast.getExplosionPower()); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, vec3d1.normalize(), this.ghast.getExplosionPower()); + // CraftBukkit - set bukkitYield when setting explosionpower + entitylargefireball.bukkitYield = entitylargefireball.explosionPower = this.ghast.getExplosionPower(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch index b43c73c23f..e16a1cf3f6 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java +++ b/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java -@@ -215,7 +215,7 @@ +@@ -217,7 +217,7 @@ @Override protected void performSpellCasting() { @@ -9,7 +9,7 @@ } @Nullable -@@ -266,7 +266,7 @@ +@@ -268,7 +268,7 @@ @Override protected void performSpellCasting() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch index 108f4665c6..6f3cac8bf9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPigZombie.java +++ b/net/minecraft/world/entity/monster/EntityPigZombie.java -@@ -148,7 +148,7 @@ +@@ -149,7 +149,7 @@ }).filter((entitypigzombie) -> { return !entitypigzombie.isAlliedTo((Entity) this.getTarget()); }).forEach((entitypigzombie) -> { @@ -9,7 +9,7 @@ }); } -@@ -157,7 +157,7 @@ +@@ -158,7 +158,7 @@ } @Override @@ -18,7 +18,7 @@ if (this.getTarget() == null && entityliving != null) { this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.sample(this.random); this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.sample(this.random); -@@ -167,12 +167,21 @@ +@@ -168,12 +168,21 @@ this.setLastHurtByPlayer((EntityHuman) entityliving); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch index d139655759..5697e18b0f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPillager.java +++ b/net/minecraft/world/entity/monster/EntityPillager.java -@@ -44,6 +44,10 @@ +@@ -48,6 +48,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.WorldAccess; @@ -11,7 +11,7 @@ public class EntityPillager extends EntityIllagerAbstract implements ICrossbow, InventoryCarrier { private static final DataWatcherObject IS_CHARGING_CROSSBOW = DataWatcher.defineId(EntityPillager.class, DataWatcherRegistry.BOOLEAN); -@@ -192,7 +196,7 @@ +@@ -195,7 +199,7 @@ ItemStack itemstack1 = this.inventory.addItem(itemstack); if (itemstack1.isEmpty()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch index 0716d305c8..a9687a1527 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityRavager.java +++ b/net/minecraft/world/entity/monster/EntityRavager.java -@@ -42,6 +42,10 @@ +@@ -43,6 +43,10 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityRavager extends EntityRaider { private static final Predicate NO_RAVAGER_AND_ALIVE = (entity) -> { -@@ -146,6 +150,11 @@ +@@ -147,6 +151,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockLeaves) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch index f70888603b..14e78b06de 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch @@ -12,7 +12,7 @@ + public class EntityShulker extends EntityGolem implements VariantHolder>, IMonster { - private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F"); + private static final MinecraftKey COVERED_ARMOR_MODIFIER_ID = MinecraftKey.withDefaultNamespace("covered"); @@ -401,6 +407,14 @@ EnumDirection enumdirection = this.findAttachableSurface(blockposition1); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch index 0d58e34745..73a2ea0695 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySkeleton.java +++ b/net/minecraft/world/entity/monster/EntitySkeleton.java -@@ -90,7 +90,7 @@ +@@ -91,7 +91,7 @@ } protected void doFreezeConversion() { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch index bab47f75c2..ba4d0f477d 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java +++ b/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java -@@ -200,8 +200,19 @@ +@@ -204,8 +204,19 @@ double d3 = Math.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level().getDifficulty().getId() * 4)); @@ -20,4 +20,4 @@ + // this.level().addFreshEntity(entityarrow); // CraftBukkit - moved up } - protected EntityArrow getArrow(ItemStack itemstack, float f) { + protected EntityArrow getArrow(ItemStack itemstack, float f, @Nullable ItemStack itemstack1) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch index b9dc3f1baa..a42658911b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySkeletonWither.java +++ b/net/minecraft/world/entity/monster/EntitySkeletonWither.java -@@ -96,7 +96,7 @@ +@@ -97,7 +97,7 @@ return false; } else { if (entity instanceof EntityLiving) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch index e5e51ef859..5d98d3aefb 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySlime.java +++ b/net/minecraft/world/entity/monster/EntitySlime.java -@@ -43,6 +43,15 @@ +@@ -45,6 +45,15 @@ import net.minecraft.world.level.levelgen.SeededRandom; import net.minecraft.world.phys.Vec3D; @@ -16,7 +16,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { private static final DataWatcherObject ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); -@@ -193,11 +202,18 @@ +@@ -195,11 +204,18 @@ @Override public EntityTypes getType() { @@ -36,7 +36,7 @@ int i = this.getSize(); if (!this.level().isClientSide && i > 1 && this.isDeadOrDying()) { -@@ -208,6 +224,19 @@ +@@ -210,6 +226,19 @@ int j = i / 2; int k = 2 + this.random.nextInt(3); @@ -56,7 +56,7 @@ for (int l = 0; l < k; ++l) { float f2 = ((float) (l % 2) - 0.5F) * f1; float f3 = ((float) (l / 2) - 0.5F) * f1; -@@ -223,12 +252,21 @@ +@@ -225,12 +254,21 @@ entityslime.setInvulnerable(this.isInvulnerable()); entityslime.setSize(j, true); entityslime.moveTo(this.getX() + (double) f2, this.getY() + 0.5D, this.getZ() + (double) f3, this.random.nextFloat() * 360.0F, 0.0F); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch index eef711a29c..85c27b27c7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityWitch.java +++ b/net/minecraft/world/entity/monster/EntityWitch.java -@@ -124,7 +124,7 @@ +@@ -125,7 +125,7 @@ PotionContents potioncontents = (PotionContents) itemstack.get(DataComponents.POTION_CONTENTS); if (itemstack.is(Items.POTION) && potioncontents != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index 2e91629171..e447f1d8e3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityZombie.java +++ b/net/minecraft/world/entity/monster/EntityZombie.java -@@ -64,6 +64,15 @@ +@@ -65,6 +65,15 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -15,8 +15,8 @@ + public class EntityZombie extends EntityMonster { - private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); -@@ -84,6 +93,7 @@ + private static final MinecraftKey SPEED_MODIFIER_BABY_ID = MinecraftKey.withDefaultNamespace("baby"); +@@ -89,6 +98,7 @@ private boolean canBreakDoors; private int inWaterTime; public int conversionTime; @@ -24,7 +24,7 @@ public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -200,7 +210,10 @@ +@@ -205,7 +215,10 @@ public void tick() { if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) { if (this.isUnderWaterConverting()) { @@ -36,7 +36,7 @@ if (this.conversionTime < 0) { this.doUnderWaterConversion(); } -@@ -217,6 +230,7 @@ +@@ -222,6 +235,7 @@ } super.tick(); @@ -44,7 +44,7 @@ } @Override -@@ -249,6 +263,7 @@ +@@ -256,6 +270,7 @@ } public void startUnderWaterConversion(int i) { @@ -52,7 +52,7 @@ this.conversionTime = i; this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true); } -@@ -262,11 +277,15 @@ +@@ -269,11 +284,15 @@ } protected void convertToZombieType(EntityTypes entitytypes) { @@ -69,7 +69,7 @@ } } -@@ -305,9 +324,9 @@ +@@ -312,9 +331,9 @@ if (EntityPositionTypes.isSpawnPositionOk(entitytypes, this.level(), blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level().random)) { entityzombie.setPos((double) i1, (double) j1, (double) k1); if (!this.level().hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level().isUnobstructed(entityzombie) && this.level().noCollision((Entity) entityzombie) && !this.level().containsAnyLiquid(entityzombie.getBoundingBox())) { @@ -78,16 +78,16 @@ entityzombie.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null); - worldserver.addFreshEntityWithPassengers(entityzombie); + worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit - this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADD_VALUE)); - entityzombie.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADD_VALUE)); - break; -@@ -328,7 +347,14 @@ + AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE); + AttributeModifier attributemodifier = attributemodifiable.getModifier(EntityZombie.REINFORCEMENT_CALLER_CHARGE_ID); + double d0 = attributemodifier != null ? attributemodifier.amount() : 0.0D; +@@ -340,7 +359,14 @@ float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) { -- entity.igniteForSeconds(2 * (int) f); +- entity.igniteForSeconds((float) (2 * (int) f)); + // CraftBukkit start -+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme ++ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), (float) (2 * (int) f)); // PAIL: fixme + this.level().getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { @@ -97,7 +97,7 @@ } } -@@ -403,8 +429,17 @@ +@@ -415,8 +441,17 @@ if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) { return flag; } @@ -116,7 +116,7 @@ if (entityzombievillager != null) { entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true)); -@@ -412,15 +447,17 @@ +@@ -424,15 +459,17 @@ entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE)); entityzombievillager.setTradeOffers(entityvillager.getOffers().copy()); entityzombievillager.setVillagerXp(entityvillager.getVillagerXp()); @@ -139,7 +139,7 @@ } @Override -@@ -471,7 +508,7 @@ +@@ -483,7 +520,7 @@ entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null); entitychicken1.setChickenJockey(true); this.startRiding(entitychicken1); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch index 4188ddaa1b..bf1c47dbef 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java -@@ -48,6 +48,13 @@ +@@ -51,6 +51,13 @@ import net.minecraft.world.level.block.state.IBlockData; import org.slf4j.Logger; @@ -14,7 +14,7 @@ public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -65,6 +72,7 @@ +@@ -68,6 +75,7 @@ @Nullable private MerchantRecipeList tradeOffers; private int villagerXp; @@ -22,7 +22,7 @@ public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -83,7 +91,7 @@ +@@ -86,7 +94,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -31,7 +31,7 @@ Logger logger = EntityZombieVillager.LOGGER; Objects.requireNonNull(logger); -@@ -118,7 +126,7 @@ +@@ -121,7 +129,7 @@ } if (nbttagcompound.contains("Offers")) { @@ -40,7 +40,7 @@ Logger logger1 = EntityZombieVillager.LOGGER; Objects.requireNonNull(logger1); -@@ -145,6 +153,10 @@ +@@ -148,6 +156,10 @@ public void tick() { if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -51,7 +51,7 @@ this.villagerConversionTime -= i; if (this.villagerConversionTime <= 0) { -@@ -153,6 +165,7 @@ +@@ -156,6 +168,7 @@ } super.tick(); @@ -59,7 +59,7 @@ } @Override -@@ -193,8 +206,10 @@ +@@ -196,8 +209,10 @@ this.conversionStarter = uuid; this.villagerConversionTime = i; this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true); @@ -72,7 +72,7 @@ this.level().broadcastEntityEvent(this, (byte) 16); } -@@ -211,7 +226,13 @@ +@@ -214,12 +229,20 @@ } private void finishConversion(WorldServer worldserver) { @@ -84,25 +84,22 @@ + return; + } + // CraftBukkit end - EnumItemSlot[] aenumitemslot = EnumItemSlot.values(); - int i = aenumitemslot.length; -@@ -226,7 +247,9 @@ - double d0 = (double) this.getEquipmentDropChance(enumitemslot); + if (entityvillager != null) { ++ this.forceDrops = true; // CraftBukkit + Iterator iterator = this.dropPreservedEquipment((itemstack) -> { + return !EnchantmentManager.has(itemstack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE); + }).iterator(); ++ this.forceDrops = false; // CraftBukkit - if (d0 > 1.0D) { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(itemstack); -+ this.forceDrops = false; // CraftBukkit - } + while (iterator.hasNext()) { + EnumItemSlot enumitemslot = (EnumItemSlot) iterator.next(); +@@ -249,7 +272,7 @@ } } -@@ -253,7 +276,7 @@ - } - } -- entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); -+ entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit - if (!this.isSilent()) { - worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0); - } +- entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); ++ entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit + if (!this.isSilent()) { + worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0); + } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch index f37c28b69c..74c59c4253 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch @@ -75,7 +75,7 @@ this.setGuaranteedDrop(EnumItemSlot.OFFHAND); } else { @@ -375,8 +403,8 @@ - if (EnchantmentManager.hasBindingCurse(itemstack1)) { + if (EnchantmentManager.has(itemstack1, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) { return false; } else { - boolean flag = PiglinAI.isLovedItem(itemstack) || itemstack.is(Items.CROSSBOW); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch index a4f91ac370..385070ba17 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/Warden.java +++ b/net/minecraft/world/entity/monster/warden/Warden.java -@@ -371,7 +371,7 @@ +@@ -372,7 +372,7 @@ @Override public BehaviorController getBrain() { @@ -9,7 +9,7 @@ } @Override -@@ -408,13 +408,13 @@ +@@ -409,7 +409,7 @@ public static void applyDarknessAround(WorldServer worldserver, Vec3D vec3d, @Nullable Entity entity, int i) { MobEffect mobeffect = new MobEffect(MobEffects.DARKNESS, 260, 0, false, false); @@ -18,32 +18,7 @@ } @Override - public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { - super.addAdditionalSaveData(nbttagcompound); -- DataResult dataresult = AngerManagement.codec(this::canTargetEntity).encodeStart(DynamicOpsNBT.INSTANCE, this.angerManagement); -+ DataResult dataresult = AngerManagement.codec(this::canTargetEntity).encodeStart(DynamicOpsNBT.INSTANCE, this.angerManagement); // CraftBukkit - decompile error - Logger logger = Warden.LOGGER; - - Objects.requireNonNull(logger); -@@ -439,7 +439,7 @@ - dataresult = AngerManagement.codec(this::canTargetEntity).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("anger"))); - logger = Warden.LOGGER; - Objects.requireNonNull(logger); -- dataresult.resultOrPartial(logger::error).ifPresent((angermanagement) -> { -+ ((DataResult) dataresult).resultOrPartial(logger::error).ifPresent((angermanagement) -> { // CraftBukkit - decompile error - this.angerManagement = angermanagement; - }); - this.syncClientAngerLevel(); -@@ -449,7 +449,7 @@ - dataresult = VibrationSystem.a.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); - logger = Warden.LOGGER; - Objects.requireNonNull(logger); -- dataresult.resultOrPartial(logger::error).ifPresent((vibrationsystem_a) -> { -+ ((DataResult) dataresult).resultOrPartial(logger::error).ifPresent((vibrationsystem_a) -> { // CraftBukkit - decompile error - this.vibrationData = vibrationsystem_a; - }); - } -@@ -547,7 +547,7 @@ +@@ -544,7 +544,7 @@ public void setAttackTarget(EntityLiving entityliving) { this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET); @@ -52,7 +27,7 @@ this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); SonicBoom.setCooldown(this, 200); } -@@ -582,12 +582,12 @@ +@@ -579,12 +579,12 @@ @Override protected NavigationAbstract createNavigation(World world) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index e4f070ce7c..a10feb4fc9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -34,7 +34,7 @@ } } -@@ -361,7 +370,13 @@ +@@ -363,7 +372,13 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -49,7 +49,7 @@ } this.resendOffersToTradingPlayer(); -@@ -430,7 +445,13 @@ +@@ -432,7 +447,13 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -64,7 +64,7 @@ } } -@@ -490,7 +511,7 @@ +@@ -492,7 +513,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -73,7 +73,7 @@ Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -513,7 +534,7 @@ +@@ -515,7 +536,7 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("VillagerData", 10)) { @@ -82,7 +82,7 @@ Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -826,9 +847,14 @@ +@@ -828,9 +849,14 @@ } entitywitch.setPersistenceRequired(); @@ -99,7 +99,7 @@ } else { super.thunderHit(worldserver, entitylightning); } -@@ -925,7 +951,7 @@ +@@ -927,7 +953,7 @@ }).limit(5L).collect(Collectors.toList()); if (list1.size() >= j) { @@ -108,7 +108,7 @@ list.forEach(SensorGolemLastSeen::golemDetected); } } -@@ -982,7 +1008,7 @@ +@@ -984,7 +1010,7 @@ @Override public void startSleeping(BlockPosition blockposition) { super.startSleeping(blockposition); @@ -117,7 +117,7 @@ this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } -@@ -990,7 +1016,7 @@ +@@ -992,7 +1018,7 @@ @Override public void stopSleeping() { super.stopSleeping(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch index 06804fd12d..20b08c4326 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch @@ -34,7 +34,7 @@ public EntityVillagerAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -173,7 +189,7 @@ +@@ -179,7 +195,7 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("Offers")) { @@ -43,7 +43,7 @@ Logger logger = EntityVillagerAbstract.LOGGER; Objects.requireNonNull(logger); -@@ -240,7 +256,16 @@ +@@ -246,7 +262,16 @@ MerchantRecipe merchantrecipe = ((VillagerTrades.IMerchantRecipeOption) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random); if (merchantrecipe != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index e0e27cae63..338068c686 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/EntityHuman.java +++ b/net/minecraft/world/entity/player/EntityHuman.java -@@ -116,6 +116,22 @@ +@@ -115,6 +115,22 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -24,7 +24,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); @@ -135,7 +151,8 @@ - public static final float DEFAULT_EYE_HEIGHT = 1.62F; + private static final int CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME_TICKS = 40; public static final Vec3D DEFAULT_VEHICLE_ATTACHMENT = new Vec3D(0.0D, 0.6D, 0.0D); public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F).withEyeHeight(1.62F).withAttachments(EntityAttachments.builder().attach(EntityAttachment.VEHICLE, EntityHuman.DEFAULT_VEHICLE_ATTACHMENT)); - private static final Map POSES = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.SWIMMING, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.SPIN_ATTACK, EntitySize.scalable(0.6F, 0.6F).withEyeHeight(0.4F)).put(EntityPose.CROUCHING, EntitySize.scalable(0.6F, 1.5F).withEyeHeight(1.27F).withAttachments(EntityAttachments.builder().attach(EntityAttachment.VEHICLE, EntityHuman.DEFAULT_VEHICLE_ATTACHMENT))).put(EntityPose.DYING, EntitySize.fixed(0.2F, 0.2F).withEyeHeight(1.62F)).build(); @@ -46,9 +46,9 @@ protected int jumpTriggerTime; public float oBob; public float bob; -@@ -181,6 +198,16 @@ - public Entity currentExplosionCause; - public boolean ignoreFallDamageFromCurrentImpulse; +@@ -182,6 +199,16 @@ + private boolean ignoreFallDamageFromCurrentImpulse; + private int currentImpulseContextResetGraceTime; + // CraftBukkit start + public boolean fauxSleeping; @@ -63,7 +63,7 @@ public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -325,7 +352,7 @@ +@@ -330,7 +357,7 @@ ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD); if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) { @@ -98,8 +98,8 @@ + this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); } - if (this.foodData.needsFood() && this.tickCount % 10 == 0) { -@@ -665,6 +699,13 @@ + if (this.foodData.getSaturationLevel() < 20.0F && this.tickCount % 20 == 0) { +@@ -683,6 +717,13 @@ @Nullable public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { @@ -113,7 +113,7 @@ if (itemstack.isEmpty()) { return null; } else { -@@ -699,6 +740,33 @@ +@@ -717,6 +758,33 @@ entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } @@ -147,7 +147,7 @@ return entityitem; } } -@@ -790,7 +858,7 @@ +@@ -803,7 +871,7 @@ } if (nbttagcompound.contains("LastDeathLocation", 10)) { @@ -156,7 +156,7 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -798,7 +866,7 @@ +@@ -811,7 +879,7 @@ } if (nbttagcompound.contains("current_explosion_impact_pos", 9)) { @@ -165,7 +165,7 @@ Logger logger1 = EntityHuman.LOGGER; Objects.requireNonNull(logger1); -@@ -834,7 +902,7 @@ +@@ -848,7 +916,7 @@ } this.getLastDeathLocation().flatMap((globalpos) -> { @@ -174,7 +174,7 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -866,12 +934,12 @@ +@@ -881,12 +949,12 @@ return false; } else { if (!this.level().isClientSide) { @@ -189,7 +189,7 @@ } if (this.level().getDifficulty() == EnumDifficulty.EASY) { -@@ -883,7 +951,13 @@ +@@ -898,7 +966,13 @@ } } @@ -204,7 +204,7 @@ } } } -@@ -903,10 +977,29 @@ +@@ -918,10 +992,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { @@ -237,7 +237,7 @@ } @Override -@@ -946,8 +1039,13 @@ +@@ -961,8 +1054,13 @@ } } @@ -252,7 +252,7 @@ if (!this.isInvulnerableTo(damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -962,7 +1060,7 @@ +@@ -977,7 +1075,7 @@ } if (f != 0.0F) { @@ -261,15 +261,15 @@ this.getCombatTracker().recordDamage(damagesource, f); this.setHealth(this.getHealth() - f); if (f < 3.4028235E37F) { -@@ -972,6 +1070,7 @@ +@@ -987,6 +1085,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } + return false; // CraftBukkit } - @Override -@@ -1127,10 +1226,16 @@ + public boolean isTextFilteringEnabled() { +@@ -1139,10 +1238,15 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -279,118 +279,71 @@ IProjectile iprojectile = (IProjectile) entity; + // CraftBukkit start -+ DamageSource damagesource = this.damageSources().playerAttack(this); + if (CraftEventFactory.handleNonLivingEntityDamageEvent(entity, damagesource, f1, false)) { + return; + } + // CraftBukkit end - iprojectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true); - } else { - if (f > 0.0F || f1 > 0.0F) { -@@ -1171,8 +1276,15 @@ - if (entity instanceof EntityLiving) { - f3 = ((EntityLiving) entity).getHealth(); - if (j > 0 && !entity.isOnFire()) { -- flag4 = true; -- entity.igniteForSeconds(1); -+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item -+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1); -+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); -+ -+ if (!combustEvent.isCancelled()) { -+ flag4 = true; -+ entity.igniteForSeconds(combustEvent.getDuration(), false); -+ } -+ // CraftBukkit end - } - } + if (iprojectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true)) { + this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); + return; +@@ -1218,8 +1322,11 @@ + if (entityliving2 != this && entityliving2 != entity && !this.isAlliedTo((Entity) entityliving2) && (!(entityliving2 instanceof EntityArmorStand) || !((EntityArmorStand) entityliving2).isMarker()) && this.distanceToSqr((Entity) entityliving2) < 9.0D) { + float f7 = this.getEnchantedDamage(entityliving2, f6, damagesource) * f2; -@@ -1182,7 +1294,7 @@ - if (flag5) { - if (i > 0) { - if (entity instanceof EntityLiving) { -- ((EntityLiving) entity).knockback((double) ((float) i * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); -+ ((EntityLiving) entity).knockback((double) ((float) i * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit - } else { - entity.push((double) (-MathHelper.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F)); - } -@@ -1200,8 +1312,11 @@ - EntityLiving entityliving = (EntityLiving) iterator.next(); - - if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { -- entityliving.knockback(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); -- entityliving.hurt(this.damageSources().playerAttack(this), f4); -+ // CraftBukkit start - Only apply knockback if the damage hits -+ if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) { -+ entityliving.knockback(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.SWEEP_ATTACK); // CraftBukkit -+ } -+ // CraftBukkit end - } - } - -@@ -1210,9 +1325,26 @@ - } - - if (entity instanceof EntityPlayer && entity.hurtMarked) { -+ // CraftBukkit start - Add Velocity Event -+ boolean cancelled = false; -+ Player player = (Player) entity.getBukkitEntity(); -+ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d); -+ -+ PlayerVelocityEvent event = new 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 (!cancelled) { - ((EntityPlayer) entity).connection.send(new PacketPlayOutEntityVelocity(entity)); - entity.hurtMarked = false; - entity.setDeltaMovement(vec3d); -+ } -+ // CraftBukkit end - } - - if (flag2) { -@@ -1257,7 +1389,14 @@ - - this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); - if (j > 0) { -- entity.igniteForSeconds(j * 4); -+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item -+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); -+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); -+ -+ if (!combustEvent.isCancelled()) { -+ entity.igniteForSeconds(combustEvent.getDuration(), false); +- entityliving2.knockback(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); +- entityliving2.hurt(damagesource, f7); ++ // CraftBukkit start - Only apply knockback if the damage hits ++ if (entityliving2.hurt(this.damageSources().playerAttack(this).sweep(), f7)) { ++ entityliving2.knockback(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.SWEEP_ATTACK); // CraftBukkit + } + // CraftBukkit end - } + World world = this.level(); - if (this.level() instanceof WorldServer && f5 > 2.0F) { -@@ -1267,12 +1406,17 @@ - } - } + if (world instanceof WorldServer) { +@@ -1235,9 +1342,26 @@ + } -- this.causeFoodExhaustion(0.1F); -+ this.causeFoodExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent - } else { - this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); - if (flag4) { - entity.clearFire(); - } -+ // CraftBukkit start - resync on cancelled event -+ if (this instanceof EntityPlayer) { -+ ((EntityPlayer) this).getBukkitEntity().updateInventory(); + if (entity instanceof EntityPlayer && entity.hurtMarked) { ++ // CraftBukkit start - Add Velocity Event ++ boolean cancelled = false; ++ Player player = (Player) entity.getBukkitEntity(); ++ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d); ++ ++ PlayerVelocityEvent event = new 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 (!cancelled) { + ((EntityPlayer) entity).connection.send(new PacketPlayOutEntityVelocity(entity)); + entity.hurtMarked = false; + entity.setDeltaMovement(vec3d); + } + // CraftBukkit end } - } -@@ -1310,7 +1454,14 @@ + if (flag2) { +@@ -1303,9 +1427,14 @@ + } + } + +- this.causeFoodExhaustion(0.1F); ++ this.causeFoodExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent + } else { + this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); ++ // CraftBukkit start - resync on cancelled event ++ if (this instanceof EntityPlayer) { ++ ((EntityPlayer) this).getBukkitEntity().updateInventory(); ++ } ++ // CraftBukkit end + } + } + +@@ -1346,7 +1475,14 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -406,7 +359,7 @@ this.inventoryMenu.removed(this); if (this.containerMenu != null && this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1346,6 +1497,12 @@ +@@ -1382,6 +1518,12 @@ } public Either startSleepInBed(BlockPosition blockposition) { @@ -419,7 +372,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1433,9 +1590,9 @@ +@@ -1444,9 +1586,9 @@ super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { @@ -431,7 +384,7 @@ } } -@@ -1462,7 +1619,11 @@ +@@ -1473,7 +1615,11 @@ this.setDeltaMovement(vec3d2.x, d0 * 0.6D, vec3d2.z); this.resetFallDistance(); @@ -444,7 +397,7 @@ } else { super.travel(vec3d); } -@@ -1522,12 +1683,24 @@ +@@ -1547,12 +1693,24 @@ } public void startFallFlying() { @@ -470,7 +423,7 @@ } @Override -@@ -1642,10 +1815,21 @@ +@@ -1667,10 +1825,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -493,7 +446,7 @@ } } -@@ -1731,13 +1915,20 @@ +@@ -1756,13 +1925,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -511,13 +464,13 @@ } else if (enumitemslot == EnumItemSlot.OFFHAND) { - this.onEquipItem(enumitemslot, (ItemStack) this.inventory.offhand.set(0, itemstack), itemstack); + this.onEquipItem(enumitemslot, (ItemStack) this.inventory.offhand.set(0, itemstack), itemstack, silent); // CraftBukkit - } else if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR) { + } else if (enumitemslot.getType() == EnumItemSlot.Function.HUMANOID_ARMOR) { - this.onEquipItem(enumitemslot, (ItemStack) this.inventory.armor.set(enumitemslot.getIndex(), itemstack), itemstack); + this.onEquipItem(enumitemslot, (ItemStack) this.inventory.armor.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit } } -@@ -1781,26 +1972,31 @@ +@@ -1806,26 +1982,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -557,3 +510,12 @@ } @Override +@@ -2040,7 +2221,7 @@ + + @Override + public ItemStack eat(World world, ItemStack itemstack, FoodInfo foodinfo) { +- this.getFoodData().eat(foodinfo); ++ this.getFoodData().eat(itemstack, foodinfo); // CraftBukkit + this.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); + world.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); + if (this instanceof EntityPlayer) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index 297edc50a7..96356c9788 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityArrow.java +++ b/net/minecraft/world/entity/projectile/EntityArrow.java -@@ -49,6 +49,13 @@ +@@ -52,6 +52,13 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.shapes.VoxelShape; @@ -14,7 +14,7 @@ public abstract class EntityArrow extends IProjectile { private static final double ARROW_BASE_DAMAGE = 2.0D; -@@ -225,7 +232,7 @@ +@@ -242,7 +249,7 @@ } if (object != null && !flag) { @@ -23,7 +23,7 @@ this.hasImpulse = true; if (projectiledeflection != ProjectileDeflection.NONE) { -@@ -316,7 +323,7 @@ +@@ -333,7 +340,7 @@ protected void tickDespawn() { ++this.life; if (this.life >= 1200) { @@ -32,7 +32,7 @@ } } -@@ -349,7 +356,7 @@ +@@ -380,7 +387,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -41,13 +41,13 @@ return; } -@@ -378,7 +385,13 @@ +@@ -401,7 +408,13 @@ int k = entity.getRemainingFireTicks(); if (this.isOnFire() && !flag) { -- entity.igniteForSeconds(5); +- entity.igniteForSeconds(5.0F); + // CraftBukkit start -+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5); ++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5.0F); + org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); + if (!combustEvent.isCancelled()) { + entity.igniteForSeconds(combustEvent.getDuration(), false); @@ -56,7 +56,7 @@ } if (entity.hurt(damagesource, (float) i)) { -@@ -429,7 +442,7 @@ +@@ -447,7 +460,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -65,7 +65,7 @@ } } else { entity.setRemainingFireTicks(k); -@@ -440,7 +453,7 @@ +@@ -458,7 +471,7 @@ this.spawnAtLocation(this.getPickupItem(), 0.1F); } @@ -74,7 +74,56 @@ } } -@@ -547,9 +560,24 @@ +@@ -614,7 +627,7 @@ + } + + if (nbttagcompound.contains("weapon", 10)) { +- this.firedFromWeapon = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("weapon")).orElse((Object) null); ++ this.firedFromWeapon = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("weapon")).orElse(null); // CraftBukkit - decompile error + } else { + this.firedFromWeapon = null; + } +@@ -630,17 +643,10 @@ + EntityArrow.PickupStatus entityarrow_pickupstatus; + + label16: +- while(true) { +- //$FF: b0->value +- //0->net/minecraft/world/entity/player/EntityHuman +- //1->net/minecraft/world/entity/OminousItemSpawner +- switch (entity1.typeSwitch(entity1, b0)) { +- case -1: +- default: +- entityarrow_pickupstatus = this.pickup; +- break label16; +- case 0: +- EntityHuman entityhuman = (EntityHuman)entity1; ++ // CraftBukkit start - decompile error ++ while (true) { ++ switch (entity1) { ++ case EntityHuman entityhuman: + + if (this.pickup != EntityArrow.PickupStatus.DISALLOWED) { + b0 = 1; +@@ -649,12 +655,15 @@ + + entityarrow_pickupstatus = EntityArrow.PickupStatus.ALLOWED; + break label16; +- case 1: +- OminousItemSpawner ominousitemspawner = (OminousItemSpawner)entity1; ++ case OminousItemSpawner ominousitemspawner: + + entityarrow_pickupstatus = EntityArrow.PickupStatus.DISALLOWED; + break label16; ++ default: ++ entityarrow_pickupstatus = this.pickup; ++ break label16; + } ++ // CraftBukkit end + } + + this.pickup = entityarrow_pickupstatus; +@@ -663,9 +672,24 @@ @Override public void playerTouch(EntityHuman entityhuman) { if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch index 2f9cb64fa2..ea87f55e66 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/EntityDragonFireball.java +++ b/net/minecraft/world/entity/projectile/EntityDragonFireball.java -@@ -15,6 +15,10 @@ - import net.minecraft.world.phys.MovingObjectPosition; +@@ -16,6 +16,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.event.entity.EntityRemoveEvent; @@ -11,7 +11,7 @@ public class EntityDragonFireball extends EntityFireball { public static final float SPLASH_RANGE = 4.0F; -@@ -61,7 +65,7 @@ +@@ -62,7 +66,7 @@ this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1); this.level().addFreshEntity(entityareaeffectcloud); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch index c043d13187..0bc3653440 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEgg.java +++ b/net/minecraft/world/entity/projectile/EntityEgg.java -@@ -11,6 +11,16 @@ +@@ -12,6 +12,16 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -16,8 +16,8 @@ + public class EntityEgg extends EntityProjectileThrowable { - public EntityEgg(EntityTypes entitytypes, World world) { -@@ -47,26 +57,53 @@ + private static final EntitySize ZERO_SIZED_DIMENSIONS = EntitySize.fixed(0.0F, 0.0F); +@@ -50,30 +60,58 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { @@ -59,14 +59,18 @@ if (entitychicken != null) { - entitychicken.setAge(-24000); -- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); -- this.level().addFreshEntity(entitychicken); + // CraftBukkit start + if (entitychicken.getBukkitEntity() instanceof Ageable) { + ((Ageable) entitychicken.getBukkitEntity()).setBaby(); + } -+ this.level().addFreshEntity(entitychicken, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); + // CraftBukkit end + entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); + if (!entitychicken.fudgePositionAfterSizeChange(EntityEgg.ZERO_SIZED_DIMENSIONS)) { + break; + } + +- this.level().addFreshEntity(entitychicken); ++ this.level().addFreshEntity(entitychicken, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit } } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch index e67aa1b758..102abdc388 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java +++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java -@@ -18,6 +18,13 @@ - import net.minecraft.world.phys.MovingObjectPosition; +@@ -21,6 +21,13 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start -+import org.bukkit.Bukkit; ++import net.minecraft.world.level.dimension.WorldDimension; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.player.PlayerTeleportEvent; @@ -14,64 +14,51 @@ public class EntityEnderPearl extends EntityProjectileThrowable { public EntityEnderPearl(EntityTypes entitytypes, World world) { -@@ -54,23 +61,34 @@ - EntityPlayer entityplayer = (EntityPlayer) entity; +@@ -65,19 +72,26 @@ + EntityPlayer entityplayer = (EntityPlayer) entity; - if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) { -- if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { -- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level()); -+ // CraftBukkit start - Fire PlayerTeleportEvent -+ org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity(); -+ org.bukkit.Location location = getBukkitEntity().getLocation(); -+ location.setPitch(player.getLocation().getPitch()); -+ location.setYaw(player.getLocation().getYaw()); - -- if (entityendermite != null) { -- entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); -- this.level().addFreshEntity(entityendermite); -+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL); -+ Bukkit.getPluginManager().callEvent(teleEvent); -+ -+ if (!teleEvent.isCancelled() && entityplayer.connection.isAcceptingMessages()) { -+ if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { -+ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level()); -+ -+ if (entityendermite != null) { -+ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); -+ this.level().addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); + if (entityplayer.connection.isAcceptingMessages()) { ++ // CraftBukkit start ++ Entity tp = entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING, PlayerTeleportEvent.TeleportCause.ENDER_PEARL)); ++ if (tp == null) { ++ this.discard(EntityRemoveEvent.Cause.HIT); ++ return; + } ++ // CraftBukkit end + if (this.random.nextFloat() < 0.05F && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { + EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(worldserver); + + if (entityendermite != null) { + entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); +- worldserver.addFreshEntity(entityendermite); ++ worldserver.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); + } + } + +- entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING)); ++ // entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING)); // CraftBukkit - moved up + entity.resetFallDistance(); + entityplayer.resetCurrentImpulseContext(); +- entity.hurt(this.damageSources().fall(), 5.0F); ++ entity.hurt(this.damageSources().fall().customEntityDamager(this), 5.0F); // CraftBukkit + this.playSound(worldserver, this.position()); } -- } + } else { +@@ -86,11 +100,11 @@ + this.playSound(worldserver, this.position()); + } -- if (entity.isPassenger()) { -- entityplayer.dismountTo(this.getX(), this.getY(), this.getZ()); -- } else { -- entity.teleportTo(this.getX(), this.getY(), this.getZ()); -- } -+ if (entity.isPassenger()) { -+ entity.stopRiding(); -+ } - -- entity.resetFallDistance(); -- entity.hurt(this.damageSources().fall(), 5.0F); -+ entityplayer.connection.teleport(teleEvent.getTo()); -+ entity.resetFallDistance(); -+ entity.hurt(this.damageSources().fall().customEntityDamager(this), 5.0F); // CraftBukkit -+ } -+ // CraftBukkit end - this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_TELEPORT, SoundCategory.PLAYERS); +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause + return; } - } else if (entity != null) { -@@ -78,7 +96,7 @@ - entity.resetFallDistance(); + +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause + return; } - -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } - - } -@@ -88,7 +106,7 @@ +@@ -116,7 +130,7 @@ Entity entity = this.getOwner(); if (entity instanceof EntityPlayer && !entity.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { @@ -80,12 +67,12 @@ } else { super.tick(); } -@@ -100,7 +118,7 @@ - public Entity changeDimension(WorldServer worldserver) { - Entity entity = this.getOwner(); +@@ -129,7 +143,7 @@ -- if (entity != null && entity.level().dimension() != worldserver.dimension()) { -+ if (entity != null && worldserver != null && entity.level().dimension() != worldserver.dimension()) { // CraftBukkit - SPIGOT-6113 - this.setOwner((Entity) null); - } + @Override + public boolean canChangeDimensions(World world, World world1) { +- if (world.dimension() == World.END) { ++ if (world.getTypeKey() == WorldDimension.END) { // CraftBukkit + Entity entity = this.getOwner(); + if (entity instanceof EntityPlayer) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch index 45c815c834..fbf2bafb58 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityEvokerFangs.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java -@@ -15,6 +15,10 @@ - import net.minecraft.world.entity.TraceableEntity; +@@ -17,6 +17,10 @@ + import net.minecraft.world.item.enchantment.EnchantmentManager; import net.minecraft.world.level.World; +// CraftBukkit start @@ -11,7 +11,7 @@ public class EntityEvokerFangs extends Entity implements TraceableEntity { public static final int ATTACK_DURATION = 20; -@@ -119,7 +123,7 @@ +@@ -121,7 +125,7 @@ } if (--this.lifeTicks < 0) { @@ -20,7 +20,7 @@ } } -@@ -130,7 +134,7 @@ +@@ -132,7 +136,7 @@ if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving1 == null) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch index 97f4340e21..7297681d7c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireball.java +++ b/net/minecraft/world/entity/projectile/EntityFireball.java -@@ -18,6 +18,11 @@ +@@ -18,11 +18,18 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -11,17 +11,15 @@ + public abstract class EntityFireball extends IProjectile { - public static final double ATTACK_DEFLECTION_SCALE = 0.1D; -@@ -25,6 +30,8 @@ - public double xPower; - public double yPower; - public double zPower; + public static final double INITAL_ACCELERATION_POWER = 0.1D; + public static final double DEFLECTION_SCALE = 0.5D; + public double accelerationPower; + public float bukkitYield = 1; // CraftBukkit + public boolean isIncendiary = true; // CraftBukkit protected EntityFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -72,7 +79,7 @@ +@@ -71,7 +78,7 @@ Entity entity = this.getOwner(); if (!this.level().isClientSide && (entity != null && entity.isRemoved() || !this.level().hasChunkAt(this.blockPosition()))) { @@ -30,7 +28,7 @@ } else { super.tick(); if (this.shouldBurn()) { -@@ -82,7 +89,13 @@ +@@ -81,7 +88,13 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch index fbb3c4563d..4330cea26b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireballFireball.java +++ b/net/minecraft/world/entity/projectile/EntityFireballFireball.java -@@ -56,7 +56,12 @@ +@@ -58,7 +58,12 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("Item", 10)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 74ee3307b6..894649a2d4 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireworks.java +++ b/net/minecraft/world/entity/projectile/EntityFireworks.java -@@ -30,6 +30,10 @@ +@@ -32,6 +32,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityFireworks extends IProjectile implements ItemSupplier { public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); -@@ -146,7 +150,7 @@ +@@ -148,7 +152,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); if (!this.noPhysics) { @@ -20,7 +20,7 @@ this.hasImpulse = true; } -@@ -161,7 +165,11 @@ +@@ -163,7 +167,11 @@ } if (!this.level().isClientSide && this.life > this.lifetime) { @@ -33,7 +33,7 @@ } } -@@ -170,14 +178,18 @@ +@@ -172,14 +180,18 @@ this.level().broadcastEntityEvent(this, (byte) 17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(); @@ -54,7 +54,7 @@ } } -@@ -187,7 +199,11 @@ +@@ -189,7 +201,11 @@ this.level().getBlockState(blockposition).entityInside(this.level(), blockposition, this); if (!this.level().isClientSide() && this.hasExplosion()) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index e3b9d7b202..9bba800012 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFishingHook.java +++ b/net/minecraft/world/entity/projectile/EntityFishingHook.java -@@ -46,6 +46,13 @@ +@@ -47,6 +47,13 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -14,7 +14,7 @@ public class EntityFishingHook extends IProjectile { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -67,6 +74,18 @@ +@@ -68,6 +75,18 @@ private final int luck; private final int lureSpeed; @@ -33,7 +33,7 @@ private EntityFishingHook(EntityTypes entitytypes, World world, int i, int j) { super(entitytypes, world); this.syncronizedRandom = RandomSource.create(); -@@ -147,12 +166,12 @@ +@@ -148,12 +167,12 @@ EntityHuman entityhuman = this.getPlayerOwner(); if (entityhuman == null) { @@ -48,7 +48,7 @@ return; } } else { -@@ -253,7 +272,7 @@ +@@ -254,7 +273,7 @@ if (!entityhuman.isRemoved() && entityhuman.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) entityhuman) <= 1024.0D) { return false; } else { @@ -57,7 +57,7 @@ return true; } } -@@ -261,7 +280,7 @@ +@@ -262,7 +281,7 @@ private void checkCollision() { MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); @@ -66,7 +66,7 @@ } @Override -@@ -294,11 +313,11 @@ +@@ -295,11 +314,11 @@ int i = 1; BlockPosition blockposition1 = blockposition.above(); @@ -80,7 +80,7 @@ --i; } -@@ -308,6 +327,10 @@ +@@ -309,6 +328,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(EntityFishingHook.DATA_BITING, false); @@ -91,7 +91,7 @@ } } else { float f; -@@ -341,6 +364,13 @@ +@@ -342,6 +365,13 @@ worldserver.sendParticles(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { @@ -105,7 +105,7 @@ this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getY() + 0.5D; -@@ -373,12 +403,16 @@ +@@ -374,12 +404,16 @@ } if (this.timeUntilLured <= 0) { @@ -118,15 +118,15 @@ } } else { - this.timeUntilLured = MathHelper.nextInt(this.random, 100, 600); -- this.timeUntilLured -= this.lureSpeed * 20 * 5; +- this.timeUntilLured -= this.lureSpeed; + // CraftBukkit start - logic to modify fishing wait time + this.timeUntilLured = MathHelper.nextInt(this.random, this.minWaitTime, this.maxWaitTime); -+ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed * 20 * 5 : 0; ++ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed : 0; + // CraftBukkit end } } -@@ -446,6 +480,14 @@ +@@ -447,6 +481,14 @@ int i = 0; if (this.hookedIn != null) { @@ -141,7 +141,7 @@ this.pullEntity(this.hookedIn); CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList()); this.level().broadcastEntityEvent(this, (byte) 31); -@@ -461,6 +503,15 @@ +@@ -462,6 +504,15 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1); @@ -157,7 +157,7 @@ double d0 = entityhuman.getX() - this.getX(); double d1 = entityhuman.getY() - this.getY(); double d2 = entityhuman.getZ() - this.getZ(); -@@ -468,7 +519,11 @@ +@@ -469,7 +520,11 @@ entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); this.level().addFreshEntity(entityitem); @@ -170,7 +170,7 @@ if (itemstack1.is(TagsItem.FISHES)) { entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1); } -@@ -478,10 +533,27 @@ +@@ -479,10 +534,27 @@ } if (this.onGround()) { @@ -199,7 +199,7 @@ return i; } else { return 0; -@@ -514,8 +586,15 @@ +@@ -515,8 +587,15 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch index 897eb439af..fe98689743 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/EntityLargeFireball.java +++ b/net/minecraft/world/entity/projectile/EntityLargeFireball.java -@@ -9,17 +9,24 @@ - import net.minecraft.world.phys.MovingObjectPosition; +@@ -13,17 +13,24 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.event.entity.EntityRemoveEvent; @@ -18,14 +18,14 @@ + isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } - public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2, int i) { - super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world); + public EntityLargeFireball(World world, EntityLiving entityliving, Vec3D vec3d, int i) { + super(EntityTypes.FIREBALL, entityliving, vec3d, world); this.explosionPower = i; + isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } @Override -@@ -28,8 +35,16 @@ +@@ -32,8 +39,16 @@ if (!this.level().isClientSide) { boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); @@ -44,7 +44,7 @@ } } -@@ -59,7 +74,8 @@ +@@ -63,7 +78,8 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("ExplosionPower", 99)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch index 3b5e333a89..7569e95b90 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityLlamaSpit.java +++ b/net/minecraft/world/entity/projectile/EntityLlamaSpit.java -@@ -15,6 +15,10 @@ +@@ -18,6 +18,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityLlamaSpit extends IProjectile { public EntityLlamaSpit(EntityTypes entitytypes, World world) { -@@ -38,7 +42,7 @@ +@@ -41,7 +45,7 @@ Vec3D vec3d = this.getDeltaMovement(); MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); @@ -20,7 +20,7 @@ double d0 = this.getX() + vec3d.x; double d1 = this.getY() + vec3d.y; double d2 = this.getZ() + vec3d.z; -@@ -47,9 +51,9 @@ +@@ -50,9 +54,9 @@ float f = 0.99F; if (this.level().getBlockStates(this.getBoundingBox()).noneMatch(BlockBase.BlockData::isAir)) { @@ -32,7 +32,7 @@ } else { this.setDeltaMovement(vec3d.scale(0.9900000095367432D)); this.applyGravity(); -@@ -72,7 +76,7 @@ +@@ -86,7 +90,7 @@ protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { super.onHitBlock(movingobjectpositionblock); if (!this.level().isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index be3ae2fb33..5045121a60 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityPotion.java +++ b/net/minecraft/world/entity/projectile/EntityPotion.java -@@ -32,6 +32,18 @@ +@@ -34,6 +34,18 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -19,7 +19,7 @@ public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier { public static final double SPLASH_RANGE = 4.0D; -@@ -96,18 +108,18 @@ +@@ -98,18 +110,18 @@ if (potioncontents.is(Potions.WATER)) { this.applyWater(); @@ -42,7 +42,7 @@ } } -@@ -142,9 +154,10 @@ +@@ -144,9 +156,10 @@ } @@ -54,7 +54,7 @@ if (!list.isEmpty()) { Entity entity1 = this.getEffectSource(); -@@ -165,24 +178,50 @@ +@@ -167,24 +180,50 @@ d1 = 1.0D - Math.sqrt(d0) / 4.0D; } @@ -120,7 +120,7 @@ } } } -@@ -191,7 +230,7 @@ +@@ -193,7 +232,7 @@ } @@ -129,7 +129,7 @@ EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); Entity entity = this.getOwner(); -@@ -204,7 +243,14 @@ +@@ -206,7 +245,14 @@ entityareaeffectcloud.setWaitTime(10); entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration()); entityareaeffectcloud.setPotionContents(potioncontents); @@ -145,7 +145,7 @@ } public boolean isLingering() { -@@ -215,13 +261,25 @@ +@@ -217,13 +263,25 @@ IBlockData iblockdata = this.level().getBlockState(blockposition); if (iblockdata.is(TagsBlock.FIRE)) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch index f0da500435..5943756d78 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/projectile/EntityProjectile.java +++ b/net/minecraft/world/entity/projectile/EntityProjectile.java -@@ -66,7 +66,7 @@ - } +@@ -46,7 +46,7 @@ + MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); - if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && !flag) { + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { - this.hitTargetOrDeflectSelf(movingobjectposition); + this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index 856120f9dc..28584287a7 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/EntityShulkerBullet.java -@@ -31,6 +31,10 @@ +@@ -32,6 +32,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityShulkerBullet extends IProjectile { private static final double SPEED = 0.15D; -@@ -59,8 +63,21 @@ +@@ -60,8 +64,21 @@ this.finalTarget = entity; this.currentMoveDirection = EnumDirection.UP; this.selectNextMoveDirection(enumdirection_enumaxis); @@ -33,7 +33,7 @@ @Override public SoundCategory getSoundSource() { return SoundCategory.HOSTILE; -@@ -193,7 +210,7 @@ +@@ -194,7 +211,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL) { @@ -42,7 +42,7 @@ } } -@@ -229,7 +246,7 @@ +@@ -230,7 +247,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { @@ -51,7 +51,7 @@ } } -@@ -298,7 +315,7 @@ +@@ -307,7 +324,7 @@ if (entity instanceof EntityLiving) { EntityLiving entityliving1 = (EntityLiving) entity; @@ -60,7 +60,7 @@ } } -@@ -312,14 +329,20 @@ +@@ -321,14 +338,20 @@ } private void destroy() { @@ -83,7 +83,7 @@ } @Override -@@ -329,10 +352,15 @@ +@@ -338,10 +361,15 @@ @Override public boolean hurt(DamageSource damagesource, float f) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch index 9a44e062a9..ccb7678537 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/EntitySmallFireball.java +++ b/net/minecraft/world/entity/projectile/EntitySmallFireball.java -@@ -13,6 +13,11 @@ - import net.minecraft.world.phys.MovingObjectPositionBlock; +@@ -16,6 +16,11 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.event.entity.EntityCombustByEntityEvent; @@ -12,10 +12,10 @@ public class EntitySmallFireball extends EntityFireballFireball { public EntitySmallFireball(EntityTypes entitytypes, World world) { -@@ -21,6 +26,11 @@ +@@ -24,6 +29,11 @@ - public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world); + public EntitySmallFireball(World world, EntityLiving entityliving, Vec3D vec3d) { + super(EntityTypes.SMALL_FIREBALL, entityliving, vec3d, world); + // CraftBukkit start + if (this.getOwner() != null && this.getOwner() instanceof EntityInsentient) { + isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); @@ -23,24 +23,24 @@ + // CraftBukkit end } - public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) { -@@ -35,7 +45,14 @@ + public EntitySmallFireball(World world, double d0, double d1, double d2, Vec3D vec3d) { +@@ -40,7 +50,14 @@ Entity entity1 = this.getOwner(); int i = entity.getRemainingFireTicks(); -- entity.igniteForSeconds(5); +- entity.igniteForSeconds(5.0F); + // CraftBukkit start - Entity damage by entity event + combust event -+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5); ++ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5.0F); + entity.level().getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entity.igniteForSeconds(event.getDuration(), false); + } + // CraftBukkit end - if (!entity.hurt(this.damageSources().fireball(this, entity1), 5.0F)) { - entity.setRemainingFireTicks(i); - } else if (entity1 instanceof EntityLiving) { -@@ -51,10 +68,10 @@ + DamageSource damagesource = this.damageSources().fireball(this, entity1); + + if (!entity.hurt(damagesource, 5.0F)) { +@@ -58,10 +75,10 @@ if (!this.level().isClientSide) { Entity entity = this.getOwner(); @@ -53,7 +53,7 @@ this.level().setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level(), blockposition)); } } -@@ -66,7 +83,7 @@ +@@ -73,7 +90,7 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch index d1941e9f5d..292ce8948a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntitySpectralArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntitySpectralArrow.java +++ b/net/minecraft/world/entity/projectile/EntitySpectralArrow.java -@@ -40,7 +40,7 @@ +@@ -41,7 +41,7 @@ super.doPostHurtEffects(entityliving); MobEffect mobeffect = new MobEffect(MobEffects.GLOWING, this.duration, 0); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch index b38276e314..477f3622e5 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityThrownTrident.java +++ b/net/minecraft/world/entity/projectile/EntityThrownTrident.java -@@ -23,6 +23,10 @@ +@@ -24,6 +24,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityThrownTrident extends EntityArrow { private static final DataWatcherObject ID_LOYALTY = DataWatcher.defineId(EntityThrownTrident.class, DataWatcherRegistry.BYTE); -@@ -68,7 +72,7 @@ +@@ -69,7 +73,7 @@ this.spawnAtLocation(this.getPickupItem(), 0.1F); } @@ -20,12 +20,12 @@ } else { this.setNoPhysics(true); Vec3D vec3d = entity.getEyePosition().subtract(this.position()); -@@ -152,7 +156,7 @@ - if (entitylightning != null) { - entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); - entitylightning.setCause(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); -- this.level().addFreshEntity(entitylightning); -+ ((WorldServer) this.level()).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit - soundeffect = SoundEffects.TRIDENT_THUNDER; - f1 = 5.0F; - } +@@ -129,7 +133,7 @@ + + world = this.level(); + if (world instanceof WorldServer) { +- worldserver = (WorldServer) world; ++ WorldServer worldserver = (WorldServer) world; // CraftBukkit - decompile error + EnchantmentManager.doPostAttackEffectsWithItemSource(worldserver, entity, damagesource, this.getWeaponItem()); + } + diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch index c4cedae4b4..49b008c6d3 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityTippedArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityTippedArrow.java +++ b/net/minecraft/world/entity/projectile/EntityTippedArrow.java -@@ -118,7 +118,7 @@ +@@ -119,7 +119,7 @@ mobeffect = (MobEffect) iterator.next(); entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.mapDuration((i) -> { return i / 8; @@ -9,7 +9,7 @@ } } -@@ -126,7 +126,7 @@ +@@ -127,7 +127,7 @@ while (iterator.hasNext()) { mobeffect = (MobEffect) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch index 83d1ec1953..d03789ba01 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityWitherSkull.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/EntityWitherSkull.java +++ b/net/minecraft/world/entity/projectile/EntityWitherSkull.java -@@ -21,6 +21,11 @@ - import net.minecraft.world.phys.MovingObjectPosition; +@@ -24,6 +24,11 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.event.entity.EntityRemoveEvent; @@ -12,16 +12,16 @@ public class EntityWitherSkull extends EntityFireball { private static final DataWatcherObject DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN); -@@ -64,7 +69,7 @@ +@@ -69,7 +74,7 @@ if (entity.isAlive()) { - this.doEnchantDamageEffects(entityliving, entity); + EnchantmentManager.doPostAttackEffects(worldserver, entity, damagesource); } else { - entityliving.heal(5.0F); + entityliving.heal(5.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit } } } else { -@@ -82,7 +87,7 @@ +@@ -86,7 +91,7 @@ } if (b0 > 0) { @@ -30,7 +30,7 @@ } } -@@ -93,8 +98,16 @@ +@@ -97,8 +102,16 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index 6b0fbedd16..8e05cbf01e 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/IProjectile.java +++ b/net/minecraft/world/entity/projectile/IProjectile.java -@@ -26,6 +26,10 @@ +@@ -30,6 +30,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,9 +11,9 @@ public abstract class IProjectile extends Entity implements TraceableEntity { @Nullable -@@ -35,6 +39,10 @@ - private boolean leftOwner; - private boolean hasBeenShot; +@@ -41,6 +45,10 @@ + @Nullable + private Entity lastDeflectedBy; + // CraftBukkit start + private boolean hitCancelled = false; @@ -22,7 +22,7 @@ IProjectile(EntityTypes entitytypes, World world) { super(entitytypes, world); } -@@ -44,6 +52,7 @@ +@@ -50,6 +58,7 @@ this.ownerUUID = entity.getUUID(); this.cachedOwner = entity; } @@ -30,7 +30,7 @@ } -@@ -170,6 +179,17 @@ +@@ -177,6 +186,17 @@ this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.onGround() ? 0.0D : vec3d.y, vec3d.z)); } @@ -48,7 +48,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(MovingObjectPosition movingobjectposition) { if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { MovingObjectPositionEntity movingobjectpositionentity = (MovingObjectPositionEntity) movingobjectposition; -@@ -225,6 +245,11 @@ +@@ -237,6 +257,11 @@ protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {} protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch index 745ac82bc8..b8cf1783a0 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java +++ b/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java -@@ -22,6 +22,10 @@ - import net.minecraft.world.phys.MovingObjectPositionBlock; +@@ -25,6 +25,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.event.entity.EntityRemoveEvent; @@ -10,17 +10,17 @@ + public abstract class AbstractWindCharge extends EntityFireball implements ItemSupplier { - public static final AbstractWindCharge.a EXPLOSION_DAMAGE_CALCULATOR = new AbstractWindCharge.a(); -@@ -95,7 +99,7 @@ - super.onHitBlock(movingobjectpositionblock); - if (!this.level().isClientSide) { - this.explode(); + public static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new SimpleExplosionDamageCalculator(true, false, Optional.empty(), BuiltInRegistries.BLOCK.getTag(TagsBlock.BLOCKS_WIND_CHARGE_EXPLOSIONS).map(Function.identity())); +@@ -113,7 +117,7 @@ + Vec3D vec3d1 = movingobjectpositionblock.getLocation().add(vec3d); + + this.explode(vec3d1); - this.discard(); + this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } } -@@ -104,7 +108,7 @@ +@@ -122,7 +126,7 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { @@ -29,10 +29,10 @@ } } -@@ -139,7 +143,7 @@ +@@ -157,7 +161,7 @@ public void tick() { if (!this.level().isClientSide && this.getBlockY() > this.level().getMaxBuildHeight() + 30) { - this.explode(); + this.explode(this.position()); - this.discard(); + this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); // CraftBukkit - add Bukkit remove cause } else { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch b/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch index c42fe4ca68..a2c11f8b95 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/EntityRaider.java +++ b/net/minecraft/world/entity/raid/EntityRaider.java -@@ -45,6 +45,10 @@ +@@ -38,6 +38,10 @@ import net.minecraft.world.level.WorldAccess; import net.minecraft.world.phys.Vec3D; @@ -11,16 +11,7 @@ public abstract class EntityRaider extends EntityMonsterPatrolling { protected static final DataWatcherObject IS_CELEBRATING = DataWatcher.defineId(EntityRaider.class, DataWatcherRegistry.BOOLEAN); -@@ -166,7 +170,7 @@ - MobEffect mobeffect1 = new MobEffect(MobEffects.BAD_OMEN, 120000, i, false, false, true); - - if (!this.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { -- entityhuman.addEffect(mobeffect1); -+ entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit - } - } - } -@@ -275,7 +279,7 @@ +@@ -233,7 +237,7 @@ this.onItemPickup(entityitem); this.setItemSlot(enumitemslot, itemstack); this.take(entityitem, itemstack.getCount()); @@ -29,7 +20,7 @@ this.getCurrentRaid().setLeader(this.getWave(), this); this.setPatrolLeader(true); } else { -@@ -324,7 +328,7 @@ +@@ -282,7 +286,7 @@ private final T mob; @@ -38,7 +29,7 @@ this.mob = entityraider1; this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -517,7 +521,7 @@ +@@ -475,7 +479,7 @@ private final float hostileRadiusSqr; public final PathfinderTargetCondition shoutTargeting = PathfinderTargetCondition.forNonCombat().range(8.0D).ignoreLineOfSight().ignoreInvisibilityTesting(); @@ -47,7 +38,7 @@ this.mob = entityillagerabstract; this.hostileRadiusSqr = f * f; this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK)); -@@ -540,7 +544,7 @@ +@@ -498,7 +502,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); @@ -56,7 +47,7 @@ } } -@@ -557,7 +561,7 @@ +@@ -515,7 +519,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch b/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch index 8d9634db94..25ced26882 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/raid/Raid.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -180,6 +180,12 @@ +@@ -177,6 +177,12 @@ return this.status == Raid.Status.LOSS; } @@ -13,7 +13,7 @@ public float getTotalHealth() { return this.totalHealth; } -@@ -284,6 +290,7 @@ +@@ -281,6 +287,7 @@ this.active = this.level.hasChunkAt(this.center); if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) { @@ -21,7 +21,7 @@ this.stop(); return; } -@@ -303,13 +310,16 @@ +@@ -300,13 +307,16 @@ if (!this.level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.Status.LOSS; @@ -38,7 +38,7 @@ this.stop(); return; } -@@ -383,6 +393,7 @@ +@@ -380,6 +390,7 @@ } if (j > 3) { @@ -46,7 +46,7 @@ this.stop(); break; } -@@ -395,6 +406,7 @@ +@@ -392,6 +403,7 @@ this.status = Raid.Status.VICTORY; Iterator iterator = this.heroesOfTheVillage.iterator(); @@ -54,7 +54,7 @@ while (iterator.hasNext()) { UUID uuid = (UUID) iterator.next(); Entity entity = this.level.getEntity(uuid); -@@ -409,10 +421,12 @@ +@@ -406,10 +418,12 @@ entityplayer.awardStat(StatisticList.RAID_WIN); CriterionTriggers.RAID_WIN.trigger(entityplayer); @@ -67,7 +67,7 @@ } } -@@ -420,6 +434,7 @@ +@@ -417,6 +431,7 @@ } else if (this.isOver()) { ++this.celebrationTicks; if (this.celebrationTicks >= 600) { @@ -75,7 +75,7 @@ this.stop(); return; } -@@ -556,6 +571,10 @@ +@@ -553,6 +568,10 @@ int j = araid_wave.length; int k = 0; @@ -86,7 +86,7 @@ while (k < j) { Raid.Wave raid_wave = araid_wave[k]; int l = this.getDefaultNumSpawns(raid_wave, i, flag1) + this.getPotentialBonusSpawns(raid_wave, this.random, i, difficultydamagescaler, flag1); -@@ -571,9 +590,11 @@ +@@ -568,9 +587,11 @@ entityraider.setPatrolLeader(true); this.setLeader(i, entityraider); flag = true; @@ -98,7 +98,7 @@ if (raid_wave.entityType == EntityTypes.RAVAGER) { EntityRaider entityraider1 = null; -@@ -592,6 +613,7 @@ +@@ -589,6 +610,7 @@ this.joinRaid(i, entityraider1, blockposition, false); entityraider1.moveTo(blockposition, 0.0F, 0.0F); entityraider1.startRiding(entityraider); @@ -106,7 +106,7 @@ } } -@@ -609,6 +631,7 @@ +@@ -606,6 +628,7 @@ ++this.groupsSpawned; this.updateBossbar(); this.setDirty(); @@ -114,16 +114,16 @@ } public void joinRaid(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { -@@ -624,7 +647,7 @@ +@@ -621,7 +644,7 @@ entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null); - entityraider.applyRaidBuffs(i, false); + entityraider.applyRaidBuffs(this.level, i, false); entityraider.setOnGround(true); - this.level.addFreshEntityWithPassengers(entityraider); + this.level.addFreshEntityWithPassengers(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit } } -@@ -873,6 +896,12 @@ +@@ -870,6 +893,12 @@ this.heroesOfTheVillage.add(entity.getUUID()); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch index 89a9c68229..1e7f11f7fd 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch @@ -36,7 +36,7 @@ } @Override -@@ -240,4 +256,51 @@ +@@ -248,4 +264,51 @@ public void stopOpen(EntityHuman entityhuman) { this.level().gameEvent((Holder) GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.a.of((Entity) entityhuman)); } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch index 49757536f1..44bbb9f2f9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityBoat.java +++ b/net/minecraft/world/entity/vehicle/EntityBoat.java -@@ -54,6 +54,15 @@ +@@ -55,6 +55,16 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -8,17 +8,18 @@ +import org.bukkit.Location; +import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.entity.Vehicle; ++import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.vehicle.VehicleDestroyEvent; +import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; +import org.bukkit.event.vehicle.VehicleMoveEvent; +// CraftBukkit end + - public class EntityBoat extends VehicleEntity implements VariantHolder { + public class EntityBoat extends VehicleEntity implements Leashable, VariantHolder { private static final DataWatcherObject DATA_ID_TYPE = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT); -@@ -91,6 +100,14 @@ - private float bubbleAngle; - private float bubbleAngleO; +@@ -94,6 +104,14 @@ + @Nullable + private Leashable.a leashData; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -31,7 +32,7 @@ public EntityBoat(EntityTypes entitytypes, World world) { super(entitytypes, world); this.paddlePositions = new float[2]; -@@ -186,9 +203,29 @@ +@@ -189,9 +207,29 @@ public void push(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { @@ -61,7 +62,7 @@ super.push(entity); } -@@ -282,6 +319,7 @@ +@@ -285,6 +323,7 @@ return this.getDirection().getClockWise(); } @@ -69,7 +70,7 @@ @Override public void tick() { this.oldStatus = this.status; -@@ -322,6 +360,22 @@ +@@ -325,6 +364,22 @@ this.setDeltaMovement(Vec3D.ZERO); } @@ -92,7 +93,27 @@ this.tickBubbleColumn(); for (int i = 0; i <= 1; ++i) { -@@ -811,6 +865,11 @@ +@@ -837,11 +892,18 @@ + + @Override + public void remove(Entity.RemovalReason entity_removalreason) { ++ // CraftBukkit start - add Bukkit remove cause ++ this.remove(entity_removalreason, null); ++ } ++ ++ @Override ++ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { ++ // CraftBukkit end + if (!this.level().isClientSide && entity_removalreason.shouldDestroy() && this.isLeashed()) { + this.dropLeash(true, true); + } + +- super.remove(entity_removalreason); ++ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause + } + + @Override +@@ -857,6 +919,11 @@ this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall()); if (!this.level().isClientSide && !this.isRemoved()) { @@ -104,7 +125,7 @@ this.kill(); if (this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { int i; -@@ -824,6 +883,7 @@ +@@ -870,6 +937,7 @@ } } } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch index d4365041ce..1579934d6a 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch @@ -61,8 +61,8 @@ } this.checkBelowWorld(); -- this.handleNetherPortal(); -+ // this.handleNetherPortal(); // CraftBukkit - handled in postTick +- this.handlePortal(); ++ // this.handlePortal(); // CraftBukkit - handled in postTick if (this.level().isClientSide) { if (this.lerpSteps > 0) { this.lerpPositionAndRotationStep(this.lerpSteps, this.lerpX, this.lerpY, this.lerpZ, this.lerpYRot, this.lerpXRot); @@ -109,7 +109,7 @@ + } + } + // CraftBukkit end - entity.push(this); + entity.push((Entity) this); } } @@ -355,6 +412,14 @@ @@ -124,7 +124,7 @@ + continue; + } + // CraftBukkit end - entity1.push(this); + entity1.push((Entity) this); } } @@ -371,7 +436,7 @@ diff --git a/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch b/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch index ca336a6dad..a697f51d2c 100644 --- a/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch +++ b/paper-server/nms-patches/net/minecraft/world/food/FoodMetaData.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/food/FoodMetaData.java +++ b/net/minecraft/world/food/FoodMetaData.java -@@ -7,15 +7,33 @@ - import net.minecraft.world.item.ItemStack; +@@ -6,15 +6,34 @@ + import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.level.GameRules; +// CraftBukkit start +import net.minecraft.network.protocol.game.PacketPlayOutUpdateHealth; +import net.minecraft.server.level.EntityPlayer; ++import net.minecraft.world.item.ItemStack; +// CraftBukkit end + public class FoodMetaData { @@ -34,27 +35,29 @@ + // CraftBukkit end private void add(int i, float f) { - this.foodLevel = Math.min(i + this.foodLevel, 20); -@@ -30,7 +48,17 @@ - FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD); - - if (foodinfo != null) { -- this.add(foodinfo.nutrition(), foodinfo.saturation()); -+ // CraftBukkit start -+ int oldFoodLevel = foodLevel; -+ -+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.nutrition() + oldFoodLevel, itemstack); -+ -+ if (!event.isCancelled()) { -+ this.add(event.getFoodLevel() - oldFoodLevel, foodinfo.saturation()); -+ } -+ -+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); -+ // CraftBukkit end - } - + this.foodLevel = MathHelper.clamp(i + this.foodLevel, 0, 20); +@@ -29,6 +48,20 @@ + this.add(foodinfo.nutrition(), foodinfo.saturation()); } -@@ -44,7 +72,15 @@ + ++ // CraftBukkit start ++ public void eat(ItemStack itemstack, FoodInfo foodinfo) { ++ int oldFoodLevel = foodLevel; ++ ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.nutrition() + oldFoodLevel, itemstack); ++ ++ if (!event.isCancelled()) { ++ this.add(event.getFoodLevel() - oldFoodLevel, foodinfo.saturation()); ++ } ++ ++ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); ++ } ++ // CraftBukkit end ++ + public void tick(EntityHuman entityhuman) { + EnumDifficulty enumdifficulty = entityhuman.level().getDifficulty(); + +@@ -38,7 +71,15 @@ if (this.saturationLevel > 0.0F) { this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { @@ -71,7 +74,7 @@ } } -@@ -52,23 +88,25 @@ +@@ -46,23 +87,25 @@ if (flag && this.saturationLevel > 0.0F && entityhuman.isHurt() && this.foodLevel >= 20) { ++this.tickTimer; diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index 56eb1c8523..2e0a8723ed 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerEnchantTable.java +++ b/net/minecraft/world/inventory/ContainerEnchantTable.java -@@ -25,6 +25,22 @@ +@@ -31,6 +31,22 @@ import net.minecraft.world.level.block.BlockEnchantmentTable; import net.minecraft.world.level.block.Blocks; @@ -22,8 +22,8 @@ + public class ContainerEnchantTable extends Container { - static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = new MinecraftKey("item/empty_slot_lapis_lazuli"); -@@ -35,6 +51,10 @@ + static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = MinecraftKey.withDefaultNamespace("item/empty_slot_lapis_lazuli"); +@@ -41,6 +57,10 @@ public final int[] costs; public final int[] enchantClue; public final int[] levelClue; @@ -34,7 +34,7 @@ public ContainerEnchantTable(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -48,6 +68,13 @@ +@@ -54,6 +74,13 @@ super.setChanged(); ContainerEnchantTable.this.slotsChanged(this); } @@ -48,7 +48,7 @@ }; this.random = RandomSource.create(); this.enchantmentSeed = ContainerProperty.standalone(); -@@ -55,13 +82,13 @@ +@@ -61,13 +88,13 @@ this.enchantClue = new int[]{-1, -1, -1}; this.levelClue = new int[]{-1, -1, -1}; this.access = containeraccess; @@ -64,7 +64,7 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.is(Items.LAPIS_LAZULI); -@@ -95,6 +122,9 @@ +@@ -101,6 +128,9 @@ this.addDataSlot(ContainerProperty.shared(this.levelClue, 0)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 1)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 2)); @@ -74,16 +74,16 @@ } @Override -@@ -102,7 +132,7 @@ +@@ -108,7 +138,7 @@ if (iinventory == this.enchantSlots) { ItemStack itemstack = iinventory.getItem(0); - if (!itemstack.isEmpty() && itemstack.isEnchantable()) { + if (!itemstack.isEmpty()) { // CraftBukkit - relax condition this.access.execute((world, blockposition) -> { + Registry> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); int i = 0; - Iterator iterator = BlockEnchantmentTable.BOOKSHELF_OFFSETS.iterator(); -@@ -141,6 +171,41 @@ +@@ -148,6 +178,41 @@ } } @@ -91,7 +91,7 @@ + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3]; + for (j = 0; j < 3; ++j) { -+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? CraftEnchantment.minecraftToBukkit(Enchantment.byId(this.enchantClue[j])) : null; ++ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? CraftEnchantment.minecraftHolderToBukkit(registry.byId(this.enchantClue[j])) : null; + offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null; + } + @@ -112,7 +112,7 @@ + EnchantmentOffer offer = event.getOffers()[j]; + if (offer != null) { + this.costs[j] = offer.getCost(); -+ this.enchantClue[j] = BuiltInRegistries.ENCHANTMENT.getId(CraftEnchantment.bukkitToMinecraft(offer.getEnchantment())); ++ this.enchantClue[j] = registry.getId(CraftEnchantment.bukkitToMinecraftHolder(offer.getEnchantment())); + this.levelClue[j] = offer.getEnchantmentLevel(); + } else { + this.costs[j] = 0; @@ -125,22 +125,23 @@ this.broadcastChanges(); }); } else { -@@ -168,21 +233,46 @@ +@@ -175,21 +240,46 @@ ItemStack itemstack2 = itemstack; - List list = this.getEnchantmentList(world.enabledFeatures(), itemstack, i, this.costs[i]); + List list = this.getEnchantmentList(world.registryAccess(), itemstack, i, this.costs[i]); - if (!list.isEmpty()) { - entityhuman.onEnchantmentPerformed(itemstack, j); + // CraftBukkit start ++ Registry> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + if (true || !list.isEmpty()) { + // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down + Map enchants = new java.util.HashMap(); + for (WeightedRandomEnchant instance : list) { -+ enchants.put(CraftEnchantment.minecraftToBukkit(instance.enchantment), instance.level); ++ enchants.put(CraftEnchantment.minecraftHolderToBukkit(instance.enchantment), instance.level); + } + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); + -+ org.bukkit.enchantments.Enchantment hintedEnchantment = CraftEnchantment.minecraftToBukkit(Enchantment.byId(enchantClue[i])); ++ org.bukkit.enchantments.Enchantment hintedEnchantment = CraftEnchantment.minecraftHolderToBukkit(registry.byId(enchantClue[i])); + int hintedEnchantmentLevel = levelClue[i]; + EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, hintedEnchantment, hintedEnchantmentLevel, i); + world.getCraftServer().getPluginManager().callEvent(event); @@ -151,7 +152,7 @@ + } + // CraftBukkit end if (itemstack.is(Items.BOOK)) { - itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK, 1); + itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK); this.enchantSlots.setItem(0, itemstack2); } @@ -161,8 +162,7 @@ - WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) iterator.next(); + // CraftBukkit start + for (Map.Entry entry : event.getEnchantsToAdd().entrySet()) { -+ NamespacedKey enchantId = entry.getKey().getKey(); -+ Enchantment nms = BuiltInRegistries.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId)); ++ Holder nms = CraftEnchantment.bukkitToMinecraftHolder(entry.getKey()); + if (nms == null) { + continue; + } @@ -175,10 +175,10 @@ + // CraftBukkit end + + // CraftBukkit - TODO: let plugins change this - if (!entityhuman.hasInfiniteMaterials()) { - itemstack1.shrink(j); - if (itemstack1.isEmpty()) { -@@ -245,6 +335,7 @@ + itemstack1.consume(j, entityhuman); + if (itemstack1.isEmpty()) { + this.enchantSlots.setItem(1, ItemStack.EMPTY); +@@ -256,6 +346,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -186,7 +186,7 @@ return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -295,4 +386,17 @@ +@@ -306,4 +397,17 @@ return itemstack; } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch index 12f662acb0..f79e8754ad 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch @@ -9,7 +9,7 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public abstract class ContainerFurnace extends ContainerRecipeBook { + public abstract class ContainerFurnace extends ContainerRecipeBook { public static final int INGREDIENT_SLOT = 0; @@ -31,6 +36,22 @@ @@ -51,12 +51,3 @@ return this.container.stillValid(entityhuman); } -@@ -159,7 +182,7 @@ - } - - protected boolean canSmelt(ItemStack itemstack) { -- return this.level.getRecipeManager().getRecipeFor(this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); -+ return this.level.getRecipeManager().getRecipeFor((Recipes) this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); // Eclipse fail - } - - protected boolean isFuel(ItemStack itemstack) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch index 46ca74696e..e35e128c0c 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerGrindstone.java +++ b/net/minecraft/world/inventory/ContainerGrindstone.java -@@ -19,8 +19,30 @@ +@@ -20,8 +20,30 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.Vec3D; @@ -31,7 +31,7 @@ public static final int MAX_NAME_LENGTH = 35; public static final int INPUT_SLOT = 0; public static final int ADDITIONAL_SLOT = 1; -@@ -46,15 +68,22 @@ +@@ -47,15 +69,22 @@ super.setChanged(); ContainerGrindstone.this.slotsChanged(this); } @@ -56,7 +56,7 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack); -@@ -124,6 +153,7 @@ +@@ -125,6 +154,7 @@ this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142)); } @@ -64,7 +64,7 @@ } @Override -@@ -136,7 +166,8 @@ +@@ -137,7 +167,8 @@ } private void createResult() { @@ -74,7 +74,7 @@ this.broadcastChanges(); } -@@ -238,6 +269,7 @@ +@@ -239,6 +270,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch index 81aa349d99..88d6bafdb2 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerHorse.java +++ b/net/minecraft/world/inventory/ContainerHorse.java -@@ -9,6 +9,11 @@ +@@ -10,6 +10,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -12,7 +12,7 @@ public class ContainerHorse extends Container { private final IInventory horseContainer; -@@ -17,8 +22,23 @@ +@@ -18,8 +23,23 @@ private static final int SLOT_BODY_ARMOR = 1; private static final int SLOT_HORSE_INVENTORY_START = 2; @@ -29,14 +29,14 @@ + return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), horseContainer.getOwner().getInventory(), this); + } + - public ContainerHorse(int i, PlayerInventory playerinventory, IInventory iinventory, final EntityHorseAbstract entityhorseabstract) { + public ContainerHorse(int i, PlayerInventory playerinventory, IInventory iinventory, final EntityHorseAbstract entityhorseabstract, int j) { super((Containers) null, i); + player = playerinventory; + // CraftBukkit end this.horseContainer = iinventory; this.armorContainer = entityhorseabstract.getBodyArmorAccess(); this.horse = entityhorseabstract; -@@ -27,7 +47,7 @@ +@@ -28,7 +48,7 @@ iinventory.startOpen(playerinventory.player); boolean flag1 = true; @@ -45,12 +45,12 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.is(Items.SADDLE) && !this.hasItem() && entityhorseabstract.isSaddleable(); -@@ -38,7 +58,7 @@ +@@ -39,7 +59,7 @@ return entityhorseabstract.isSaddleable(); } }); -- this.addSlot(new Slot(this, this.armorContainer, 0, 8, 36) { -+ this.addSlot(new Slot(this.armorContainer, 0, 8, 36) { // CraftBukkit - decompile error +- this.addSlot(new ArmorSlot(this, this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) { ++ this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { return entityhorseabstract.isBodyArmorItem(itemstack); diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch index b17d6a725e..0c5eaf1b27 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ContainerPlayer.java +++ b/net/minecraft/world/inventory/ContainerPlayer.java @@ -13,6 +13,12 @@ + import net.minecraft.world.item.crafting.RecipeCrafting; import net.minecraft.world.item.crafting.RecipeHolder; - import net.minecraft.world.item.enchantment.EnchantmentManager; +// CraftBukkit start +import net.minecraft.network.chat.IChatBaseComponent; @@ -10,12 +10,12 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerPlayer extends ContainerRecipeBook { + public class ContainerPlayer extends ContainerRecipeBook { public static final int CONTAINER_ID = 0; @@ -36,15 +42,28 @@ - public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = new MinecraftKey("item/empty_armor_slot_shield"); - static final MinecraftKey[] TEXTURE_EMPTY_SLOTS = new MinecraftKey[]{ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET}; + public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = MinecraftKey.withDefaultNamespace("item/empty_armor_slot_shield"); + private static final Map TEXTURE_EMPTY_SLOTS = Map.of(EnumItemSlot.FEET, ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, EnumItemSlot.LEGS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, EnumItemSlot.CHEST, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, EnumItemSlot.HEAD, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET); private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; - private final InventoryCrafting craftSlots = new TransientCraftingContainer(this, 2, 2); - private final InventoryCraftResult resultSlots = new InventoryCraftResult(); @@ -44,16 +44,7 @@ this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28)); int i; -@@ -59,7 +78,7 @@ - for (i = 0; i < 4; ++i) { - final EnumItemSlot enumitemslot = ContainerPlayer.SLOT_IDS[i]; - -- this.addSlot(new Slot(this, playerinventory, 39 - i, 8, 8 + i * 18) { -+ this.addSlot(new Slot(playerinventory, 39 - i, 8, 8 + i * 18) { // CraftBukkit - decompile error - @Override - public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) { - ContainerPlayer.onEquipItem(entityhuman, enumitemslot, itemstack, itemstack1); -@@ -100,7 +119,7 @@ +@@ -73,7 +92,7 @@ this.addSlot(new Slot(playerinventory, i, 8 + i * 18, 142)); } @@ -61,8 +52,8 @@ + this.addSlot(new Slot(playerinventory, 40, 77, 62) { // CraftBukkit - decompile error @Override public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) { - ContainerPlayer.onEquipItem(entityhuman, EnumItemSlot.OFFHAND, itemstack, itemstack1); -@@ -261,4 +280,17 @@ + entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack); +@@ -230,4 +249,17 @@ public boolean shouldMoveToInventory(int i) { return i != this.getResultSlotIndex(); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch index 3484de6c67..5d29097d80 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerSmithing.java +++ b/net/minecraft/world/inventory/ContainerSmithing.java -@@ -13,6 +13,8 @@ +@@ -14,6 +14,8 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -9,7 +9,7 @@ public class ContainerSmithing extends ContainerAnvilAbstract { public static final int TEMPLATE_SLOT = 0; -@@ -28,6 +30,9 @@ +@@ -29,6 +31,9 @@ @Nullable private RecipeHolder selectedRecipe; private final List> recipes; @@ -19,16 +19,16 @@ public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -97,7 +102,7 @@ - List> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level); +@@ -103,7 +108,7 @@ + List> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, smithingrecipeinput, this.level); if (list.isEmpty()) { - this.resultSlots.setItem(0, ItemStack.EMPTY); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit } else { RecipeHolder recipeholder = (RecipeHolder) list.get(0); - ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(this.inputSlots, this.level.registryAccess()); -@@ -105,7 +110,9 @@ + ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(smithingrecipeinput, this.level.registryAccess()); +@@ -111,7 +116,9 @@ if (itemstack.isItemEnabled(this.level.enabledFeatures())) { this.selectedRecipe = recipeholder; this.resultSlots.setRecipeUsed(recipeholder); @@ -39,7 +39,7 @@ } } -@@ -137,4 +144,18 @@ +@@ -143,4 +150,18 @@ return !this.getSlot(i).hasItem(); }).findFirst(); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch index 2ea9c6719b..46a9a52aec 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerStonecutter.java +++ b/net/minecraft/world/inventory/ContainerStonecutter.java -@@ -16,6 +16,13 @@ +@@ -17,6 +17,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -14,7 +14,7 @@ public class ContainerStonecutter extends Container { public static final int INPUT_SLOT = 0; -@@ -35,6 +42,21 @@ +@@ -36,6 +43,21 @@ Runnable slotUpdateListener; public final IInventory container; final InventoryCraftResult resultContainer; @@ -36,7 +36,7 @@ public ContainerStonecutter(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -54,6 +76,13 @@ +@@ -55,6 +77,13 @@ ContainerStonecutter.this.slotsChanged(this); ContainerStonecutter.this.slotUpdateListener.run(); } @@ -50,7 +50,7 @@ }; this.resultContainer = new InventoryCraftResult(); this.access = containeraccess; -@@ -105,6 +134,7 @@ +@@ -106,6 +135,7 @@ } this.addDataSlot(this.selectedRecipeIndex); @@ -58,7 +58,7 @@ } public int getSelectedRecipeIndex() { -@@ -125,6 +155,7 @@ +@@ -126,6 +156,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch index 7c32f5f318..a3acf03d3f 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerWorkbench.java +++ b/net/minecraft/world/inventory/ContainerWorkbench.java -@@ -15,6 +15,12 @@ +@@ -16,6 +16,12 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -10,10 +10,10 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerWorkbench extends ContainerRecipeBook { + public class ContainerWorkbench extends ContainerRecipeBook { public static final int RESULT_SLOT = 0; -@@ -24,10 +30,13 @@ +@@ -25,11 +31,14 @@ private static final int INV_SLOT_END = 37; private static final int USE_ROW_SLOT_START = 37; private static final int USE_ROW_SLOT_END = 46; @@ -22,13 +22,14 @@ public final InventoryCraftResult resultSlots; public final ContainerAccess access; private final EntityHuman player; + private boolean placingRecipe; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + // CraftBukkit end public ContainerWorkbench(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -35,8 +44,11 @@ +@@ -37,8 +46,11 @@ public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) { super(Containers.CRAFTING, i); @@ -41,7 +42,15 @@ this.access = containeraccess; this.player = playerinventory.player; this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35)); -@@ -80,6 +92,7 @@ +@@ -70,6 +82,7 @@ + EntityPlayer entityplayer = (EntityPlayer) entityhuman; + ItemStack itemstack = ItemStack.EMPTY; + Optional> optional = world.getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, world, recipeholder); ++ inventorycrafting.setCurrentRecipe(optional.orElse(null)); // CraftBukkit + + if (optional.isPresent()) { + RecipeHolder recipeholder1 = (RecipeHolder) optional.get(); +@@ -83,6 +96,7 @@ } } } @@ -49,7 +58,7 @@ inventorycraftresult.setItem(0, itemstack); container.setRemoteSlot(0, itemstack); -@@ -120,6 +133,7 @@ +@@ -139,6 +153,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -57,7 +66,7 @@ return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE); } -@@ -208,4 +222,17 @@ +@@ -227,4 +242,17 @@ public boolean shouldMoveToInventory(int i) { return i != this.getResultSlotIndex(); } diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch b/paper-server/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch index 6939d4ac54..156735c76a 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/CrafterMenu.java +++ b/net/minecraft/world/inventory/CrafterMenu.java -@@ -9,8 +9,27 @@ +@@ -10,8 +10,27 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.CrafterBlock; @@ -28,7 +28,7 @@ protected static final int SLOT_COUNT = 9; private static final int INV_SLOT_START = 9; private static final int INV_SLOT_END = 36; -@@ -117,6 +136,7 @@ +@@ -118,6 +137,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch new file mode 100644 index 0000000000..32f823c9fa --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/inventory/InventoryCrafting.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/world/inventory/InventoryCrafting.java ++++ b/net/minecraft/world/inventory/InventoryCrafting.java +@@ -5,6 +5,10 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.crafting.CraftingInput; + ++// CraftBukkit start ++import net.minecraft.world.item.crafting.RecipeHolder; ++// CraftBukkit end ++ + public interface InventoryCrafting extends IInventory, AutoRecipeOutput { + + int getWidth(); +@@ -13,6 +17,15 @@ + + List getItems(); + ++ // CraftBukkit start ++ default RecipeHolder getCurrentRecipe() { ++ return null; ++ } ++ ++ default void setCurrentRecipe(RecipeHolder recipe) { ++ } ++ // CraftBukkit end ++ + default CraftingInput asCraftInput() { + return this.asPositionedCraftInput().input(); + } diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch index d9045615c2..1c25dc58ce 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemArmor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemArmor.java +++ b/net/minecraft/world/item/ItemArmor.java -@@ -31,6 +31,12 @@ +@@ -29,6 +29,12 @@ import net.minecraft.world.level.block.BlockDispenser; import net.minecraft.world.phys.AxisAlignedBB; @@ -12,10 +12,10 @@ + public class ItemArmor extends Item implements Equipable { - private static final EnumMap ARMOR_MODIFIER_UUID_PER_TYPE = (EnumMap) SystemUtils.make(new EnumMap(ItemArmor.a.class), (enummap) -> { -@@ -60,8 +66,34 @@ + public static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() { +@@ -51,8 +57,34 @@ EntityLiving entityliving = (EntityLiving) list.get(0); - EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack); + EnumItemSlot enumitemslot = entityliving.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = itemstack.split(1); + // CraftBukkit start + World world = sourceblock.level(); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch index 8e138afa51..418749bd0e 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemBucket.patch @@ -17,7 +17,7 @@ public class ItemBucket extends Item implements DispensibleContainerItem { public final FluidType content; -@@ -62,6 +72,17 @@ +@@ -63,6 +73,17 @@ if (block instanceof IFluidSource) { IFluidSource ifluidsource = (IFluidSource) block; @@ -32,10 +32,10 @@ + return InteractionResultWrapper.fail(itemstack); + } + // CraftBukkit end - ItemStack itemstack1 = ifluidsource.pickupBlock(entityhuman, world, blockposition, iblockdata); + itemstack1 = ifluidsource.pickupBlock(entityhuman, world, blockposition, iblockdata); if (!itemstack1.isEmpty()) { -@@ -70,7 +91,7 @@ +@@ -71,7 +92,7 @@ entityhuman.playSound(soundeffect, 1.0F, 1.0F); }); world.gameEvent((Entity) entityhuman, (Holder) GameEvent.FLUID_PICKUP, blockposition); @@ -44,7 +44,7 @@ if (!world.isClientSide) { CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1); -@@ -85,7 +106,7 @@ +@@ -86,7 +107,7 @@ iblockdata = world.getBlockState(blockposition); BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1; @@ -53,7 +53,7 @@ this.checkExtraContent(entityhuman, world, itemstack, blockposition2); if (entityhuman instanceof EntityPlayer) { CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition2, itemstack); -@@ -112,6 +133,12 @@ +@@ -114,6 +135,12 @@ @Override public boolean emptyContents(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) { @@ -66,7 +66,7 @@ FluidType fluidtype = this.content; if (!(fluidtype instanceof FluidTypeFlowing fluidtypeflowing)) { -@@ -147,8 +174,18 @@ +@@ -149,8 +176,18 @@ boolean flag2 = flag1; diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch index 6542d1181f..9050013b43 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemEnderEye.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemEnderEye.java +++ b/net/minecraft/world/item/ItemEnderEye.java -@@ -95,7 +95,11 @@ +@@ -97,7 +97,11 @@ entityendersignal.setItem(itemstack); entityendersignal.signalTo(blockposition); world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman)); @@ -11,5 +11,5 @@ + } + // CraftBukkit end if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.USED_ENDER_EYE.trigger((EntityPlayer) entityhuman, blockposition); - } + EntityPlayer entityplayer = (EntityPlayer) entityhuman; + diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch index f77b17bb04..0977a96c1f 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemFishingRod.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemFishingRod.java +++ b/net/minecraft/world/item/ItemFishingRod.java -@@ -12,6 +12,11 @@ +@@ -13,6 +13,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,19 +12,20 @@ public class ItemFishingRod extends Item { public ItemFishingRod(Item.Info item_info) { -@@ -32,12 +37,23 @@ +@@ -33,13 +38,24 @@ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH); } else { - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); - if (!world.isClientSide) { - i = EnchantmentManager.getFishingSpeedBonus(itemstack); - int j = EnchantmentManager.getFishingLuckBonus(itemstack); + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; + int j = (int) (EnchantmentManager.getFishingTimeReduction(worldserver, itemstack, entityhuman) * 20.0F); + int k = EnchantmentManager.getFishingLuckBonus(worldserver, itemstack, entityhuman); -- world.addFreshEntity(new EntityFishingHook(entityhuman, world, j, i)); +- world.addFreshEntity(new EntityFishingHook(entityhuman, world, k, j)); + // CraftBukkit start -+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i); ++ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j); + PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), PlayerFishEvent.State.FISHING); + world.getCraftServer().getPluginManager().callEvent(playerFishEvent); + diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch index 56fb587865..4c64f39fed 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemHanging.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemHanging.java +++ b/net/minecraft/world/item/ItemHanging.java -@@ -23,6 +23,11 @@ +@@ -24,6 +24,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,7 +12,7 @@ public class ItemHanging extends Item { private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY); -@@ -73,6 +78,19 @@ +@@ -74,6 +79,19 @@ if (((EntityHanging) object).survives()) { if (!world.isClientSide) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch index 6fd18937eb..d26c8aac0e 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemLeash.patch @@ -1,18 +1,19 @@ --- a/net/minecraft/world/item/ItemLeash.java +++ b/net/minecraft/world/item/ItemLeash.java -@@ -16,6 +16,11 @@ +@@ -19,6 +19,12 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AxisAlignedBB; +// CraftBukkit start +import org.bukkit.craftbukkit.CraftEquipmentSlot; ++import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.hanging.HangingPlaceEvent; +// CraftBukkit end + public class ItemLeash extends Item { public ItemLeash(Item.Info item_info) { -@@ -32,7 +37,7 @@ +@@ -35,7 +41,7 @@ EntityHuman entityhuman = itemactioncontext.getPlayer(); if (!world.isClientSide && entityhuman != null) { @@ -21,28 +22,28 @@ } return EnumInteractionResult.sidedSuccess(world.isClientSide); -@@ -41,7 +46,7 @@ +@@ -44,7 +50,7 @@ } } - public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) { + public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition, net.minecraft.world.EnumHand enumhand) { // CraftBukkit - Add EnumHand EntityLeash entityleash = null; - double d0 = 7.0D; - int i = blockposition.getX(); -@@ -54,19 +59,50 @@ + List list = leashableInArea(world, blockposition, (leashable) -> { + return leashable.getLeashHolder() == entityhuman; +@@ -52,22 +58,55 @@ - EntityInsentient entityinsentient; + Leashable leashable; -- for (Iterator iterator = list.iterator(); iterator.hasNext(); entityinsentient.setLeashedTo(entityleash, true)) { +- for (Iterator iterator = list.iterator(); iterator.hasNext(); leashable.setLeashedTo(entityleash, true)) { + for (Iterator iterator = list.iterator(); iterator.hasNext();) { // CraftBukkit - handle setLeashedTo at end of loop - entityinsentient = (EntityInsentient) iterator.next(); + leashable = (Leashable) iterator.next(); if (entityleash == null) { entityleash = EntityLeash.getOrCreateKnot(world, blockposition); + + // CraftBukkit start - fire HangingPlaceEvent + org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand); -+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF, hand); ++ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, CraftBlock.at(world, blockposition), org.bukkit.block.BlockFace.SELF, hand); + world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -54,12 +55,14 @@ } + + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) { -+ iterator.remove(); -+ continue; ++ if (leashable instanceof Entity leashed) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(leashed, entityleash, entityhuman, enumhand).isCancelled()) { ++ iterator.remove(); ++ continue; ++ } + } + -+ entityinsentient.setLeashedTo(entityleash, true); ++ leashable.setLeashedTo(entityleash, true); + // CraftBukkit end } @@ -75,10 +78,13 @@ return EnumInteractionResult.PASS; } } -+ + + // CraftBukkit start + public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) { + return bindPlayerMobs(entityhuman, world, blockposition, net.minecraft.world.EnumHand.MAIN_HAND); + } + // CraftBukkit end - } ++ + public static List leashableInArea(World world, BlockPosition blockposition, Predicate predicate) { + double d0 = 7.0D; + int i = blockposition.getX(); diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch index 3aaf24a966..57a4d3646d 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/item/ItemMilkBucket.java +++ b/net/minecraft/world/item/ItemMilkBucket.java -@@ -26,7 +26,7 @@ +@@ -25,7 +25,7 @@ + } - itemstack.consume(1, entityliving); if (!world.isClientSide) { - entityliving.removeAllEffects(); + entityliving.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.MILK); // CraftBukkit } - return itemstack.isEmpty() ? new ItemStack(Items.BUCKET) : itemstack; + if (entityliving instanceof EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch index 4b2a399368..a3aaf32f97 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch @@ -1,15 +1,10 @@ --- a/net/minecraft/world/item/ItemProjectileWeapon.java +++ b/net/minecraft/world/item/ItemProjectileWeapon.java -@@ -59,11 +59,28 @@ - float f6 = f4 + f5 * (float) ((i + 1) / 2) * f3; - - f5 = -f5; -- itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand)); -+ // itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand)); // CraftBukkit - moved down - IProjectile iprojectile = this.createProjectile(world, entityliving, itemstack, itemstack1, flag); +@@ -62,7 +62,22 @@ + IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag); this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1); -- world.addFreshEntity(iprojectile); +- worldserver.addFreshEntity(iprojectile); + // CraftBukkit start + org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, iprojectile, enumhand, f, true); + if (event.isCancelled()) { @@ -17,10 +12,8 @@ + return; + } + -+ itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand)); -+ + if (event.getProjectile() == iprojectile.getBukkitEntity()) { -+ if (!world.addFreshEntity(iprojectile)) { ++ if (!worldserver.addFreshEntity(iprojectile)) { + if (entityliving instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityliving).getBukkitEntity().updateInventory(); + } @@ -28,6 +21,6 @@ + } + } + // CraftBukkit end - } - } - + itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand)); + if (itemstack.isEmpty()) { + break; diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch deleted file mode 100644 index 2b2be2b018..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemRecord.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/item/ItemRecord.java -+++ b/net/minecraft/world/item/ItemRecord.java -@@ -47,6 +47,7 @@ - ItemStack itemstack = itemactioncontext.getItemInHand(); - - if (!world.isClientSide) { -+ if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack - EntityHuman entityhuman = itemactioncontext.getPlayer(); - TileEntity tileentity = world.getBlockEntity(blockposition); - diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch index 84a2ad4a2f..c49da51fe6 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -92,6 +92,40 @@ +@@ -91,6 +91,40 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -41,13 +41,13 @@ public final class ItemStack implements DataComponentHolder { public static final Codec> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM.holderByNameCodec().validate((holder) -> { -@@ -100,14 +134,14 @@ +@@ -99,14 +133,14 @@ }) : DataResult.success(holder); }); public static final Codec CODEC = Codec.lazyInitialized(() -> { - return RecordCodecBuilder.create((instance) -> { + return RecordCodecBuilder.create((instance) -> { // CraftBukkit - decompile error - return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.POSITIVE_INT.fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { + return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.intRange(1, 99).fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { return itemstack.components.asPatch(); })).apply(instance, ItemStack::new); }); @@ -58,7 +58,7 @@ return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { return itemstack.components.asPatch(); })).apply(instance, (holder, datacomponentpatch) -> { -@@ -132,19 +166,25 @@ +@@ -131,19 +165,25 @@ if (i <= 0) { return ItemStack.EMPTY; } else { @@ -88,7 +88,7 @@ DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch()); } } -@@ -188,7 +228,7 @@ +@@ -187,7 +227,7 @@ return dataresult.isError() ? dataresult.map((unit) -> { return itemstack; @@ -97,7 +97,18 @@ int i = itemstack.getCount(); return "Item stack with stack size of " + i + " was larger than maximum: " + itemstack.getMaxStackSize(); -@@ -347,11 +387,191 @@ +@@ -286,8 +326,9 @@ + j = itemstack.getMaxStackSize(); + } while (i <= j); + ++ int finalI = i, finalJ = j; // CraftBukkit - decompile error + return DataResult.error(() -> { +- return "Item stack with count of " + i + " was larger than maximum: " + j; ++ return "Item stack with count of " + finalI + " was larger than maximum: " + finalJ; // CraftBukkit - decompile error + }); + } + } +@@ -369,11 +410,169 @@ return EnumInteractionResult.PASS; } else { Item item = this.getItem(); @@ -213,28 +224,6 @@ + world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point + } + -+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord. -+ // PAIL: checkme on updates. -+ if (this.item instanceof ItemRecord) { -+ TileEntity tileentity = world.getBlockEntity(blockposition); -+ -+ if (tileentity instanceof TileEntityJukeBox) { -+ TileEntityJukeBox tileentityjukebox = (TileEntityJukeBox) tileentity; -+ -+ // There can only be one -+ ItemStack record = this.copy(); -+ if (!record.isEmpty()) { -+ record.setCount(1); -+ } -+ -+ tileentityjukebox.setTheItem(record); -+ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entityhuman, world.getBlockState(blockposition))); -+ } -+ -+ this.shrink(1); -+ entityhuman.awardStat(StatisticList.PLAY_RECORD); -+ } -+ + if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled + BlockPosition bp = blockposition; + if (!world.getBlockState(blockposition).canBeReplaced()) { @@ -291,41 +280,41 @@ return enuminteractionresult; } -@@ -432,6 +652,21 @@ - } +@@ -444,6 +643,21 @@ + if (entityplayer == null || !entityplayer.hasInfiniteMaterials()) { + if (i > 0) { + i = EnchantmentManager.processDurabilityChange(worldserver, this, i); ++ // CraftBukkit start ++ if (entityplayer != null) { ++ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), i); ++ event.getPlayer().getServer().getPluginManager().callEvent(event); ++ ++ if (i != event.getDamage() || event.isCancelled()) { ++ event.getPlayer().updateInventory(); ++ } ++ if (event.isCancelled()) { ++ return; ++ } ++ ++ i = event.getDamage(); ++ } ++ // CraftBukkit end + if (i <= 0) { + return; + } +@@ -480,6 +694,11 @@ + } - i -= k; -+ // CraftBukkit start -+ if (entityplayer != null) { -+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), i); -+ event.getPlayer().getServer().getPluginManager().callEvent(event); -+ -+ if (i != event.getDamage() || event.isCancelled()) { -+ event.getPlayer().updateInventory(); -+ } -+ if (event.isCancelled()) { -+ return; -+ } -+ -+ i = event.getDamage(); -+ } -+ // CraftBukkit end - if (i <= 0) { - return; - } -@@ -474,6 +709,11 @@ - this.hurtAndBreak(i, randomsource, entityplayer, () -> { - entityliving.broadcastBreakEvent(enumitemslot); - Item item = this.getItem(); + this.hurtAndBreak(i, worldserver, entityplayer, (item) -> { + // CraftBukkit start - Check for item breaking + if (this.count == 1 && entityliving instanceof EntityHuman) { + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this); + } + // CraftBukkit end - - this.shrink(1); - if (entityliving instanceof EntityHuman) { -@@ -669,6 +909,12 @@ + entityliving.onEquippedItemBroken(item, enumitemslot); + }); + } +@@ -693,6 +912,12 @@ return this.getItem().useOnRelease(this); } @@ -338,7 +327,7 @@ @Nullable public T set(DataComponentType datacomponenttype, @Nullable T t0) { return this.components.set(datacomponenttype, t0); -@@ -728,7 +974,7 @@ +@@ -752,7 +977,7 @@ } private void addToTooltip(DataComponentType datacomponenttype, Item.b item_b, Consumer consumer, TooltipFlag tooltipflag) { @@ -347,8 +336,8 @@ if (t0 != null) { t0.addToTooltip(item_b, consumer, tooltipflag); -@@ -955,6 +1201,13 @@ - +@@ -992,6 +1217,13 @@ + EnchantmentManager.forEachModifier(this, enumitemslot, biconsumer); } + // CraftBukkit start @@ -361,7 +350,7 @@ public IChatBaseComponent getDisplayName() { IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName()); -@@ -1017,7 +1270,7 @@ +@@ -1054,7 +1286,7 @@ } public void consume(int i, @Nullable EntityLiving entityliving) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch index 2fea326921..f645aecb26 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemTrident.patch @@ -1,47 +1,47 @@ --- a/net/minecraft/world/item/ItemTrident.java +++ b/net/minecraft/world/item/ItemTrident.java -@@ -72,7 +72,7 @@ +@@ -77,7 +77,7 @@ + Holder holder = (Holder) EnchantmentManager.pickHighestLevel(itemstack, EnchantmentEffectComponents.TRIDENT_SOUND).orElse(SoundEffects.TRIDENT_THROW); - if (k <= 0 || entityhuman.isInWaterOrRain()) { - if (!world.isClientSide) { -- itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); -+ // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down - if (k == 0) { - EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); + if (!world.isClientSide) { +- itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); ++ // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down + if (f == 0.0F) { + EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); -@@ -81,11 +81,26 @@ - entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; - } +@@ -86,11 +86,26 @@ + entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; + } -- world.addFreshEntity(entitythrowntrident); -+ // CraftBukkit start -+ if (!world.addFreshEntity(entitythrowntrident)) { -+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { -+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); +- world.addFreshEntity(entitythrowntrident); ++ // CraftBukkit start ++ if (!world.addFreshEntity(entitythrowntrident)) { ++ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { ++ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); ++ } ++ return; + } -+ return; -+ } + -+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); -+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved -+ // CraftBukkit end ++ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); ++ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved ++ // CraftBukkit end + - world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); - if (!entityhuman.hasInfiniteMaterials()) { - entityhuman.getInventory().removeItem(itemstack); + world.playSound((EntityHuman) null, (Entity) entitythrowntrident, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F); + if (!entityhuman.hasInfiniteMaterials()) { + entityhuman.getInventory().removeItem(itemstack); + } ++ // CraftBukkit start - SPIGOT-5458 also need in this branch :( ++ } else { ++ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); ++ // CraftBukkkit end } -+ // CraftBukkit start - SPIGOT-5458 also need in this branch :( -+ } else { -+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); -+ // CraftBukkkit end } - } -@@ -102,6 +117,7 @@ - f2 *= f6 / f5; - f3 *= f6 / f5; - f4 *= f6 / f5; -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f2, f3, f4); // CraftBukkit - entityhuman.push((double) f2, (double) f3, (double) f4); - entityhuman.startAutoSpinAttack(20); - if (entityhuman.onGround()) { +@@ -106,6 +121,7 @@ + f3 *= f / f6; + f4 *= f / f6; + f5 *= f / f6; ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f3, f4, f5); // CraftBukkit + entityhuman.push((double) f3, (double) f4, (double) f5); + entityhuman.startAutoSpinAttack(20, 8.0F, itemstack); + if (entityhuman.onGround()) { diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index 57d77d8233..17bd7807a9 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -12,7 +12,7 @@ public class CraftingManager extends ResourceDataJson { private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); -@@ -70,19 +75,39 @@ +@@ -70,11 +75,26 @@ } } @@ -41,48 +41,32 @@ public boolean hadErrorsLoading() { return this.hasErrors; } - - public > Optional> getRecipeFor(Recipes recipes, C c0, World world) { -- return this.byType(recipes).stream().filter((recipeholder) -> { -+ // CraftBukkit start -+ List> list = this.byType(recipes).stream().filter((recipeholder) -> { - return recipeholder.value().matches(c0, world); -- }).findFirst(); -+ }).toList(); -+ Optional> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority -+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found -+ return recipe; -+ // CraftBukkit end +@@ -90,9 +110,13 @@ } - public > Optional> getRecipeFor(Recipes recipes, C c0, World world, @Nullable MinecraftKey minecraftkey) { -@@ -94,9 +119,14 @@ - } - } - -- return this.byType(recipes).stream().filter((recipeholder1) -> { + public > Optional> getRecipeFor(Recipes recipes, I i0, World world, @Nullable RecipeHolder recipeholder) { +- return i0.isEmpty() ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : this.byType(recipes).stream().filter((recipeholder1) -> { + // CraftBukkit start + List> list = this.byType(recipes).stream().filter((recipeholder1) -> { - return recipeholder1.value().matches(c0, world); -- }).findFirst(); + return recipeholder1.value().matches(i0, world); +- }).findFirst()); + }).toList(); -+ Optional> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority -+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found ++ Optional> recipe = (list.isEmpty() || i0.isEmpty()) ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : Optional.of(list.getLast())); // CraftBukkit - SPIGOT-4638: last recipe gets priority + return recipe; + // CraftBukkit end } - public > List> getAllRecipesFor(Recipes recipes) { -@@ -112,7 +142,7 @@ + public > List> getAllRecipesFor(Recipes recipes) { +@@ -108,7 +132,7 @@ } - private > Collection> byType(Recipes recipes) { + private > Collection> byType(Recipes recipes) { - return this.byType.get(recipes); + return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error } - public > NonNullList getRemainingItemsFor(Recipes recipes, C c0, World world) { -@@ -139,7 +169,7 @@ + public > NonNullList getRemainingItemsFor(Recipes recipes, I i0, World world) { +@@ -135,7 +159,7 @@ private > RecipeHolder byKeyTyped(Recipes recipes, MinecraftKey minecraftkey) { RecipeHolder recipeholder = (RecipeHolder) this.byName.get(minecraftkey); @@ -91,7 +75,7 @@ } public Collection> getOrderedRecipes() { -@@ -175,10 +205,31 @@ +@@ -171,10 +195,31 @@ com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder); } @@ -101,8 +85,8 @@ + this.byType = LinkedHashMultimap.create(builder.build()); + this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build()); + // CraftBukkit end - } - ++ } ++ + // CraftBukkit start + public boolean removeRecipe(MinecraftKey mcKey) { + Iterator> iter = byType.values().iterator(); @@ -114,14 +98,14 @@ + } + + return byName.remove(mcKey) != null; -+ } -+ + } + + public void clearRecipes() { + this.byType = LinkedHashMultimap.create(); + this.byName = Maps.newHashMap(); + } + // CraftBukkit end + - public static > CraftingManager.a createCheck(final Recipes recipes) { - return new CraftingManager.a() { + public static > CraftingManager.a createCheck(final Recipes recipes) { + return new CraftingManager.a() { @Nullable diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch index af2e2a5e68..85949adca2 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/IRecipe.java +++ b/net/minecraft/world/item/crafting/IRecipe.java -@@ -72,4 +72,6 @@ +@@ -71,4 +71,6 @@ return recipeitemstack.getItems().length == 0; }); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch index 8f96573bb3..21b2a7fe2b 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RecipeStonecutting.java +++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java -@@ -5,6 +5,14 @@ +@@ -4,6 +4,14 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; @@ -15,7 +15,7 @@ public class RecipeStonecutting extends RecipeSingleItem { public RecipeStonecutting(String s, RecipeItemStack recipeitemstack, ItemStack itemstack) { -@@ -20,4 +28,16 @@ +@@ -18,4 +26,16 @@ public ItemStack getToastSymbol() { return new ItemStack(Blocks.STONECUTTER); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch index b903beaab1..a9a8c24aa0 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipes.java +++ b/net/minecraft/world/item/crafting/ShapedRecipes.java -@@ -11,6 +11,14 @@ +@@ -10,6 +10,14 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -15,7 +15,7 @@ public class ShapedRecipes implements RecipeCrafting { final ShapedRecipePattern pattern; -@@ -31,6 +39,68 @@ +@@ -30,6 +38,68 @@ this(s, craftingbookcategory, shapedrecipepattern, itemstack, true); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch index b96f2c73cc..68bf0e1eed 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipes.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipes.java -@@ -15,6 +15,13 @@ +@@ -13,6 +13,13 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -14,7 +14,7 @@ public class ShapelessRecipes implements RecipeCrafting { final String group; -@@ -29,6 +36,22 @@ +@@ -27,6 +34,22 @@ this.ingredients = nonnulllist; } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch index eb6a5fea65..30f56c61d3 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -10,6 +10,14 @@ +@@ -9,6 +9,14 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -15,7 +15,7 @@ public class SmithingTransformRecipe implements SmithingRecipe { final RecipeItemStack template; -@@ -67,6 +75,17 @@ +@@ -64,6 +72,17 @@ return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch index 125c7675f2..3cf830349c 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -20,6 +20,13 @@ +@@ -19,6 +19,13 @@ import net.minecraft.world.item.armortrim.TrimPatterns; import net.minecraft.world.level.World; @@ -14,7 +14,7 @@ public class SmithingTrimRecipe implements SmithingRecipe { final RecipeItemStack template; -@@ -100,6 +107,13 @@ +@@ -97,6 +104,13 @@ return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty); } diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch deleted file mode 100644 index 55deb2c840..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java -+++ b/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java -@@ -39,8 +39,11 @@ - IBlockData iblockdata2 = world.getBlockState(blockposition1); - - if (iblockdata2 == BlockIceFrost.meltsInto() && iblockdata.canSurvive(world, blockposition1) && world.isUnobstructed(iblockdata, blockposition1, VoxelShapeCollision.empty())) { -- world.setBlockAndUpdate(blockposition1, iblockdata); -- world.scheduleTick(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); -+ // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition1, iblockdata, entityliving)) { -+ world.scheduleTick(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); -+ } -+ // CraftBukkit End - } - } - } diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch deleted file mode 100644 index 9b79034546..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java -+++ b/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java -@@ -35,7 +35,7 @@ - if (this.targets.get() == TagsEntity.SENSITIVE_TO_BANE_OF_ARTHROPODS && i > 0 && entityliving1.getType().is((TagKey) this.targets.get())) { - int j = 20 + entityliving.getRandom().nextInt(10 * i); - -- entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3)); -+ entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit - } - } - diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.patch new file mode 100644 index 0000000000..1a7d62e54b --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java ++++ b/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java +@@ -34,7 +34,7 @@ + int j = Math.round(MathHelper.randomBetween(randomsource, this.minDuration.calculate(i), this.maxDuration.calculate(i)) * 20.0F); + int k = Math.max(0, Math.round(MathHelper.randomBetween(randomsource, this.minAmplifier.calculate(i), this.maxAmplifier.calculate(i)))); + +- entityliving.addEffect(new MobEffect((Holder) optional.get(), j, k)); ++ entityliving.addEffect(new MobEffect((Holder) optional.get(), j, k), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + } + } + diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/Ignite.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/Ignite.patch new file mode 100644 index 0000000000..900b7668d1 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/Ignite.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/item/enchantment/effects/Ignite.java ++++ b/net/minecraft/world/item/enchantment/effects/Ignite.java +@@ -8,6 +8,10 @@ + import net.minecraft.world.item.enchantment.LevelBasedValue; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityCombustByEntityEvent; ++// CraftBukkit end ++ + public record Ignite(LevelBasedValue duration) implements EnchantmentEntityEffect { + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { +@@ -18,7 +22,15 @@ + + @Override + public void apply(WorldServer worldserver, int i, EnchantedItemInUse enchantediteminuse, Entity entity, Vec3D vec3d) { +- entity.igniteForSeconds(this.duration.calculate(i)); ++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item ++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(enchantediteminuse.owner().getBukkitEntity(), entity.getBukkitEntity(), this.duration.calculate(i)); ++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); ++ ++ if (combustEvent.isCancelled()) { ++ return; ++ } ++ entity.igniteForSeconds(combustEvent.getDuration(), false); ++ // CraftBukkit end + } + + @Override diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceBlock.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceBlock.patch new file mode 100644 index 0000000000..9135b466fe --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceBlock.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java ++++ b/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java +@@ -26,7 +26,7 @@ + + if ((Boolean) this.predicate.map((blockpredicate) -> { + return blockpredicate.test(worldserver, blockposition); +- }).orElse(true) && worldserver.setBlockAndUpdate(blockposition, this.blockState.getState(entity.getRandom(), blockposition))) { ++ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition, this.blockState.getState(entity.getRandom(), blockposition), entity)) { // CraftBukkit - Call EntityBlockFormEvent + this.triggerGameEvent.ifPresent((holder) -> { + worldserver.gameEvent(entity, holder, blockposition); + }); diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch new file mode 100644 index 0000000000..350911b209 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/ReplaceDisk.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java ++++ b/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java +@@ -37,7 +37,7 @@ + + if (blockposition1.distToCenterSqr(vec3d.x(), (double) blockposition1.getY() + 0.5D, vec3d.z()) < (double) MathHelper.square(j) && (Boolean) this.predicate.map((blockpredicate) -> { + return blockpredicate.test(worldserver, blockposition1); +- }).orElse(true) && worldserver.setBlockAndUpdate(blockposition1, this.blockState.getState(randomsource, blockposition1))) { ++ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition1, this.blockState.getState(randomsource, blockposition1), entity)) { // CraftBukkit - Call EntityBlockFormEvent for Frost Walker + this.triggerGameEvent.ifPresent((holder) -> { + worldserver.gameEvent(entity, holder, blockposition1); + }); diff --git a/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch new file mode 100644 index 0000000000..b95be72a12 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch @@ -0,0 +1,36 @@ +--- a/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java ++++ b/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java +@@ -20,6 +20,12 @@ + import net.minecraft.world.level.World; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import net.minecraft.world.item.Items; ++import org.bukkit.event.entity.CreatureSpawnEvent; ++import org.bukkit.event.weather.LightningStrikeEvent; ++// CraftBukkit end ++ + public record SummonEntityEffect(HolderSet> entityTypes, boolean joinTeam) implements EnchantmentEntityEffect { + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { +@@ -34,7 +40,7 @@ + Optional>> optional = this.entityTypes().getRandomElement(worldserver.getRandom()); + + if (!optional.isEmpty()) { +- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EnumMobSpawn.TRIGGERED); ++ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EnumMobSpawn.TRIGGERED, false, false); // CraftBukkit + + if (entity1 != null) { + if (entity1 instanceof EntityLightning) { +@@ -46,6 +52,11 @@ + + entitylightning.setCause(entityplayer); + } ++ // CraftBukkit start ++ worldserver.strikeLightning(entity1, (enchantediteminuse.itemStack().getItem() == Items.TRIDENT) ? LightningStrikeEvent.Cause.TRIDENT : LightningStrikeEvent.Cause.ENCHANTMENT); ++ } else { ++ worldserver.addFreshEntityWithPassengers(entity, CreatureSpawnEvent.SpawnReason.ENCHANTMENT); ++ // CraftBukkit end + } + + if (this.joinTeam && entity.getTeam() != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch index 28df90838c..8d191c26b2 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/Explosion.java +++ b/net/minecraft/world/level/Explosion.java -@@ -40,6 +40,16 @@ +@@ -41,6 +41,16 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -17,7 +17,7 @@ public class Explosion { private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new ExplosionDamageCalculator(); -@@ -61,6 +71,10 @@ +@@ -62,6 +72,10 @@ private final Holder explosionSound; private final ObjectArrayList toBlow; private final Map hitPlayers; @@ -28,7 +28,7 @@ public static DamageSource getDefaultDamageSource(World world, @Nullable Entity entity) { return world.damageSources().explosion(entity, getIndirectSourceEntityInternal(entity)); -@@ -86,7 +100,7 @@ +@@ -87,7 +101,7 @@ this.hitPlayers = Maps.newHashMap(); this.level = world; this.source = entity; @@ -37,7 +37,7 @@ this.x = d0; this.y = d1; this.z = d2; -@@ -97,6 +111,7 @@ +@@ -98,6 +112,7 @@ this.smallExplosionParticles = particleparam; this.largeExplosionParticles = particleparam1; this.explosionSound = holder; @@ -45,7 +45,7 @@ } private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { -@@ -147,6 +162,11 @@ +@@ -148,6 +163,11 @@ } public void explode() { @@ -57,7 +57,7 @@ this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, new Vec3D(this.x, this.y, this.z)); Set set = Sets.newHashSet(); boolean flag = true; -@@ -229,7 +249,35 @@ +@@ -230,7 +250,35 @@ d9 /= d11; d10 /= d11; if (this.damageCalculator.shouldDamageEntity(this, entity)) { @@ -94,7 +94,7 @@ } double d12 = (1.0D - d7) * (double) getSeenPercent(vec3d, entity) * (double) this.damageCalculator.getKnockbackMultiplier(entity); -@@ -248,6 +296,17 @@ +@@ -249,6 +297,17 @@ d10 *= d13; Vec3D vec3d1 = new Vec3D(d8, d9, d10); @@ -112,7 +112,7 @@ entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); if (entity instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entity; -@@ -290,9 +349,65 @@ +@@ -291,9 +350,65 @@ SystemUtils.shuffle(this.toBlow, this.level.random); ObjectListIterator objectlistiterator = this.toBlow.iterator(); @@ -178,7 +178,7 @@ this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> { addOrAppendStack(list, itemstack, blockposition1); -@@ -317,7 +432,11 @@ +@@ -318,7 +433,11 @@ BlockPosition blockposition1 = (BlockPosition) objectlistiterator1.next(); if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition1).isAir() && this.level.getBlockState(blockposition1.below()).isSolidRender(this.level, blockposition1.below())) { @@ -191,7 +191,7 @@ } } } -@@ -325,6 +444,7 @@ +@@ -326,6 +445,7 @@ } private static void addOrAppendStack(List> list, ItemStack itemstack, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/World.patch b/paper-server/nms-patches/net/minecraft/world/level/World.patch index c1c3f937ce..80116f14b3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/World.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/World.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/World.java +++ b/net/minecraft/world/level/World.java -@@ -77,6 +77,28 @@ +@@ -78,6 +78,28 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.scores.Scoreboard; @@ -29,7 +29,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); -@@ -118,7 +140,42 @@ +@@ -119,7 +141,42 @@ private final DamageSources damageSources; private long subTickCount; @@ -73,7 +73,7 @@ this.profiler = supplier; this.levelData = worlddatamutable; this.dimensionTypeRegistration = holder; -@@ -127,15 +184,15 @@ +@@ -128,15 +185,15 @@ this.dimension = resourcekey; this.isClientSide = flag; if (dimensionmanager.coordinateScale() != 1.0D) { @@ -92,7 +92,7 @@ } }; } else { -@@ -148,6 +205,42 @@ +@@ -149,6 +206,42 @@ this.neighborUpdater = new CollectingNeighborUpdater(this, j); this.registryAccess = iregistrycustom; this.damageSources = new DamageSources(iregistrycustom); @@ -135,7 +135,7 @@ } @Override -@@ -205,6 +298,18 @@ +@@ -206,6 +299,18 @@ @Override public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -154,7 +154,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return false; } else if (!this.isClientSide && this.isDebug()) { -@@ -212,13 +317,29 @@ +@@ -213,13 +318,29 @@ } else { Chunk chunk = this.getChunkAt(blockposition); Block block = iblockdata.getBlock(); @@ -185,7 +185,7 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); -@@ -245,12 +366,69 @@ +@@ -246,12 +367,69 @@ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } @@ -255,7 +255,7 @@ public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -336,6 +514,14 @@ +@@ -337,6 +515,14 @@ @Override public IBlockData getBlockState(BlockPosition blockposition) { @@ -270,7 +270,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -518,6 +704,11 @@ +@@ -523,6 +709,11 @@ case 4: explosion_effect = Explosion.Effect.TRIGGER_BLOCK; break; @@ -282,7 +282,7 @@ default: throw new MatchException((String) null, (Throwable) null); } -@@ -539,6 +730,16 @@ +@@ -544,6 +735,16 @@ @Nullable @Override public TileEntity getBlockEntity(BlockPosition blockposition) { @@ -299,7 +299,7 @@ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -546,6 +747,12 @@ +@@ -551,6 +752,12 @@ BlockPosition blockposition = tileentity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { @@ -312,7 +312,7 @@ this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -675,7 +882,7 @@ +@@ -680,7 +887,7 @@ for (int k = 0; k < j; ++k) { EntityComplexPart entitycomplexpart = aentitycomplexpart[k]; @@ -321,12 +321,12 @@ if (t0 != null && predicate.test(t0)) { list.add(t0); -@@ -953,7 +1160,7 @@ +@@ -958,7 +1165,7 @@ - public static enum a { + public static enum a implements INamable { -- NONE, BLOCK, MOB, TNT, BLOW; -+ NONE, BLOCK, MOB, TNT, BLOW, STANDARD; // CraftBukkit - Add STANDARD which will always use Explosion.Effect.DESTROY +- NONE("none"), BLOCK("block"), MOB("mob"), TNT("tnt"), TRIGGER("trigger"); ++ NONE("none"), BLOCK("block"), MOB("mob"), TNT("tnt"), TRIGGER("trigger"), STANDARD("standard"); // CraftBukkit - Add STANDARD which will always use Explosion.Effect.DESTROY - private a() {} - } + public static final Codec CODEC = INamable.fromEnum(World.a::values); + private final String id; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch b/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch index ff2b233eb8..5bb1b6171e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/Block.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -341,7 +341,13 @@ +@@ -340,7 +340,13 @@ EntityItem entityitem = (EntityItem) supplier.get(); entityitem.setDefaultPickUpDelay(); @@ -15,7 +15,7 @@ } } -@@ -367,7 +373,7 @@ +@@ -366,7 +372,7 @@ public void playerDestroy(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) { entityhuman.awardStat(StatisticList.BLOCK_MINED.get(this)); @@ -24,21 +24,19 @@ dropResources(iblockdata, world, blockposition, tileentity, entityhuman, itemstack); } -@@ -500,17 +506,25 @@ +@@ -499,15 +505,23 @@ return this.builtInRegistryHolder; } - protected void tryDropExperience(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, IntProvider intprovider) { + // CraftBukkit start + protected int tryDropExperience(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, IntProvider intprovider) { - if (EnchantmentManager.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { - int i = intprovider.sample(worldserver.random); + int i = EnchantmentManager.processBlockExperience(worldserver, itemstack, intprovider.sample(worldserver.getRandom())); - if (i > 0) { -- this.popExperience(worldserver, blockposition, i); -+ // this.popExperience(worldserver, blockposition, i); -+ return i; - } + if (i > 0) { +- this.popExperience(worldserver, blockposition, i); ++ // this.popExperience(worldserver, blockposition, i); ++ return i; } + return 0; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch index 34927b8d20..ebc661f7c3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch @@ -29,9 +29,9 @@ + return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end - this.press(iblockdata, world, blockposition); - this.playSound(entityhuman, world, blockposition, true); - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.BLOCK_ACTIVATE, blockposition); + this.press(iblockdata, world, blockposition, entityhuman); + return EnumInteractionResult.sidedSuccess(world.isClientSide); + } @@ -195,11 +213,36 @@ } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch index 86b9b02752..f7dbcd4f6b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCake.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCake.java +++ b/net/minecraft/world/level/block/BlockCake.java -@@ -100,7 +100,18 @@ +@@ -97,7 +97,18 @@ return EnumInteractionResult.PASS; } else { entityhuman.awardStat(StatisticList.EAT_CAKE_SLICE); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch index 615dfdd8b6..434f54515b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockCampfire.java +++ b/net/minecraft/world/level/block/BlockCampfire.java -@@ -106,7 +106,7 @@ +@@ -105,7 +105,7 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if ((Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { -- entity.hurt(world.damageSources().inFire(), (float) this.fireDamage); -+ entity.hurt(world.damageSources().inFire().directBlock(world, blockposition), (float) this.fireDamage); // CraftBukkit + if ((Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving) { +- entity.hurt(world.damageSources().campfire(), (float) this.fireDamage); ++ entity.hurt(world.damageSources().campfire().directBlock(world, blockposition), (float) this.fireDamage); // CraftBukkit } super.entityInside(iblockdata, world, blockposition, entity); -@@ -216,6 +216,11 @@ +@@ -215,6 +215,11 @@ BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); if (!world.isClientSide && iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch index 55c26c92ff..a0e4dc714f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockDropper.patch @@ -32,10 +32,10 @@ if (iinventory == null) { itemstack1 = BlockDropper.DISPENSE_BEHAVIOUR.dispense(sourceblock, itemstack); } else { -- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.copy().split(1), enumdirection.getOpposite()); +- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.copyWithCount(1), enumdirection.getOpposite()); - if (itemstack1.isEmpty()) { + // CraftBukkit start - Fire event when pushing items into other inventories -+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copy().split(1)); ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copyWithCount(1)); + + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch new file mode 100644 index 0000000000..97412076c1 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/level/block/BlockEndGateway.java ++++ b/net/minecraft/world/level/block/BlockEndGateway.java +@@ -21,6 +21,10 @@ + import net.minecraft.world.level.portal.DimensionTransition; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import org.bukkit.event.player.PlayerTeleportEvent; ++// CraftBukkit end ++ + public class BlockEndGateway extends BlockTileEntity implements Portal { + + public static final MapCodec CODEC = simpleCodec(BlockEndGateway::new); +@@ -110,7 +114,7 @@ + if (tileentity instanceof TileEntityEndGateway tileentityendgateway) { + Vec3D vec3d = tileentityendgateway.getPortalPosition(worldserver, blockposition); + +- return vec3d != null ? new DimensionTransition(worldserver, vec3d, calculateExitMovement(entity), entity.getYRot(), entity.getXRot(), DimensionTransition.PLACE_PORTAL_TICKET) : null; ++ return vec3d != null ? new DimensionTransition(worldserver, vec3d, calculateExitMovement(entity), entity.getYRot(), entity.getXRot(), DimensionTransition.PLACE_PORTAL_TICKET, PlayerTeleportEvent.TeleportCause.END_GATEWAY) : null; // CraftBukkit + } else { + return null; + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch index 2e4c3a2185..efe0c0080f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch @@ -1,41 +1,80 @@ --- a/net/minecraft/world/level/block/BlockEnderPortal.java +++ b/net/minecraft/world/level/block/BlockEnderPortal.java -@@ -21,6 +21,13 @@ +@@ -26,6 +26,19 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start ++import java.util.List; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.level.dimension.WorldDimension; ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.CraftWorld; ++import org.bukkit.craftbukkit.event.CraftPortalEvent; ++import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.event.entity.EntityPortalEnterEvent; ++import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end + - public class BlockEnderPortal extends BlockTileEntity { + public class BlockEnderPortal extends BlockTileEntity implements Portal { public static final MapCodec CODEC = simpleCodec(BlockEnderPortal::new); -@@ -48,13 +55,22 @@ +@@ -53,6 +66,10 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (world instanceof WorldServer && entity.canChangeDimensions() && VoxelShapes.joinIsNotEmpty(VoxelShapes.create(entity.getBoundingBox().move((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { -- ResourceKey resourcekey = world.dimension() == World.END ? World.OVERWORLD : World.END; -+ ResourceKey resourcekey = world.getTypeKey() == WorldDimension.END ? World.OVERWORLD : World.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends - WorldServer worldserver = ((WorldServer) world).getServer().getLevel(resourcekey); - - if (worldserver == null) { -- return; -+ // return; // CraftBukkit - always fire event in case plugins wish to change it - } - + if (entity.canUsePortal(false) && VoxelShapes.joinIsNotEmpty(VoxelShapes.create(entity.getBoundingBox().move((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (entity instanceof EntityPlayer) { -+ ((EntityPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL); -+ return; -+ } + // CraftBukkit end - entity.changeDimension(worldserver); - } + if (!world.isClientSide && world.dimension() == World.END && entity instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) entity; + +@@ -69,11 +86,11 @@ + + @Override + public DimensionTransition getPortalDestination(WorldServer worldserver, Entity entity, BlockPosition blockposition) { +- ResourceKey resourcekey = worldserver.dimension() == World.END ? World.OVERWORLD : World.END; ++ ResourceKey resourcekey = worldserver.getTypeKey() == WorldDimension.END ? World.OVERWORLD : World.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends + WorldServer worldserver1 = worldserver.getServer().getLevel(resourcekey); + + if (worldserver1 == null) { +- return null; ++ return new DimensionTransition(PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit- always fire event in case plugins wish to change it + } else { + boolean flag = resourcekey == World.END; + BlockPosition blockposition1 = flag ? WorldServer.END_SPAWN_POINT : worldserver1.getSharedSpawnPos(); +@@ -81,7 +98,7 @@ + float f = entity.getYRot(); + + if (flag) { +- EndPlatformFeature.createEndPlatform(worldserver1, BlockPosition.containing(vec3d).below(), true); ++ EndPlatformFeature.createEndPlatform(worldserver1, BlockPosition.containing(vec3d).below(), true, entity); // CraftBukkit + f = EnumDirection.WEST.toYRot(); + if (entity instanceof EntityPlayer) { + vec3d = vec3d.subtract(0.0D, 1.0D, 0.0D); +@@ -90,13 +107,21 @@ + if (entity instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) entity; + +- return entityplayer.findRespawnPositionAndUseSpawnBlock(false, DimensionTransition.DO_NOTHING); ++ return entityplayer.findRespawnPositionAndUseSpawnBlock(false, DimensionTransition.DO_NOTHING, PlayerRespawnEvent.RespawnReason.END_PORTAL); // CraftBukkit + } + + vec3d = entity.adjustSpawnLocation(worldserver1, blockposition1).getBottomCenter(); + } + +- return new DimensionTransition(worldserver1, vec3d, entity.getDeltaMovement(), f, entity.getXRot(), DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET)); ++ // CraftBukkit start ++ CraftPortalEvent event = entity.callPortalEvent(entity, CraftLocation.toBukkit(vec3d, worldserver1.getWorld(), f, entity.getXRot()), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0); ++ if (event == null) { ++ return null; ++ } ++ Location to = event.getTo(); ++ ++ return new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), entity.getDeltaMovement(), to.getYaw(), to.getPitch(), DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET), PlayerTeleportEvent.TeleportCause.END_PORTAL); ++ // CraftBukkit end + } + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch index 98746fb1b0..b218c72c2e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch @@ -4,9 +4,9 @@ if (!entity.fireImmune()) { entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 1); if (entity.getRemainingFireTicks() == 0) { -- entity.igniteForSeconds(8); +- entity.igniteForSeconds(8.0F); + // CraftBukkit start -+ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition), entity.getBukkitEntity(), 8); ++ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition), entity.getBukkitEntity(), 8.0F); + world.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch index 3af3ec5615..645c4d73f0 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLectern.java +++ b/net/minecraft/world/level/block/BlockLectern.java -@@ -207,11 +207,12 @@ +@@ -208,11 +208,12 @@ } private void popBook(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch index 35959fa06a..19b5501471 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLever.java +++ b/net/minecraft/world/level/block/BlockLever.java -@@ -28,6 +28,8 @@ +@@ -29,6 +29,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -27,6 +27,6 @@ + } + // CraftBukkit end + - iblockdata1 = this.pull(iblockdata, world, blockposition); - float f = (Boolean) iblockdata1.getValue(BlockLever.POWERED) ? 0.6F : 0.5F; - + this.pull(iblockdata, world, blockposition, (EntityHuman) null); + return EnumInteractionResult.CONSUME; + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch index d1126b4eb4..708bbfa85d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockMagma.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/BlockMagma.java +++ b/net/minecraft/world/level/block/BlockMagma.java -@@ -30,7 +30,7 @@ +@@ -29,7 +29,7 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - if (!entity.isSteppingCarefully() && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { + if (!entity.isSteppingCarefully() && entity instanceof EntityLiving) { - entity.hurt(world.damageSources().hotFloor(), 1.0F); + entity.hurt(world.damageSources().hotFloor().directBlock(world, blockposition), 1.0F); // CraftBukkit } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch index 79e9f0e996..0c279c6e03 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockPortal.patch @@ -1,17 +1,22 @@ --- a/net/minecraft/world/level/block/BlockPortal.java +++ b/net/minecraft/world/level/block/BlockPortal.java -@@ -26,6 +26,10 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -38,6 +38,15 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import org.slf4j.Logger; +// CraftBukkit start ++import net.minecraft.world.level.dimension.WorldDimension; ++import org.bukkit.craftbukkit.CraftWorld; ++import org.bukkit.craftbukkit.event.CraftPortalEvent; ++import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.event.entity.EntityPortalEnterEvent; ++import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end + - public class BlockPortal extends Block { + public class BlockPortal extends Block implements Portal { public static final MapCodec CODEC = simpleCodec(BlockPortal::new); -@@ -63,7 +67,8 @@ +@@ -76,7 +85,8 @@ } if (worldserver.getBlockState(blockposition).isValidSpawn(worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { @@ -21,14 +26,90 @@ if (entity != null) { entity.setPortalCooldown(); -@@ -85,6 +90,10 @@ +@@ -98,6 +108,10 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (entity.canChangeDimensions()) { + if (entity.canUsePortal(false)) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent(event); + // CraftBukkit end - entity.handleInsidePortal(blockposition); + entity.setAsInsidePortal(this, blockposition); } +@@ -115,24 +129,34 @@ + @Nullable + @Override + public DimensionTransition getPortalDestination(WorldServer worldserver, Entity entity, BlockPosition blockposition) { +- ResourceKey resourcekey = worldserver.dimension() == World.NETHER ? World.OVERWORLD : World.NETHER; ++ // CraftBukkit start ++ ResourceKey resourcekey = worldserver.getTypeKey() == WorldDimension.NETHER ? World.OVERWORLD : World.NETHER; + WorldServer worldserver1 = worldserver.getServer().getLevel(resourcekey); + + if (worldserver1 == null) { +- return null; ++ return new DimensionTransition(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // always fire event in case plugins wish to change it + } else { +- boolean flag = worldserver1.dimension() == World.NETHER; ++ boolean flag = worldserver1.getTypeKey() == WorldDimension.NETHER; ++ // CraftBukkit end + WorldBorder worldborder = worldserver1.getWorldBorder(); + double d0 = DimensionManager.getTeleportationScale(worldserver.dimensionType(), worldserver1.dimensionType()); + BlockPosition blockposition1 = worldborder.clampToBounds(entity.getX() * d0, entity.getY(), entity.getZ() * d0); ++ // CraftBukkit start ++ CraftPortalEvent event = entity.callPortalEvent(entity, CraftLocation.toBukkit(blockposition1, worldserver1.getWorld()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag ? 16 : 128, 16); ++ if (event == null) { ++ return null; ++ } ++ worldserver1 = ((CraftWorld) event.getTo().getWorld()).getHandle(); ++ worldborder = worldserver1.getWorldBorder(); ++ blockposition1 = worldborder.clampToBounds(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + +- return this.getExitPortal(worldserver1, entity, blockposition, blockposition1, flag, worldborder); ++ return this.getExitPortal(worldserver1, entity, blockposition, blockposition1, flag, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()); + } + } + + @Nullable +- private DimensionTransition getExitPortal(WorldServer worldserver, Entity entity, BlockPosition blockposition, BlockPosition blockposition1, boolean flag, WorldBorder worldborder) { +- Optional optional = worldserver.getPortalForcer().findClosestPortalPosition(blockposition1, flag, worldborder); ++ private DimensionTransition getExitPortal(WorldServer worldserver, Entity entity, BlockPosition blockposition, BlockPosition blockposition1, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { ++ Optional optional = worldserver.getPortalForcer().findClosestPortalPosition(blockposition1, worldborder, searchRadius); + BlockUtil.Rectangle blockutil_rectangle; + DimensionTransition.a dimensiontransition_a; + +@@ -146,17 +170,22 @@ + dimensiontransition_a = DimensionTransition.PLAY_PORTAL_SOUND.then((entity1) -> { + entity1.placePortalTicket(blockposition2); + }); +- } else { ++ } else if (canCreatePortal) { + EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) entity.level().getBlockState(blockposition).getOptionalValue(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X); +- Optional optional1 = worldserver.getPortalForcer().createPortal(blockposition1, enumdirection_enumaxis); ++ Optional optional1 = worldserver.getPortalForcer().createPortal(blockposition1, enumdirection_enumaxis, entity, createRadius); ++ // CraftBukkit end + + if (optional1.isEmpty()) { +- BlockPortal.LOGGER.error("Unable to create a portal, likely target out of worldborder"); ++ // BlockPortal.LOGGER.error("Unable to create a portal, likely target out of worldborder"); // CraftBukkit + return null; + } + + blockutil_rectangle = (BlockUtil.Rectangle) optional1.get(); + dimensiontransition_a = DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET); ++ // CraftBukkit start ++ } else { ++ return null; ++ // CraftBukkit end + } + + return getDimensionTransitionFromExit(entity, blockposition, blockutil_rectangle, worldserver, dimensiontransition_a); +@@ -198,7 +227,7 @@ + Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); + Vec3D vec3d4 = BlockPortalShape.findCollisionFreePosition(vec3d3, worldserver, entity, entitysize); + +- return new DimensionTransition(worldserver, vec3d4, vec3d2, f + (float) i, f1, dimensiontransition_a); ++ return new DimensionTransition(worldserver, vec3d4, vec3d2, f + (float) i, f1, dimensiontransition_a, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // CraftBukkit + } + + @Override diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch index a3ea951a32..cb76dcb3b9 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockRedstoneOre.java +++ b/net/minecraft/world/level/block/BlockRedstoneOre.java -@@ -22,6 +22,11 @@ +@@ -21,6 +21,11 @@ import net.minecraft.world.level.block.state.properties.BlockStateBoolean; import net.minecraft.world.phys.MovingObjectPositionBlock; @@ -12,7 +12,7 @@ public class BlockRedstoneOre extends Block { public static final MapCodec CODEC = simpleCodec(BlockRedstoneOre::new); -@@ -39,14 +44,27 @@ +@@ -38,14 +43,27 @@ @Override protected void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { @@ -42,7 +42,7 @@ } super.stepOn(world, blockposition, iblockdata, entity); -@@ -57,15 +75,20 @@ +@@ -56,15 +74,20 @@ if (world.isClientSide) { spawnParticles(world, blockposition); } else { @@ -65,7 +65,7 @@ world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneOre.LIT, true), 3); } -@@ -79,6 +102,11 @@ +@@ -78,6 +101,11 @@ @Override protected void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if ((Boolean) iblockdata.getValue(BlockRedstoneOre.LIT)) { @@ -77,7 +77,7 @@ worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneOre.LIT, false), 3); } -@@ -87,12 +115,20 @@ +@@ -86,10 +114,17 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); @@ -86,12 +86,9 @@ + + @Override + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { - if (flag && EnchantmentManager.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { - int i = 1 + worldserver.random.nextInt(5); - -- this.popExperience(worldserver, blockposition, i); -+ // this.popExperience(worldserver, blockposition, i); -+ return i; + if (flag) { +- this.tryDropExperience(worldserver, blockposition, itemstack, UniformInt.of(1, 5)); ++ return this.tryDropExperience(worldserver, blockposition, itemstack, UniformInt.of(1, 5)); } + return 0; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSign.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSign.patch index 47254a4363..bd27f5de6d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockSign.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockSign.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockSign.java +++ b/net/minecraft/world/level/block/BlockSign.java -@@ -142,7 +142,7 @@ +@@ -139,7 +139,7 @@ } else if (flag1) { return EnumInteractionResult.SUCCESS; } else if (!this.otherPlayerIsEditingSign(entityhuman, tileentitysign) && entityhuman.mayBuild() && this.hasEditableText(entityhuman, tileentitysign, flag)) { @@ -9,7 +9,7 @@ return EnumInteractionResult.SUCCESS; } else { return EnumInteractionResult.PASS; -@@ -188,6 +188,15 @@ +@@ -185,6 +185,15 @@ } public void openTextEdit(EntityHuman entityhuman, TileEntitySign tileentitysign, boolean flag) { @@ -25,7 +25,7 @@ tileentitysign.setAllowedPlayerEditor(entityhuman.getUUID()); entityhuman.openTextEdit(tileentitysign, flag); } -@@ -201,6 +210,6 @@ +@@ -198,6 +207,6 @@ @Nullable @Override public BlockEntityTicker getTicker(World world, IBlockData iblockdata, TileEntityTypes tileentitytypes) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch index 560a87771b..a01659be10 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/BlockTNT.patch @@ -51,7 +51,7 @@ explode(world, blockposition, entityhuman); world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 11); Item item = itemstack.getItem(); -@@ -125,6 +135,11 @@ +@@ -123,6 +133,11 @@ Entity entity = iprojectile.getOwner(); if (iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch index 52a45a5095..4d646728df 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DecoratedPotBlock.java +++ b/net/minecraft/world/level/block/DecoratedPotBlock.java -@@ -238,6 +238,11 @@ +@@ -239,6 +239,11 @@ BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile.mayBreak(world)) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch index c67e7fcb32..f0665b99fe 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/LightningRodBlock.java +++ b/net/minecraft/world/level/block/LightningRodBlock.java -@@ -33,6 +33,11 @@ - import net.minecraft.world.phys.MovingObjectPositionBlock; - import net.minecraft.world.phys.Vec3D; +@@ -22,6 +22,11 @@ + import net.minecraft.world.level.material.FluidType; + import net.minecraft.world.level.material.FluidTypes; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlock; @@ -12,7 +12,7 @@ public class LightningRodBlock extends RodBlock implements IBlockWaterlogged { public static final MapCodec CODEC = simpleCodec(LightningRodBlock::new); -@@ -85,6 +90,18 @@ +@@ -74,6 +79,18 @@ } public void onLightningStrike(IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -31,12 +31,3 @@ world.setBlock(blockposition, (IBlockData) iblockdata.setValue(LightningRodBlock.POWERED, true), 3); this.updateNeighbours(iblockdata, world, blockposition); world.scheduleTick(blockposition, (Block) this, 8); -@@ -142,7 +159,7 @@ - Entity entity = iprojectile.getOwner(); - - entitylightning.setCause(entity instanceof EntityPlayer ? (EntityPlayer) entity : null); -- world.addFreshEntity(entitylightning); -+ ((WorldServer) world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit - } - - world.playSound((EntityHuman) null, blockposition, SoundEffects.TRIDENT_THUNDER, SoundCategory.WEATHER, 5.0F, 1.0F); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch index 0068930326..5186a7c531 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java -@@ -34,10 +34,13 @@ +@@ -35,10 +35,13 @@ public SculkCatalystBlockEntity(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.SCULK_CATALYST, blockposition, iblockdata); this.catalystListener = new SculkCatalystBlockEntity.CatalystListener(iblockdata, new BlockPositionSource(blockposition)); @@ -14,7 +14,7 @@ } @Override -@@ -63,11 +66,13 @@ +@@ -64,11 +67,13 @@ final SculkSpreader sculkSpreader; private final IBlockData blockState; private final PositionSource positionSource; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch index 0a8a93b726..6a15e04531 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch @@ -98,11 +98,11 @@ if (flag2 && flag) { - doBrew(world, blockposition, tileentitybrewingstand.items); + doBrew(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit - setChanged(world, blockposition, iblockdata); } else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) { tileentitybrewingstand.brewTime = 0; -@@ -128,7 +188,11 @@ } +@@ -128,7 +188,11 @@ + setChanged(world, blockposition, iblockdata); } else if (flag && tileentitybrewingstand.fuel > 0) { --tileentitybrewingstand.fuel; - tileentitybrewingstand.brewTime = 400; diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch index e9fade9c85..5fe4b5dc0e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityCampfire.java +++ b/net/minecraft/world/level/block/entity/TileEntityCampfire.java -@@ -31,6 +31,14 @@ +@@ -30,6 +30,14 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.gameevent.GameEvent; @@ -15,7 +15,7 @@ public class TileEntityCampfire extends TileEntity implements Clearable { private static final int BURN_COOL_SPEED = 2; -@@ -65,6 +73,20 @@ +@@ -64,6 +72,20 @@ }).orElse(itemstack); if (itemstack1.isItemEnabled(world.enabledFeatures())) { @@ -36,7 +36,7 @@ InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); tileentitycampfire.items.set(i, ItemStack.EMPTY); world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); -@@ -177,7 +199,11 @@ +@@ -176,7 +198,11 @@ ItemStack itemstack1 = (ItemStack) this.items.get(j); if (itemstack1.isEmpty()) { @@ -47,5 +47,5 @@ + this.cookingTime[j] = event.getTotalCookTime(); // i -> event.getTotalCookTime() + // CraftBukkit end this.cookingProgress[j] = 0; - this.items.set(j, itemstack.split(1)); - this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entity, this.getBlockState())); + this.items.set(j, itemstack.consumeAndReturn(1, entityliving)); + this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState())); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch index dc71c38831..e6456e8fcc 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch @@ -1,72 +1,22 @@ --- a/net/minecraft/world/level/block/entity/TileEntityEndGateway.java +++ b/net/minecraft/world/level/block/entity/TileEntityEndGateway.java -@@ -34,6 +34,15 @@ +@@ -27,6 +27,10 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.dimension.WorldDimension; -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.entity.CraftPlayer; -+import org.bukkit.craftbukkit.util.CraftLocation; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end + public class TileEntityEndGateway extends TileEntityEnderPortal { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -163,7 +172,7 @@ - tileentityendgateway.teleportCooldown = 100; - BlockPosition blockposition1; +@@ -143,7 +147,7 @@ + public Vec3D getPortalPosition(WorldServer worldserver, BlockPosition blockposition) { + BlockPosition blockposition1; -- if (tileentityendgateway.exitPortal == null && world.dimension() == World.END) { -+ if (tileentityendgateway.exitPortal == null && world.getTypeKey() == WorldDimension.END) { // CraftBukkit - work in alternate worlds - blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition); - blockposition1 = blockposition1.above(10); - TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1); -@@ -184,7 +193,7 @@ - - if (entity2 != null) { - entity1 = entity2; -- entity.discard(); -+ entity.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause - } else { - entity1 = entity; - } -@@ -192,8 +201,34 @@ - entity1 = entity.getRootVehicle(); - } - -+ // CraftBukkit start - Fire PlayerTeleportEvent/EntityTeleportEvent -+ if (entity1 instanceof EntityPlayer) { -+ org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity(); -+ org.bukkit.Location location = CraftLocation.toBukkit(blockposition1, world.getWorld()).add(0.5D, 0.5D, 0.5D); -+ location.setPitch(player.getLocation().getPitch()); -+ location.setYaw(player.getLocation().getYaw()); -+ -+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.END_GATEWAY); -+ Bukkit.getPluginManager().callEvent(teleEvent); -+ if (teleEvent.isCancelled()) { -+ return; -+ } -+ -+ entity1.setPortalCooldown(); -+ ((EntityPlayer) entity1).connection.teleport(teleEvent.getTo()); -+ triggerCooldown(world, blockposition, iblockdata, tileentityendgateway); // CraftBukkit - call at end of method -+ return; -+ -+ } -+ -+ org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); -+ if (teleEvent.isCancelled()) { -+ return; -+ } -+ - entity1.setPortalCooldown(); -- entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); -+ entity1.teleportToWithTicket(teleEvent.getTo().getX(), teleEvent.getTo().getY(), teleEvent.getTo().getZ()); -+ // CraftBukkit end - } - - triggerCooldown(world, blockposition, iblockdata, tileentityendgateway); +- if (this.exitPortal == null && worldserver.dimension() == World.END) { ++ if (this.exitPortal == null && worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit - work in alternate worlds + blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition); + blockposition1 = blockposition1.above(10); + TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1); diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch index 8a5ff56834..fd6b054cb4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -72,16 +72,16 @@ private static boolean isNeverAFurnaceFuel(Item item) { return item.builtInRegistryHolder().is(TagsItem.NON_FLAMMABLE_WOOD); } -@@ -285,7 +334,7 @@ +@@ -286,7 +335,7 @@ RecipeHolder recipeholder; if (flag2) { -- recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(tileentityfurnace, world).orElse((Object) null); -+ recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(tileentityfurnace, world).orElse(null); // CraftBukkit - decompile error +- recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(new SingleRecipeInput(itemstack1), world).orElse((Object) null); ++ recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(new SingleRecipeInput(itemstack1), world).orElse(null); // CraftBukkit - decompile error } else { recipeholder = null; } -@@ -293,9 +342,20 @@ +@@ -294,9 +343,20 @@ int i = tileentityfurnace.getMaxStackSize(); if (!tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) { @@ -104,7 +104,7 @@ flag1 = true; if (flag3) { Item item = itemstack.getItem(); -@@ -311,11 +371,23 @@ +@@ -312,11 +372,23 @@ } if (tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) { @@ -129,7 +129,7 @@ tileentityfurnace.setRecipeUsed(recipeholder); } -@@ -354,17 +426,44 @@ +@@ -355,17 +427,44 @@ } } @@ -175,15 +175,15 @@ if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).is(Items.BUCKET)) { nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET)); -@@ -388,6 +487,7 @@ +@@ -389,6 +488,7 @@ } private static int getTotalCookTime(World world, TileEntityFurnace tileentityfurnace) { + if (world == null) return 200; // CraftBukkit - SPIGOT-4302 - return (Integer) tileentityfurnace.quickCheck.getRecipeFor(tileentityfurnace, world).map((recipeholder) -> { - return ((RecipeCooking) recipeholder.value()).getCookingTime(); - }).orElse(200); -@@ -474,8 +574,8 @@ + SingleRecipeInput singlerecipeinput = new SingleRecipeInput(tileentityfurnace.getItem(0)); + + return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, world).map((recipeholder) -> { +@@ -477,8 +577,8 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman, List list) {} @@ -194,7 +194,7 @@ entityplayer.awardRecipes(list); Iterator iterator = list.iterator(); -@@ -492,6 +592,12 @@ +@@ -495,6 +595,12 @@ } public List> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) { @@ -207,7 +207,7 @@ List> list = Lists.newArrayList(); ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator(); -@@ -500,14 +606,14 @@ +@@ -503,14 +609,14 @@ worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((recipeholder) -> { list.add(recipeholder); @@ -224,7 +224,7 @@ int j = MathHelper.floor((float) i * f); float f1 = MathHelper.frac((float) i * f); -@@ -515,6 +621,17 @@ +@@ -518,6 +624,17 @@ ++j; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch index b9973d9112..b3d264bf5a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java -@@ -24,6 +24,14 @@ +@@ -20,12 +20,56 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.ticks.ContainerSingleItem; @@ -14,11 +14,10 @@ + public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem.a { - private static final int SONG_END_PADDING = 20; -@@ -32,6 +40,42 @@ - public long tickCount; - public long recordStartedTick; - public boolean isPlaying; + 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; + private final JukeboxSongPlayer jukeboxSongPlayer; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; @@ -58,7 +57,7 @@ public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.JUKEBOX, blockposition, iblockdata); -@@ -154,7 +198,7 @@ +@@ -134,7 +178,7 @@ @Override public int getMaxStackSize() { @@ -67,10 +66,18 @@ } @Override -@@ -206,7 +250,11 @@ +@@ -153,12 +197,17 @@ + } + @VisibleForTesting - public void setRecordWithoutPlaying(ItemStack itemstack) { +- public void setSongItemWithoutPlaying(ItemStack itemstack) { ++ public void setSongItemWithoutPlaying(ItemStack itemstack, long ticksSinceSongStarted) { // CraftBukkit - add argument this.item = itemstack; ++ this.jukeboxSongPlayer.song = null; // CraftBukkit - reset + JukeboxSong.fromStack(this.level.registryAccess(), itemstack).ifPresent((holder) -> { +- this.jukeboxSongPlayer.setSongWithoutPlaying(holder, 0L); ++ this.jukeboxSongPlayer.setSongWithoutPlaying(holder, ticksSinceSongStarted); // CraftBukkit - add argument + }); - this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); + // CraftBukkit start - add null check for level + if (level != null) { @@ -79,4 +86,4 @@ + // CraftBukkit end this.setChanged(); } - } + diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch index fba8790203..518244325e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java -@@ -179,13 +179,13 @@ +@@ -206,7 +206,7 @@ } public void resetAfterBecomingOminous(TrialSpawner trialspawner, WorldServer worldserver) { @@ -9,8 +9,10 @@ Objects.requireNonNull(worldserver); stream.map(worldserver::getEntity).forEach((entity) -> { - if (entity != null) { - worldserver.levelEvent(3012, entity.blockPosition(), TrialSpawner.a.NORMAL.encode()); +@@ -218,7 +218,7 @@ + entityinsentient.dropPreservedEquipment(); + } + - entity.remove(Entity.RemovalReason.DISCARDED); + entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - Add bukkit remove cause; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch b/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch index f0e7da3a91..324b31ff47 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/state/BlockBase.java +++ b/net/minecraft/world/level/block/state/BlockBase.java -@@ -174,8 +174,10 @@ +@@ -173,8 +173,10 @@ TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition) : null; LootParams.a lootparams_a = (new LootParams.a(worldserver)).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, explosion.getDirectSourceEntity()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch b/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch index 30e7fd67a6..e3d8ca0c46 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/border/WorldBorder.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -29,6 +29,7 @@ +@@ -30,6 +30,7 @@ int absoluteMaxSize = 29999984; private WorldBorder.a extent = new WorldBorder.d(5.9999968E7D); public static final WorldBorder.c DEFAULT_SETTINGS = new WorldBorder.c(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 5.9999968E7D, 0L, 0.0D); @@ -8,7 +8,7 @@ public WorldBorder() {} -@@ -164,6 +165,7 @@ +@@ -181,6 +182,7 @@ } public void addListener(IWorldBorderListener iworldborderlistener) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch index 7f74b40da0..9793fde0c3 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/Chunk.patch @@ -82,21 +82,15 @@ if (tileentity == null) { NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition); -@@ -418,6 +440,13 @@ - tileentity1.setRemoved(); - } +@@ -412,6 +434,7 @@ -+ // CraftBukkit start -+ } else { -+ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.getBlockPos().getX() + "," + tileentity.getBlockPos().getY() + "," + tileentity.getBlockPos().getZ() -+ + " (" + getBlockState(blockposition) + ") where there was no entity tile!"); -+ System.out.println("Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16)); -+ new Exception().printStackTrace(); -+ // CraftBukkit end - } - } + if (!iblockdata.hasBlockEntity()) { + Chunk.LOGGER.warn("Trying to set block entity {} at position {}, but state {} does not allow it", new Object[]{tileentity, blockposition, iblockdata}); ++ new Exception().printStackTrace(); // CraftBukkit + } else { + IBlockData iblockdata1 = tileentity.getBlockState(); -@@ -447,6 +476,12 @@ +@@ -465,6 +488,12 @@ if (this.isInLevel()) { TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition); @@ -109,7 +103,7 @@ if (tileentity != null) { World world = this.level; -@@ -500,6 +535,57 @@ +@@ -518,6 +547,57 @@ } @@ -167,7 +161,7 @@ public boolean isEmpty() { return false; } -@@ -695,7 +781,7 @@ +@@ -713,7 +793,7 @@ private void updateBlockEntityTicker(T t0) { IBlockData iblockdata = t0.getBlockState(); @@ -176,7 +170,7 @@ if (blockentityticker == null) { this.removeBlockEntityTicker(t0.getBlockPos()); -@@ -780,7 +866,7 @@ +@@ -798,7 +878,7 @@ private boolean loggedInvalidBlockState; a(final TileEntity tileentity, final BlockEntityTicker blockentityticker) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch index f4e11018ae..80b8ff67ee 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/ChunkGenerator.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -312,7 +312,7 @@ +@@ -311,7 +311,7 @@ } } @@ -9,7 +9,7 @@ ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) { -@@ -334,7 +334,7 @@ +@@ -333,7 +333,7 @@ for (int k = 0; k < j; ++k) { ChunkSection chunksection = achunksection[k]; @@ -18,7 +18,7 @@ Objects.requireNonNull(set); palettedcontainerro.getAll(set::add); -@@ -445,6 +445,33 @@ +@@ -444,6 +444,33 @@ } } @@ -52,7 +52,7 @@ private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) { ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); int i = chunkcoordintpair.getMinBlockX(); -@@ -582,6 +609,14 @@ +@@ -581,6 +608,14 @@ StructureStart structurestart = structure.generate(iregistrycustom, this, this.biomeSource, randomstate, structuretemplatemanager, i, chunkcoordintpair, j, ichunkaccess, predicate); if (structurestart.isValid()) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch index 489886dea0..715e6fbb9e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch @@ -24,7 +24,7 @@ private static void replaceMissingSections(IRegistry iregistry, ChunkSection[] achunksection) { for (int i = 0; i < achunksection.length; ++i) { -@@ -266,10 +275,11 @@ +@@ -270,10 +279,11 @@ public void setUnsaved(boolean flag) { this.unsaved = flag; @@ -36,8 +36,8 @@ + return this.unsaved || this.persistentDataContainer.dirty(); // CraftBukkit - SPIGOT-6814: chunk is unsaved if pdc was mutated } - public abstract ChunkStatus getStatus(); -@@ -445,6 +455,27 @@ + public abstract ChunkStatus getPersistedStatus(); +@@ -449,6 +459,27 @@ } } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch index e86d6a481a..e8d99c2b75 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -@@ -33,7 +33,7 @@ - static CompletableFuture generateStructureStarts(WorldGenContext worldgencontext, ChunkStatus chunkstatus, Executor executor, ToFullChunk tofullchunk, List list, IChunkAccess ichunkaccess) { +@@ -38,7 +38,7 @@ + static CompletableFuture generateStructureStarts(WorldGenContext worldgencontext, ChunkStep chunkstep, StaticCache2D staticcache2d, IChunkAccess ichunkaccess) { WorldServer worldserver = worldgencontext.level(); - if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) { @@ -9,3 +9,26 @@ worldgencontext.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, worldgencontext.structureManager()); } +@@ -177,7 +177,21 @@ + + private static void postLoadProtoChunk(WorldServer worldserver, List list) { + if (!list.isEmpty()) { +- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver)); ++ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities ++ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver).filter((entity) -> { ++ boolean needsRemoval = false; ++ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer(); ++ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.NPC) { ++ entity.discard(null); // CraftBukkit - add Bukkit remove cause ++ needsRemoval = true; ++ } ++ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { ++ entity.discard(null); // CraftBukkit - add Bukkit remove cause ++ needsRemoval = true; ++ } ++ return !needsRemoval; ++ })); ++ // CraftBukkit end + } + + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch index c043f5abf7..f8b2d18345 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java +++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java -@@ -104,7 +104,7 @@ +@@ -105,7 +105,7 @@ ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); LevelLightEngine levellightengine = chunkproviderserver.getLightEngine(); IRegistry iregistry = worldserver.registryAccess().registryOrThrow(Registries.BIOME); @@ -9,7 +9,7 @@ boolean flag2 = false; for (int j = 0; j < nbttaglist.size(); ++j) { -@@ -123,17 +123,17 @@ +@@ -124,17 +124,17 @@ datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES); } @@ -30,7 +30,7 @@ achunksection[k] = chunksection; SectionPosition sectionposition = SectionPosition.of(chunkcoordintpair, b0); -@@ -170,7 +170,7 @@ +@@ -171,7 +171,7 @@ dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data"))); logger = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger); @@ -39,7 +39,7 @@ } else { blendingdata = null; } -@@ -201,7 +201,7 @@ +@@ -202,7 +202,7 @@ dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen"))); logger = ChunkRegionLoader.LOGGER; Objects.requireNonNull(logger); @@ -48,7 +48,7 @@ Objects.requireNonNull(protochunk); optional.ifPresent(protochunk::setBelowZeroRetrogen); -@@ -215,6 +215,13 @@ +@@ -216,6 +216,13 @@ } } @@ -62,7 +62,7 @@ ((IChunkAccess) object1).setLightCorrect(flag); NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps"); EnumSet enumset = EnumSet.noneOf(HeightMap.Type.class); -@@ -294,6 +301,12 @@ +@@ -295,6 +302,12 @@ return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); } @@ -75,16 +75,16 @@ public static NBTTagCompound write(WorldServer worldserver, IChunkAccess ichunkaccess) { ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); NBTTagCompound nbttagcompound = GameProfileSerializer.addCurrentDataVersion(new NBTTagCompound()); -@@ -305,7 +318,7 @@ +@@ -306,7 +319,7 @@ nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime()); - nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(ichunkaccess.getStatus()).toString()); + nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(ichunkaccess.getPersistedStatus()).toString()); BlendingData blendingdata = ichunkaccess.getBlendingData(); - DataResult dataresult; + DataResult dataresult; // CraftBukkit - decompile error Logger logger; if (blendingdata != null) { -@@ -429,6 +442,11 @@ +@@ -430,6 +443,11 @@ nbttagcompound.put("Heightmaps", nbttagcompound3); nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences())); @@ -96,7 +96,7 @@ return nbttagcompound; } -@@ -533,6 +551,12 @@ +@@ -534,6 +552,12 @@ StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i); if (structurestart != null) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch index f2645f2d9e..38001e3b97 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch @@ -16,7 +16,7 @@ public class IChunkLoader implements AutoCloseable { public static final int LAST_MONOLYTH_STRUCTURE_DATA_VERSION = 1493; -@@ -39,10 +48,54 @@ +@@ -39,13 +48,57 @@ return this.worker.isOldChunkAround(chunkcoordintpair, i); } @@ -56,23 +56,26 @@ + // CraftBukkit end int i = getVersion(nbttagcompound); - try { -+ // CraftBukkit start -+ if (i < 1466) { -+ NBTTagCompound level = nbttagcompound.getCompound("Level"); -+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { -+ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkSource(); -+ if (check(cps, pos.x - 1, pos.z) && check(cps, pos.x - 1, pos.z - 1) && check(cps, pos.x, pos.z - 1)) { -+ level.putBoolean("LightPopulated", true); + if (i == SharedConstants.getCurrentVersion().getDataVersion().getVersion()) { + return nbttagcompound; + } else { + try { ++ // CraftBukkit start ++ if (i < 1466) { ++ NBTTagCompound level = nbttagcompound.getCompound("Level"); ++ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { ++ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkSource(); ++ if (check(cps, pos.x - 1, pos.z) && check(cps, pos.x - 1, pos.z - 1) && check(cps, pos.x, pos.z - 1)) { ++ level.putBoolean("LightPopulated", true); ++ } + } + } -+ } -+ // CraftBukkit end ++ // CraftBukkit end + - if (i < 1493) { - nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493); - if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { -@@ -69,7 +122,7 @@ + if (i < 1493) { + nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493); + if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { +@@ -70,7 +123,7 @@ } } @@ -81,7 +84,7 @@ PersistentStructureLegacy persistentstructurelegacy = this.legacyStructureHandler; if (persistentstructurelegacy == null) { -@@ -84,7 +137,7 @@ +@@ -85,7 +138,7 @@ return persistentstructurelegacy; } diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch index 6434e53e09..73fd98881d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/ChunkProviderFlat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/ChunkProviderFlat.java +++ b/net/minecraft/world/level/levelgen/ChunkProviderFlat.java -@@ -35,10 +35,16 @@ +@@ -34,10 +34,16 @@ private final GeneratorSettingsFlat settings; public ChunkProviderFlat(GeneratorSettingsFlat generatorsettingsflat) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch new file mode 100644 index 0000000000..a62c0d3712 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java ++++ b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java +@@ -8,6 +8,12 @@ + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.levelgen.feature.configurations.WorldGenFeatureEmptyConfiguration; + ++// CraftBukkit start ++import java.util.List; ++import org.bukkit.block.BlockState; ++import org.bukkit.event.world.PortalCreateEvent; ++// CraftBukkit end ++ + public class EndPlatformFeature extends WorldGenerator { + + public EndPlatformFeature(Codec codec) { +@@ -21,6 +27,13 @@ + } + + public static void createEndPlatform(WorldAccess worldaccess, BlockPosition blockposition, boolean flag) { ++ createEndPlatform(worldaccess, blockposition, flag, null); ++ // CraftBukkit start ++ } ++ ++ public static void createEndPlatform(WorldAccess worldaccess, BlockPosition blockposition, boolean flag, Entity entity) { ++ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldaccess); ++ // CraftBukkit end + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); + + for (int i = -2; i <= 2; ++i) { +@@ -29,16 +42,27 @@ + BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i); + Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR; + +- if (!worldaccess.getBlockState(blockposition_mutableblockposition1).is(block)) { ++ // CraftBukkit start ++ if (!blockList.getBlockState(blockposition_mutableblockposition1).is(block)) { + if (flag) { +- worldaccess.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null); ++ blockList.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null); + } + +- worldaccess.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3); ++ blockList.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3); ++ // CraftBukkit end + } + } + } + } ++ // CraftBukkit start ++ org.bukkit.World bworld = worldaccess.getLevel().getWorld(); ++ PortalCreateEvent portalEvent = new PortalCreateEvent((List) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); ++ ++ worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent); ++ if (!portalEvent.isCancelled()) { ++ blockList.updateList(); ++ } ++ // CraftBukkit end + + } + } diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch index 184c09f4fd..d4be33f99e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch @@ -9,25 +9,7 @@ protected StructurePiece(WorldGenFeatureStructurePieceType worldgenfeaturestructurepiecetype, int i, StructureBoundingBox structureboundingbox) { this.type = worldgenfeaturestructurepiecetype; -@@ -60,14 +60,11 @@ - } - - public StructurePiece(WorldGenFeatureStructurePieceType worldgenfeaturestructurepiecetype, NBTTagCompound nbttagcompound) { -- int i = nbttagcompound.getInt("GD"); -- DataResult dataresult = StructureBoundingBox.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("BB")); -- Logger logger = StructurePiece.LOGGER; -- -- Objects.requireNonNull(logger); -- this(worldgenfeaturestructurepiecetype, i, (StructureBoundingBox) dataresult.resultOrPartial(logger::error).orElseThrow(() -> { -+ // CraftBukkit start - decompile error -+ this(worldgenfeaturestructurepiecetype, nbttagcompound.getInt("GD"), (StructureBoundingBox) StructureBoundingBox.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("BB")).resultOrPartial(Objects.requireNonNull(StructurePiece.LOGGER)::error).orElseThrow(() -> { - return new IllegalArgumentException("Invalid boundingbox"); - })); -+ // CraftBukkit end - int j = nbttagcompound.getInt("O"); - - this.setOrientation(j == -1 ? null : EnumDirection.from2DDataValue(j)); -@@ -85,13 +82,11 @@ +@@ -80,13 +80,11 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.putString("id", BuiltInRegistries.STRUCTURE_PIECE.getKey(this.getType()).toString()); @@ -45,7 +27,7 @@ EnumDirection enumdirection = this.getOrientation(); nbttagcompound.putInt("O", enumdirection == null ? -1 : enumdirection.get2DDataValue()); -@@ -191,6 +186,11 @@ +@@ -186,6 +184,11 @@ } generatoraccessseed.setBlock(blockposition_mutableblockposition, iblockdata, 2); @@ -57,7 +39,7 @@ Fluid fluid = generatoraccessseed.getFluidState(blockposition_mutableblockposition); if (!fluid.isEmpty()) { -@@ -205,6 +205,38 @@ +@@ -200,6 +203,38 @@ } } @@ -96,7 +78,7 @@ protected boolean canBeReplaced(IWorldReader iworldreader, int i, int j, int k, StructureBoundingBox structureboundingbox) { return true; } -@@ -398,12 +430,20 @@ +@@ -393,12 +428,20 @@ iblockdata = reorient(worldaccess, blockposition, Blocks.CHEST.defaultBlockState()); } @@ -117,7 +99,7 @@ return true; } else { -@@ -415,12 +455,31 @@ +@@ -410,12 +453,31 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = this.getWorldPos(i, j, k); if (structureboundingbox.isInside(blockposition_mutableblockposition) && !generatoraccessseed.getBlockState(blockposition_mutableblockposition).is(Blocks.DISPENSER)) { @@ -149,7 +131,7 @@ return true; } else { -@@ -433,7 +492,7 @@ +@@ -428,7 +490,7 @@ } public static StructureBoundingBox createBoundingBox(Stream stream) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.patch index 5d607215b4..85ee41d10a 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java -@@ -85,11 +85,16 @@ +@@ -86,11 +86,16 @@ protected void handleDataMarker(String s, BlockPosition blockposition, WorldAccess worldaccess, RandomSource randomsource, StructureBoundingBox structureboundingbox) { if ("chest".equals(s)) { worldaccess.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3); diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch index e9a703f1e4..08f32d6b1c 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java @@ -22,7 +22,7 @@ - private boolean keepLiquids; + private LiquidSettings liquidSettings; @Nullable private RandomSource random; - private int palette; diff --git a/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch b/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch index a45205cfec..9fd436b40f 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/BlockPortalShape.java +++ b/net/minecraft/world/level/portal/BlockPortalShape.java -@@ -22,6 +22,11 @@ +@@ -21,6 +21,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,7 +12,7 @@ public class BlockPortalShape { private static final int MIN_WIDTH = 2; -@@ -41,6 +46,7 @@ +@@ -40,6 +45,7 @@ private BlockPosition bottomLeft; private int height; private final int width; @@ -20,7 +20,7 @@ public static Optional findEmptyPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { return findPortalShape(generatoraccess, blockposition, (blockportalshape) -> { -@@ -61,6 +67,7 @@ +@@ -60,6 +66,7 @@ } public BlockPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { @@ -28,7 +28,7 @@ this.level = generatoraccess; this.axis = enumdirection_enumaxis; this.rightDir = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? EnumDirection.WEST : EnumDirection.SOUTH; -@@ -105,6 +112,7 @@ +@@ -104,6 +111,7 @@ if (!isEmpty(iblockdata)) { if (BlockPortalShape.FRAME.test(iblockdata, this.level, blockposition_mutableblockposition)) { @@ -36,7 +36,7 @@ return i; } break; -@@ -115,6 +123,7 @@ +@@ -114,6 +122,7 @@ if (!BlockPortalShape.FRAME.test(iblockdata1, this.level, blockposition_mutableblockposition)) { break; } @@ -44,7 +44,7 @@ } return 0; -@@ -134,6 +143,7 @@ +@@ -133,6 +142,7 @@ if (!BlockPortalShape.FRAME.test(this.level.getBlockState(blockposition_mutableblockposition1), this.level, blockposition_mutableblockposition1)) { return false; } @@ -52,7 +52,7 @@ } return true; -@@ -163,6 +173,10 @@ +@@ -162,6 +172,10 @@ ++this.numPortalBlocks; } } @@ -63,7 +63,7 @@ } return 21; -@@ -176,12 +190,28 @@ +@@ -175,12 +189,28 @@ return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -93,21 +93,3 @@ } public boolean isComplete() { -@@ -217,7 +247,7 @@ - return new Vec3D(d3, d2, d4); - } - -- public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, Entity entity, Vec3D vec3d1, float f, float f1) { -+ public static ShapeDetectorShape createPortalInfo(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, Entity entity, Vec3D vec3d1, float f, float f1, CraftPortalEvent portalEventInfo) { // CraftBukkit - BlockPosition blockposition = blockutil_rectangle.minCorner; - IBlockData iblockdata = worldserver.getBlockState(blockposition); - EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.getOptionalValue(BlockProperties.HORIZONTAL_AXIS).orElse(EnumDirection.EnumAxis.X); -@@ -233,7 +263,7 @@ - Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); - Vec3D vec3d4 = findCollisionFreePosition(vec3d3, worldserver, entity, entitysize); - -- return new ShapeDetectorShape(vec3d4, vec3d2, f + (float) i, f1); -+ return new ShapeDetectorShape(vec3d4, vec3d2, f + (float) i, f1, worldserver, portalEventInfo); // CraftBukkit - } - - private static Vec3D findCollisionFreePosition(Vec3D vec3d, WorldServer worldserver, Entity entity, EntitySize entitysize) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/portal/DimensionTransition.patch b/paper-server/nms-patches/net/minecraft/world/level/portal/DimensionTransition.patch new file mode 100644 index 0000000000..2b377bae08 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/level/portal/DimensionTransition.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/world/level/portal/DimensionTransition.java ++++ b/net/minecraft/world/level/portal/DimensionTransition.java +@@ -7,7 +7,19 @@ + import net.minecraft.world.entity.Entity; + import net.minecraft.world.phys.Vec3D; + +-public record DimensionTransition(WorldServer newLevel, Vec3D pos, Vec3D speed, float yRot, float xRot, boolean missingRespawnBlock, DimensionTransition.a postDimensionTransition) { ++// CraftBukkit start ++import org.bukkit.event.player.PlayerTeleportEvent; ++ ++public record DimensionTransition(WorldServer newLevel, Vec3D pos, Vec3D speed, float yRot, float xRot, boolean missingRespawnBlock, DimensionTransition.a postDimensionTransition, PlayerTeleportEvent.TeleportCause cause) { ++ ++ public DimensionTransition(WorldServer newLevel, Vec3D pos, Vec3D speed, float yRot, float xRot, boolean missingRespawnBlock, DimensionTransition.a postDimensionTransition) { ++ this(newLevel, pos, speed, yRot, xRot, missingRespawnBlock, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public DimensionTransition(PlayerTeleportEvent.TeleportCause cause) { ++ this(null, Vec3D.ZERO, Vec3D.ZERO, 0.0F, 0.0F, false, DO_NOTHING, cause); ++ } ++ // CraftBukkit end + + public static final DimensionTransition.a DO_NOTHING = (entity) -> { + }; +@@ -15,11 +27,21 @@ + public static final DimensionTransition.a PLACE_PORTAL_TICKET = DimensionTransition::placePortalTicket; + + public DimensionTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, DimensionTransition.a dimensiontransition_a) { +- this(worldserver, vec3d, vec3d1, f, f1, false, dimensiontransition_a); ++ // CraftBukkit start ++ this(worldserver, vec3d, vec3d1, f, f1, dimensiontransition_a, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public DimensionTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, DimensionTransition.a dimensiontransition_a, PlayerTeleportEvent.TeleportCause cause) { ++ this(worldserver, vec3d, vec3d1, f, f1, false, dimensiontransition_a, cause); + } + + public DimensionTransition(WorldServer worldserver, Entity entity, DimensionTransition.a dimensiontransition_a) { +- this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3D.ZERO, 0.0F, 0.0F, false, dimensiontransition_a); ++ this(worldserver, entity, dimensiontransition_a, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public DimensionTransition(WorldServer worldserver, Entity entity, DimensionTransition.a dimensiontransition_a, PlayerTeleportEvent.TeleportCause cause) { ++ this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3D.ZERO, 0.0F, 0.0F, false, dimensiontransition_a, cause); ++ // CraftBukkit end + } + + private static void playPortalSound(Entity entity) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch b/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch index aad3697fda..43293e1343 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch @@ -1,30 +1,32 @@ --- a/net/minecraft/world/level/portal/PortalTravelAgent.java +++ b/net/minecraft/world/level/portal/PortalTravelAgent.java -@@ -42,15 +42,21 @@ +@@ -43,23 +43,35 @@ } - public Optional findPortalAround(BlockPosition blockposition, boolean flag, WorldBorder worldborder) { + public Optional findClosestPortalPosition(BlockPosition blockposition, boolean flag, WorldBorder worldborder) { + // CraftBukkit start -+ return findPortalAround(blockposition, worldborder, flag ? 16 : 128); // Search Radius ++ return findClosestPortalPosition(blockposition, worldborder, flag ? 16 : 128); // Search Radius + } + -+ public Optional findPortalAround(BlockPosition blockposition, WorldBorder worldborder, int i) { ++ public Optional findClosestPortalPosition(BlockPosition blockposition, WorldBorder worldborder, int i) { VillagePlace villageplace = this.level.getPoiManager(); - int i = flag ? 16 : 128; + // int i = flag ? 16 : 128; + // CraftBukkit end villageplace.ensureLoadedAndValid(this.level, blockposition, i); - Optional optional = villageplace.getInSquare((holder) -> { +- Stream stream = villageplace.getInSquare((holder) -> { ++ Stream stream = villageplace.getInSquare((holder) -> { // CraftBukkit - decompile error return holder.is(PoiTypes.NETHER_PORTAL); - }, blockposition, i, VillagePlace.Occupancy.ANY).filter((villageplacerecord) -> { - return worldborder.isWithinBounds(villageplacerecord.getPos()); -- }).sorted(Comparator.comparingDouble((villageplacerecord) -> { -+ }).sorted(Comparator.comparingDouble((VillagePlaceRecord villageplacerecord) -> { // CraftBukkit - decompile error - return villageplacerecord.getPos().distSqr(blockposition); - }).thenComparingInt((villageplacerecord) -> { - return villageplacerecord.getPos().getY(); -@@ -71,6 +77,12 @@ + }, blockposition, i, VillagePlace.Occupancy.ANY).map(VillagePlaceRecord::getPos); + + Objects.requireNonNull(worldborder); + return stream.filter(worldborder::isWithinBounds).filter((blockposition1) -> { + return this.level.getBlockState(blockposition1).hasProperty(BlockProperties.HORIZONTAL_AXIS); +- }).min(Comparator.comparingDouble((blockposition1) -> { ++ }).min(Comparator.comparingDouble((BlockPosition blockposition1) -> { // CraftBukkit - decompile error + return blockposition1.distSqr(blockposition); + }).thenComparingInt(BaseBlockPosition::getY)); } public Optional createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { @@ -37,16 +39,16 @@ EnumDirection enumdirection = EnumDirection.get(EnumDirection.EnumAxisDirection.POSITIVE, enumdirection_enumaxis); double d0 = -1.0D; BlockPosition blockposition1 = null; -@@ -79,7 +91,7 @@ - WorldBorder worldborder = this.level.getWorldBorder(); +@@ -69,7 +81,7 @@ int i = Math.min(this.level.getMaxBuildHeight(), this.level.getMinBuildHeight() + this.level.getLogicalHeight()) - 1; + boolean flag = true; BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); - Iterator iterator = BlockPosition.spiralAround(blockposition, 16, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); + Iterator iterator = BlockPosition.spiralAround(blockposition, createRadius, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); // CraftBukkit int j; int k; -@@ -134,6 +146,7 @@ +@@ -122,6 +134,7 @@ int j1; int k1; @@ -54,16 +56,16 @@ if (d0 == -1.0D) { j1 = Math.max(this.level.getMinBuildHeight() - -1, 70); k1 = i - 9; -@@ -154,7 +167,7 @@ - IBlockData iblockdata = l < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); +@@ -139,7 +152,7 @@ + IBlockData iblockdata = i1 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); - blockposition_mutableblockposition.setWithOffset(blockposition1, k * enumdirection.getStepX() + l1 * enumdirection1.getStepX(), l, k * enumdirection.getStepZ() + l1 * enumdirection1.getStepZ()); + blockposition_mutableblockposition.setWithOffset(blockposition1, l * enumdirection.getStepX() + k * enumdirection1.getStepX(), i1, l * enumdirection.getStepZ() + k * enumdirection1.getStepZ()); - this.level.setBlockAndUpdate(blockposition_mutableblockposition, iblockdata); + blockList.setBlock(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit } } } -@@ -164,7 +177,7 @@ +@@ -149,7 +162,7 @@ for (k1 = -1; k1 < 4; ++k1) { if (j1 == -1 || j1 == 2 || k1 == -1 || k1 == 3) { blockposition_mutableblockposition.setWithOffset(blockposition1, j1 * enumdirection.getStepX(), k1, j1 * enumdirection.getStepZ()); @@ -72,7 +74,7 @@ } } } -@@ -174,10 +187,20 @@ +@@ -159,10 +172,20 @@ for (k1 = 0; k1 < 2; ++k1) { for (j = 0; j < 3; ++j) { blockposition_mutableblockposition.setWithOffset(blockposition1, k1 * enumdirection.getStepX(), j, k1 * enumdirection.getStepZ()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch b/paper-server/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch deleted file mode 100644 index 55ca342786..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/portal/ShapeDetectorShape.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/world/level/portal/ShapeDetectorShape.java -+++ b/net/minecraft/world/level/portal/ShapeDetectorShape.java -@@ -2,14 +2,25 @@ - - import net.minecraft.world.phys.Vec3D; - -+// CraftBukkit start -+import net.minecraft.server.level.WorldServer; -+import org.bukkit.craftbukkit.event.CraftPortalEvent; -+// CraftBukkit end -+ - public class ShapeDetectorShape { - - public final Vec3D pos; - public final Vec3D speed; - public final float yRot; - public final float xRot; -+ // CraftBukkit start -+ public final WorldServer world; -+ public final CraftPortalEvent portalEventInfo; - -- public ShapeDetectorShape(Vec3D vec3d, Vec3D vec3d1, float f, float f1) { -+ public ShapeDetectorShape(Vec3D vec3d, Vec3D vec3d1, float f, float f1, WorldServer world, CraftPortalEvent portalEventInfo) { -+ this.world = world; -+ this.portalEventInfo = portalEventInfo; -+ // CraftBukkit end - this.pos = vec3d; - this.speed = vec3d1; - this.yRot = f; diff --git a/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch b/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch index f7c4baa633..9aa14f1c1b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch @@ -18,7 +18,7 @@ public class WorldMap extends PersistentBase { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -66,6 +77,13 @@ +@@ -67,6 +78,13 @@ private final Map frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; @@ -32,7 +32,7 @@ public static PersistentBase.a factory() { return new PersistentBase.a<>(() -> { throw new IllegalStateException("Should never create an empty map saved data"); -@@ -81,6 +99,10 @@ +@@ -82,6 +100,10 @@ this.unlimitedTracking = flag1; this.locked = flag2; this.setDirty(); @@ -43,7 +43,7 @@ } public static WorldMap createFresh(double d0, double d1, byte b0, boolean flag, boolean flag1, ResourceKey resourcekey) { -@@ -98,12 +120,30 @@ +@@ -99,12 +121,30 @@ } public static WorldMap load(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { @@ -77,7 +77,7 @@ }); int i = nbttagcompound.getInt("xCenter"); int j = nbttagcompound.getInt("zCenter"); -@@ -128,7 +168,8 @@ +@@ -129,7 +169,8 @@ MapIconBanner mapiconbanner = (MapIconBanner) iterator.next(); worldmap.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner); @@ -87,7 +87,7 @@ } NBTTagList nbttaglist = nbttagcompound.getList("frames", 10); -@@ -147,13 +188,32 @@ +@@ -148,13 +189,32 @@ @Override public NBTTagCompound save(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { @@ -121,7 +121,7 @@ nbttagcompound.putInt("xCenter", this.centerX); nbttagcompound.putInt("zCenter", this.centerZ); nbttagcompound.putByte("scale", this.scale); -@@ -408,7 +468,7 @@ +@@ -409,7 +469,7 @@ if (!this.isTrackedCountOverLimit(256)) { this.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner); @@ -130,7 +130,7 @@ return true; } } -@@ -514,7 +574,7 @@ +@@ -519,7 +579,7 @@ this.player = entityhuman; } @@ -139,7 +139,7 @@ int i = this.minDirtyX; int j = this.minDirtyY; int k = this.maxDirtyX + 1 - this.minDirtyX; -@@ -523,7 +583,7 @@ +@@ -528,7 +588,7 @@ for (int i1 = 0; i1 < k; ++i1) { for (int j1 = 0; j1 < l; ++j1) { @@ -148,7 +148,7 @@ } } -@@ -533,19 +593,29 @@ +@@ -538,19 +598,29 @@ @Nullable Packet nextUpdatePacket(MapId mapid) { WorldMap.b worldmap_b; diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch index 18a93d4ca2..56748563b5 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/storage/loot/LootDataType.java +++ b/net/minecraft/world/level/storage/loot/LootDataType.java -@@ -16,6 +16,11 @@ - import net.minecraft.world.level.storage.loot.predicates.LootItemConditions; +@@ -15,6 +15,11 @@ + import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import org.slf4j.Logger; +// CraftBukkit start @@ -9,10 +9,10 @@ +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +// CraftBukkit end + - public record LootDataType(ResourceKey> registryKey, Codec codec, String directory, LootDataType.a validator) { + public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.a validator) { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -49,6 +54,7 @@ +@@ -48,6 +53,7 @@ private static LootDataType.a createLootTableValidator() { return (lootcollector, resourcekey, loottable) -> { loottable.validate(lootcollector.setParams(loottable.getParamSet()).enterElement("{" + String.valueOf(resourcekey.registry()) + "/" + String.valueOf(resourcekey.location()) + "}", resourcekey)); diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch index 94f9f0da52..3b5177ef01 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch @@ -22,7 +22,7 @@ LootTable(LootContextParameterSet lootcontextparameterset, Optional optional, List list, List list1) { this.paramSet = lootcontextparameterset; -@@ -153,9 +161,22 @@ +@@ -157,9 +165,22 @@ } public void fill(IInventory iinventory, LootParams lootparams, long i) { diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch deleted file mode 100644 index 29bd58bedf..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.java -+++ b/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.java -@@ -57,8 +57,13 @@ - - if (entity instanceof EntityLiving) { - int i = EnchantmentManager.getMobLooting((EntityLiving) entity); -+ // CraftBukkit start - use lootingModifier if set by plugin -+ if (loottableinfo.hasParam(LootContextParameters.LOOTING_MOD)) { -+ i = loottableinfo.getParamOrNull(LootContextParameters.LOOTING_MOD); -+ } -+ // CraftBukkit end - -- if (i == 0) { -+ if (i <= 0) { // CraftBukkit - account for possible negative looting values from Bukkit - return itemstack; - } - diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch deleted file mode 100644 index c0e4302af4..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.java -+++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.java -@@ -21,6 +21,7 @@ - public static final LootContextParameter BLOCK_ENTITY = create("block_entity"); - public static final LootContextParameter TOOL = create("tool"); - public static final LootContextParameter EXPLOSION_RADIUS = create("explosion_radius"); -+ public static final LootContextParameter LOOTING_MOD = new LootContextParameter<>(new MinecraftKey("bukkit:looting_mod")); // CraftBukkit - - public LootContextParameters() {} - diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch deleted file mode 100644 index 48c94f6177..0000000000 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.java -+++ b/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.java -@@ -35,6 +35,11 @@ - if (entity instanceof EntityLiving) { - i = EnchantmentManager.getMobLooting((EntityLiving) entity); - } -+ // CraftBukkit start - only use lootingModifier if set by Bukkit -+ if (loottableinfo.hasParam(LootContextParameters.LOOTING_MOD)) { -+ i = loottableinfo.getParamOrNull(LootContextParameters.LOOTING_MOD); -+ } -+ // CraftBukkit end - - return loottableinfo.getRandom().nextFloat() < this.percent + (float) i * this.lootingMultiplier; - } diff --git a/paper-server/pom.xml b/paper-server/pom.xml index 3651ba848c..d470178509 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.20.6-R0.1-SNAPSHOT + 1.21-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -13,7 +13,7 @@ UTF-8 unknown git - 1_20_R4 + 1_21_R1 21 @@ -78,7 +78,7 @@ com.mojang datafixerupper - 7.0.14 + 8.0.16 compile @@ -232,13 +232,13 @@ org.xerial sqlite-jdbc - 3.45.3.0 + 3.46.0.0 runtime com.mysql mysql-connector-j - 8.3.0 + 8.4.0 runtime diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 9cada3b580..4271f0a9c8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -194,7 +194,7 @@ public class CraftChunk implements Chunk { @Override public boolean isGenerated() { IChunkAccess chunk = getHandle(ChunkStatus.EMPTY); - return chunk.getStatus().isOrAfter(ChunkStatus.FULL); + return chunk.getPersistedStatus().isOrAfter(ChunkStatus.FULL); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java new file mode 100644 index 0000000000..647b8d4afa --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit; + +import com.google.common.base.Preconditions; +import net.minecraft.core.Holder; +import net.minecraft.core.IRegistry; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.contents.TranslatableContents; +import org.bukkit.JukeboxSong; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; +import org.bukkit.craftbukkit.util.Handleable; +import org.jetbrains.annotations.NotNull; + +public class CraftJukeboxSong implements JukeboxSong, Handleable { + + public static JukeboxSong minecraftToBukkit(net.minecraft.world.item.JukeboxSong minecraft) { + return CraftRegistry.minecraftToBukkit(minecraft, Registries.JUKEBOX_SONG, Registry.JUKEBOX_SONG); + } + + public static JukeboxSong minecraftHolderToBukkit(Holder minecraft) { + return minecraftToBukkit(minecraft.value()); + } + + public static net.minecraft.world.item.JukeboxSong bukkitToMinecraft(JukeboxSong bukkit) { + return CraftRegistry.bukkitToMinecraft(bukkit); + } + + public static Holder bukkitToMinecraftHolder(JukeboxSong bukkit) { + Preconditions.checkArgument(bukkit != null); + + IRegistry registry = CraftRegistry.getMinecraftRegistry(Registries.JUKEBOX_SONG); + + if (registry.wrapAsHolder(bukkitToMinecraft(bukkit)) instanceof Holder.c holder) { + return holder; + } + + throw new IllegalArgumentException("No Reference holder found for " + bukkit + + ", this can happen if a plugin creates its own trim pattern without properly registering it."); + } + + private final NamespacedKey key; + private final net.minecraft.world.item.JukeboxSong handle; + + public CraftJukeboxSong(NamespacedKey key, net.minecraft.world.item.JukeboxSong handle) { + this.key = key; + this.handle = handle; + } + + @Override + public net.minecraft.world.item.JukeboxSong getHandle() { + return handle; + } + + @Override + @NotNull + public NamespacedKey getKey() { + return key; + } + + @NotNull + @Override + public String getTranslationKey() { + return ((TranslatableContents) handle.description().getContents()).getKey(); + } +} 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 31cd586b39..74b48a48e4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -123,17 +123,12 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { if (context.getKiller() != null) { EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle(); - setMaybe(builder, LootContextParameters.KILLER_ENTITY, nmsKiller); + setMaybe(builder, LootContextParameters.ATTACKING_ENTITY, nmsKiller); // If there is a player killer, damage source should reflect that in case loot tables use that information setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, handle.damageSources().playerAttack(nmsKiller)); setMaybe(builder, LootContextParameters.LAST_DAMAGE_PLAYER, nmsKiller); // SPIGOT-5603 - Set minecraft:killed_by_player setMaybe(builder, LootContextParameters.TOOL, nmsKiller.getUseItem()); // SPIGOT-6925 - Set minecraft:match_tool } - - // SPIGOT-5603 - Use LootContext#lootingModifier - if (context.getLootingModifier() != LootContext.DEFAULT_LOOT_MODIFIER) { - setMaybe(builder, LootContextParameters.LOOTING_MOD, context.getLootingModifier()); - } } // SPIGOT-5603 - Avoid IllegalArgumentException in LootTableInfo#build() @@ -146,7 +141,6 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { nmsBuilder.optional(param); } } - nmsBuilder.optional(LootContextParameters.LOOTING_MOD); return builder.create(getHandle().getParamSet()); } @@ -165,8 +159,8 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { Location location = CraftLocation.toBukkit(position, info.getLevel().getWorld()); LootContext.Builder contextBuilder = new LootContext.Builder(location); - if (info.hasParam(LootContextParameters.KILLER_ENTITY)) { - CraftEntity killer = info.getParamOrNull(LootContextParameters.KILLER_ENTITY).getBukkitEntity(); + if (info.hasParam(LootContextParameters.ATTACKING_ENTITY)) { + CraftEntity killer = info.getParamOrNull(LootContextParameters.ATTACKING_ENTITY).getBukkitEntity(); if (killer instanceof CraftHumanEntity) { contextBuilder.killer((CraftHumanEntity) killer); } @@ -176,10 +170,6 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { contextBuilder.lootedEntity(info.getParamOrNull(LootContextParameters.THIS_ENTITY).getBukkitEntity()); } - if (info.hasParam(LootContextParameters.LOOTING_MOD)) { - contextBuilder.lootingModifier(info.getParamOrNull(LootContextParameters.LOOTING_MOD)); - } - contextBuilder.luck(info.getLuck()); return contextBuilder.build(); } 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 f91a5ab4f0..5d8e491cfa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -24,6 +24,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured; +import net.minecraft.world.level.portal.DimensionTransition; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.RegionAccessor; @@ -418,7 +419,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { Preconditions.checkArgument(!entity.isInWorld(), "Entity has already been added to a world"); net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle(); if (nmsEntity.level() != getHandle().getLevel()) { - nmsEntity = nmsEntity.changeDimension(getHandle().getLevel()); + nmsEntity = nmsEntity.changeDimension(new DimensionTransition(getHandle().getLevel(), nmsEntity, DimensionTransition.DO_NOTHING)); } addEntityWithPassengers(nmsEntity, CreatureSpawnEvent.SpawnReason.CUSTOM); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java index 01250131a7..0d44f4ce4e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -13,6 +13,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import org.bukkit.GameEvent; +import org.bukkit.JukeboxSong; import org.bukkit.Keyed; import org.bukkit.MusicInstrument; import org.bukkit.NamespacedKey; @@ -146,6 +147,9 @@ public class CraftRegistry implements Registry { if (bukkitClass == DamageType.class) { return new CraftRegistry<>(DamageType.class, registryHolder.registryOrThrow(Registries.DAMAGE_TYPE), CraftDamageType::new, FieldRename.NONE); } + if (bukkitClass == JukeboxSong.class) { + return new CraftRegistry<>(JukeboxSong.class, registryHolder.registryOrThrow(Registries.JUKEBOX_SONG), CraftJukeboxSong::new, FieldRename.NONE); + } if (bukkitClass == Wolf.Variant.class) { return new CraftRegistry<>(Wolf.Variant.class, registryHolder.registryOrThrow(Registries.WOLF_VARIANT), CraftWolf.CraftVariant::new, FieldRename.NONE); } 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 18e347dd5e..820508c0a3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -127,6 +127,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; import org.bukkit.Registry; import org.bukkit.Server; +import org.bukkit.ServerLinks; import org.bukkit.ServerTickManager; import org.bukkit.StructureType; import org.bukkit.UnsafeValues; @@ -296,6 +297,7 @@ public final class CraftServer implements Server { public CraftScoreboardManager scoreboardManager; public CraftDataPackManager dataPackManager; private CraftServerTickManager serverTickManager; + private CraftServerLinks serverLinks; public boolean playerCommandState; private boolean printSaveWarning; private CraftIconCache icon; @@ -325,6 +327,7 @@ public final class CraftServer implements Server { this.structureManager = new CraftStructureManager(console.getStructureManager(), console.registryAccess()); this.dataPackManager = new CraftDataPackManager(this.getServer().getPackRepository()); this.serverTickManager = new CraftServerTickManager(console.tickRateManager()); + this.serverLinks = new CraftServerLinks(console); Bukkit.setServer(this); @@ -706,7 +709,7 @@ public final class CraftServer implements Server { @Override public boolean getAllowNether() { - return this.getServer().isNetherEnabled(); + return this.getProperties().allowNether; } @Override @@ -1203,7 +1206,7 @@ public final class CraftServer implements Server { } else if (name.equals(levelName + "_the_end")) { worldKey = net.minecraft.world.level.World.END; } else { - worldKey = ResourceKey.create(Registries.DIMENSION, new MinecraftKey(name.toLowerCase(Locale.ROOT))); + worldKey = ResourceKey.create(Registries.DIMENSION, MinecraftKey.withDefaultNamespace(name.toLowerCase(Locale.ROOT))); } // If set to not keep spawn in memory (changed from default) then adjust rule accordingly @@ -1452,7 +1455,7 @@ public final class CraftServer implements Server { if (recipe.isPresent()) { RecipeHolder recipeCrafting = recipe.get(); if (craftResult.setRecipeUsed(craftWorld.getHandle(), craftPlayer.getHandle(), recipeCrafting)) { - itemstack = recipeCrafting.value().assemble(inventoryCrafting, craftWorld.getHandle().registryAccess()); + itemstack = recipeCrafting.value().assemble(inventoryCrafting.asCraftInput(), craftWorld.getHandle().registryAccess()); } } @@ -1482,7 +1485,7 @@ public final class CraftServer implements Server { net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.EMPTY; if (recipe.isPresent()) { - itemStack = recipe.get().value().assemble(inventoryCrafting, craftWorld.getHandle().registryAccess()); + itemStack = recipe.get().value().assemble(inventoryCrafting.asCraftInput(), craftWorld.getHandle().registryAccess()); } return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); @@ -1490,7 +1493,7 @@ public final class CraftServer implements Server { private CraftItemCraftResult createItemCraftResult(ItemStack itemStack, InventoryCrafting inventoryCrafting, WorldServer worldServer) { CraftItemCraftResult craftItemResult = new CraftItemCraftResult(itemStack); - NonNullList remainingItems = getServer().getRecipeManager().getRemainingItemsFor(Recipes.CRAFTING, inventoryCrafting, worldServer); + NonNullList remainingItems = getServer().getRecipeManager().getRemainingItemsFor(Recipes.CRAFTING, inventoryCrafting.asCraftInput(), worldServer); // Set the resulting matrix items and overflow items for (int i = 0; i < remainingItems.size(); ++i) { @@ -1530,7 +1533,7 @@ public final class CraftServer implements Server { inventoryCrafting.setItem(i, CraftItemStack.asNMSCopy(craftingMatrix[i])); } - return getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventoryCrafting, world.getHandle()); + return getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventoryCrafting.asCraftInput(), world.getHandle()); } @Override @@ -2133,6 +2136,11 @@ public final class CraftServer implements Server { console.setMotd(motd); } + @Override + public ServerLinks getServerLinks() { + return this.serverLinks; + } + @Override public WarningState getWarningState() { return warningState; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java new file mode 100644 index 0000000000..e245477cf9 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java @@ -0,0 +1,142 @@ +package org.bukkit.craftbukkit; + +import com.google.common.base.Preconditions; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.server.dedicated.DedicatedServer; +import org.bukkit.ServerLinks; +import org.bukkit.craftbukkit.util.CraftChatMessage; + +public class CraftServerLinks implements ServerLinks { + + private final DedicatedServer server; + private net.minecraft.server.ServerLinks serverLinks; + + public CraftServerLinks(DedicatedServer server) { + this(server, null); + } + + public CraftServerLinks(net.minecraft.server.ServerLinks serverLinks) { + this(null, serverLinks); + } + + private CraftServerLinks(DedicatedServer server, net.minecraft.server.ServerLinks serverLinks) { + this.server = server; + this.serverLinks = serverLinks; + } + + @Override + public ServerLink getLink(Type type) { + Preconditions.checkArgument(type != null, "type cannot be null"); + + return getServerLinks().findKnownType(fromBukkit(type)).map(CraftServerLink::new).orElse(null); + } + + @Override + public List getLinks() { + return getServerLinks().entries().stream().map(nms -> (ServerLink) new CraftServerLink(nms)).toList(); + } + + @Override + public ServerLink setLink(Type type, URI url) { + Preconditions.checkArgument(type != null, "type cannot be null"); + Preconditions.checkArgument(url != null, "url cannot be null"); + + ServerLink existing = getLink(type); + if (existing != null) { + removeLink(existing); + } + return addLink(type, url); + } + + @Override + public ServerLink addLink(Type type, URI url) { + Preconditions.checkArgument(type != null, "type cannot be null"); + Preconditions.checkArgument(url != null, "url cannot be null"); + + CraftServerLink link = new CraftServerLink(net.minecraft.server.ServerLinks.Entry.knownType(fromBukkit(type), url)); + addLink(link); + + return link; + } + + @Override + public ServerLink addLink(String displayName, URI url) { + Preconditions.checkArgument(displayName != null, "displayName cannot be null"); + Preconditions.checkArgument(url != null, "url cannot be null"); + + CraftServerLink link = new CraftServerLink(net.minecraft.server.ServerLinks.Entry.custom(CraftChatMessage.fromStringOrNull(displayName), url)); + addLink(link); + + return link; + } + + private void addLink(CraftServerLink link) { + List lst = new ArrayList<>(getServerLinks().entries()); + lst.add(link.handle); + + setLinks(new net.minecraft.server.ServerLinks(lst)); + } + + @Override + public boolean removeLink(ServerLink link) { + Preconditions.checkArgument(link != null, "link cannot be null"); + + List lst = new ArrayList<>(getServerLinks().entries()); + boolean result = lst.remove(((CraftServerLink) link).handle); + + setLinks(new net.minecraft.server.ServerLinks(lst)); + + return result; + } + + @Override + public ServerLinks copy() { + return new CraftServerLinks(getServerLinks()); + } + + public net.minecraft.server.ServerLinks getServerLinks() { + return (server != null) ? server.serverLinks() : serverLinks; + } + + private void setLinks(net.minecraft.server.ServerLinks links) { + if (server != null) { + server.serverLinks = links; + } else { + this.serverLinks = links; + } + } + + private static net.minecraft.server.ServerLinks.KnownLinkType fromBukkit(Type type) { + return net.minecraft.server.ServerLinks.KnownLinkType.values()[type.ordinal()]; + } + + private static ServerLinks.Type fromNMS(net.minecraft.server.ServerLinks.KnownLinkType nms) { + return ServerLinks.Type.values()[nms.ordinal()]; + } + + public static class CraftServerLink implements ServerLink { + + private final net.minecraft.server.ServerLinks.Entry handle; + + public CraftServerLink(net.minecraft.server.ServerLinks.Entry handle) { + this.handle = handle; + } + + @Override + public Type getType() { + return handle.type().left().map(CraftServerLinks::fromNMS).orElse(null); + } + + @Override + public String getDisplayName() { + return CraftChatMessage.fromComponent(handle.displayName()); + } + + @Override + public URI getUrl() { + return handle.link(); + } + } +} 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 c1f07a9314..a1318890cf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -31,8 +31,8 @@ public enum CraftStatistic { LEAVE_GAME(StatisticList.LEAVE_GAME), JUMP(StatisticList.JUMP), DROP_COUNT(StatisticList.DROP), - DROP(new MinecraftKey("dropped")), - PICKUP(new MinecraftKey("picked_up")), + DROP(MinecraftKey.withDefaultNamespace("dropped")), + PICKUP(MinecraftKey.withDefaultNamespace("picked_up")), PLAY_ONE_MINUTE(StatisticList.PLAY_TIME), TOTAL_WORLD_TIME(StatisticList.TOTAL_WORLD_TIME), WALK_ONE_CM(StatisticList.WALK_ONE_CM), @@ -49,12 +49,12 @@ public enum CraftStatistic { SPRINT_ONE_CM(StatisticList.SPRINT_ONE_CM), CROUCH_ONE_CM(StatisticList.CROUCH_ONE_CM), AVIATE_ONE_CM(StatisticList.AVIATE_ONE_CM), - MINE_BLOCK(new MinecraftKey("mined")), - USE_ITEM(new MinecraftKey("used")), - BREAK_ITEM(new MinecraftKey("broken")), - CRAFT_ITEM(new MinecraftKey("crafted")), - KILL_ENTITY(new MinecraftKey("killed")), - ENTITY_KILLED_BY(new MinecraftKey("killed_by")), + MINE_BLOCK(MinecraftKey.withDefaultNamespace("mined")), + USE_ITEM(MinecraftKey.withDefaultNamespace("used")), + BREAK_ITEM(MinecraftKey.withDefaultNamespace("broken")), + CRAFT_ITEM(MinecraftKey.withDefaultNamespace("crafted")), + KILL_ENTITY(MinecraftKey.withDefaultNamespace("killed")), + ENTITY_KILLED_BY(MinecraftKey.withDefaultNamespace("killed_by")), TIME_SINCE_DEATH(StatisticList.TIME_SINCE_DEATH), TALKED_TO_VILLAGER(StatisticList.TALKED_TO_VILLAGER), TRADED_WITH_VILLAGER(StatisticList.TRADED_WITH_VILLAGER), 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 4f3a11b478..eb6369ca72 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1663,7 +1663,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { double y = loc.getY(); double z = loc.getZ(); - PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), SoundCategory.valueOf(category.name()), x, y, z, volume, pitch, seed); + PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(Holder.direct(SoundEffect.createVariableRangeEvent(MinecraftKey.parse(sound))), SoundCategory.valueOf(category.name()), x, y, z, volume, pitch, seed); world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet); } @@ -1702,7 +1702,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { public void playSound(Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; - PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); + PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(Holder.direct(SoundEffect.createVariableRangeEvent(MinecraftKey.parse(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); PlayerChunkMap.EntityTracker entityTracker = getHandle().getChunkSource().chunkMap.entityMap.get(entity.getEntityId()); if (entityTracker != null) { entityTracker.broadcastAndSend(packet); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index 18f3ab1359..26cb1bcb78 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -201,11 +201,11 @@ public class Main { useConsole = false; } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -21); + deadline.add(Calendar.DAY_OF_YEAR, -3); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java index a0d5e86980..82076cb7f9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; import org.bukkit.attribute.AttributeModifier; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.EquipmentSlot; public class CraftAttributeInstance implements AttributeInstance { @@ -67,14 +68,14 @@ public class CraftAttributeInstance implements AttributeInstance { } public static net.minecraft.world.entity.ai.attributes.AttributeModifier convert(AttributeModifier bukkit) { - return new net.minecraft.world.entity.ai.attributes.AttributeModifier(bukkit.getUniqueId(), bukkit.getName(), bukkit.getAmount(), net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation.values()[bukkit.getOperation().ordinal()]); + return new net.minecraft.world.entity.ai.attributes.AttributeModifier(CraftNamespacedKey.toMinecraft(bukkit.getKey()), bukkit.getAmount(), net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation.values()[bukkit.getOperation().ordinal()]); } public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms) { - return new AttributeModifier(nms.id(), nms.name, nms.amount(), AttributeModifier.Operation.values()[nms.operation().ordinal()]); + return new AttributeModifier(CraftNamespacedKey.fromMinecraft(nms.id()), nms.amount(), AttributeModifier.Operation.values()[nms.operation().ordinal()], org.bukkit.inventory.EquipmentSlotGroup.ANY); } public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms, EquipmentSlot slot) { - return new AttributeModifier(nms.id(), nms.name, nms.amount(), AttributeModifier.Operation.values()[nms.operation().ordinal()], slot); + return new AttributeModifier(CraftNamespacedKey.fromMinecraft(nms.id()), nms.amount(), AttributeModifier.Operation.values()[nms.operation().ordinal()], slot.getGroup()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index 841c1f92b9..880e32a8ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -4,12 +4,10 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.BlockJukeBox; import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.entity.TileEntityJukeBox; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Jukebox; -import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.inventory.CraftInventoryJukebox; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemType; @@ -44,18 +42,11 @@ public class CraftJukebox extends CraftBlockEntityState imple boolean result = super.update(force, applyPhysics); if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) { - Material record = this.getPlaying(); getWorldHandle().setBlock(this.getPosition(), data, 3); TileEntity tileEntity = this.getTileEntityFromWorld(); if (tileEntity instanceof TileEntityJukeBox jukebox) { - CraftWorld world = (CraftWorld) this.getWorld(); - if (record.isAir()) { - jukebox.setRecordWithoutPlaying(ItemStack.EMPTY); - world.playEffect(this.getLocation(), Effect.IRON_DOOR_CLOSE, 0); // TODO: Fix this enum constant. This stops jukeboxes - } else { - world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record); - } + jukebox.setTheItem(jukebox.getTheItem()); } } @@ -92,9 +83,7 @@ public class CraftJukebox extends CraftBlockEntityState imple ItemStack nms = CraftItemStack.asNMSCopy(record); TileEntityJukeBox snapshot = this.getSnapshot(); - snapshot.setRecordWithoutPlaying(nms); - snapshot.recordStartedTick = snapshot.tickCount; - snapshot.isPlaying = !nms.isEmpty(); + snapshot.setSongItemWithoutPlaying(nms, snapshot.getSongPlayer().getTicksSinceSongStarted()); this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, !nms.isEmpty()); } @@ -104,7 +93,7 @@ public class CraftJukebox extends CraftBlockEntityState imple requirePlaced(); TileEntity tileEntity = this.getTileEntityFromWorld(); - return tileEntity instanceof TileEntityJukeBox jukebox && jukebox.isRecordPlaying(); + return tileEntity instanceof TileEntityJukeBox jukebox && jukebox.getSongPlayer().isPlaying(); } @Override @@ -121,9 +110,7 @@ public class CraftJukebox extends CraftBlockEntityState imple return false; } - jukebox.isPlaying = true; - jukebox.recordStartedTick = jukebox.tickCount; - getWorld().playEffect(getLocation(), Effect.RECORD_PLAY, CraftItemType.minecraftToBukkit(record.getItem())); + jukebox.tryForcePlaySong(); return true; } @@ -136,8 +123,7 @@ public class CraftJukebox extends CraftBlockEntityState imple return; } - jukebox.isPlaying = false; - getWorld().playEffect(getLocation(), Effect.IRON_DOOR_CLOSE, 0); // TODO: Fix this enum constant. This stops jukeboxes + jukebox.getSongPlayer().stop(tileEntity.getLevel(), tileEntity.getBlockState()); } @Override @@ -149,7 +135,7 @@ public class CraftJukebox extends CraftBlockEntityState imple TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity; boolean result = !jukebox.getTheItem().isEmpty(); - jukebox.popOutRecord(); + jukebox.popOutTheItem(); return result; } 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 d2101c4ff7..0391d8b85c 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 @@ -2,11 +2,10 @@ package org.bukkit.craftbukkit.enchantments; import com.google.common.base.Preconditions; import java.util.Locale; +import net.minecraft.SystemUtils; import net.minecraft.core.Holder; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; -import net.minecraft.world.item.enchantment.EnchantmentBinding; -import net.minecraft.world.item.enchantment.EnchantmentVanishing; +import net.minecraft.tags.EnchantmentTags; import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.craftbukkit.CraftRegistry; @@ -33,6 +32,10 @@ public class CraftEnchantment extends Enchantment implements Handleable bukkitToMinecraftHolder(Enchantment bukkit) { + return CraftRegistry.bukkitToMinecraftHolder(bukkit, Registries.ENCHANTMENT); + } + public static String bukkitToString(Enchantment bukkit) { Preconditions.checkArgument(bukkit != null); @@ -53,18 +56,18 @@ public class CraftEnchantment extends Enchantment implements Handleable handle; private final int id; public CraftEnchantment(NamespacedKey key, net.minecraft.world.item.enchantment.Enchantment handle) { this.key = key; - this.handle = handle; - this.id = BuiltInRegistries.ENCHANTMENT.getId(handle); + this.handle = CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT).wrapAsHolder(handle); + this.id = CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT).getId(handle); } @Override public net.minecraft.world.item.enchantment.Enchantment getHandle() { - return handle; + return handle.value(); } @Override @@ -74,12 +77,12 @@ public class CraftEnchantment extends Enchantment implements Handleable= 0, "Knockback value (%s) cannot be negative", knockbackStrength); - getHandle().setKnockback(knockbackStrength); } @Override public int getKnockbackStrength() { - return getHandle().knockback; + return 0; } @Override @@ -117,7 +115,6 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr @Override public void setShotFromCrossbow(boolean shotFromCrossbow) { - getHandle().setShotFromCrossbow(shotFromCrossbow); } @Override @@ -132,6 +129,18 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr getHandle().pickupItemStack = CraftItemStack.asNMSCopy(item); } + @Override + public ItemStack getWeapon() { + return CraftItemStack.asBukkitCopy(getHandle().getWeaponItem()); + } + + @Override + public void setWeapon(ItemStack item) { + Preconditions.checkArgument(item != null, "ItemStack cannot be null"); + + getHandle().firedFromWeapon = CraftItemStack.asNMSCopy(item); + } + @Override public EntityArrow getHandle() { return (EntityArrow) 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 5e6bbeeea0..59df9031e8 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 @@ -11,7 +11,7 @@ public abstract class CraftAbstractWindCharge extends CraftFireball implements A @Override public void explode() { - this.getHandle().explode(); + this.getHandle().explode(this.getHandle().position()); this.getHandle().discard(EntityRemoveEvent.Cause.EXPLODE); // SPIGOT-7577 - explode doesn't discard the entity, this happens only in tick and onHitBlock } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java new file mode 100644 index 0000000000..d26d4a5027 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java @@ -0,0 +1,20 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.world.entity.decoration.BlockAttachedEntity; +import org.bukkit.craftbukkit.CraftServer; + +public class CraftBlockAttachedEntity extends CraftEntity { + public CraftBlockAttachedEntity(CraftServer server, BlockAttachedEntity entity) { + super(server, entity); + } + + @Override + public BlockAttachedEntity getHandle() { + return (BlockAttachedEntity) entity; + } + + @Override + public String toString() { + return "CraftBlockAttachedEntity"; + } +} 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 f5b6b5cd24..0d56f8658b 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 @@ -21,7 +21,9 @@ import net.minecraft.world.entity.boss.EntityComplexPart; import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.entity.projectile.EntityArrow; +import net.minecraft.world.level.portal.DimensionTransition; import net.minecraft.world.phys.AxisAlignedBB; +import net.minecraft.world.phys.Vec3D; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Server; @@ -202,7 +204,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (location.getWorld() != null && !location.getWorld().equals(getWorld())) { // Prevent teleportation to an other world during world generation Preconditions.checkState(!entity.generation, "Cannot teleport entity to an other world during world generation"); - entity.teleportTo(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location)); + entity.changeDimension(new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getPitch(), location.getYaw(), DimensionTransition.DO_NOTHING, TeleportCause.PLUGIN)); return true; } @@ -856,7 +858,22 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return; } - entityTracker.broadcast(getHandle().getAddEntityPacket()); + entityTracker.broadcast(getHandle().getAddEntityPacket(entityTracker.serverEntity)); + } + + public void update(EntityPlayer player) { + if (!getHandle().isAlive()) { + return; + } + + WorldServer world = ((CraftWorld) getWorld()).getHandle(); + PlayerChunkMap.EntityTracker entityTracker = world.getChunkSource().chunkMap.entityMap.get(getEntityId()); + + if (entityTracker == null) { + return; + } + + player.connection.send(getHandle().getAddEntityPacket(entityTracker.serverEntity)); } private static PermissibleBase getPermissibleBase() { 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 9630a59a42..45691e2c6f 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 @@ -41,6 +41,7 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.block.BlockDiodeAbstract; import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.AxisAlignedBB; +import net.minecraft.world.phys.Vec3D; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -226,8 +227,8 @@ public final class CraftEntityTypes { private static final BiConsumer MOVE = (spawnData, entity) -> entity.moveTo(spawnData.x(), spawnData.y(), spawnData.z(), spawnData.yaw(), spawnData.pitch()); private static final BiConsumer MOVE_EMPTY_ROT = (spawnData, entity) -> entity.moveTo(spawnData.x(), spawnData.y(), spawnData.z(), 0, 0); private static final BiConsumer DIRECTION = (spawnData, entity) -> { - Vector direction = spawnData.location().getDirection().multiply(10); - entity.assignPower(direction.getX(), direction.getY(), direction.getZ()); + Vector direction = spawnData.location().getDirection(); + entity.assignDirectionalMovement(new Vec3D(direction.getX(), direction.getY(), direction.getZ()), 1.0); }; private static final Map, EntityTypeData> CLASS_TYPE_DATA = new HashMap<>(); private static final Map> ENTITY_TYPE_DATA = new HashMap<>(); @@ -472,8 +473,8 @@ public final class CraftEntityTypes { if (nmsBlock.isSolid() || BlockDiodeAbstract.isDiode(nmsBlock)) { boolean taken = false; AxisAlignedBB bb = (ItemFrame.class.isAssignableFrom(clazz)) - ? EntityItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height) - : EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height); + ? EntityItemFrame.calculateBoundingBoxStatic(pos, CraftBlock.blockFaceToNotch(dir).getOpposite()) + : EntityPainting.calculateBoundingBoxStatic(pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height); List list = spawnData.world().getEntities(null, bb); for (Iterator it = list.iterator(); !taken && it.hasNext(); ) { net.minecraft.world.entity.Entity e = it.next(); 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 206ca3ccde..7e5107378c 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 @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import net.minecraft.world.entity.projectile.EntityFireball; +import net.minecraft.world.phys.Vec3D; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Fireball; import org.bukkit.projectiles.ProjectileSource; @@ -72,16 +73,15 @@ public class CraftFireball extends AbstractProjectile implements Fireball { Preconditions.checkArgument(acceleration != null, "Vector acceleration cannot be null"); // SPIGOT-6993: EntityFireball#assignPower will normalize the given values // Note: Because of MC-80142 the fireball will stutter on the client when setting the power to something other than 0 or the normalized vector * 0.1 - getHandle().xPower = acceleration.getX(); - getHandle().yPower = acceleration.getY(); - getHandle().zPower = acceleration.getZ(); + getHandle().assignDirectionalMovement(new Vec3D(acceleration.getX(), acceleration.getY(), acceleration.getZ()), acceleration.length()); update(); // SPIGOT-6579 } @NotNull @Override public Vector getAcceleration() { - return new Vector(getHandle().xPower, getHandle().yPower, getHandle().zPower); + Vec3D delta = getHandle().getDeltaMovement(); + return new Vector(delta.x, delta.y, delta.z); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java index 8734dbb619..753f510267 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.entity.Hanging; -public class CraftHanging extends CraftEntity implements Hanging { +public class CraftHanging extends CraftBlockAttachedEntity implements Hanging { public CraftHanging(CraftServer server, EntityHanging entity) { super(server, entity); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 26cc6ca6ab..2097f9106c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -46,7 +46,7 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { // update redstone if (!getHandle().generation) { - getHandle().level().updateNeighbourForOutputSignal(getHandle().pos, Blocks.AIR); + getHandle().level().updateNeighbourForOutputSignal(getHandle().getPos(), Blocks.AIR); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java index b0203c6a30..eed038271b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java @@ -6,7 +6,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.LeashHitch; -public class CraftLeash extends CraftHanging implements LeashHitch { +public class CraftLeash extends CraftBlockAttachedEntity implements LeashHitch { public CraftLeash(CraftServer server, EntityLeash entity) { super(server, entity); } @@ -24,6 +24,17 @@ public class CraftLeash extends CraftHanging implements LeashHitch { return BlockFace.SELF; } + @Override + public BlockFace getAttachedFace() { + // Leash hitch has no facing direction, so we return self + return BlockFace.SELF; + } + + @Override + public void setFacingDirection(BlockFace face) { + // Leash hitch has no facing direction + } + @Override public EntityLeash getHandle() { return (EntityLeash) entity; 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 d21fb09b01..a0fae73dbf 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 @@ -40,6 +40,7 @@ import net.minecraft.world.entity.projectile.EntityThrownExpBottle; import net.minecraft.world.entity.projectile.EntityThrownTrident; import net.minecraft.world.entity.projectile.EntityTippedArrow; import net.minecraft.world.entity.projectile.EntityWitherSkull; +import net.minecraft.world.phys.Vec3D; import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.Material; @@ -462,14 +463,14 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { ((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEnderPearl } else if (AbstractArrow.class.isAssignableFrom(projectile)) { if (TippedArrow.class.isAssignableFrom(projectile)) { - launch = new EntityTippedArrow(world, getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW)); + launch = new EntityTippedArrow(world, 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 EntitySpectralArrow(world, getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW)); + launch = new EntitySpectralArrow(world, getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null); } else if (Trident.class.isAssignableFrom(projectile)) { launch = new EntityThrownTrident(world, getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.TRIDENT)); } else { - launch = new EntityTippedArrow(world, getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW)); + launch = new EntityTippedArrow(world, getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); } ((EntityArrow) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 3.0F, 1.0F); // ItemBow } else if (ThrownPotion.class.isAssignableFrom(projectile)) { @@ -489,19 +490,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10); + Vec3D vec = new Vec3D(direction.getX(), direction.getY(), direction.getZ()); if (SmallFireball.class.isAssignableFrom(projectile)) { - launch = new EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); + launch = new EntitySmallFireball(world, getHandle(), vec); } else if (WitherSkull.class.isAssignableFrom(projectile)) { - launch = new EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); + launch = new EntityWitherSkull(world, getHandle(), vec); } else if (DragonFireball.class.isAssignableFrom(projectile)) { - launch = new EntityDragonFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); + launch = new EntityDragonFireball(world, getHandle(), vec); } else if (WindCharge.class.isAssignableFrom(projectile)) { launch = EntityTypes.WIND_CHARGE.create(world); ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).setOwner(getHandle()); - ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).assignPower(direction.getX(), direction.getY(), direction.getZ()); + ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).assignDirectionalMovement(vec, 0.1D); } else { - launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ(), 1); + launch = new EntityLargeFireball(world, getHandle(), vec, 1); } ((EntityFireball) launch).projectileSource = this; 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 c1eae7f2c0..efa32ec217 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 @@ -47,6 +47,7 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; import net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket; import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket; +import net.minecraft.network.protocol.common.ClientboundServerLinksPacket; import net.minecraft.network.protocol.common.ClientboundStoreCookiePacket; import net.minecraft.network.protocol.common.ClientboundTransferPacket; import net.minecraft.network.protocol.common.custom.DiscardedPayload; @@ -98,7 +99,6 @@ import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.ai.attributes.AttributeMapBase; import net.minecraft.world.entity.ai.attributes.AttributeModifiable; import net.minecraft.world.entity.ai.attributes.GenericAttributes; -import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.food.FoodMetaData; import net.minecraft.world.inventory.Container; import net.minecraft.world.item.EnumColor; @@ -111,7 +111,6 @@ import net.minecraft.world.level.border.IWorldBorderListener; import net.minecraft.world.level.saveddata.maps.MapIcon; import net.minecraft.world.level.saveddata.maps.MapId; import net.minecraft.world.level.saveddata.maps.WorldMap; -import net.minecraft.world.phys.Vec3D; import org.bukkit.BanEntry; import org.bukkit.BanList; import org.bukkit.Bukkit; @@ -125,6 +124,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.Note; import org.bukkit.OfflinePlayer; import org.bukkit.Particle; +import org.bukkit.ServerLinks; import org.bukkit.Sound; import org.bukkit.Statistic; import org.bukkit.WeatherType; @@ -146,6 +146,7 @@ import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.CraftOfflinePlayer; import org.bukkit.craftbukkit.CraftParticle; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftServerLinks; import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.CraftStatistic; import org.bukkit.craftbukkit.CraftWorld; @@ -478,7 +479,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void kickPlayer(String message) { if (getHandle().connection == null) return; - getHandle().connection.disconnect(message == null ? "" : message); + getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message)); } @Override @@ -562,7 +563,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { if (loc == null || sound == null || category == null || getHandle().connection == null) return; - playSound0(loc, Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch, seed); + playSound0(loc, Holder.direct(SoundEffect.createVariableRangeEvent(MinecraftKey.parse(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch, seed); } private void playSound0(Location loc, Holder soundEffectHolder, net.minecraft.sounds.SoundCategory categoryNMS, float volume, float pitch, long seed) { @@ -605,7 +606,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void playSound(org.bukkit.entity.Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return; - playSound0(entity, Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch, seed); + playSound0(entity, Holder.direct(SoundEffect.createVariableRangeEvent(MinecraftKey.parse(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch, seed); } private void playSound0(org.bukkit.entity.Entity entity, Holder soundEffectHolder, net.minecraft.sounds.SoundCategory categoryNMS, float volume, float pitch, long seed) { @@ -639,7 +640,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void stopSound(String sound, org.bukkit.SoundCategory category) { if (getHandle().connection == null) return; - getHandle().connection.send(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name()))); + getHandle().connection.send(new PacketPlayOutStopSound(MinecraftKey.parse(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name()))); } @Override @@ -978,6 +979,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().connection.send(new ClientboundHurtAnimationPacket(getEntityId(), actualYaw)); } + @Override + public void sendLinks(ServerLinks links) { + if (getHandle().connection == null) { + return; + } + Preconditions.checkArgument(links != null, "links cannot be null"); + + net.minecraft.server.ServerLinks nms = ((CraftServerLinks) links).getServerLinks(); + getHandle().connection.send(new ClientboundServerLinksPacket(nms.untrust())); + } + @Override public void addCustomChatCompletions(Collection completions) { this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.ADD); @@ -1064,7 +1076,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { entity.connection.teleport(to); } else { // The respawn reason should never be used if the passed location is non null. - server.getHandle().respawn(entity, toWorld, true, to, true, null); + server.getHandle().respawn(entity, true, Entity.RemovalReason.CHANGED_DIMENSION, null, to); } return true; } @@ -1127,10 +1139,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { BlockPosition bed = getHandle().getRespawnPosition(); if (world != null && bed != null) { - Optional spawnLoc = EntityHuman.findRespawnPositionAndUseSpawnBlock(world, bed, getHandle().getRespawnAngle(), getHandle().isRespawnForced(), true); + Optional spawnLoc = EntityPlayer.findRespawnAndUseSpawnBlock(world, bed, getHandle().getRespawnAngle(), getHandle().isRespawnForced(), true); if (spawnLoc.isPresent()) { - Vec3D vec = spawnLoc.get(); - return CraftLocation.toBukkit(vec, world.getWorld(), getHandle().getRespawnAngle(), 0); + EntityPlayer.RespawnPosAngle vec = spawnLoc.get(); + return CraftLocation.toBukkit(vec.position(), world.getWorld(), vec.yaw(), 0); } } return null; @@ -1787,7 +1799,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().connection == null) return; if (channels.contains(channel)) { - MinecraftKey id = new MinecraftKey(StandardMessenger.validateAndCorrectChannel(channel)); + MinecraftKey id = MinecraftKey.parse(StandardMessenger.validateAndCorrectChannel(channel)); sendCustomPayload(id, message); } } @@ -1914,7 +1926,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - sendCustomPayload(new MinecraftKey("register"), stream.toByteArray()); + sendCustomPayload(MinecraftKey.withDefaultNamespace("register"), stream.toByteArray()); } } 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 5d2724fdcb..b21f91958d 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 @@ -56,6 +56,7 @@ import net.minecraft.world.entity.raid.EntityRaider; import net.minecraft.world.entity.raid.Raid; import net.minecraft.world.inventory.Container; import net.minecraft.world.inventory.ContainerMerchant; +import net.minecraft.world.inventory.InventoryCrafting; import net.minecraft.world.inventory.RecipeBookType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -887,7 +888,7 @@ public class CraftEventFactory { public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, DamageSource damageSource, List drops) { CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); - EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward()); + EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity())); CraftWorld world = (CraftWorld) entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); @@ -905,7 +906,7 @@ public class CraftEventFactory { public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, DamageSource damageSource, List drops, String deathMessage, boolean keepInventory) { CraftPlayer entity = victim.getBukkitEntity(); CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); - PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(), 0, deathMessage); + PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity()), 0, deathMessage); event.setKeepInventory(keepInventory); event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel org.bukkit.World world = entity.getWorld(); @@ -1257,7 +1258,7 @@ public class CraftEventFactory { return container; } - public static ItemStack callPreCraftEvent(IInventory matrix, IInventory resultInventory, ItemStack result, InventoryView lastCraftView, boolean isRepair) { + public static ItemStack callPreCraftEvent(InventoryCrafting matrix, IInventory resultInventory, ItemStack result, InventoryView lastCraftView, boolean isRepair) { CraftInventoryCrafting inventory = new CraftInventoryCrafting(matrix, resultInventory); inventory.setResult(CraftItemStack.asCraftMirror(result)); @@ -1438,13 +1439,13 @@ public class CraftEventFactory { Bukkit.getPluginManager().callEvent(new PlayerRecipeBookSettingsChangeEvent(player.getBukkitEntity(), bukkitType, open, filter)); } - public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player, EnumHand enumhand) { + public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Entity entity, EntityHuman player, EnumHand enumhand) { PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand)); entity.level().getCraftServer().getPluginManager().callEvent(event); return event; } - public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(EntityInsentient entity, Entity leashHolder, EntityHuman player, EnumHand enumhand) { + public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(Entity entity, Entity leashHolder, EntityHuman player, EnumHand enumhand) { PlayerLeashEntityEvent event = new PlayerLeashEntityEvent(entity.getBukkitEntity(), leashHolder.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand)); entity.level().getCraftServer().getPluginManager().callEvent(event); return event; @@ -1794,6 +1795,11 @@ public class CraftEventFactory { public static EntityTeleportEvent callEntityTeleportEvent(Entity nmsEntity, double x, double y, double z) { CraftEntity entity = nmsEntity.getBukkitEntity(); Location to = new Location(entity.getWorld(), x, y, z, nmsEntity.getYRot(), nmsEntity.getXRot()); + return callEntityTeleportEvent(nmsEntity, to); + } + + public static EntityTeleportEvent callEntityTeleportEvent(Entity nmsEntity, Location to) { + CraftEntity entity = nmsEntity.getBukkitEntity(); EntityTeleportEvent event = new org.bukkit.event.entity.EntityTeleportEvent(entity, entity.getLocation(), to); Bukkit.getPluginManager().callEvent(event); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index b1eb38418b..c750ee5cdb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -5,7 +5,6 @@ import com.mojang.serialization.MapCodec; import java.util.List; import java.util.Random; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; import net.minecraft.core.BlockPosition; import net.minecraft.core.Holder; import net.minecraft.core.IRegistryCustom; @@ -245,7 +244,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public CompletableFuture fillFromNoise(Executor executor, Blender blender, RandomState randomstate, StructureManager structuremanager, IChunkAccess ichunkaccess) { + public CompletableFuture fillFromNoise(Blender blender, RandomState randomstate, StructureManager structuremanager, IChunkAccess ichunkaccess) { CompletableFuture future = null; SeededRandom random = getSeededRandom(); int x = ichunkaccess.getPos().x; @@ -253,7 +252,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { random.setSeed(MathHelper.getSeed(x, "should-noise".hashCode(), z) ^ this.world.getSeed()); if (generator.shouldGenerateNoise(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z)) { - future = delegate.fillFromNoise(executor, blender, randomstate, structuremanager, ichunkaccess); + future = delegate.fillFromNoise(blender, randomstate, structuremanager, ichunkaccess); } java.util.function.Function function = (ichunkaccess1) -> { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index 9276033014..48e80f6d19 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import java.util.Arrays; import java.util.List; import net.minecraft.world.IInventory; +import net.minecraft.world.inventory.InventoryCrafting; import net.minecraft.world.item.crafting.RecipeHolder; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; @@ -12,7 +13,7 @@ import org.bukkit.inventory.Recipe; public class CraftInventoryCrafting extends CraftInventory implements CraftingInventory { private final IInventory resultInventory; - public CraftInventoryCrafting(IInventory inventory, IInventory resultInventory) { + public CraftInventoryCrafting(InventoryCrafting inventory, IInventory resultInventory) { super(inventory); this.resultInventory = resultInventory; } @@ -21,8 +22,8 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn return resultInventory; } - public IInventory getMatrixInventory() { - return inventory; + public InventoryCrafting getMatrixInventory() { + return (InventoryCrafting) inventory; } @Override @@ -115,7 +116,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn @Override public Recipe getRecipe() { - RecipeHolder recipe = getInventory().getCurrentRecipe(); + RecipeHolder recipe = getMatrixInventory().getCurrentRecipe(); return recipe == null ? null : recipe.toBukkitRecipe(); } } 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 afa2ad4771..43ff0152c9 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 @@ -3,22 +3,30 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.base.Preconditions; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import java.util.Optional; import net.minecraft.commands.arguments.item.ArgumentParserItemStack; -import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.HolderSet; +import net.minecraft.core.IRegistryCustom; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.registries.Registries; import net.minecraft.server.MinecraftServer; +import net.minecraft.tags.EnchantmentTags; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemMonsterEgg; +import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentManager; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.configuration.serialization.ConfigurationSerialization; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntityType; import org.bukkit.craftbukkit.inventory.components.CraftFoodComponent; +import org.bukkit.craftbukkit.inventory.components.CraftJukeboxComponent; import org.bukkit.craftbukkit.inventory.components.CraftToolComponent; import org.bukkit.craftbukkit.util.CraftLegacy; import org.bukkit.entity.Entity; @@ -39,6 +47,7 @@ public final class CraftItemFactory implements ItemFactory { ConfigurationSerialization.registerClass(CraftFoodComponent.CraftFoodEffect.class); ConfigurationSerialization.registerClass(CraftToolComponent.class); ConfigurationSerialization.registerClass(CraftToolComponent.CraftToolRule.class); + ConfigurationSerialization.registerClass(CraftJukeboxComponent.class); } private CraftItemFactory() { @@ -448,7 +457,7 @@ public final class CraftItemFactory implements ItemFactory { Item item = arg.item().value(); net.minecraft.world.item.ItemStack nmsItemStack = new net.minecraft.world.item.ItemStack(item); - DataComponentMap nbt = arg.components(); + DataComponentPatch nbt = arg.components(); if (nbt != null) { nmsItemStack.applyComponents(nbt); } @@ -498,6 +507,8 @@ public final class CraftItemFactory implements ItemFactory { Preconditions.checkArgument(!itemStack.getType().isAir(), "ItemStack must not be air"); itemStack = CraftItemStack.asCraftCopy(itemStack); CraftItemStack craft = (CraftItemStack) itemStack; - return CraftItemStack.asCraftMirror(EnchantmentManager.enchantItem(MinecraftServer.getServer().getWorldData().enabledFeatures(), source, craft.handle, level, allowTreasures)); + IRegistryCustom registry = CraftRegistry.getMinecraftRegistry(); + Optional> optional = (allowTreasures) ? Optional.empty() : registry.registryOrThrow(Registries.ENCHANTMENT).getTag(EnchantmentTags.IN_ENCHANTING_TABLE); + return CraftItemStack.asCraftMirror(EnchantmentManager.enchantItem(source, craft.handle, level, registry, optional)); } } 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 1705b3ed58..933c69abc5 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 @@ -185,7 +185,7 @@ public final class CraftItemStack extends ItemStack { list = ItemEnchantments.EMPTY; } ItemEnchantments.a listCopy = new ItemEnchantments.a(list); - listCopy.set(CraftEnchantment.bukkitToMinecraft(ench), level); + listCopy.set(CraftEnchantment.bukkitToMinecraftHolder(ench), level); handle.set(DataComponents.ENCHANTMENTS, listCopy.toImmutable()); } @@ -208,7 +208,7 @@ public final class CraftItemStack extends ItemStack { if (handle == null) { return 0; } - return EnchantmentManager.getItemEnchantmentLevel(CraftEnchantment.bukkitToMinecraft(ench), handle); + return EnchantmentManager.getItemEnchantmentLevel(CraftEnchantment.bukkitToMinecraftHolder(ench), handle); } @Override @@ -231,7 +231,7 @@ public final class CraftItemStack extends ItemStack { } ItemEnchantments.a listCopy = new ItemEnchantments.a(list); - listCopy.set(CraftEnchantment.bukkitToMinecraft(ench), -1); // Negative to remove + listCopy.set(CraftEnchantment.bukkitToMinecraftHolder(ench), -1); // Negative to remove handle.set(DataComponents.ENCHANTMENTS, listCopy.toImmutable()); return level; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java index fe7cd23ec9..e5e7edc5c0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java @@ -8,7 +8,6 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemBlock; -import net.minecraft.world.item.ItemRecord; import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.level.block.BlockComposter; import net.minecraft.world.level.block.entity.TileEntityFurnace; @@ -169,7 +168,7 @@ public class CraftItemType implements ItemType.Typed, Han @Override public boolean isRecord() { - return item instanceof ItemRecord; + return item.components().has(DataComponents.JUKEBOX_PLAYABLE); } @Override 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 f125452376..e2b54e93e7 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 @@ -61,7 +61,10 @@ import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.entity.ai.attributes.AttributeBase; import net.minecraft.world.food.FoodInfo; +import net.minecraft.world.item.EitherHolder; import net.minecraft.world.item.EnumItemRarity; +import net.minecraft.world.item.JukeboxPlayable; +import net.minecraft.world.item.JukeboxSongs; import net.minecraft.world.item.component.BlockItemStateProperties; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.item.component.CustomModelData; @@ -86,6 +89,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey.Specific; import org.bukkit.craftbukkit.inventory.components.CraftFoodComponent; +import org.bukkit.craftbukkit.inventory.components.CraftJukeboxComponent; import org.bukkit.craftbukkit.inventory.components.CraftToolComponent; import org.bukkit.craftbukkit.inventory.tags.DeprecatedCustomTagContainer; import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -102,6 +106,7 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.Repairable; import org.bukkit.inventory.meta.components.FoodComponent; +import org.bukkit.inventory.meta.components.JukeboxPlayableComponent; import org.bukkit.inventory.meta.components.ToolComponent; import org.bukkit.inventory.meta.tags.CustomItemTagContainer; import org.bukkit.persistence.PersistentDataContainer; @@ -226,6 +231,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Specific(Specific.To.NBT) static final ItemMetaKeyType TOOL = new ItemMetaKeyType<>(DataComponents.TOOL, "tool"); @Specific(Specific.To.NBT) + static final ItemMetaKeyType JUKEBOX_PLAYABLE = new ItemMetaKeyType<>(DataComponents.JUKEBOX_PLAYABLE, "jukebox-playable"); + @Specific(Specific.To.NBT) static final ItemMetaKeyType DAMAGE = new ItemMetaKeyType<>(DataComponents.DAMAGE, "Damage"); @Specific(Specific.To.NBT) static final ItemMetaKeyType MAX_DAMAGE = new ItemMetaKeyType<>(DataComponents.MAX_DAMAGE, "max-damage"); @@ -255,6 +262,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { private ItemRarity rarity; private CraftFoodComponent food; private CraftToolComponent tool; + private CraftJukeboxComponent jukebox; private int damage; private Integer maxDamage; @@ -304,6 +312,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (meta.hasTool()) { this.tool = new CraftToolComponent(meta.tool); } + if (meta.hasJukeboxPlayable()) { + this.jukebox = new CraftJukeboxComponent(meta.jukebox); + } this.damage = meta.damage; this.maxDamage = meta.maxDamage; this.unhandledTags = meta.unhandledTags; @@ -385,6 +396,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { getOrEmpty(tag, TOOL).ifPresent((toolInfo) -> { tool = new CraftToolComponent(toolInfo); }); + getOrEmpty(tag, JUKEBOX_PLAYABLE).ifPresent((jukeboxPlayable) -> { + jukebox = new CraftJukeboxComponent(jukeboxPlayable); + }); getOrEmpty(tag, DAMAGE).ifPresent((i) -> { damage = i; }); @@ -474,7 +488,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { continue; } - attribMod = new AttributeModifier(attribMod.getUniqueId(), attribMod.getName(), attribMod.getAmount(), attribMod.getOperation(), slot); + attribMod = new AttributeModifier(attribMod.getKey(), attribMod.getAmount(), attribMod.getOperation(), slot); } modifiers.put(attribute, attribMod); } @@ -568,6 +582,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { setTool(tool); } + CraftJukeboxComponent jukeboxPlayable = SerializableMeta.getObject(CraftJukeboxComponent.class, map, JUKEBOX_PLAYABLE.BUKKIT, true); + if (jukeboxPlayable != null) { + setJukeboxPlayable(jukeboxPlayable); + } + Integer damage = SerializableMeta.getObject(Integer.class, map, DAMAGE.BUKKIT, true); if (damage != null) { setDamage(damage); @@ -673,7 +692,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { continue; } - attribMod = new AttributeModifier(attribMod.getUniqueId(), attribMod.getName(), attribMod.getAmount(), attribMod.getOperation(), slot); + attribMod = new AttributeModifier(attribMod.getKey(), attribMod.getAmount(), attribMod.getOperation(), slot.getGroup()); } modifiers.put(attribute, attribMod); } @@ -800,6 +819,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { itemTag.put(TOOL, tool.getHandle()); } + if (hasJukeboxPlayable()) { + itemTag.put(JUKEBOX_PLAYABLE, jukebox.getHandle()); + } + if (hasDamage()) { itemTag.put(DAMAGE, damage); } @@ -842,7 +865,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { ItemEnchantments.a list = new ItemEnchantments.a(ItemEnchantments.EMPTY); for (Map.Entry entry : enchantments.entrySet()) { - list.set(CraftEnchantment.bukkitToMinecraft(entry.getKey()), entry.getValue()); + list.set(CraftEnchantment.bukkitToMinecraftHolder(entry.getKey()), entry.getValue()); } list.showInTooltip = !hasItemFlag(itemFlag); @@ -1187,7 +1210,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Override public FoodComponent getFood() { - return (this.hasFood()) ? new CraftFoodComponent(this.food) : new CraftFoodComponent(new FoodInfo(0, 0, false, 0, Collections.emptyList())); + return (this.hasFood()) ? new CraftFoodComponent(this.food) : new CraftFoodComponent(new FoodInfo(0, 0, false, 0, Optional.empty(), Collections.emptyList())); } @Override @@ -1210,6 +1233,21 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { this.tool = (tool == null) ? null : new CraftToolComponent((CraftToolComponent) tool); } + @Override + public boolean hasJukeboxPlayable() { + return this.jukebox != null; + } + + @Override + public JukeboxPlayableComponent getJukeboxPlayable() { + return (this.hasJukeboxPlayable()) ? new CraftJukeboxComponent(this.jukebox) : new CraftJukeboxComponent(new JukeboxPlayable(new EitherHolder<>(JukeboxSongs.THIRTEEN), true)); + } + + @Override + public void setJukeboxPlayable(JukeboxPlayableComponent jukeboxPlayable) { + this.jukebox = (jukeboxPlayable == null) ? null : new CraftJukeboxComponent((CraftJukeboxComponent) jukeboxPlayable); + } + @Override public boolean hasAttributeModifiers() { return attributeModifiers != null && !attributeModifiers.isEmpty(); @@ -1250,7 +1288,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { Preconditions.checkNotNull(modifier, "AttributeModifier cannot be null"); checkAttributeList(); for (Map.Entry entry : attributeModifiers.entries()) { - Preconditions.checkArgument(!entry.getValue().getUniqueId().equals(modifier.getUniqueId()), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); + Preconditions.checkArgument(!entry.getValue().getKey().equals(modifier.getKey()), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); } return attributeModifiers.put(attribute, modifier); } @@ -1318,7 +1356,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { continue; // remove all null values while we are here } - if (entry.getKey() == attribute && entry.getValue().getUniqueId().equals(modifier.getUniqueId())) { + if (entry.getKey() == attribute && entry.getValue().getKey().equals(modifier.getKey())) { iter.remove(); ++removed; } @@ -1356,7 +1394,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { String componentValueAsNBTString = new SnbtPrinterTagVisitor("", 0, new ArrayList<>()).visit(componentValueAsNBT); componentString.add(componentKey + "=" + componentValueAsNBTString); } else { - // TODO: 1.21, remove component (!) format + componentString.add("!" + componentKey); } } @@ -1462,6 +1500,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { && (this.rarity == that.rarity) && (this.hasFood() ? that.hasFood() && this.food.equals(that.food) : !that.hasFood()) && (this.hasTool() ? that.hasTool() && this.tool.equals(that.tool) : !that.hasTool()) + && (this.hasJukeboxPlayable() ? that.hasJukeboxPlayable() && this.jukebox.equals(that.jukebox) : !that.hasJukeboxPlayable()) && (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage()) && (this.hasMaxDamage() ? that.hasMaxDamage() && this.maxDamage.equals(that.maxDamage) : !that.hasMaxDamage()) && (this.version == that.version); @@ -1504,6 +1543,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { hash = 61 * hash + (hasRarity() ? this.rarity.hashCode() : 0); hash = 61 * hash + (hasFood() ? this.food.hashCode() : 0); hash = 61 * hash + (hasTool() ? this.tool.hashCode() : 0); + hash = 61 * hash + (hasJukeboxPlayable() ? this.jukebox.hashCode() : 0); hash = 61 * hash + (hasDamage() ? this.damage : 0); hash = 61 * hash + (hasMaxDamage() ? 1231 : 1237); hash = 61 * hash + (hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0); @@ -1544,6 +1584,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (this.hasTool()) { clone.tool = new CraftToolComponent(tool); } + if (this.hasJukeboxPlayable()) { + clone.jukebox = new CraftJukeboxComponent(jukebox); + } clone.damage = this.damage; clone.maxDamage = this.maxDamage; clone.version = this.version; @@ -1636,6 +1679,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { builder.put(TOOL.BUKKIT, tool); } + if (hasJukeboxPlayable()) { + builder.put(JUKEBOX_PLAYABLE.BUKKIT, jukebox); + } + if (hasDamage()) { builder.put(DAMAGE.BUKKIT, damage); } @@ -1799,6 +1846,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { RARITY.TYPE, FOOD.TYPE, TOOL.TYPE, + JUKEBOX_PLAYABLE.TYPE, DAMAGE.TYPE, MAX_DAMAGE.TYPE, CUSTOM_DATA.TYPE, diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java index d30703aa35..514dab2d4b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftFoodComponent.java @@ -7,11 +7,14 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; import net.minecraft.world.food.FoodInfo; import org.bukkit.configuration.serialization.SerializableAs; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.SerializableMeta; import org.bukkit.craftbukkit.potion.CraftPotionUtil; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.components.FoodComponent; import org.bukkit.potion.PotionEffect; @@ -38,6 +41,8 @@ public final class CraftFoodComponent implements FoodComponent { eatSeconds = 1.6f; } + ItemStack usingConvertsTo = SerializableMeta.getObject(ItemStack.class, map, "using-converts-to", true); + ImmutableList.Builder effects = ImmutableList.builder(); Iterable rawEffectList = SerializableMeta.getObject(Iterable.class, map, "effects", true); if (rawEffectList != null) { @@ -47,7 +52,7 @@ public final class CraftFoodComponent implements FoodComponent { } } - this.handle = new FoodInfo(nutrition, saturationModifier, canAlwaysEat, eatSeconds, effects.build().stream().map(CraftFoodEffect::new).map(CraftFoodEffect::getHandle).toList()); + this.handle = new FoodInfo(nutrition, saturationModifier, canAlwaysEat, eatSeconds, Optional.ofNullable(usingConvertsTo).map(CraftItemStack::asNMSCopy), effects.build().stream().map(CraftFoodEffect::new).map(CraftFoodEffect::getHandle).toList()); } @Override @@ -57,6 +62,7 @@ public final class CraftFoodComponent implements FoodComponent { result.put("saturation", getSaturation()); result.put("can-always-eat", canAlwaysEat()); result.put("eat-seconds", getEatSeconds()); + result.put("using-converts-to", getUsingConvertsTo()); result.put("effects", getEffects()); return result; } @@ -73,7 +79,7 @@ public final class CraftFoodComponent implements FoodComponent { @Override public void setNutrition(int nutrition) { Preconditions.checkArgument(nutrition >= 0, "Nutrition cannot be negative"); - handle = new FoodInfo(nutrition, handle.saturation(), handle.canAlwaysEat(), handle.eatSeconds(), handle.effects()); + handle = new FoodInfo(nutrition, handle.saturation(), handle.canAlwaysEat(), handle.eatSeconds(), handle.usingConvertsTo(), handle.effects()); } @Override @@ -83,7 +89,7 @@ public final class CraftFoodComponent implements FoodComponent { @Override public void setSaturation(float saturation) { - handle = new FoodInfo(handle.nutrition(), saturation, handle.canAlwaysEat(), handle.eatSeconds(), handle.effects()); + handle = new FoodInfo(handle.nutrition(), saturation, handle.canAlwaysEat(), handle.eatSeconds(), handle.usingConvertsTo(), handle.effects()); } @Override @@ -93,7 +99,7 @@ public final class CraftFoodComponent implements FoodComponent { @Override public void setCanAlwaysEat(boolean canAlwaysEat) { - handle = new FoodInfo(handle.nutrition(), handle.saturation(), canAlwaysEat, handle.eatSeconds(), handle.effects()); + handle = new FoodInfo(handle.nutrition(), handle.saturation(), canAlwaysEat, handle.eatSeconds(), handle.usingConvertsTo(), handle.effects()); } @Override @@ -103,7 +109,17 @@ public final class CraftFoodComponent implements FoodComponent { @Override public void setEatSeconds(float eatSeconds) { - handle = new FoodInfo(handle.nutrition(), handle.saturation(), handle.canAlwaysEat(), eatSeconds, handle.effects()); + handle = new FoodInfo(handle.nutrition(), handle.saturation(), handle.canAlwaysEat(), eatSeconds, handle.usingConvertsTo(), handle.effects()); + } + + @Override + public ItemStack getUsingConvertsTo() { + return handle.usingConvertsTo().map(CraftItemStack::asBukkitCopy).orElse(null); + } + + @Override + public void setUsingConvertsTo(ItemStack item) { + handle = new FoodInfo(handle.nutrition(), handle.saturation(), handle.canAlwaysEat(), handle.eatSeconds(), Optional.ofNullable(item).map(CraftItemStack::asNMSCopy), handle.effects()); } @Override @@ -113,7 +129,7 @@ public final class CraftFoodComponent implements FoodComponent { @Override public void setEffects(List effects) { - handle = new FoodInfo(handle.nutrition(), handle.saturation(), handle.canAlwaysEat(), handle.eatSeconds(), effects.stream().map(CraftFoodEffect::new).map(CraftFoodEffect::getHandle).toList()); + handle = new FoodInfo(handle.nutrition(), handle.saturation(), handle.canAlwaysEat(), handle.eatSeconds(), handle.usingConvertsTo(), effects.stream().map(CraftFoodEffect::new).map(CraftFoodEffect::getHandle).toList()); } @Override @@ -123,7 +139,7 @@ public final class CraftFoodComponent implements FoodComponent { FoodInfo.b newEffect = new net.minecraft.world.food.FoodInfo.b(CraftPotionUtil.fromBukkit(effect), probability); effects.add(newEffect); - handle = new FoodInfo(handle.nutrition(), handle.saturation(), handle.canAlwaysEat(), handle.eatSeconds(), effects); + handle = new FoodInfo(handle.nutrition(), handle.saturation(), handle.canAlwaysEat(), handle.eatSeconds(), handle.usingConvertsTo(), effects); return new CraftFoodEffect(newEffect); } 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 new file mode 100644 index 0000000000..62166cca31 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftJukeboxComponent.java @@ -0,0 +1,116 @@ +package org.bukkit.craftbukkit.inventory.components; + +import com.google.common.base.Preconditions; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.MinecraftKey; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.EitherHolder; +import net.minecraft.world.item.JukeboxPlayable; +import org.bukkit.JukeboxSong; +import org.bukkit.NamespacedKey; +import org.bukkit.configuration.serialization.SerializableAs; +import org.bukkit.craftbukkit.CraftJukeboxSong; +import org.bukkit.craftbukkit.CraftRegistry; +import org.bukkit.craftbukkit.inventory.SerializableMeta; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.meta.components.JukeboxPlayableComponent; + +@SerializableAs("JukeboxPlayable") +public final class CraftJukeboxComponent implements JukeboxPlayableComponent { + + private JukeboxPlayable handle; + + public CraftJukeboxComponent(JukeboxPlayable jukebox) { + this.handle = jukebox; + } + + public CraftJukeboxComponent(CraftJukeboxComponent jukebox) { + this.handle = jukebox.handle; + } + + public CraftJukeboxComponent(Map map) { + String song = SerializableMeta.getObject(String.class, map, "song", false); + Boolean showTooltip = SerializableMeta.getObject(boolean.class, map, "show-in-tooltip", true); + + this.handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, MinecraftKey.parse(song))), (showTooltip != null) ? showTooltip : true); + } + + @Override + public Map serialize() { + Map result = new LinkedHashMap<>(); + result.put("song", getSongKey().toString()); + result.put("show-in-tooltip", isShowInTooltip()); + return result; + } + + public JukeboxPlayable getHandle() { + return handle; + } + + @Override + public JukeboxSong getSong() { + Optional> song = handle.song().unwrap(CraftRegistry.getMinecraftRegistry()); + return (song.isPresent()) ? CraftJukeboxSong.minecraftHolderToBukkit(song.get()) : null; + } + + @Override + public NamespacedKey getSongKey() { + return CraftNamespacedKey.fromMinecraft(handle.song().key().location()); + } + + @Override + public void setSong(JukeboxSong song) { + Preconditions.checkArgument(song != null, "song cannot be null"); + + handle = new JukeboxPlayable(new EitherHolder<>(CraftJukeboxSong.bukkitToMinecraftHolder(song)), handle.showInTooltip()); + } + + @Override + public void setSongKey(NamespacedKey song) { + Preconditions.checkArgument(song != null, "song cannot be null"); + + handle = new JukeboxPlayable(new EitherHolder<>(ResourceKey.create(Registries.JUKEBOX_SONG, CraftNamespacedKey.toMinecraft(song))), handle.showInTooltip()); + } + + @Override + public boolean isShowInTooltip() { + return handle.showInTooltip(); + } + + @Override + public void setShowInTooltip(boolean show) { + handle = new JukeboxPlayable(handle.song(), show); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 73 * hash + Objects.hashCode(this.handle); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftJukeboxComponent other = (CraftJukeboxComponent) obj; + return Objects.equals(this.handle, other.handle); + } + + @Override + public String toString() { + return "CraftJukeboxComponent{" + "handle=" + handle + '}'; + } +} 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 7c0914ecb2..01a01dad78 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 @@ -342,7 +342,7 @@ public final class CraftLegacy { } String name = blockTag.get("Name").asString(""); - Block block = BuiltInRegistries.BLOCK.get(new MinecraftKey(name)); + Block block = BuiltInRegistries.BLOCK.get(MinecraftKey.parse(name)); if (block == null) { continue; } @@ -416,7 +416,7 @@ public final class CraftLegacy { } // Preconditions.checkState(newId.contains("minecraft:"), "Unknown new material for " + matData); - Item newMaterial = BuiltInRegistries.ITEM.get(new MinecraftKey(newId)); + Item newMaterial = BuiltInRegistries.ITEM.get(MinecraftKey.parse(newId)); if (newMaterial == Items.AIR) { continue; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/MethodRerouting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/MethodRerouting.java new file mode 100644 index 0000000000..c2ef6390bf --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/MethodRerouting.java @@ -0,0 +1,12 @@ +package org.bukkit.craftbukkit.legacy; + +import org.bukkit.craftbukkit.legacy.reroute.NotInBukkit; +import org.bukkit.event.entity.EntityCombustEvent; + +public class MethodRerouting { + + @NotInBukkit + public static int getDuration(EntityCombustEvent event) { + return (int) event.getDuration(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java index 6710fa4673..f7d387d899 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java @@ -21,6 +21,7 @@ import net.minecraft.world.entity.projectile.EntityTippedArrow; import net.minecraft.world.entity.projectile.IProjectile; import net.minecraft.world.level.block.BlockDispenser; import net.minecraft.world.level.block.entity.TileEntityDispenser; +import net.minecraft.world.phys.Vec3D; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -90,12 +91,12 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { } } else if (AbstractArrow.class.isAssignableFrom(projectile)) { if (TippedArrow.class.isAssignableFrom(projectile)) { - launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW)); + launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z(), 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 EntitySpectralArrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW)); + launch = new EntitySpectralArrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null); } else { - launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW)); + launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); } ((EntityArrow) launch).pickup = EntityArrow.PickupStatus.ALLOWED; ((EntityArrow) launch).projectileSource = this; @@ -109,23 +110,17 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ(); if (SmallFireball.class.isAssignableFrom(projectile)) { - launch = new EntitySmallFireball(world, null, d0, d1, d2); + launch = new EntitySmallFireball(world, null, new Vec3D(d0, d1, d2)); } else if (WitherSkull.class.isAssignableFrom(projectile)) { launch = EntityTypes.WITHER_SKULL.create(world); launch.setPos(d0, d1, d2); - double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - ((EntityFireball) launch).xPower = d3 / d6 * 0.1D; - ((EntityFireball) launch).yPower = d4 / d6 * 0.1D; - ((EntityFireball) launch).zPower = d5 / d6 * 0.1D; + ((EntityFireball) launch).assignDirectionalMovement(new Vec3D(d3, d4, d5), 0.1D); } else { launch = EntityTypes.FIREBALL.create(world); launch.setPos(d0, d1, d2); - double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - ((EntityFireball) launch).xPower = d3 / d6 * 0.1D; - ((EntityFireball) launch).yPower = d4 / d6 * 0.1D; - ((EntityFireball) launch).zPower = d5 / d6 * 0.1D; + ((EntityFireball) launch).assignDirectionalMovement(new Vec3D(d3, d4, d5), 0.1D); } ((EntityFireball) launch).projectileSource = this; 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 755bcc3265..10fbddfeaa 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 @@ -124,14 +124,14 @@ public class CraftStructureManager implements StructureManager { if (unregister) { structureManager.structureRepository.remove(key); } - Path path = structureManager.getPathToGeneratedStructure(key, ".nbt"); + Path path = structureManager.createAndValidatePathToGeneratedStructure(key, ".nbt"); Files.deleteIfExists(path); } @Override public File getStructureFile(NamespacedKey structureKey) { MinecraftKey minecraftKey = createAndValidateMinecraftStructureKey(structureKey); - return structureManager.getPathToGeneratedStructure(minecraftKey, ".nbt").toFile(); + return structureManager.createAndValidatePathToGeneratedStructure(minecraftKey, ".nbt").toFile(); } @Override 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 d1fc742616..97e01aeb7e 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 @@ -15,7 +15,7 @@ public final class ApiVersion implements Comparable { static { versions = new HashMap<>(); - CURRENT = getOrCreateVersion("1.20.6"); + CURRENT = getOrCreateVersion("1.21"); FLATTENING = getOrCreateVersion("1.13"); FIELD_NAME_PARITY = getOrCreateVersion("1.20.5"); NONE = getOrCreateVersion("none"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 7e51bfa603..5d28381b3f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -23,6 +23,7 @@ import joptsimple.OptionSpec; import org.bukkit.Material; import org.bukkit.craftbukkit.legacy.FieldRename; import org.bukkit.craftbukkit.legacy.MaterialRerouting; +import org.bukkit.craftbukkit.legacy.MethodRerouting; import org.bukkit.craftbukkit.legacy.reroute.RerouteArgument; import org.bukkit.craftbukkit.legacy.reroute.RerouteBuilder; import org.bukkit.craftbukkit.legacy.reroute.RerouteMethodData; @@ -76,6 +77,7 @@ public class Commodore { public static final List> REROUTES = new ArrayList<>(); // Only used for testing private static final Map FIELD_RENAME_METHOD_REROUTE = createReroutes(FieldRename.class); private static final Map MATERIAL_METHOD_REROUTE = createReroutes(MaterialRerouting.class); + private static final Map METHOD_REROUTE = createReroutes(MethodRerouting.class); public static void main(String[] args) { OptionParser parser = new OptionParser(); @@ -282,6 +284,9 @@ public class Commodore { if (checkReroute(visitor, FIELD_RENAME_METHOD_REROUTE, opcode, owner, name, desc, samMethodType, instantiatedMethodType)) { return; } + if (checkReroute(visitor, METHOD_REROUTE, opcode, owner, name, desc, samMethodType, instantiatedMethodType)) { + return; + } // SPIGOT-4496 if (owner.equals("org/bukkit/map/MapView") && name.equals("getId") && desc.equals("()S")) { 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 d81071d712..e31e106cdf 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 @@ -230,7 +230,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "ee13f98a43b9c5abffdcc0bb24154460"; + return "229d7afc75b70a6c388337687ac4da1f"; } @Override 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 82eb945736..7ad6f66eed 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 @@ -17,7 +17,7 @@ public final class CraftNamespacedKey { } public static NamespacedKey fromString(String string) { - return fromMinecraft(new MinecraftKey(string)); + return fromMinecraft(MinecraftKey.parse(string)); } public static NamespacedKey fromMinecraft(MinecraftKey minecraft) { @@ -25,6 +25,6 @@ public final class CraftNamespacedKey { } public static MinecraftKey toMinecraft(NamespacedKey key) { - return new MinecraftKey(key.getNamespace(), key.getKey()); + return MinecraftKey.fromNamespaceAndPath(key.getNamespace(), key.getKey()); } } diff --git a/paper-server/src/test/java/org/bukkit/ArtTest.java b/paper-server/src/test/java/org/bukkit/ArtTest.java index f317c7d509..ea288c3ff3 100644 --- a/paper-server/src/test/java/org/bukkit/ArtTest.java +++ b/paper-server/src/test/java/org/bukkit/ArtTest.java @@ -10,25 +10,25 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import net.minecraft.core.Holder; -import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.decoration.PaintingVariant; import org.bukkit.craftbukkit.CraftArt; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.support.AbstractTestingBase; import org.junit.jupiter.api.Test; public class ArtTest extends AbstractTestingBase { - private static final int UNIT_MULTIPLIER = 16; @Test public void verifyMapping() { List arts = Lists.newArrayList(Art.values()); - for (ResourceKey key : BuiltInRegistries.PAINTING_VARIANT.registryKeySet()) { - Holder enumArt = BuiltInRegistries.PAINTING_VARIANT.getHolderOrThrow(key); + for (ResourceKey key : CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).registryKeySet()) { + Holder enumArt = CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).getHolderOrThrow(key); String name = key.location().getPath(); - int width = enumArt.value().getWidth() / UNIT_MULTIPLIER; - int height = enumArt.value().getHeight() / UNIT_MULTIPLIER; + int width = enumArt.value().width(); + int height = enumArt.value().height(); Art subject = CraftArt.minecraftHolderToBukkit(enumArt); @@ -58,7 +58,7 @@ public class ArtTest extends AbstractTestingBase { @Test public void testCraftArtToBukkit() { Map> cache = new EnumMap(Art.class); - for (Holder enumArt : BuiltInRegistries.PAINTING_VARIANT.asHolderIdMap()) { + for (Holder enumArt : CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).asHolderIdMap()) { Art art = CraftArt.minecraftHolderToBukkit(enumArt); assertNotNull(art, "Could not CraftArt.NotchToBukkit " + enumArt); assertThat(cache.put(art, enumArt), is(nullValue()), "Duplicate artwork " + enumArt); diff --git a/paper-server/src/test/java/org/bukkit/DyeColorsTest.java b/paper-server/src/test/java/org/bukkit/DyeColorsTest.java index 9b75155e54..15dbe07be6 100644 --- a/paper-server/src/test/java/org/bukkit/DyeColorsTest.java +++ b/paper-server/src/test/java/org/bukkit/DyeColorsTest.java @@ -13,8 +13,8 @@ public class DyeColorsTest extends AbstractTestingBase { @EnumSource(DyeColor.class) public void checkColor(DyeColor dye) { Color color = dye.getColor(); - float[] nmsColorArray = EnumColor.byId(dye.getWoolData()).getTextureDiffuseColors(); - Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255)); + int nmsColorArray = EnumColor.byId(dye.getWoolData()).getTextureDiffuseColor(); + Color nmsColor = Color.fromARGB(nmsColorArray); assertThat(color, is(nmsColor)); } diff --git a/paper-server/src/test/java/org/bukkit/EnchantmentTest.java b/paper-server/src/test/java/org/bukkit/EnchantmentTest.java index dff04b4d57..6c064f1d86 100644 --- a/paper-server/src/test/java/org/bukkit/EnchantmentTest.java +++ b/paper-server/src/test/java/org/bukkit/EnchantmentTest.java @@ -1,8 +1,9 @@ package org.bukkit; import static org.junit.jupiter.api.Assertions.*; -import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.MinecraftKey; +import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.support.AbstractTestingBase; @@ -12,8 +13,8 @@ public class EnchantmentTest extends AbstractTestingBase { @Test public void verifyMapping() { - for (MinecraftKey key : BuiltInRegistries.ENCHANTMENT.keySet()) { - net.minecraft.world.item.enchantment.Enchantment nms = BuiltInRegistries.ENCHANTMENT.get(key); + for (MinecraftKey key : CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT).keySet()) { + net.minecraft.world.item.enchantment.Enchantment nms = CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT).get(key); Enchantment bukkitById = Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(key)); diff --git a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java index d0db98bc16..a56c681a98 100644 --- a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java @@ -7,10 +7,10 @@ import java.util.Map; import net.minecraft.core.BlockPosition; import net.minecraft.core.component.DataComponents; import net.minecraft.world.EnumHand; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.item.Equipable; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemRecord; import net.minecraft.world.level.BlockAccessAir; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.BlockFalling; @@ -74,7 +74,11 @@ public class PerMaterialTest extends AbstractTestingBase { @ParameterizedTest @EnumSource(value = Material.class, names = "LEGACY_.*", mode = EnumSource.Mode.MATCH_NONE) public void isRecord(Material material) { - assertThat(material.isRecord(), is(CraftMagicNumbers.getItem(material) instanceof ItemRecord)); + if (material.isBlock()) { + assertFalse(material.isRecord()); + } else { + assertThat(material.isRecord(), is(CraftMagicNumbers.getItem(material).components().has(DataComponents.JUKEBOX_PLAYABLE))); + } } @ParameterizedTest @@ -304,7 +308,8 @@ public class PerMaterialTest extends AbstractTestingBase { @EnumSource(value = Material.class, names = "LEGACY_.*", mode = EnumSource.Mode.MATCH_NONE) public void testEquipmentSlot(Material material) { if (material.isItem()) { - EquipmentSlot expected = CraftEquipmentSlot.getSlot(EntityInsentient.getEquipmentSlotForItem(CraftItemStack.asNMSCopy(new ItemStack(material)))); + Equipable equipable = Equipable.get(CraftItemStack.asNMSCopy(new ItemStack(material))); + EquipmentSlot expected = CraftEquipmentSlot.getSlot(equipable != null ? equipable.getEquipmentSlot() : EnumItemSlot.MAINHAND); assertThat(material.getEquipmentSlot(), is(expected)); } } diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java index cf3a60c179..b2ae19da82 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java @@ -2,7 +2,8 @@ package org.bukkit.craftbukkit.inventory; import static org.bukkit.support.MatcherAssert.*; import static org.hamcrest.Matchers.*; -import net.minecraft.world.item.enchantment.Enchantments; +import org.bukkit.craftbukkit.enchantments.CraftEnchantment; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.support.AbstractTestingBase; import org.junit.jupiter.api.Test; @@ -12,7 +13,7 @@ public class NMSCraftItemStackTest extends AbstractTestingBase { @Test public void testCloneEnchantedItem() throws Exception { net.minecraft.world.item.ItemStack nmsItemStack = new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.POTION); - nmsItemStack.enchant(Enchantments.SHARPNESS, 1); + nmsItemStack.enchant(CraftEnchantment.bukkitToMinecraftHolder(Enchantment.SHARPNESS), 1); ItemStack itemStack = CraftItemStack.asCraftMirror(nmsItemStack); ItemStack clone = itemStack.clone(); assertThat(clone.getType(), is(itemStack.getType())); 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 5dca082dc5..9b78ced4c3 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 @@ -123,6 +123,8 @@ public class LegacyTest extends AbstractTestingBase { // 1.20.5 Material.ARMADILLO_SCUTE, Material.ARMADILLO_SPAWN_EGG, Material.BOGGED_SPAWN_EGG, Material.WIND_CHARGE, Material.WOLF_ARMOR, Material.VAULT, Material.HEAVY_CORE, Material.MACE, Material.FLOW_BANNER_PATTERN, Material.GUSTER_BANNER_PATTERN, Material.FLOW_ARMOR_TRIM_SMITHING_TEMPLATE, Material.BOLT_ARMOR_TRIM_SMITHING_TEMPLATE, Material.FLOW_POTTERY_SHERD, Material.GUSTER_POTTERY_SHERD, Material.SCRAPE_POTTERY_SHERD, Material.BREEZE_ROD, Material.OMINOUS_TRIAL_KEY, Material.OMINOUS_BOTTLE, + // 1.21 + Material.MUSIC_DISC_CREATOR, Material.MUSIC_DISC_CREATOR_MUSIC_BOX, Material.MUSIC_DISC_PRECIPICE, // 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/util/ApiVersionTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/util/ApiVersionTest.java index 42ecc28d1b..9f62ad1d5b 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/util/ApiVersionTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/util/ApiVersionTest.java @@ -66,7 +66,14 @@ public class ApiVersionTest extends AbstractTestingBase { @Test public void testCurrentVersionUpdated() { - ApiVersion apiVersionOne = ApiVersion.getOrCreateVersion(SharedConstants.getCurrentVersion().getName()); + ApiVersion apiVersionOne = null; + try { + apiVersionOne = ApiVersion.getOrCreateVersion(SharedConstants.getCurrentVersion().getName()); + } catch (IllegalArgumentException ex) { + if (!SharedConstants.getCurrentVersion().isStable()) { + return; + } + } ApiVersion apiVersionTwo = ApiVersion.CURRENT; assertEquals(apiVersionOne, apiVersionTwo, "The current version in ApiVersion not match current minecraft version"); 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 22c2efb665..c4076fb3c1 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 @@ -9,9 +9,11 @@ import net.minecraft.world.effect.MobEffectList; import net.minecraft.world.entity.animal.WolfVariant; import net.minecraft.world.item.Instrument; import org.bukkit.GameEvent; +import org.bukkit.JukeboxSong; import org.bukkit.MusicInstrument; import org.bukkit.block.BlockType; import org.bukkit.craftbukkit.CraftGameEvent; +import org.bukkit.craftbukkit.CraftJukeboxSong; import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.block.CraftBlockType; import org.bukkit.craftbukkit.damage.CraftDamageType; @@ -51,6 +53,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider { register(TrimMaterial.class, Registries.TRIM_MATERIAL, CraftTrimMaterial.class, net.minecraft.world.item.armortrim.TrimMaterial.class); register(TrimPattern.class, Registries.TRIM_PATTERN, CraftTrimPattern.class, net.minecraft.world.item.armortrim.TrimPattern.class); register(DamageType.class, Registries.DAMAGE_TYPE, CraftDamageType.class, net.minecraft.world.damagesource.DamageType.class); + register(JukeboxSong.class, Registries.JUKEBOX_SONG, CraftJukeboxSong.class, net.minecraft.world.item.JukeboxSong.class); register(Wolf.Variant.class, Registries.WOLF_VARIANT, CraftWolf.CraftVariant.class, WolfVariant.class); register(ItemType.class, Registries.ITEM, CraftItemType.class, net.minecraft.world.item.Item.class, true); register(BlockType.class, Registries.BLOCK, CraftBlockType.class, net.minecraft.world.level.block.Block.class, true);