mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
SPIGOT-5865: Piglin does not trigger EntityPickupItemEvent
This commit is contained in:
parent
2ab04d248a
commit
53c9562773
93
nms-patches/PiglinAI.patch
Normal file
93
nms-patches/PiglinAI.patch
Normal file
@ -0,0 +1,93 @@
|
||||
--- a/net/minecraft/server/PiglinAI.java
|
||||
+++ b/net/minecraft/server/PiglinAI.java
|
||||
@@ -52,7 +52,8 @@
|
||||
private static void b(EntityPiglin entitypiglin, BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
behaviorcontroller.a(Activity.FLIGHT, 10, ImmutableList.of(new BehaviorAttackTargetForget<>((entityliving) -> {
|
||||
return !d(entitypiglin, entityliving);
|
||||
- }), new BehaviorRunIf<>(PiglinAI::c, new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::n, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET);
|
||||
+ // CraftBukkit - decompile error
|
||||
+ }), new BehaviorRunIf<>((l) -> PiglinAI.c((EntityLiving) l), new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::n, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET);
|
||||
}
|
||||
|
||||
private static void c(BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
@@ -70,7 +71,8 @@
|
||||
}
|
||||
|
||||
private static void f(BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
- behaviorcontroller.a(Activity.RIDE, 10, ImmutableList.of(new BehaviorStartRiding<>(0.8F), new BehaviorLookTarget(PiglinAI::b, 8.0F), new BehaviorRunIf<>(Entity::isPassenger, a()), new BehaviorStopRiding<>(8, PiglinAI::a)), MemoryModuleType.RIDE_TARGET);
|
||||
+ // CraftBukkit - decompile error
|
||||
+ behaviorcontroller.a(Activity.RIDE, 10, ImmutableList.of(new BehaviorStartRiding<>(0.8F), new BehaviorLookTarget(PiglinAI::b, 8.0F), new BehaviorRunIf<>(Entity::isPassenger, a()), new BehaviorStopRiding<EntityPiglin, Entity>(8, PiglinAI::a)), MemoryModuleType.RIDE_TARGET);
|
||||
}
|
||||
|
||||
private static BehaviorGateSingle<EntityPiglin> a() {
|
||||
@@ -78,7 +80,8 @@
|
||||
}
|
||||
|
||||
private static BehaviorGateSingle<EntityPiglin> b() {
|
||||
- return new BehaviorGateSingle<>(ImmutableList.of(Pair.of(new BehaviorStrollRandomUnconstrained(0.6F), 2), Pair.of(BehaviorInteract.a(EntityTypes.PIGLIN, 8, MemoryModuleType.INTERACTION_TARGET, 0.6F, 2), 2), Pair.of(new BehaviorRunIf<>(PiglinAI::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1)));
|
||||
+ // CraftBukkit - decompile error
|
||||
+ return new BehaviorGateSingle<>(ImmutableList.of(Pair.of(new BehaviorStrollRandomUnconstrained(0.6F), 2), Pair.of(BehaviorInteract.a(EntityTypes.PIGLIN, 8, MemoryModuleType.INTERACTION_TARGET, 0.6F, 2), 2), Pair.of(new BehaviorRunIf<>((java.util.function.Predicate<EntityLiving>) PiglinAI::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1)));
|
||||
}
|
||||
|
||||
private static BehaviorWalkAway<BlockPosition> c() {
|
||||
@@ -95,10 +98,10 @@
|
||||
|
||||
protected static void b(EntityPiglin entitypiglin) {
|
||||
BehaviorController<EntityPiglin> behaviorcontroller = entitypiglin.getBehaviorController();
|
||||
- Activity activity = (Activity) behaviorcontroller.f().orElse((Object) null);
|
||||
+ Activity activity = (Activity) behaviorcontroller.f().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
behaviorcontroller.a((List) ImmutableList.of(Activity.ADMIRE_ITEM, Activity.FLIGHT, Activity.AVOID, Activity.CELEBRATE, Activity.RIDE, Activity.IDLE));
|
||||
- Activity activity1 = (Activity) behaviorcontroller.f().orElse((Object) null);
|
||||
+ Activity activity1 = (Activity) behaviorcontroller.f().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (activity != activity1) {
|
||||
d(entitypiglin).ifPresent(entitypiglin::a);
|
||||
@@ -130,14 +133,18 @@
|
||||
s(entitypiglin);
|
||||
ItemStack itemstack;
|
||||
|
||||
- if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET) {
|
||||
+ // CraftBukkit start
|
||||
+ if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, 0, false).isCancelled()) {
|
||||
entitypiglin.receive(entityitem, entityitem.getItemStack().getCount());
|
||||
itemstack = entityitem.getItemStack();
|
||||
entityitem.die();
|
||||
- } else {
|
||||
+ } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, entityitem.getItemStack().getCount() - 1, false).isCancelled()) {
|
||||
entitypiglin.receive(entityitem, 1);
|
||||
itemstack = a(entityitem);
|
||||
+ } else {
|
||||
+ return;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
@@ -147,7 +154,7 @@
|
||||
} else if (c(item) && !A(entitypiglin)) {
|
||||
y(entitypiglin);
|
||||
} else {
|
||||
- boolean flag = entitypiglin.g(itemstack);
|
||||
+ boolean flag = entitypiglin.g(itemstack, entityitem); // CraftBukkit
|
||||
|
||||
if (!flag) {
|
||||
d(entitypiglin, itemstack);
|
||||
@@ -583,7 +590,7 @@
|
||||
EntityLiving entityliving = (EntityLiving) behaviorcontroller.getMemory(MemoryModuleType.AVOID_TARGET).get();
|
||||
EntityTypes<?> entitytypes = entityliving.getEntityType();
|
||||
|
||||
- return entitytypes == EntityTypes.HOGLIN ? v(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, (Object) entityliving) : false);
|
||||
+ return entitytypes == EntityTypes.HOGLIN ? v(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, entityliving) : false); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,7 +672,7 @@
|
||||
}
|
||||
|
||||
public static boolean b(EntityLiving entityliving) {
|
||||
- return entityliving.getEntityType() == EntityTypes.PLAYER && entityliving.a(PiglinAI::a);
|
||||
+ return entityliving.getEntityType() == EntityTypes.PLAYER && entityliving.a((java.util.function.Predicate<Item>) PiglinAI::a); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
private static boolean D(EntityPiglin entitypiglin) {
|
Loading…
Reference in New Issue
Block a user