--- 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 !b(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::j, 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::j, 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 @@ n(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(); @@ -148,7 +155,7 @@ } else if (c(item) && !u(entitypiglin)) { s(entitypiglin); } else { - boolean flag = entitypiglin.g(itemstack); + boolean flag = entitypiglin.g(itemstack, entityitem); // CraftBukkit if (!flag) { d(entitypiglin, itemstack); @@ -350,7 +357,7 @@ } public static void a(EntityHuman entityhuman, boolean flag) { - List<EntityPiglin> list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); + List<EntityPiglinAbstract> list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); // CraftBukkit - decompile error list.stream().filter(PiglinAI::d).filter((entitypiglin) -> { return !flag || BehaviorUtil.c(entitypiglin, entityhuman); @@ -586,7 +593,7 @@ EntityLiving entityliving = (EntityLiving) behaviorcontroller.getMemory(MemoryModuleType.AVOID_TARGET).get(); EntityTypes<?> entitytypes = entityliving.getEntityType(); - return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, (Object) entityliving) : false); + return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, entityliving) : false); // CraftBukkit - decompile error } } @@ -668,7 +675,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 x(EntityPiglin entitypiglin) {