@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
|
||||
@@ -56,6 +56,18 @@
|
||||
@@ -55,6 +55,18 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
+
|
||||
public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier {
|
||||
|
||||
private static final DataWatcherObject<Boolean> DATA_BABY_ID = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -76,6 +88,10 @@
|
||||
private static final DataWatcherObject<Boolean> DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -75,6 +87,10 @@
|
||||
public boolean cannotHunt;
|
||||
protected static final ImmutableList<SensorType<? extends Sensor<? super EntityPiglin>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR);
|
||||
protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.WALK_TARGET, new MemoryModuleType[]{MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT});
|
||||
@@ -30,76 +30,67 @@
|
||||
|
||||
public EntityPiglin(EntityTypes<? extends EntityPiglinAbstract> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -94,6 +110,14 @@
|
||||
@@ -93,6 +109,14 @@
|
||||
}
|
||||
|
||||
nbttagcompound.set("Inventory", this.inventory.g());
|
||||
nbttagcompound.put("Inventory", this.inventory.createTag());
|
||||
+ // CraftBukkit start
|
||||
+ NBTTagList barterList = new NBTTagList();
|
||||
+ allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::a).forEach(barterList::add);
|
||||
+ nbttagcompound.set("Bukkit.BarterList", barterList);
|
||||
+ allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(barterList::add);
|
||||
+ nbttagcompound.put("Bukkit.BarterList", barterList);
|
||||
+ NBTTagList interestList = new NBTTagList();
|
||||
+ interestItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::a).forEach(interestList::add);
|
||||
+ nbttagcompound.set("Bukkit.InterestList", interestList);
|
||||
+ interestItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(interestList::add);
|
||||
+ nbttagcompound.put("Bukkit.InterestList", interestList);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,6 +126,10 @@
|
||||
@@ -101,6 +125,10 @@
|
||||
this.setBaby(nbttagcompound.getBoolean("IsBaby"));
|
||||
this.x(nbttagcompound.getBoolean("CannotHunt"));
|
||||
this.inventory.a(nbttagcompound.getList("Inventory", 10));
|
||||
this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt"));
|
||||
this.inventory.fromTag(nbttagcompound.getList("Inventory", 10));
|
||||
+ // CraftBukkit start
|
||||
+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::asString).map(MinecraftKey::a).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new));
|
||||
+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::asString).map(MinecraftKey::a).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new));
|
||||
+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new));
|
||||
+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@VisibleForDebug
|
||||
@@ -206,7 +234,7 @@
|
||||
@@ -205,7 +233,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<EntityPiglin> getBehaviorController() {
|
||||
- return super.getBehaviorController();
|
||||
+ return (BehaviorController<EntityPiglin>) super.getBehaviorController(); // CraftBukkit - Decompile error
|
||||
public BehaviorController<EntityPiglin> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<EntityPiglin>) super.getBrain(); // CraftBukkit - Decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -265,7 +293,7 @@
|
||||
@Override
|
||||
protected void mobTick() {
|
||||
this.level.getMethodProfiler().enter("piglinBrain");
|
||||
- this.getBehaviorController().a((WorldServer) this.level, (EntityLiving) this);
|
||||
+ this.getBehaviorController().a((WorldServer) this.level, (EntityPiglin) this); // CraftBukkit - decompile error
|
||||
this.level.getMethodProfiler().exit();
|
||||
PiglinAI.b(this);
|
||||
super.mobTick();
|
||||
@@ -349,7 +377,7 @@
|
||||
@@ -348,7 +376,7 @@
|
||||
}
|
||||
|
||||
protected void p(ItemStack itemstack) {
|
||||
- if (itemstack.a(PiglinAI.BARTERING_ITEM)) {
|
||||
+ if (itemstack.a(PiglinAI.BARTERING_ITEM) || allowedBarterItems.contains(itemstack.getItem())) { // CraftBukkit - Changes to accept custom payment items
|
||||
this.setSlot(EnumItemSlot.OFFHAND, itemstack);
|
||||
this.d(EnumItemSlot.OFFHAND);
|
||||
protected void holdInOffHand(ItemStack itemstack) {
|
||||
- if (itemstack.is(PiglinAI.BARTERING_ITEM)) {
|
||||
+ if (itemstack.is(PiglinAI.BARTERING_ITEM) || allowedBarterItems.contains(itemstack.getItem())) { // CraftBukkit - Changes to accept custom payment items
|
||||
this.setItemSlot(EnumItemSlot.OFFHAND, itemstack);
|
||||
this.setGuaranteedDrop(EnumItemSlot.OFFHAND);
|
||||
} else {
|
||||
@@ -375,8 +403,8 @@
|
||||
if (EnchantmentManager.d(itemstack1)) {
|
||||
@@ -374,8 +402,8 @@
|
||||
if (EnchantmentManager.hasBindingCurse(itemstack1)) {
|
||||
return false;
|
||||
} else {
|
||||
- boolean flag = PiglinAI.a(itemstack) || itemstack.a(Items.CROSSBOW);
|
||||
- boolean flag1 = PiglinAI.a(itemstack1) || itemstack1.a(Items.CROSSBOW);
|
||||
+ boolean flag = PiglinAI.isLovedByPiglin(itemstack, this) || itemstack.a(Items.CROSSBOW); // CraftBukkit
|
||||
+ boolean flag1 = PiglinAI.isLovedByPiglin(itemstack1, this) || itemstack1.a(Items.CROSSBOW); // CraftBukkit
|
||||
- boolean flag = PiglinAI.isLovedItem(itemstack) || itemstack.is(Items.CROSSBOW);
|
||||
- boolean flag1 = PiglinAI.isLovedItem(itemstack1) || itemstack1.is(Items.CROSSBOW);
|
||||
+ boolean flag = PiglinAI.isLovedItem(itemstack, this) || itemstack.is(Items.CROSSBOW); // CraftBukkit
|
||||
+ boolean flag1 = PiglinAI.isLovedItem(itemstack1, this) || itemstack1.is(Items.CROSSBOW); // CraftBukkit
|
||||
|
||||
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.fw() && !itemstack.a(Items.CROSSBOW) && itemstack1.a(Items.CROSSBOW) ? false : super.a(itemstack, itemstack1)));
|
||||
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1)));
|
||||
}
|
||||
@@ -405,7 +433,7 @@
|
||||
@@ -404,7 +432,7 @@
|
||||
|
||||
@Override
|
||||
protected SoundEffect getSoundAmbient() {
|
||||
- return this.level.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse((Object) null);
|
||||
+ return this.level.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse(null); // CraftBukkit - Decompile error
|
||||
protected SoundEffect getAmbientSound() {
|
||||
- return this.level.isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse((Object) null);
|
||||
+ return this.level.isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse(null); // CraftBukkit - Decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
@@ -100,7 +100,7 @@
|
||||
}
|
||||
|
||||
protected void c(WorldServer worldserver) {
|
||||
- EntityPigZombie entitypigzombie = (EntityPigZombie) this.a(EntityTypes.ZOMBIFIED_PIGLIN, true);
|
||||
+ EntityPigZombie entitypigzombie = (EntityPigZombie) this.a(EntityTypes.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
|
||||
protected void finishConversion(WorldServer worldserver) {
|
||||
- EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true);
|
||||
+ EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
|
||||
|
||||
if (entitypigzombie != null) {
|
||||
entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
|
||||
@@ -117,7 +117,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public EntityLiving getGoalTarget() {
|
||||
public EntityLiving getTarget() {
|
||||
- return (EntityLiving) this.brain.getMemory(MemoryModuleType.ATTACK_TARGET).orElse((Object) null);
|
||||
+ return (EntityLiving) this.brain.getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected boolean fy() {
|
||||
protected boolean isHoldingMeleeWeapon() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java
|
||||
@@ -73,6 +73,13 @@
|
||||
@@ -72,6 +72,13 @@
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -14,179 +14,131 @@
|
||||
public class PiglinAI {
|
||||
|
||||
public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8;
|
||||
@@ -145,7 +152,8 @@
|
||||
private static void b(EntityPiglin entitypiglin, BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
behaviorcontroller.a(Activity.FIGHT, 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);
|
||||
}
|
||||
@@ -187,13 +194,13 @@
|
||||
|
||||
private static void c(BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
@@ -163,7 +171,8 @@
|
||||
}
|
||||
protected static void updateActivity(EntityPiglin entitypiglin) {
|
||||
BehaviorController<EntityPiglin> behaviorcontroller = entitypiglin.getBrain();
|
||||
- Activity activity = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse((Object) null);
|
||||
+ Activity activity = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
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() {
|
||||
@@ -171,7 +180,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::f, 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::f, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1)));
|
||||
}
|
||||
|
||||
private static BehaviorWalkAway<BlockPosition> c() {
|
||||
@@ -188,13 +198,13 @@
|
||||
|
||||
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.FIGHT, 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
|
||||
behaviorcontroller.setActiveActivityToFirstValid(ImmutableList.of(Activity.ADMIRE_ITEM, Activity.FIGHT, Activity.AVOID, Activity.CELEBRATE, Activity.RIDE, Activity.IDLE));
|
||||
- Activity activity1 = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse((Object) null);
|
||||
+ Activity activity1 = (Activity) behaviorcontroller.getActiveNonCoreActivity().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (activity != activity1) {
|
||||
- Optional optional = d(entitypiglin);
|
||||
+ Optional<SoundEffect> optional = d(entitypiglin); // CraftBukkit - decompile error
|
||||
- Optional optional = getSoundForCurrentActivity(entitypiglin);
|
||||
+ Optional<SoundEffect> optional = getSoundForCurrentActivity(entitypiglin); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(entitypiglin);
|
||||
optional.ifPresent(entitypiglin::a);
|
||||
@@ -226,23 +236,27 @@
|
||||
n(entitypiglin);
|
||||
optional.ifPresent(entitypiglin::playSound);
|
||||
@@ -225,23 +232,27 @@
|
||||
stopWalking(entitypiglin);
|
||||
ItemStack itemstack;
|
||||
|
||||
- if (entityitem.getItemStack().a(Items.GOLD_NUGGET)) {
|
||||
- if (entityitem.getItem().is(Items.GOLD_NUGGET)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (entityitem.getItemStack().a(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();
|
||||
+ if (entityitem.getItem().is(Items.GOLD_NUGGET) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, 0, false).isCancelled()) {
|
||||
entitypiglin.take(entityitem, entityitem.getItem().getCount());
|
||||
itemstack = entityitem.getItem();
|
||||
entityitem.discard();
|
||||
- } 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 if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, entityitem.getItem().getCount() - 1, false).isCancelled()) {
|
||||
entitypiglin.take(entityitem, 1);
|
||||
itemstack = removeOneItemFromItemEntity(entityitem);
|
||||
+ } else {
|
||||
+ return;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
- if (a(itemstack)) {
|
||||
+ if (isLovedByPiglin(itemstack, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
|
||||
entitypiglin.getBehaviorController().removeMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM);
|
||||
c(entitypiglin, itemstack);
|
||||
d((EntityLiving) entitypiglin);
|
||||
} else if (c(itemstack) && !u(entitypiglin)) {
|
||||
s(entitypiglin);
|
||||
- if (isLovedItem(itemstack)) {
|
||||
+ if (isLovedItem(itemstack, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
|
||||
entitypiglin.getBrain().eraseMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM);
|
||||
holdInOffhand(entitypiglin, itemstack);
|
||||
admireGoldItem(entitypiglin);
|
||||
} else if (isFood(itemstack) && !hasEatenRecently(entitypiglin)) {
|
||||
eat(entitypiglin);
|
||||
} else {
|
||||
- boolean flag = entitypiglin.j(itemstack);
|
||||
+ boolean flag = entitypiglin.j(itemstack, entityitem); // CraftBukkit
|
||||
- boolean flag = entitypiglin.equipItemIfPossible(itemstack);
|
||||
+ boolean flag = entitypiglin.equipItemIfPossible(itemstack, entityitem); // CraftBukkit
|
||||
|
||||
if (!flag) {
|
||||
d(entitypiglin, itemstack);
|
||||
@@ -278,9 +292,14 @@
|
||||
putInInventory(entitypiglin, itemstack);
|
||||
@@ -277,9 +288,14 @@
|
||||
boolean flag1;
|
||||
|
||||
if (entitypiglin.fw()) {
|
||||
- flag1 = b(itemstack);
|
||||
+ flag1 = isBarterItem(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
|
||||
if (entitypiglin.isAdult()) {
|
||||
- flag1 = isBarterCurrency(itemstack);
|
||||
+ flag1 = isBarterCurrency(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
|
||||
if (flag && flag1) {
|
||||
- a(entitypiglin, i(entitypiglin));
|
||||
- throwItems(entitypiglin, getBarterResponseItems(entitypiglin));
|
||||
+ // CraftBukkit start
|
||||
+ PiglinBarterEvent event = CraftEventFactory.callPiglinBarterEvent(entitypiglin, i(entitypiglin), itemstack);
|
||||
+ PiglinBarterEvent event = CraftEventFactory.callPiglinBarterEvent(entitypiglin, getBarterResponseItems(entitypiglin), itemstack);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ a(entitypiglin, event.getOutcome().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList()));
|
||||
+ throwItems(entitypiglin, event.getOutcome().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else if (!flag1) {
|
||||
boolean flag2 = entitypiglin.j(itemstack);
|
||||
boolean flag2 = entitypiglin.equipItemIfPossible(itemstack);
|
||||
|
||||
@@ -293,7 +312,7 @@
|
||||
@@ -292,7 +308,7 @@
|
||||
if (!flag1) {
|
||||
ItemStack itemstack1 = entitypiglin.getItemInMainHand();
|
||||
ItemStack itemstack1 = entitypiglin.getMainHandItem();
|
||||
|
||||
- if (a(itemstack1)) {
|
||||
+ if (isLovedByPiglin(itemstack1, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
|
||||
d(entitypiglin, itemstack1);
|
||||
- if (isLovedItem(itemstack1)) {
|
||||
+ if (isLovedItem(itemstack1, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
|
||||
putInInventory(entitypiglin, itemstack1);
|
||||
} else {
|
||||
a(entitypiglin, Collections.singletonList(itemstack1));
|
||||
@@ -370,7 +389,7 @@
|
||||
throwItems(entitypiglin, Collections.singletonList(itemstack1));
|
||||
@@ -369,7 +385,7 @@
|
||||
return false;
|
||||
} else if (x(entitypiglin) && entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ATTACK_TARGET)) {
|
||||
} else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) {
|
||||
return false;
|
||||
- } else if (b(itemstack)) {
|
||||
+ } else if (isBarterItem(itemstack, entitypiglin)) { // CraftBukkit
|
||||
return z(entitypiglin);
|
||||
- } else if (isBarterCurrency(itemstack)) {
|
||||
+ } else if (isBarterCurrency(itemstack, entitypiglin)) { // CraftBukkit
|
||||
return isNotHoldingLovedItemInOffHand(entitypiglin);
|
||||
} else {
|
||||
boolean flag = entitypiglin.n(itemstack);
|
||||
@@ -379,6 +398,12 @@
|
||||
boolean flag = entitypiglin.canAddToInventory(itemstack);
|
||||
@@ -378,6 +394,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Added method to allow checking for custom payment items
|
||||
+ protected static boolean isLovedByPiglin(ItemStack itemstack, EntityPiglin piglin) {
|
||||
+ return a(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem()));
|
||||
+ protected static boolean isLovedItem(ItemStack itemstack, EntityPiglin piglin) {
|
||||
+ return isLovedItem(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected static boolean a(ItemStack itemstack) {
|
||||
return itemstack.a((Tag) TagsItem.PIGLIN_LOVED);
|
||||
protected static boolean isLovedItem(ItemStack itemstack) {
|
||||
return itemstack.is((Tag) TagsItem.PIGLIN_LOVED);
|
||||
}
|
||||
@@ -444,7 +469,7 @@
|
||||
@@ -473,7 +495,7 @@
|
||||
}
|
||||
|
||||
public static void a(EntityHuman entityhuman, boolean flag) {
|
||||
- List<EntityPiglin> list = entityhuman.level.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D));
|
||||
+ List<EntityPiglinAbstract> list = (List) entityhuman.level.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); // CraftBukkit - decompile error
|
||||
|
||||
list.stream().filter(PiglinAI::d).filter((entitypiglin) -> {
|
||||
return !flag || BehaviorUtil.b((EntityLiving) entitypiglin, entityhuman);
|
||||
@@ -474,7 +499,7 @@
|
||||
protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) {
|
||||
- return !isAdmiringDisabled(entitypiglin) && !isAdmiringItem(entitypiglin) && entitypiglin.isAdult() && isBarterCurrency(itemstack);
|
||||
+ return !isAdmiringDisabled(entitypiglin) && !isAdmiringItem(entitypiglin) && entitypiglin.isAdult() && isBarterCurrency(itemstack, entitypiglin); // CraftBukkit
|
||||
}
|
||||
|
||||
protected static boolean b(EntityPiglin entitypiglin, ItemStack itemstack) {
|
||||
- return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fw() && b(itemstack);
|
||||
+ return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fw() && isBarterItem(itemstack, entitypiglin); // CraftBukkit
|
||||
}
|
||||
|
||||
protected static void a(EntityPiglin entitypiglin, EntityLiving entityliving) {
|
||||
@@ -680,7 +705,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -741,6 +766,12 @@
|
||||
return entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ADMIRING_ITEM);
|
||||
protected static void wasHurtBy(EntityPiglin entitypiglin, EntityLiving entityliving) {
|
||||
@@ -740,6 +762,12 @@
|
||||
return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Changes to allow custom payment for bartering
|
||||
+ private static boolean isBarterItem(ItemStack itemstack, EntityPiglin piglin) {
|
||||
+ return b(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem());
|
||||
+ private static boolean isBarterCurrency(ItemStack itemstack, EntityPiglin piglin) {
|
||||
+ return isBarterCurrency(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private static boolean b(ItemStack itemstack) {
|
||||
return itemstack.a(PiglinAI.BARTERING_ITEM);
|
||||
private static boolean isBarterCurrency(ItemStack itemstack) {
|
||||
return itemstack.is(PiglinAI.BARTERING_ITEM);
|
||||
}
|
||||
@@ -778,7 +809,7 @@
|
||||
@@ -777,7 +805,7 @@
|
||||
}
|
||||
|
||||
private static boolean z(EntityPiglin entitypiglin) {
|
||||
- return entitypiglin.getItemInOffHand().isEmpty() || !a(entitypiglin.getItemInOffHand());
|
||||
+ return entitypiglin.getItemInOffHand().isEmpty() || !isLovedByPiglin(entitypiglin.getItemInOffHand(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
|
||||
private static boolean isNotHoldingLovedItemInOffHand(EntityPiglin entitypiglin) {
|
||||
- return entitypiglin.getOffhandItem().isEmpty() || !isLovedItem(entitypiglin.getOffhandItem());
|
||||
+ return entitypiglin.getOffhandItem().isEmpty() || !isLovedItem(entitypiglin.getOffhandItem(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
|
||||
}
|
||||
|
||||
public static boolean a(EntityTypes<?> entitytypes) {
|
||||
public static boolean isZombified(EntityTypes<?> entitytypes) {
|
||||
|
||||
Reference in New Issue
Block a user