Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -4,8 +4,8 @@
}
if (b0 > 0) {
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0));
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this);
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/monster/EntityCreeper.java
+++ b/net/minecraft/world/entity/monster/EntityCreeper.java
@@ -38,13 +38,19 @@
import net.minecraft.world.level.IMaterial;
@@ -44,6 +44,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -10,22 +10,14 @@
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityCreeper extends EntityMonster {
public class EntityCreeper extends EntityMonster implements PowerableMob {
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b);
private static final DataWatcherObject<Boolean> POWERED = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.i);
private static final DataWatcherObject<Boolean> d = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.i);
private int bo;
- private int fuseTicks;
+ public int fuseTicks; // PAIL
public int maxFuseTicks = 30;
public int explosionRadius = 3;
private int bs;
@@ -200,9 +206,19 @@
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.INT);
@@ -219,9 +225,19 @@
@Override
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
super.onLightningStrike(worldserver, entitylightning);
- this.datawatcher.set(EntityCreeper.POWERED, true);
- this.entityData.set(EntityCreeper.DATA_IS_POWERED, true);
+ // CraftBukkit start
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
+ return;
@@ -35,50 +27,50 @@
}
+ public void setPowered(boolean powered) {
+ this.datawatcher.set(EntityCreeper.POWERED, powered);
+ this.entityData.set(EntityCreeper.DATA_IS_POWERED, powered);
+ }
+ // CraftBukkit end
+
@Override
protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
@@ -227,10 +243,18 @@
Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
@@ -246,10 +262,18 @@
Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
float f = this.isPowered() ? 2.0F : 1.0F;
- this.killed = true;
- this.world.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect);
- this.dead = true;
- this.level.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect);
- this.die();
- this.createEffectCloud();
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.killed = true;
+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
+ this.dead = true;
+ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
+ this.die();
+ this.createEffectCloud();
+ } else {
+ fuseTicks = 0;
+ swell = 0;
+ }
+ // CraftBukkit end
}
}
@@ -241,6 +265,7 @@
@@ -260,6 +284,7 @@
if (!collection.isEmpty()) {
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX(), this.locY(), this.locZ());
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.locX(), this.locY(), this.locZ());
+ entityareaeffectcloud.setSource(this); // CraftBukkit
entityareaeffectcloud.setRadius(2.5F);
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
@@ -254,7 +279,7 @@
@@ -273,7 +298,7 @@
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
}
- this.world.addEntity(entityareaeffectcloud);
+ this.world.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
- this.level.addEntity(entityareaeffectcloud);
+ this.level.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
}
}

View File

@@ -20,38 +20,41 @@
if (entityliving == null) {
@@ -120,6 +130,7 @@
attributemodifiable.b(EntityEnderman.c);
attributemodifiable.b(EntityEnderman.SPEED_MODIFIER_ATTACKING);
}
}
+ return true;
}
@@ -413,8 +424,12 @@
@@ -446,9 +457,13 @@
if (iblockdata2 != null) {
iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.enderman.level, blockposition);
if (this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) {
world.setTypeAndData(blockposition, iblockdata2, 3);
world.a((Entity) this.enderman, GameEvent.BLOCK_PLACE, blockposition);
this.enderman.setCarried((IBlockData) null);
+ }
+ // CraftBukkit end
}
}
@@ -487,9 +502,13 @@
boolean flag = movingobjectpositionblock.getBlockPosition().equals(blockposition);
if (block.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) {
if (iblockdata.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) {
- world.a(blockposition, false);
- world.a((Entity) this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
- this.enderman.setCarried(iblockdata.getBlock().getBlockData());
+ // CraftBukkit start - Pickup event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ world.a(blockposition, false);
+ world.a((Entity) this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
+ this.enderman.setCarried(iblockdata.getBlock().getBlockData());
+ }
+ // CraftBukkit end
}
}
@@ -449,8 +464,12 @@
if (iblockdata2 != null) {
iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.a.world, blockposition);
if (this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) {
world.setTypeAndData(blockposition, iblockdata2, 3);
this.a.setCarried((IBlockData) null);
+ }
+ // CraftBukkit end
}
}

View File

@@ -1,12 +1,11 @@
--- a/net/minecraft/world/entity/monster/EntityGhast.java
+++ b/net/minecraft/world/entity/monster/EntityGhast.java
@@ -193,7 +193,8 @@
@@ -318,6 +318,8 @@
EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4);
EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4, this.ghast.getPower());
- entitylargefireball.yield = this.ghast.getPower();
+ // CraftBukkit - set bukkitYield when setting explosionpower
+ entitylargefireball.bukkitYield = entitylargefireball.yield = this.ghast.getPower();
+ entitylargefireball.bukkitYield = entitylargefireball.explosionPower = this.ghast.getPower();
entitylargefireball.setPosition(this.ghast.locX() + vec3d.x * 4.0D, this.ghast.e(0.5D) + 0.5D, entitylargefireball.locZ() + vec3d.z * 4.0D);
world.addEntity(entitylargefireball);
this.a = -40;
this.chargeTime = -40;

