mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
bd38e0318a
Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f02baa38 PR-988: Add World#getIntersectingChunks(BoundingBox) 9321d665 Move getItemInUse up to LivingEntity 819eef73 PR-959: Add access to current item's remaining ticks c4fdadb0 SPIGOT-7601: Add AbstractArrow#getItem be8261ca Add support for Java 22 26119676 PR-979: Add more translation keys 66753362 PR-985: Correct book maximum pages and characters per page documentation c8be92fa PR-980: Improve getArmorContents() documentation f1120ee2 PR-983: Expose riptide velocity to PlayerRiptideEvent CraftBukkit Changes: dfaa89bbe PR-1369: Add World#getIntersectingChunks(BoundingBox) 51bbab2b9 Move getItemInUse up to LivingEntity 668e09602 PR-1331: Add access to current item's remaining ticks a639406d1 SPIGOT-7601: Add AbstractArrow#getItem 0398930fc SPIGOT-7602: Allow opening in-world horse and related inventories ffd15611c SPIGOT-7608: Allow empty lists to morph to any PDT list 2188dcfa9 Add support for Java 22 45d6a609f SPIGOT-7604: Revert "SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime" 06d915943 SPIGOT-7365: DamageCause blocked by shield should trigger invulnerableTime ca3bc3707 PR-1361: Add more translation keys 366c3ca80 SPIGOT-7600: EntityChangeBlockEvent is not fired for frog eggs 06d0f9ba8 SPIGOT-7593: Fix sapling growth physics / client-side updates 45c2608e4 PR-1366: Expose riptide velocity to PlayerRiptideEvent 29b6bb79b SPIGOT-7587: Remove fixes for now-resolved MC-142590 and MC-109346
106 lines
5.0 KiB
Diff
106 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
|
Date: Thu, 31 Aug 2023 17:32:48 +0200
|
|
Subject: [PATCH] Fix silent equipment change for mobs
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
index d1833dcc92b1570e62a1941bbea6d66ff0b2ee5f..4e8aee81cb9e9fe4a4e5df4e228c0314b3af486b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -1047,13 +1047,20 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
|
|
|
@Override
|
|
public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
|
|
+ // Paper start - Fix silent equipment change
|
|
+ setItemSlot(slot, stack, false);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) {
|
|
+ // Paper end - Fix silent equipment change
|
|
this.verifyEquippedItem(stack);
|
|
switch (slot.getType()) {
|
|
case HAND:
|
|
- this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack);
|
|
+ this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change
|
|
break;
|
|
case ARMOR:
|
|
- this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack);
|
|
+ this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
|
index 40664cc7e3665432a2ab5e552802c3fc3edbdb22..586e3e92ccc275446df6dbbff9bf010a37a9aa8f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
|
@@ -250,8 +250,8 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
|
|
// Paper end - shouldBurnInDay API
|
|
|
|
@Override
|
|
- public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
|
|
- super.setItemSlot(slot, stack);
|
|
+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { // Paper - Fix silent equipment change
|
|
+ super.setItemSlot(slot, stack, silent); // Paper - Fix silent equipment change
|
|
if (!this.level().isClientSide) {
|
|
this.reassessWeaponGoal();
|
|
}
|
|
diff --git a/src/test/java/io/papermc/paper/entity/EntitySetItemSlotSilentOverrideTest.java b/src/test/java/io/papermc/paper/entity/EntitySetItemSlotSilentOverrideTest.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..81947843d1f2f7dc6f59d7b52f327d60b17d0dcc
|
|
--- /dev/null
|
|
+++ b/src/test/java/io/papermc/paper/entity/EntitySetItemSlotSilentOverrideTest.java
|
|
@@ -0,0 +1,51 @@
|
|
+package io.papermc.paper.entity;
|
|
+
|
|
+import io.github.classgraph.ClassGraph;
|
|
+import io.github.classgraph.ClassInfo;
|
|
+import io.github.classgraph.MethodInfo;
|
|
+import io.github.classgraph.MethodInfoList;
|
|
+import io.github.classgraph.MethodParameterInfo;
|
|
+import io.github.classgraph.ScanResult;
|
|
+import java.util.ArrayList;
|
|
+import java.util.List;
|
|
+import java.util.stream.Stream;
|
|
+import org.bukkit.support.AbstractTestingBase;
|
|
+import org.junit.jupiter.params.ParameterizedTest;
|
|
+import org.junit.jupiter.params.provider.MethodSource;
|
|
+
|
|
+import static org.junit.jupiter.api.Assertions.fail;
|
|
+
|
|
+public class EntitySetItemSlotSilentOverrideTest extends AbstractTestingBase {
|
|
+
|
|
+ public static Stream<ClassInfo> parameters() {
|
|
+ final List<ClassInfo> classInfo = new ArrayList<>();
|
|
+ try (ScanResult scanResult = new ClassGraph()
|
|
+ .enableClassInfo()
|
|
+ .enableMethodInfo()
|
|
+ .whitelistPackages("net.minecraft")
|
|
+ .scan()
|
|
+ ) {
|
|
+ for (final ClassInfo subclass : scanResult.getSubclasses("net.minecraft.world.entity.LivingEntity")) {
|
|
+ final MethodInfoList setItemSlot = subclass.getDeclaredMethodInfo("setItemSlot");
|
|
+ if (!setItemSlot.isEmpty()) {
|
|
+ classInfo.add(subclass);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return classInfo.stream();
|
|
+ }
|
|
+
|
|
+ @ParameterizedTest
|
|
+ @MethodSource("parameters")
|
|
+ public void checkSetItemSlotSilentOverrides(ClassInfo overridesSetItemSlot) {
|
|
+ final MethodInfoList setItemSlot = overridesSetItemSlot.getDeclaredMethodInfo("setItemSlot");
|
|
+ for (final MethodInfo methodInfo : setItemSlot) {
|
|
+ for (final MethodParameterInfo methodParameterInfo : methodInfo.getParameterInfo()) {
|
|
+ if ("boolean".equals(methodParameterInfo.getTypeDescriptor().toStringWithSimpleNames())) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ fail(overridesSetItemSlot.getName() + " needs to override setItemSlot with the boolean silent parameter as well");
|
|
+ }
|
|
+}
|