From c9e7a34e4b3d5dafc07754f0ac0e73d7efae4c3c Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 23 Oct 2024 20:50:46 +0200 Subject: [PATCH] Work work work work --- .../server/Add-EntityDamageItemEvent.patch | 94 +++++++++++++++++++ .../server/Add-PlayerArmSwingEvent.patch | 0 .../server/Add-PlayerSetSpawnEvent.patch | 4 +- .../server/Add-System.out-err-catcher.patch | 0 .../Add-missing-forceDrop-toggles.patch | 54 +++++------ ...riting-of-comments-to-server.propert.patch | 0 ...target-without-changing-other-things.patch | 0 ...g-option-for-Piglins-guarding-chests.patch | 2 +- ...tem-frame-map-cursor-update-interval.patch | 0 ...n-t-apply-cramming-damage-to-players.patch | 14 +-- ...from-signs-not-firing-command-events.patch | 17 ++-- ...k-event-leave-message-not-being-sent.patch | 0 ...-of-Block-applyBoneMeal-always-being.patch | 0 ...ers-respect-inventory-max-stack-size.patch | 0 ...mize-entity-tracker-passenger-checks.patch | 0 ...ptimize-indirect-passenger-iteration.patch | 0 ...-AFK-kick-while-watching-end-credits.patch | 6 +- ...nd-timings-for-sensors-and-behaviors.patch | 1 + .../{unapplied => }/server/Stinger-API.patch | 15 +-- ...etChunkIfLoadedImmediately-in-places.patch | 6 +- .../server/Add-EntityDamageItemEvent.patch | 89 ------------------ 21 files changed, 146 insertions(+), 156 deletions(-) create mode 100644 patches/server/Add-EntityDamageItemEvent.patch rename patches/{unapplied => }/server/Add-PlayerArmSwingEvent.patch (100%) rename patches/{unapplied => }/server/Add-PlayerSetSpawnEvent.patch (99%) rename patches/{unapplied => }/server/Add-System.out-err-catcher.patch (100%) rename patches/{unapplied => }/server/Add-missing-forceDrop-toggles.patch (70%) rename patches/{unapplied => }/server/Allow-skipping-writing-of-comments-to-server.propert.patch (100%) rename patches/{unapplied => }/server/Change-EnderEye-target-without-changing-other-things.patch (100%) rename patches/{unapplied => }/server/Config-option-for-Piglins-guarding-chests.patch (91%) rename patches/{unapplied => }/server/Configurable-item-frame-map-cursor-update-interval.patch (100%) rename patches/{unapplied => }/server/Don-t-apply-cramming-damage-to-players.patch (56%) rename patches/{unapplied => }/server/Fix-commands-from-signs-not-firing-command-events.patch (92%) rename patches/{unapplied => }/server/Fix-kick-event-leave-message-not-being-sent.patch (100%) rename patches/{unapplied => }/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch (100%) rename patches/{unapplied => }/server/Make-hoppers-respect-inventory-max-stack-size.patch (100%) rename patches/{unapplied => }/server/Optimize-entity-tracker-passenger-checks.patch (100%) rename patches/{unapplied => }/server/Optimize-indirect-passenger-iteration.patch (100%) rename patches/{unapplied => }/server/Prevent-AFK-kick-while-watching-end-credits.patch (88%) rename patches/{unapplied => }/server/Rate-options-and-timings-for-sensors-and-behaviors.patch (99%) rename patches/{unapplied => }/server/Stinger-API.patch (81%) rename patches/{unapplied => }/server/Use-getChunkIfLoadedImmediately-in-places.patch (83%) delete mode 100644 patches/unapplied/server/Add-EntityDamageItemEvent.patch diff --git a/patches/server/Add-EntityDamageItemEvent.patch b/patches/server/Add-EntityDamageItemEvent.patch new file mode 100644 index 0000000000..78c20b02a1 --- /dev/null +++ b/patches/server/Add-EntityDamageItemEvent.patch @@ -0,0 +1,94 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Tue, 22 Dec 2020 13:52:48 -0800 +Subject: [PATCH] Add EntityDamageItemEvent + + +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { + return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; + } + +- public void hurtAndBreak(int amount, ServerLevel world, @Nullable ServerPlayer player, Consumer breakCallback) { ++ public void hurtAndBreak(int amount, ServerLevel world, @Nullable LivingEntity player, Consumer breakCallback) { // Paper - Add EntityDamageItemEvent + int j = this.processDurabilityChange(amount, world, player); + // CraftBukkit start +- if (player != null) { +- PlayerItemDamageEvent event = new PlayerItemDamageEvent(player.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j); ++ if (player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent ++ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j); // Paper - Add EntityDamageItemEvent + event.getPlayer().getServer().getPluginManager().callEvent(event); + + if (j != event.getDamage() || event.isCancelled()) { +@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { + } + + j = event.getDamage(); ++ // Paper start - Add EntityDamageItemEvent ++ } else if (player != null) { ++ io.papermc.paper.event.entity.EntityDamageItemEvent event = new io.papermc.paper.event.entity.EntityDamageItemEvent(player.getBukkitLivingEntity(), CraftItemStack.asCraftMirror(this), amount); ++ if (!event.callEvent()) { ++ return; ++ } ++ j = event.getDamage(); ++ // Paper end - Add EntityDamageItemEvent + } + // CraftBukkit end + +@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { + + } + +- private int processDurabilityChange(int baseDamage, ServerLevel world, @Nullable ServerPlayer player) { +- return !this.isDamageableItem() ? 0 : (player != null && player.hasInfiniteMaterials() ? 0 : (baseDamage > 0 ? EnchantmentHelper.processDurabilityChange(world, this, baseDamage) : baseDamage)); ++ private int processDurabilityChange(int baseDamage, ServerLevel world, @Nullable LivingEntity player) { // Paper - Add EntityDamageItemEvent ++ return !this.isDamageableItem() ? 0 : (player instanceof ServerPlayer && player.hasInfiniteMaterials() ? 0 : (baseDamage > 0 ? EnchantmentHelper.processDurabilityChange(world, this, baseDamage) : baseDamage)); // Paper - Add EntityDamageItemEvent + } + +- private void applyDamage(int damage, @Nullable ServerPlayer player, Consumer breakCallback) { +- if (player != null) { +- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(player, this, damage); ++ private void applyDamage(int damage, @Nullable LivingEntity player, Consumer breakCallback) { // Paper - Add EntityDamageItemEvent ++ if (player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent ++ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverPlayer, this, damage); // Paper - Add EntityDamageItemEvent + } + + this.setDamageValue(damage); + if (this.isBroken()) { + Item item = this.getItem(); + // CraftBukkit start - Check for item breaking +- if (this.count == 1 && player != null) { +- org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(player, this); ++ if (this.count == 1 && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(serverPlayer, this); // Paper - Add EntityDamageItemEvent + } + // CraftBukkit end + +@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { + entityplayer = null; + } + +- this.hurtAndBreak(amount, worldserver, entityplayer, (item) -> { ++ this.hurtAndBreak(amount, worldserver, entity, (item) -> { // Paper - Add EntityDamageItemEvent + entity.onEquippedItemBroken(item, slot); + }); + } +diff --git a/src/main/java/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java b/src/main/java/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java ++++ b/src/main/java/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java +@@ -0,0 +0,0 @@ public record ChangeItemDamage(LevelBasedValue amount) implements EnchantmentEnt + public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity user, Vec3 pos) { + ItemStack itemStack = context.itemStack(); + if (itemStack.has(DataComponents.MAX_DAMAGE) && itemStack.has(DataComponents.DAMAGE)) { +- ServerPlayer serverPlayer2 = context.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null; ++ // ServerPlayer serverPlayer2 = context.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null; // Paper - EntityDamageItemEvent - always pass in entity + int i = (int)this.amount.calculate(level); +- itemStack.hurtAndBreak(i, world, serverPlayer2, context.onBreak()); ++ itemStack.hurtAndBreak(i, world, context.owner(), context.onBreak()); // Paper - EntityDamageItemEvent - always pass in entity + } + } + diff --git a/patches/unapplied/server/Add-PlayerArmSwingEvent.patch b/patches/server/Add-PlayerArmSwingEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PlayerArmSwingEvent.patch rename to patches/server/Add-PlayerArmSwingEvent.patch diff --git a/patches/unapplied/server/Add-PlayerSetSpawnEvent.patch b/patches/server/Add-PlayerSetSpawnEvent.patch similarity index 99% rename from patches/unapplied/server/Add-PlayerSetSpawnEvent.patch rename to patches/server/Add-PlayerSetSpawnEvent.patch index 17506b4d08..8d858f1e7b 100644 --- a/patches/unapplied/server/Add-PlayerSetSpawnEvent.patch +++ b/patches/server/Add-PlayerSetSpawnEvent.patch @@ -159,7 +159,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { // CraftBukkit end - if (dimensiontransition.missingRespawnBlock()) { + if (teleporttransition.missingRespawnBlock()) { entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.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.setRespawnPosition(null, null, 0f, false, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed // Paper - PlayerSetSpawnEvent @@ -177,7 +177,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - entityplayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.RESPAWN_ANCHOR); // CraftBukkit + if (entityplayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent world.playSound((Player) null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F); - return InteractionResult.SUCCESS; + return InteractionResult.SUCCESS_SERVER; + // Paper start - Add PlayerSetSpawnEvent + } else { + return InteractionResult.FAIL; diff --git a/patches/unapplied/server/Add-System.out-err-catcher.patch b/patches/server/Add-System.out-err-catcher.patch similarity index 100% rename from patches/unapplied/server/Add-System.out-err-catcher.patch rename to patches/server/Add-System.out-err-catcher.patch diff --git a/patches/unapplied/server/Add-missing-forceDrop-toggles.patch b/patches/server/Add-missing-forceDrop-toggles.patch similarity index 70% rename from patches/unapplied/server/Add-missing-forceDrop-toggles.patch rename to patches/server/Add-missing-forceDrop-toggles.patch index f939302057..07077e8fd8 100644 --- a/patches/unapplied/server/Add-missing-forceDrop-toggles.patch +++ b/patches/server/Add-missing-forceDrop-toggles.patch @@ -12,9 +12,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 simpleContainer.removeItemType(Items.WHEAT, m); ItemStack itemStack = simpleContainer.addItem(new ItemStack(Items.BREAD, l)); if (!itemStack.isEmpty()) { -+ entity.forceDrops = true; // Paper - Add missing forceDrop toggles - entity.spawnAtLocation(itemStack, 0.5F); -+ entity.forceDrops = false; // Paper - Add missing forceDrop toggles ++ villager.forceDrops = true; // Paper - Add missing forceDrop toggles + villager.spawnAtLocation(world, itemStack, 0.5F); ++ villager.forceDrops = false; // Paper - Add missing forceDrop toggles } } } @@ -23,35 +23,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/animal/Panda.java +++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java @@ -0,0 +0,0 @@ public class Panda extends Animal { - List list1 = loottable.getRandomItems(lootparams); - Iterator iterator1 = list1.iterator(); -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles - while (iterator1.hasNext()) { - ItemStack itemstack = (ItemStack) iterator1.next(); - - this.spawnAtLocation(itemstack); + if (world1 instanceof ServerLevel worldserver) { + if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { ++ this.forceDrops = true; // Paper - Add missing forceDrop toggles + this.dropFromGiftLootTable(worldserver, BuiltInLootTables.PANDA_SNEEZE, this::spawnAtLocation); ++ this.forceDrops = false; // Paper - Add missing forceDrop toggles } -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles } - } @@ -0,0 +0,0 @@ public class Panda extends Animal { - ItemStack itemstack1 = this.getItemBySlot(EquipmentSlot.MAINHAND); + ItemStack itemstack1 = this.getItemBySlot(EquipmentSlot.MAINHAND); - if (!itemstack1.isEmpty() && !player.hasInfiniteMaterials()) { -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.spawnAtLocation(itemstack1); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles - } + if (!itemstack1.isEmpty() && !player.hasInfiniteMaterials()) { ++ this.forceDrops = true; // Paper - Add missing forceDrop toggles + this.spawnAtLocation(worldserver, itemstack1); ++ this.forceDrops = false; // Paper - Add missing forceDrop toggles + } - this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemstack.getItem(), 1)); + this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemstack.getItem(), 1)); @@ -0,0 +0,0 @@ public class Panda extends Animal { ItemStack itemstack = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemstack.isEmpty()) { + Panda.this.forceDrops = true; // Paper - Add missing forceDrop toggles - Panda.this.spawnAtLocation(itemstack); + Panda.this.spawnAtLocation(getServerLevel(Panda.this.level()), itemstack); + Panda.this.forceDrops = false; // Paper - Add missing forceDrop toggles Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); int i = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10; @@ -63,9 +59,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento @Override protected void finishConversion(ServerLevel world) { - PiglinAi.cancelAdmiring(this); + PiglinAi.cancelAdmiring(world, this); + this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.inventory.removeAllItems().forEach(this::spawnAtLocation); + this.inventory.removeAllItems().forEach((itemstack) -> { + this.spawnAtLocation(world, itemstack); + }); + this.forceDrops = false; // Paper - Add missing forceDrop toggles super.finishConversion(world); } @@ -76,20 +74,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java @@ -0,0 +0,0 @@ public class PiglinAi { - private static void holdInOffhand(Piglin piglin, ItemStack stack) { + private static void holdInOffhand(ServerLevel world, Piglin piglin, ItemStack stack) { if (PiglinAi.isHoldingItemInOffHand(piglin)) { + piglin.forceDrops = true; // Paper - Add missing forceDrop toggles - piglin.spawnAtLocation(piglin.getItemInHand(InteractionHand.OFF_HAND)); + piglin.spawnAtLocation(world, piglin.getItemInHand(InteractionHand.OFF_HAND)); + piglin.forceDrops = false; // Paper - Add missing forceDrop toggles } piglin.holdInOffHand(stack); @@ -0,0 +0,0 @@ public class PiglinAi { - protected static void cancelAdmiring(Piglin piglin) { + protected static void cancelAdmiring(ServerLevel world, Piglin piglin) { if (PiglinAi.isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) { + piglin.forceDrops = true; // Paper - Add missing forceDrop toggles - piglin.spawnAtLocation(piglin.getOffhandItem()); + piglin.spawnAtLocation(world, piglin.getOffhandItem()); + piglin.forceDrops = false; // Paper - Add missing forceDrop toggles piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); } @@ -103,8 +101,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { + this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.spawnAtLocation(itemstack1); + this.spawnAtLocation(world, itemstack1); + this.forceDrops = false; // Paper - Add missing forceDrop toggles } - this.onItemPickup(item); + this.onItemPickup(itemEntity); diff --git a/patches/unapplied/server/Allow-skipping-writing-of-comments-to-server.propert.patch b/patches/server/Allow-skipping-writing-of-comments-to-server.propert.patch similarity index 100% rename from patches/unapplied/server/Allow-skipping-writing-of-comments-to-server.propert.patch rename to patches/server/Allow-skipping-writing-of-comments-to-server.propert.patch diff --git a/patches/unapplied/server/Change-EnderEye-target-without-changing-other-things.patch b/patches/server/Change-EnderEye-target-without-changing-other-things.patch similarity index 100% rename from patches/unapplied/server/Change-EnderEye-target-without-changing-other-things.patch rename to patches/server/Change-EnderEye-target-without-changing-other-things.patch diff --git a/patches/unapplied/server/Config-option-for-Piglins-guarding-chests.patch b/patches/server/Config-option-for-Piglins-guarding-chests.patch similarity index 91% rename from patches/unapplied/server/Config-option-for-Piglins-guarding-chests.patch rename to patches/server/Config-option-for-Piglins-guarding-chests.patch index 981eab76f0..df0760edf9 100644 --- a/patches/unapplied/server/Config-option-for-Piglins-guarding-chests.patch +++ b/patches/server/Config-option-for-Piglins-guarding-chests.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class PiglinAi { } - public static void angerNearbyPiglins(Player player, boolean blockOpen) { + public static void angerNearbyPiglins(ServerLevel world, Player player, boolean blockOpen) { + if (!player.level().paperConfig().entities.behavior.piglinsGuardChests) return; // Paper - Config option for Piglins guarding chests List list = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0D)); diff --git a/patches/unapplied/server/Configurable-item-frame-map-cursor-update-interval.patch b/patches/server/Configurable-item-frame-map-cursor-update-interval.patch similarity index 100% rename from patches/unapplied/server/Configurable-item-frame-map-cursor-update-interval.patch rename to patches/server/Configurable-item-frame-map-cursor-update-interval.patch diff --git a/patches/unapplied/server/Don-t-apply-cramming-damage-to-players.patch b/patches/server/Don-t-apply-cramming-damage-to-players.patch similarity index 56% rename from patches/unapplied/server/Don-t-apply-cramming-damage-to-players.patch rename to patches/server/Don-t-apply-cramming-damage-to-players.patch index a6e1334f2c..5fcc74f34c 100644 --- a/patches/unapplied/server/Don-t-apply-cramming-damage-to-players.patch +++ b/patches/server/Don-t-apply-cramming-damage-to-players.patch @@ -14,20 +14,12 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -0,0 +0,0 @@ import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.Unit; - import net.minecraft.world.damagesource.DamageSource; -+import net.minecraft.world.damagesource.DamageSources; - import net.minecraft.world.effect.MobEffectInstance; - import net.minecraft.world.effect.MobEffects; - import net.minecraft.world.entity.Entity; @@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { @Override - public boolean isInvulnerableTo(DamageSource damageSource) { -- return super.isInvulnerableTo(damageSource) || this.isChangingDimension(); -+ return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || !this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource == damageSources().cramming(); // Paper - disable player cramming + public boolean isInvulnerableTo(ServerLevel world, DamageSource source) { +- return super.isInvulnerableTo(world, source) || this.isChangingDimension() && !source.is(DamageTypes.ENDER_PEARL); ++ return super.isInvulnerableTo(world, source) || (this.isChangingDimension() && !source.is(DamageTypes.ENDER_PEARL)) || (!this.level().paperConfig().collisions.allowPlayerCrammingDamage && source.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; } @Override diff --git a/patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch similarity index 92% rename from patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch rename to patches/server/Fix-commands-from-signs-not-firing-command-events.patch index 2bccb70e1e..b4f4e76d67 100644 --- a/patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch +++ b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch @@ -61,7 +61,7 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntit index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C +@@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity { ClickEvent chatclickable = chatmodifier.getClickEvent(); if (chatclickable != null && chatclickable.getAction() == ClickEvent.Action.RUN_COMMAND) { @@ -80,16 +80,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 flag1 = true; } } -@@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C +@@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity { String s = player == null ? "Sign" : player.getName().getString(); Object object = player == null ? Component.literal("Sign") : player.getDisplayName(); +- // CraftBukkit - commandSource +- return new CommandSourceStack(this.commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, s, (Component) object, world.getServer(), player); + // Paper start - Fix commands from signs not firing command events -+ CommandSource commandSource = this.level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this) { ++ CommandSource commandSource = this.level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this.commandSource) { + @Override + public void sendSystemMessage(Component message) { -+ if (player != null) { -+ player.sendSystemMessage(message); ++ if (player instanceof final ServerPlayer serverPlayer) { ++ serverPlayer.sendSystemMessage(message); + } + } + @@ -97,10 +99,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean acceptsFailure() { + return true; + } -+ } : this; ++ } : this.commandSource; + // Paper end - Fix commands from signs not firing command events - // CraftBukkit - this -- return new CommandSourceStack(this, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, s, (Component) object, world.getServer(), player); ++ // CraftBukkit - this + return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, s, (Component) object, world.getServer(), player); // Paper - Fix commands from signs not firing command events } diff --git a/patches/unapplied/server/Fix-kick-event-leave-message-not-being-sent.patch b/patches/server/Fix-kick-event-leave-message-not-being-sent.patch similarity index 100% rename from patches/unapplied/server/Fix-kick-event-leave-message-not-being-sent.patch rename to patches/server/Fix-kick-event-leave-message-not-being-sent.patch diff --git a/patches/unapplied/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch b/patches/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch similarity index 100% rename from patches/unapplied/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch rename to patches/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch diff --git a/patches/unapplied/server/Make-hoppers-respect-inventory-max-stack-size.patch b/patches/server/Make-hoppers-respect-inventory-max-stack-size.patch similarity index 100% rename from patches/unapplied/server/Make-hoppers-respect-inventory-max-stack-size.patch rename to patches/server/Make-hoppers-respect-inventory-max-stack-size.patch diff --git a/patches/unapplied/server/Optimize-entity-tracker-passenger-checks.patch b/patches/server/Optimize-entity-tracker-passenger-checks.patch similarity index 100% rename from patches/unapplied/server/Optimize-entity-tracker-passenger-checks.patch rename to patches/server/Optimize-entity-tracker-passenger-checks.patch diff --git a/patches/unapplied/server/Optimize-indirect-passenger-iteration.patch b/patches/server/Optimize-indirect-passenger-iteration.patch similarity index 100% rename from patches/unapplied/server/Optimize-indirect-passenger-iteration.patch rename to patches/server/Optimize-indirect-passenger-iteration.patch diff --git a/patches/unapplied/server/Prevent-AFK-kick-while-watching-end-credits.patch b/patches/server/Prevent-AFK-kick-while-watching-end-credits.patch similarity index 88% rename from patches/unapplied/server/Prevent-AFK-kick-while-watching-end-credits.patch rename to patches/server/Prevent-AFK-kick-while-watching-end-credits.patch index d6608eab0c..d60b01529a 100644 --- a/patches/unapplied/server/Prevent-AFK-kick-while-watching-end-credits.patch +++ b/patches/server/Prevent-AFK-kick-while-watching-end-credits.patch @@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - --this.dropSpamTickCount; - } - + this.tabSpamThrottler.tick(); // Paper - configurable tab spam limits + this.recipeSpamPackets.tick(); // Paper - auto recipe limit + this.dropSpamThrottler.tick(); - if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { + if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 diff --git a/patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch b/patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch similarity index 99% rename from patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch rename to patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch index 91af1425a3..793fdc2240 100644 --- a/patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch +++ b/patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch @@ -126,6 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - configurable sensor tick rate and timings + this.timeToTick = java.util.Objects.requireNonNullElse(world.paperConfig().tickRates.sensor.get(entity.getType(), this.configKey), this.scanRate); + this.timing.startTiming(); + this.updateTargetingConditionRanges(entity); + // Paper end this.doTick(world, entity); + this.timing.stopTiming(); // Paper - sensor timings diff --git a/patches/unapplied/server/Stinger-API.patch b/patches/server/Stinger-API.patch similarity index 81% rename from patches/unapplied/server/Stinger-API.patch rename to patches/server/Stinger-API.patch index cc8b671568..8bee8e416a 100644 --- a/patches/unapplied/server/Stinger-API.patch +++ b/patches/server/Stinger-API.patch @@ -9,21 +9,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - } - // Paper end + public boolean isInvulnerable() { + return this.getHandle().isInvulnerableTo((ServerLevel) this.getHandle().level(), this.getHandle().damageSources().generic()); } + // Paper start - Bee Stinger API + @Override + public int getBeeStingerCooldown() { + return getHandle().removeStingerTime; + } - - // Paper start - Add methods for working with arrows stuck in living entities - @Override -@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - } - // Paper end - Add methods for working with arrows stuck in living entities - ++ + @Override + public void setBeeStingerCooldown(int ticks) { + getHandle().removeStingerTime = ticks; @@ -51,7 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.getHandle().removeStingerTime; + } + // Paper end - Bee Stinger API -+ + @Override public void damage(double amount) { - this.damage(amount, this.getHandle().damageSources().generic()); diff --git a/patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch similarity index 83% rename from patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch rename to patches/server/Use-getChunkIfLoadedImmediately-in-places.patch index a5c41de0ea..9d2239f9db 100644 --- a/patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch +++ b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch @@ -11,7 +11,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent public LevelChunk getChunkIfLoaded(int x, int z) { @@ -25,9 +25,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + public CraftServer getCraftServer() { return (CraftServer) Bukkit.getServer(); } - + // Paper start - Use getChunkIfLoadedImmediately + @Override + public boolean hasChunk(int chunkX, int chunkZ) { @@ -35,9 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - Use getChunkIfLoadedImmediately + + public abstract ResourceKey getTypeKey(); - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper - create paper world config diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java diff --git a/patches/unapplied/server/Add-EntityDamageItemEvent.patch b/patches/unapplied/server/Add-EntityDamageItemEvent.patch deleted file mode 100644 index 832ee6664c..0000000000 --- a/patches/unapplied/server/Add-EntityDamageItemEvent.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Tue, 22 Dec 2020 13:52:48 -0800 -Subject: [PATCH] Add EntityDamageItemEvent - - -diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/ItemStack.java -+++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - return (Integer) this.getOrDefault(DataComponents.MAX_DAMAGE, 0); - } - -- public void hurtAndBreak(int amount, ServerLevel world, @Nullable ServerPlayer player, Consumer breakCallback) { -+ public void hurtAndBreak(int amount, ServerLevel world, @Nullable LivingEntity player, Consumer breakCallback) { // Paper - Add EntityDamageItemEvent - if (this.isDamageableItem()) { - if (player == null || !player.hasInfiniteMaterials()) { - if (amount > 0) { - amount = EnchantmentHelper.processDurabilityChange(world, this, amount); - // CraftBukkit start -- if (player != null) { -- PlayerItemDamageEvent event = new PlayerItemDamageEvent(player.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); -+ if (player instanceof ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent -+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); // Paper - Add EntityDamageItemEvent - event.getPlayer().getServer().getPluginManager().callEvent(event); - - if (amount != event.getDamage() || event.isCancelled()) { -@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - } - - amount = event.getDamage(); -+ // Paper start - Add EntityDamageItemEvent -+ } else if (player != null) { -+ io.papermc.paper.event.entity.EntityDamageItemEvent event = new io.papermc.paper.event.entity.EntityDamageItemEvent(player.getBukkitLivingEntity(), CraftItemStack.asCraftMirror(this), amount); -+ if (!event.callEvent()) { -+ return; -+ } -+ amount = event.getDamage(); -+ // Paper end - Add EntityDamageItemEvent - } - // CraftBukkit end - if (amount <= 0) { -@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - } - } - -- if (player != null && amount != 0) { -- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(player, this, this.getDamageValue() + amount); -+ if (player instanceof ServerPlayer serverPlayer && amount != 0) { // Paper - Add EntityDamageItemEvent -+ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverPlayer, this, this.getDamageValue() + amount); // Paper - Add EntityDamageItemEvent - } - - int j = this.getDamageValue() + amount; -@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - if (j >= this.getMaxDamage()) { - Item item = this.getItem(); - // CraftBukkit start - Check for item breaking -- if (this.count == 1 && player != null) { -- org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(player, this); -+ if (this.count == 1 && player != null && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(serverPlayer, this); // Paper - Add EntityDamageItemEvent - } - // CraftBukkit end - -@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - entityplayer = null; - } - -- this.hurtAndBreak(amount, worldserver, entityplayer, (item) -> { -+ this.hurtAndBreak(amount, worldserver, entity, (item) -> { // Paper - Add EntityDamageItemEvent - entity.onEquippedItemBroken(item, slot); - }); - } -diff --git a/src/main/java/net/minecraft/world/item/enchantment/effects/DamageItem.java b/src/main/java/net/minecraft/world/item/enchantment/effects/DamageItem.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/enchantment/effects/DamageItem.java -+++ b/src/main/java/net/minecraft/world/item/enchantment/effects/DamageItem.java -@@ -0,0 +0,0 @@ public record DamageItem(LevelBasedValue amount) implements EnchantmentEntityEff - - @Override - public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity user, Vec3 pos) { -- ServerPlayer serverPlayer2 = context.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null; -- context.itemStack().hurtAndBreak((int)this.amount.calculate(level), world, serverPlayer2, context.onBreak()); -+ // ServerPlayer serverPlayer2 = context.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null; // Paper - always pass in entity -+ context.itemStack().hurtAndBreak((int)this.amount.calculate(level), world, context.owner(), context.onBreak()); // Paper - always pass in entity - } - - @Override