View File

@@ -3,9 +3,9 @@
@@ -79,7 +79,7 @@
if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.k, this.isSilent() ? 0.0F : 1.0F));
- entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2));
+ entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F));
- entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), this);
+ entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java
+++ b/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java
@@ -67,7 +67,7 @@
@@ -70,7 +70,7 @@
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
@@ -9,16 +9,7 @@
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300));
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
@@ -206,7 +206,7 @@
@Override
protected void j() {
- EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400));
+ EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
@Override
@@ -243,7 +243,7 @@
@@ -228,7 +228,7 @@
@Override
protected void j() {
@@ -27,3 +18,12 @@
}
@Nullable
@@ -274,7 +274,7 @@
@Override
protected void j() {
- EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), EntityIllagerIllusioner.this);
+ EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), EntityIllagerIllusioner.this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
@Override

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/entity/monster/EntityIllagerWizard.java
+++ b/net/minecraft/world/entity/monster/EntityIllagerWizard.java
@@ -156,6 +156,11 @@
@@ -161,6 +161,11 @@
public void e() {
--this.b;
if (this.b == 0) {
--this.attackWarmupDelay;
if (this.attackWarmupDelay == 0) {
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, this.getCastSpell())) {
+ return;

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/entity/monster/EntityPhantom.java
+++ b/net/minecraft/world/entity/monster/EntityPhantom.java
@@ -243,7 +243,7 @@
@@ -529,7 +529,7 @@
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) {
if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.DEFAULT)) {
- EntityPhantom.this.setGoalTarget(entityhuman);
+ EntityPhantom.this.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason
return true;

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/monster/EntityPigZombie.java
+++ b/net/minecraft/world/entity/monster/EntityPigZombie.java
@@ -69,7 +69,7 @@
protected void m() {
@@ -71,7 +71,7 @@
protected void n() {
this.goalSelector.a(2, new PathfinderGoalZombieAttack(this, 1.0D, false));
this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D));
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
@@ -9,25 +9,25 @@
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_));
this.targetSelector.a(3, new PathfinderGoalUniversalAngerReset<>(this, true));
}
@@ -142,7 +142,7 @@
@@ -144,7 +144,7 @@
}).filter((entitypigzombie) -> {
return !entitypigzombie.r(this.getGoalTarget());
return !entitypigzombie.p(this.getGoalTarget());
}).forEach((entitypigzombie) -> {
- entitypigzombie.setGoalTarget(this.getGoalTarget());
+ entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit
});
}
@@ -151,7 +151,7 @@
@@ -153,7 +153,7 @@
}
@Override
- public void setGoalTarget(@Nullable EntityLiving entityliving) {
+ public boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature
if (this.getGoalTarget() == null && entityliving != null) {
this.bo = EntityPigZombie.d.a(this.random);
this.bt = EntityPigZombie.bs.a(this.random);
@@ -161,12 +161,21 @@
this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.a(this.random);
this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.a(this.random);
@@ -163,12 +163,21 @@
this.e((EntityHuman) entityliving);
}
@@ -37,11 +37,11 @@
@Override
public void anger() {
- this.setAnger(EntityPigZombie.bp.a(this.random));
- this.setAnger(EntityPigZombie.PERSISTENT_ANGER_TIME.a(this.random));
+ // CraftBukkit start
+ Entity entity = ((WorldServer) this.world).getEntity(getAngerTarget());
+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.bp.a(this.random));
+ this.world.getServer().getPluginManager().callEvent(event);
+ Entity entity = ((WorldServer) this.level).getEntity(getAngerTarget());
+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.PERSISTENT_ANGER_TIME.a(this.random));
+ this.level.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ this.setAngerTarget(null);
+ return;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityPillager.java
+++ b/net/minecraft/world/entity/monster/EntityPillager.java
@@ -70,7 +70,7 @@
@@ -75,7 +75,7 @@
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 15.0F, 1.0F));
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 15.0F));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityRavager.java
+++ b/net/minecraft/world/entity/monster/EntityRavager.java
@@ -69,7 +69,7 @@
@@ -78,7 +78,7 @@
this.goalSelector.a(5, new PathfinderGoalRandomStrollLand(this, 0.4D));
this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
@@ -9,12 +9,12 @@
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, true));
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
@@ -160,7 +160,7 @@
IBlockData iblockdata = this.world.getType(blockposition);
@@ -169,7 +169,7 @@
IBlockData iblockdata = this.level.getType(blockposition);
Block block = iblockdata.getBlock();
- if (block instanceof BlockLeaves) {
+ if (block instanceof BlockLeaves && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit
flag = this.world.a(blockposition, true, this) || flag;
flag = this.level.a(blockposition, true, this) || flag;
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityShulker.java
+++ b/net/minecraft/world/entity/monster/EntityShulker.java
@@ -47,11 +47,17 @@
@@ -57,6 +57,12 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -12,29 +12,23 @@
+
public class EntityShulker extends EntityGolem implements IMonster {
private static final UUID bp = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
private static final AttributeModifier bq = new AttributeModifier(EntityShulker.bp, "Covered armor bonus", 20.0D, AttributeModifier.Operation.ADDITION);
- protected static final DataWatcherObject<EnumDirection> b = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.n);
+ public static final DataWatcherObject<EnumDirection> b = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.n); // PAIL protected -> public, rename ATTACH_FACE
protected static final DataWatcherObject<Optional<BlockPosition>> c = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.m);
protected static final DataWatcherObject<Byte> d = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a);
public static final DataWatcherObject<Byte> COLOR = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a);
@@ -71,7 +77,7 @@
private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
@@ -95,7 +101,7 @@
this.goalSelector.a(4, new EntityShulker.a());
this.goalSelector.a(7, new EntityShulker.e());
this.goalSelector.a(7, new EntityShulker.f());
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
this.targetSelector.a(2, new EntityShulker.d(this));
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{this.getClass()})).a());
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{this.getClass()})).a(new Class[0])); // CraftBukkit - decompile error
this.targetSelector.a(2, new EntityShulker.e(this));
this.targetSelector.a(3, new EntityShulker.c(this));
}
@@ -319,6 +325,16 @@
@@ -405,6 +411,16 @@
EnumDirection enumdirection = this.g(blockposition1);
if (enumdirection != null) {
+ // CraftBukkit start
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.world.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()));
+ this.world.getServer().getPluginManager().callEvent(teleport);
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.level.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()));
+ this.level.getServer().getPluginManager().callEvent(teleport);
+ if (!teleport.isCancelled()) {
+ Location to = teleport.getTo();
+ blockposition1 = new BlockPosition(to.getX(), to.getY(), to.getZ());
@@ -42,14 +36,15 @@
+ return false;
+ }
+ // CraftBukkit end
this.datawatcher.set(EntityShulker.b, enumdirection);
this.playSound(SoundEffects.ENTITY_SHULKER_TELEPORT, 1.0F, 1.0F);
this.datawatcher.set(EntityShulker.c, Optional.of(blockposition1));
@@ -359,6 +375,7 @@
this.decouple();
this.setAttachFace(enumdirection);
this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F);
@@ -477,7 +493,7 @@
}
this.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D);
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
entityshulker.d(vec3d);
- this.level.addEntity(entityshulker);
+ this.level.addEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life
}
}
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/monster/EntitySilverfish.java
+++ b/net/minecraft/world/entity/monster/EntitySilverfish.java
@@ -45,7 +45,7 @@
this.goalSelector.a(3, this.b);
@@ -46,7 +46,7 @@
this.goalSelector.a(3, this.friendsGoal);
this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, false));
this.goalSelector.a(5, new EntitySilverfish.PathfinderGoalSilverfishHideInBlock(this));
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
@@ -9,19 +9,7 @@
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
}
@@ -183,6 +183,11 @@
IBlockData iblockdata = world.getType(blockposition);
if (BlockMonsterEggs.h(iblockdata)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.c(iblockdata.getBlock())).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, BlockMonsterEggs.c(iblockdata.getBlock()), 3);
this.a.doSpawnEffect();
this.a.die();
@@ -229,6 +234,11 @@
@@ -171,6 +171,11 @@
Block block = iblockdata.getBlock();
if (block instanceof BlockMonsterEggs) {
@@ -30,6 +18,18 @@
+ continue;
+ }
+ // CraftBukkit end
if (world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
world.a(blockposition1, true, this.silverfish);
} else {
@@ -239,6 +244,11 @@
IBlockData iblockdata = world.getType(blockposition);
if (BlockMonsterEggs.h(iblockdata)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, BlockMonsterEggs.n(iblockdata)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, BlockMonsterEggs.n(iblockdata), 3);
this.mob.doSpawnEffect();
this.mob.die();

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
+++ b/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
@@ -196,8 +196,19 @@
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
@@ -195,8 +195,19 @@
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4));
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().a() * 4));
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), null, entityarrow, net.minecraft.world.EnumHand.MAIN_HAND, 0.8F, true);
+ if (event.isCancelled()) {
@@ -12,11 +12,11 @@
+ }
+
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ world.addEntity(entityarrow);
+ level.addEntity(entityarrow);
+ }
+ // CraftBukkit end
this.playSound(SoundEffects.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
- this.world.addEntity(entityarrow);
this.playSound(SoundEffects.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
- this.level.addEntity(entityarrow);
+ // this.world.addEntity(entityarrow); // CraftBukkit - moved up
}

View File

@@ -4,8 +4,8 @@
return false;
} else {
if (entity instanceof EntityLiving) {
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200));
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200), this);
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
return true;

View File

@@ -14,8 +14,8 @@
+
public class EntitySlime extends EntityInsentient implements IMonster {
private static final DataWatcherObject<Integer> bo = DataWatcher.a(EntitySlime.class, DataWatcherRegistry.b);
@@ -188,7 +196,7 @@
private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.a(EntitySlime.class, DataWatcherRegistry.INT);
@@ -186,7 +194,7 @@
@Override
public EntityTypes<? extends EntitySlime> getEntityType() {
@@ -24,13 +24,13 @@
}
@Override
@@ -202,6 +210,19 @@
@@ -200,6 +208,19 @@
int j = i / 2;
int k = 2 + this.random.nextInt(3);
+ // CraftBukkit start
+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k);
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled() && event.getCount() > 0) {
+ k = event.getCount();
@@ -44,11 +44,11 @@
for (int l = 0; l < k; ++l) {
float f1 = ((float) (l % 2) - 0.5F) * f;
float f2 = ((float) (l / 2) - 0.5F) * f;
@@ -216,8 +237,17 @@
@@ -214,8 +235,17 @@
entityslime.setInvulnerable(this.isInvulnerable());
entityslime.setSize(j, true);
entityslime.setPositionRotation(this.locX() + (double) f1, this.locY() + 0.5D, this.locZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F);
- this.world.addEntity(entityslime);
- this.level.addEntity(entityslime);
+ slimes.add(entityslime); // CraftBukkit
+ }
+
@@ -57,9 +57,9 @@
+ return;
+ }
+ for (EntityLiving living : slimes) {
+ this.world.addEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
+ this.level.addEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
}
+ // CraftBukkit end
}
super.die();
super.a(entity_removalreason);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/monster/EntitySpider.java
+++ b/net/minecraft/world/entity/monster/EntitySpider.java
@@ -175,7 +175,7 @@
MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).a;
@@ -176,7 +176,7 @@
MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).effect;
if (mobeffectlist != null) {
- this.addEffect(new MobEffect(mobeffectlist, Integer.MAX_VALUE));

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/monster/EntityStrider.java
+++ b/net/minecraft/world/entity/monster/EntityStrider.java
@@ -318,7 +318,12 @@
IBlockData iblockdata1 = this.aN();
@@ -321,7 +321,12 @@
IBlockData iblockdata1 = this.aU();
boolean flag = iblockdata.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || this.b((Tag) TagsFluid.LAVA) > 0.0D;
- this.setShivering(!flag);
@@ -12,5 +12,5 @@
+ }
+ // CraftBukkit end
super.tick();
this.eU();
this.fD();
this.checkBlockCollisions();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityVex.java
+++ b/net/minecraft/world/entity/monster/EntityVex.java
@@ -81,7 +81,7 @@
@@ -89,7 +89,7 @@
this.goalSelector.a(8, new EntityVex.d());
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
@@ -9,12 +9,12 @@
this.targetSelector.a(2, new EntityVex.b(this));
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
}
@@ -222,7 +222,7 @@
@@ -355,7 +355,7 @@
@Override
public void c() {
- EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget());
+ EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit
- EntityVex.this.setGoalTarget(EntityVex.this.owner.getGoalTarget());
+ EntityVex.this.setGoalTarget(EntityVex.this.owner.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit
super.c();
}
}

View File

@@ -15,28 +15,28 @@
+
public class EntityZombie extends EntityMonster {
private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
@@ -84,6 +93,7 @@
private boolean bs;
private int bt;
public int drownedConversionTime;
private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
@@ -89,6 +98,7 @@
private boolean canBreakDoors;
private int inWaterTime;
public int conversionTime;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
super(entitytypes, world);
@@ -200,7 +210,10 @@
@@ -205,7 +215,10 @@
public void tick() {
if (!this.world.isClientSide && this.isAlive() && !this.isNoAI()) {
if (!this.level.isClientSide && this.isAlive() && !this.isNoAI()) {
if (this.isDrownConverting()) {
- --this.drownedConversionTime;
- --this.conversionTime;
+ // CraftBukkit start - Use wall time instead of ticks for conversion
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.drownedConversionTime -= elapsedTicks;
+ this.conversionTime -= elapsedTicks;
+ // CraftBukkit end
if (this.drownedConversionTime < 0) {
this.eP();
if (this.conversionTime < 0) {
this.fy();
}
@@ -217,6 +230,7 @@
@@ -222,6 +235,7 @@
}
super.tick();
@@ -44,15 +44,15 @@
}
@Override
@@ -249,6 +263,7 @@
@@ -254,6 +268,7 @@
}
public void startDrownedConversion(int i) {
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
this.drownedConversionTime = i;
this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true);
this.conversionTime = i;
this.getDataWatcher().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true);
}
@@ -262,11 +277,15 @@
@@ -267,11 +282,15 @@
}
protected void b(EntityTypes<? extends EntityZombie> entitytypes) {
@@ -60,8 +60,8 @@
+ EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
if (entityzombie != null) {
entityzombie.y(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d());
entityzombie.u(entityzombie.eK() && this.eU());
entityzombie.z(entityzombie.level.getDamageScaler(entityzombie.getChunkCoordinates()).d());
entityzombie.w(entityzombie.p() && this.fD());
+ // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam
+ } else {
+ ((Zombie) getBukkitEntity()).setConversionTime(-1);
@@ -69,26 +69,26 @@
}
}
@@ -306,9 +325,9 @@
if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) {
@@ -311,9 +330,9 @@
if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.level, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level.random)) {
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.j((Entity) entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
if (!this.level.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.level.f((Entity) entityzombie) && this.level.getCubes(entityzombie) && !this.level.containsLiquid(entityzombie.getBoundingBox())) {
- entityzombie.setGoalTarget(entityliving);
+ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
entityzombie.prepare(worldserver, this.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
entityzombie.prepare(worldserver, this.level.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
- worldserver.addAllEntities(entityzombie);
+ worldserver.addAllEntities(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
this.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
this.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
break;
@@ -329,7 +348,14 @@
float f = this.world.getDamageScaler(this.getChunkCoordinates()).b();
@@ -334,7 +353,14 @@
float f = this.level.getDamageScaler(this.getChunkCoordinates()).b();
if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) {
- entity.setOnFire(2 * (int) f);
+ // CraftBukkit start
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ entity.setOnFire(event.getDuration(), false);
@@ -97,7 +97,7 @@
}
}
@@ -410,7 +436,12 @@
@@ -415,7 +441,12 @@
}
EntityVillager entityvillager = (EntityVillager) entityliving;
@@ -111,7 +111,7 @@
entityzombievillager.prepare(worldserver, worldserver.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null);
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
@@ -467,7 +498,7 @@
@@ -472,7 +503,7 @@
entitychicken1.prepare(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.setChickenJockey(true);
this.startRiding(entitychicken1);

View File

@@ -2,10 +2,10 @@
+++ b/net/minecraft/world/entity/monster/EntityZombieHusk.java
@@ -58,7 +58,7 @@
if (flag && this.getItemInMainHand().isEmpty() && entity instanceof EntityLiving) {
float f = this.world.getDamageScaler(this.getChunkCoordinates()).b();
float f = this.level.getDamageScaler(this.getChunkCoordinates()).b();
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f));
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), this);
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
return flag;

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/monster/EntityZombieVillager.java
+++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java
@@ -47,6 +47,13 @@
import net.minecraft.world.level.block.Blocks;
@@ -49,6 +49,13 @@
import net.minecraft.world.level.gameevent.GameEvent;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
@@ -13,36 +13,36 @@
+
public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder {
public static final DataWatcherObject<Boolean> CONVERTING = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.i);
@@ -56,6 +63,7 @@
private NBTBase bp;
private NBTTagCompound bq;
private int br;
public static final DataWatcherObject<Boolean> DATA_CONVERTING_ID = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.BOOLEAN);
@@ -62,6 +69,7 @@
private NBTBase gossips;
private NBTTagCompound tradeOffers;
private int villagerXp;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) {
super(entitytypes, world);
@@ -72,7 +80,7 @@
@@ -78,7 +86,7 @@
@Override
public void saveData(NBTTagCompound nbttagcompound) {
super.saveData(nbttagcompound);
- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData());
+ DataResult<NBTBase> dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error
- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData());
+ DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
Logger logger = EntityZombieVillager.LOGGER;
logger.getClass();
@@ -128,6 +136,10 @@
Objects.requireNonNull(logger);
@@ -134,6 +142,10 @@
public void tick() {
if (!this.world.isClientSide && this.isAlive() && this.isConverting()) {
if (!this.level.isClientSide && this.isAlive() && this.isConverting()) {
int i = this.getConversionProgress();
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ i *= elapsedTicks;
+ // CraftBukkit end
this.conversionTime -= i;
if (this.conversionTime <= 0) {
@@ -136,6 +148,7 @@
this.villagerConversionTime -= i;
if (this.villagerConversionTime <= 0) {
@@ -142,6 +154,7 @@
}
super.tick();
@@ -50,18 +50,21 @@
}
@Override
@@ -179,13 +192,22 @@
this.conversionPlayer = uuid;
this.conversionTime = i;
this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true);
@@ -186,8 +199,11 @@
this.conversionStarter = uuid;
this.villagerConversionTime = i;
this.getDataWatcher().set(EntityZombieVillager.DATA_CONVERTING_ID, true);
- this.removeEffect(MobEffects.WEAKNESS);
- this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)));
- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0)));
+ // CraftBukkit start
+ this.persistent = true; // CraftBukkit - SPIGOT-4684 update persistence
+ this.persistenceRequired = true; // CraftBukkit - SPIGOT-4684 update persistence
+ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
+ this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
+ // CraftBukkit end
this.world.broadcastEntityEffect(this, (byte) 16);
this.level.broadcastEntityEffect(this, (byte) 16);
}
@@ -204,7 +220,13 @@
}
private void c(WorldServer worldserver) {
@@ -76,17 +79,17 @@
EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
int i = aenumitemslot.length;
@@ -200,7 +222,9 @@
@@ -219,7 +241,9 @@
double d0 = (double) this.e(enumitemslot);
if (d0 > 1.0D) {
+ this.forceDrops = true; // CraftBukkit
this.a(itemstack);
this.b(itemstack);
+ this.forceDrops = false; // CraftBukkit
}
}
}
@@ -226,7 +250,7 @@
@@ -245,7 +269,7 @@
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
@@ -53,6 +53,18 @@
@@ -56,6 +56,18 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -16,18 +16,13 @@
+import net.minecraft.world.item.Item;
+// CraftBukkit end
+
public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow {
public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier {
private static final DataWatcherObject<Boolean> bp = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.i);
@@ -60,10 +72,14 @@
private static final DataWatcherObject<Boolean> br = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.i);
private static final UUID bs = UUID.fromString("766bfa64-11f3-11ea-8d71-362b9e155667");
private static final AttributeModifier bt = new AttributeModifier(EntityPiglin.bs, "Baby speed boost", 0.20000000298023224D, AttributeModifier.Operation.MULTIPLY_BASE);
- private final InventorySubcontainer bu = new InventorySubcontainer(8);
+ public final InventorySubcontainer bu = new InventorySubcontainer(8); // PAIL private -> public
public boolean cannotHunt = false;
protected static final ImmutableList<SensorType<? extends Sensor<? super EntityPiglin>>> d = ImmutableList.of(SensorType.c, SensorType.d, SensorType.b, SensorType.f, SensorType.k);
protected static final ImmutableList<MemoryModuleType<?>> bo = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_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_NEMSIS, 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});
private static final DataWatcherObject<Boolean> DATA_BABY_ID = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.BOOLEAN);
@@ -76,6 +88,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});
+ // CraftBukkit start - Custom bartering and interest list
+ public Set<Item> allowedBarterItems = new HashSet<>();
+ public Set<Item> interestItems = new HashSet<>();
@@ -35,10 +30,10 @@
public EntityPiglin(EntityTypes<? extends EntityPiglinAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -82,6 +98,14 @@
@@ -94,6 +110,14 @@
}
nbttagcompound.set("Inventory", this.bu.g());
nbttagcompound.set("Inventory", this.inventory.g());
+ // CraftBukkit start
+ NBTTagList barterList = new NBTTagList();
+ allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::a).forEach(barterList::add);
@@ -50,18 +45,18 @@
}
@Override
@@ -90,6 +114,10 @@
@@ -102,6 +126,10 @@
this.setBaby(nbttagcompound.getBoolean("IsBaby"));
this.v(nbttagcompound.getBoolean("CannotHunt"));
this.bu.a(nbttagcompound.getList("Inventory", 10));
this.x(nbttagcompound.getBoolean("CannotHunt"));
this.inventory.a(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));
+ // CraftBukkit end
}
@Override
@@ -188,7 +216,7 @@
@VisibleForDebug
@@ -206,7 +234,7 @@
@Override
public BehaviorController<EntityPiglin> getBehaviorController() {
@@ -70,41 +65,41 @@
}
@Override
@@ -247,7 +275,7 @@
@@ -265,7 +293,7 @@
@Override
protected void mobTick() {
this.world.getMethodProfiler().enter("piglinBrain");
- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this);
+ this.getBehaviorController().a((WorldServer) this.world, (EntityPiglin) this); // CraftBukkit - decompile error
this.world.getMethodProfiler().exit();
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();
@@ -330,7 +358,7 @@
@@ -349,7 +377,7 @@
}
protected void n(ItemStack itemstack) {
- if (itemstack.getItem() == PiglinAI.a) {
+ if (itemstack.getItem() == PiglinAI.a || allowedBarterItems.contains(itemstack.getItem())) { // CraftBukkit - Changes to accept custom payment items
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);
} else {
@@ -356,8 +384,8 @@
@@ -375,8 +403,8 @@
if (EnchantmentManager.d(itemstack1)) {
return false;
} else {
- boolean flag = PiglinAI.a(itemstack.getItem()) || itemstack.getItem() == Items.CROSSBOW;
- boolean flag1 = PiglinAI.a(itemstack1.getItem()) || itemstack1.getItem() == Items.CROSSBOW;
+ boolean flag = PiglinAI.isLovedByPiglin(itemstack.getItem(), this) || itemstack.getItem() == Items.CROSSBOW; // CraftBukkit
+ boolean flag1 = PiglinAI.isLovedByPiglin(itemstack1.getItem(), this) || itemstack1.getItem() == Items.CROSSBOW; // CraftBukkit
- 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
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.eM() && itemstack.getItem() != Items.CROSSBOW && itemstack1.getItem() == Items.CROSSBOW ? false : super.a(itemstack, itemstack1)));
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.fv() && !itemstack.a(Items.CROSSBOW) && itemstack1.a(Items.CROSSBOW) ? false : super.a(itemstack, itemstack1)));
}
@@ -386,7 +414,7 @@
@@ -405,7 +433,7 @@
@Override
protected SoundEffect getSoundAmbient() {
- return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse((Object) null);
+ return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse(null); // CraftBukkit - Decompile error
- 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
}
@Override

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java
@@ -99,7 +99,7 @@
@@ -100,7 +100,7 @@
}
protected void c(WorldServer worldserver) {
@@ -9,12 +9,12 @@
if (entitypigzombie != null) {
entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
@@ -114,7 +114,7 @@
@@ -117,7 +117,7 @@
@Nullable
@Override
public EntityLiving getGoalTarget() {
- return (EntityLiving) this.bg.getMemory(MemoryModuleType.ATTACK_TARGET).orElse((Object) null);
+ return (EntityLiving) this.bg.getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); // CraftBukkit - decompile error
- 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 eO() {
protected boolean fx() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java
+++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java
@@ -72,6 +72,13 @@
@@ -73,6 +73,13 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
import net.minecraft.world.phys.Vec3D;
@@ -13,10 +13,10 @@
+
public class PiglinAI {
public static final Item a = Items.GOLD_INGOT;
@@ -114,7 +121,8 @@
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.FLIGHT, 10, ImmutableList.of(new BehaviorAttackTargetForget<>((entityliving) -> {
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
@@ -24,7 +24,7 @@
}
private static void c(BehaviorController<EntityPiglin> behaviorcontroller) {
@@ -132,7 +140,8 @@
@@ -163,7 +171,8 @@
}
private static void f(BehaviorController<EntityPiglin> behaviorcontroller) {
@@ -34,36 +34,40 @@
}
private static BehaviorGateSingle<EntityPiglin> a() {
@@ -140,7 +149,8 @@
@@ -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::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1)));
- 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::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1)));
+ 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() {
@@ -157,10 +167,10 @@
@@ -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.FLIGHT, Activity.AVOID, Activity.CELEBRATE, Activity.RIDE, Activity.IDLE));
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
if (activity != activity1) {
d(entitypiglin).ifPresent(entitypiglin::a);
@@ -192,25 +202,29 @@
- Optional optional = d(entitypiglin);
+ Optional<SoundEffect> optional = d(entitypiglin); // CraftBukkit - decompile error
Objects.requireNonNull(entitypiglin);
optional.ifPresent(entitypiglin::a);
@@ -226,23 +236,27 @@
n(entitypiglin);
ItemStack itemstack;
- if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET) {
- if (entityitem.getItemStack().a(Items.GOLD_NUGGET)) {
+ // CraftBukkit start
+ if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, 0, false).isCancelled()) {
+ 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();
@@ -76,27 +80,25 @@
}
+ // CraftBukkit end
Item item = itemstack.getItem();
- if (a(item)) {
+ if (isLovedByPiglin(item, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
- 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(item) && !u(entitypiglin)) {
} else if (c(itemstack) && !u(entitypiglin)) {
s(entitypiglin);
} else {
- boolean flag = entitypiglin.g(itemstack);
+ boolean flag = entitypiglin.g(itemstack, entityitem); // CraftBukkit
- boolean flag = entitypiglin.j(itemstack);
+ boolean flag = entitypiglin.j(itemstack, entityitem); // CraftBukkit
if (!flag) {
d(entitypiglin, itemstack);
@@ -246,9 +260,14 @@
@@ -278,9 +292,14 @@
boolean flag1;
if (entitypiglin.eM()) {
- flag1 = b(itemstack.getItem());
+ flag1 = isBarterItem(itemstack.getItem(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
if (entitypiglin.fv()) {
- flag1 = b(itemstack);
+ flag1 = isBarterItem(itemstack, entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
if (flag && flag1) {
- a(entitypiglin, i(entitypiglin));
+ // CraftBukkit start
@@ -106,60 +108,58 @@
+ }
+ // CraftBukkit end
} else if (!flag1) {
boolean flag2 = entitypiglin.g(itemstack);
boolean flag2 = entitypiglin.j(itemstack);
@@ -261,7 +280,7 @@
@@ -293,7 +312,7 @@
if (!flag1) {
ItemStack itemstack1 = entitypiglin.getItemInMainHand();
- if (a(itemstack1.getItem())) {
+ if (isLovedByPiglin(itemstack1.getItem(), entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
- if (a(itemstack1)) {
+ if (isLovedByPiglin(itemstack1, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
d(entitypiglin, itemstack1);
} else {
a(entitypiglin, Collections.singletonList(itemstack1));
@@ -338,15 +357,21 @@
@@ -370,7 +389,7 @@
return false;
} else if (x(entitypiglin) && entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ATTACK_TARGET)) {
return false;
- } else if (b(item)) {
+ } else if (isBarterItem(item, entitypiglin)) { // CraftBukkit
- } else if (b(itemstack)) {
+ } else if (isBarterItem(itemstack, entitypiglin)) { // CraftBukkit
return z(entitypiglin);
} else {
boolean flag = entitypiglin.l(itemstack);
- return item == Items.GOLD_NUGGET ? flag : (c(item) ? !u(entitypiglin) && flag : (!a(item) ? entitypiglin.o(itemstack) : z(entitypiglin) && flag));
+ return item == Items.GOLD_NUGGET ? flag : (c(item) ? !u(entitypiglin) && flag : (!isLovedByPiglin(item, entitypiglin) ? entitypiglin.o(itemstack) : z(entitypiglin) && flag)); //CraftBukkit
boolean flag = entitypiglin.n(itemstack);
@@ -379,6 +398,12 @@
}
}
+ // CraftBukkit start - Added method to allow checking for custom payment items
+ protected static boolean isLovedByPiglin(Item item, EntityPiglin piglin) {
+ return a(item) || (piglin.interestItems.contains(item) || piglin.allowedBarterItems.contains(item));
+ protected static boolean isLovedByPiglin(ItemStack itemstack, EntityPiglin piglin) {
+ return a(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem()));
+ }
+ // CraftBukkit end
+
protected static boolean a(Item item) {
return item.a((Tag) TagsItem.PIGLIN_LOVED);
protected static boolean a(ItemStack itemstack) {
return itemstack.a((Tag) TagsItem.PIGLIN_LOVED);
}
@@ -412,7 +437,7 @@
@@ -444,7 +469,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<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.c(entitypiglin, entityhuman);
@@ -442,7 +467,7 @@
return !flag || BehaviorUtil.b((EntityLiving) entitypiglin, entityhuman);
@@ -474,7 +499,7 @@
}
protected static boolean b(EntityPiglin entitypiglin, ItemStack itemstack) {
- return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.eM() && b(itemstack.getItem());
+ return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.eM() && isBarterItem(itemstack.getItem(), entitypiglin); // CraftBukkit
- return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fv() && b(itemstack);
+ return !x(entitypiglin) && !v(entitypiglin) && entitypiglin.fv() && isBarterItem(itemstack, entitypiglin); // CraftBukkit
}
protected static void a(EntityPiglin entitypiglin, EntityLiving entityliving) {
@@ -648,7 +673,7 @@
@@ -680,7 +705,7 @@
EntityLiving entityliving = (EntityLiving) behaviorcontroller.getMemory(MemoryModuleType.AVOID_TARGET).get();
EntityTypes<?> entitytypes = entityliving.getEntityType();
@@ -168,34 +168,25 @@
}
}
@@ -705,6 +730,12 @@
@@ -741,6 +766,12 @@
return entitypiglin.getBehaviorController().hasMemory(MemoryModuleType.ADMIRING_ITEM);
}
+ // CraftBukkit start - Changes to allow custom payment for bartering
+ private static boolean isBarterItem(Item item, EntityPiglin piglin) {
+ return b(item) || piglin.allowedBarterItems.contains(item);
+ private static boolean isBarterItem(ItemStack itemstack, EntityPiglin piglin) {
+ return b(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem());
+ }
+ // CraftBukkit end
+
private static boolean b(Item item) {
return item == PiglinAI.a;
private static boolean b(ItemStack itemstack) {
return itemstack.a(PiglinAI.BARTERING_ITEM);
}
@@ -730,7 +761,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) {
@@ -746,7 +777,7 @@
@@ -778,7 +809,7 @@
}
private static boolean z(EntityPiglin entitypiglin) {
- return entitypiglin.getItemInOffHand().isEmpty() || !a(entitypiglin.getItemInOffHand().getItem());
+ return entitypiglin.getItemInOffHand().isEmpty() || !isLovedByPiglin(entitypiglin.getItemInOffHand().getItem(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
- return entitypiglin.getItemInOffHand().isEmpty() || !a(entitypiglin.getItemInOffHand());
+ return entitypiglin.getItemInOffHand().isEmpty() || !isLovedByPiglin(entitypiglin.getItemInOffHand(), entitypiglin); // CraftBukkit - Changes to allow custom payment for bartering
}
public static boolean a(EntityTypes entitytypes) {
public static boolean a(EntityTypes<?> entitytypes) {