1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
double squareRoot = Math.sqrt(d * d + d2 * d2);
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), arrow.getPickupItem(), arrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); // Paper - improve entity shhot bow event - add arrow stack to event
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), arrow.getPickupItem(), arrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); // Paper - improve entity shoot bow event, add arrow stack to event
|
||||
+ if (event.isCancelled()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
@@ -63,17 +63,18 @@
|
||||
}
|
||||
|
||||
this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
@@ -222,11 +_,23 @@
|
||||
@@ -222,11 +_,22 @@
|
||||
public void readAdditionalSaveData(CompoundTag compound) {
|
||||
super.readAdditionalSaveData(compound);
|
||||
this.reassessWeaponGoal();
|
||||
- }
|
||||
+ // Paper start - shouldBurnInDay API
|
||||
+ if (compound.contains("Paper.ShouldBurnInDay")) {
|
||||
+ this.shouldBurnInDay = compound.getBoolean("Paper.ShouldBurnInDay");
|
||||
+ }
|
||||
+ // Paper end - shouldBurnInDay API
|
||||
-
|
||||
- @Override
|
||||
- public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) {
|
||||
- super.onEquipItem(slot, oldItem, newItem);
|
||||
+ this.shouldBurnInDay = compound.getBooleanOr("Paper.ShouldBurnInDay", true); // Paper - shouldBurnInDay API
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - shouldBurnInDay API
|
||||
+ @Override
|
||||
+ public void addAdditionalSaveData(final net.minecraft.nbt.CompoundTag nbt) {
|
||||
@@ -81,12 +82,12 @@
|
||||
+ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
|
||||
+ }
|
||||
+ // Paper end - shouldBurnInDay API
|
||||
|
||||
@Override
|
||||
- public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
|
||||
- super.setItemSlot(slot, stack);
|
||||
+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { // Paper - Fix silent equipment change
|
||||
+ super.setItemSlot(slot, stack, silent); // Paper - Fix silent equipment change
|
||||
+
|
||||
+ // Paper start - silent equipping
|
||||
+ @Override
|
||||
+ public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem, boolean silent) {
|
||||
+ super.onEquipItem(slot, oldItem, newItem, silent);
|
||||
+ // Paper end - silent equipping
|
||||
if (!this.level().isClientSide) {
|
||||
this.reassessWeaponGoal();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Bogged.java
|
||||
+++ b/net/minecraft/world/entity/monster/Bogged.java
|
||||
@@ -72,7 +_,19 @@
|
||||
@@ -73,7 +_,19 @@
|
||||
ItemStack itemInHand = player.getItemInHand(hand);
|
||||
if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) {
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
@@ -21,11 +21,11 @@
|
||||
this.gameEvent(GameEvent.SHEAR, player);
|
||||
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
|
||||
}
|
||||
@@ -125,15 +_,33 @@
|
||||
@@ -126,15 +_,33 @@
|
||||
|
||||
@Override
|
||||
public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) {
|
||||
+ // Paper start - custom shear drops
|
||||
+ // Paper start - custom shear drops
|
||||
+ this.shear(level, soundSource, shears, this.generateDefaultDrops(level, shears));
|
||||
+ }
|
||||
+
|
||||
@@ -40,7 +40,7 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears, java.util.List<ItemStack> drops) {
|
||||
+ // Paper end - custom shear drops
|
||||
+ // Paper end - custom shear drops
|
||||
level.playSound(null, this, SoundEvents.BOGGED_SHEAR, soundSource, 1.0F, 1.0F);
|
||||
- this.spawnShearedMushrooms(level, shears);
|
||||
+ this.spawnShearedMushrooms(level, shears, drops); // Paper - custom shear drops
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
--- a/net/minecraft/world/entity/monster/Creeper.java
|
||||
+++ b/net/minecraft/world/entity/monster/Creeper.java
|
||||
@@ -49,6 +_,7 @@
|
||||
@@ -53,6 +_,7 @@
|
||||
public int maxSwell = 30;
|
||||
public int explosionRadius = 3;
|
||||
private int droppedSkulls;
|
||||
+ public Entity entityIgniter; // CraftBukkit
|
||||
+ public @Nullable Entity entityIgniter; // CraftBukkit
|
||||
|
||||
public Creeper(EntityType<? extends Creeper> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -121,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (compound.getBoolean("ignited")) {
|
||||
@@ -116,7 +_,7 @@
|
||||
this.maxSwell = compound.getShortOr("Fuse", (short)30);
|
||||
this.explosionRadius = compound.getByteOr("ExplosionRadius", (byte)3);
|
||||
if (compound.getBooleanOr("ignited", false)) {
|
||||
- this.ignite();
|
||||
+ this.entityData.set(DATA_IS_IGNITED, true); // Paper - set directly to avoid firing event
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,8 +_,19 @@
|
||||
@@ -149,10 +_,11 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void setTarget(@Nullable LivingEntity target) {
|
||||
+ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit
|
||||
if (!(target instanceof Goat)) {
|
||||
- super.setTarget(target);
|
||||
+ return super.setTarget(target, reason); // CraftBukkit
|
||||
}
|
||||
+ return false; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,9 +_,20 @@
|
||||
@Override
|
||||
public void thunderHit(ServerLevel level, LightningBolt lightning) {
|
||||
super.thunderHit(level, lightning);
|
||||
@@ -28,16 +42,17 @@
|
||||
+ // CraftBukkit end
|
||||
this.entityData.set(DATA_IS_POWERED, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setPowered(boolean powered) {
|
||||
+ this.entityData.set(Creeper.DATA_IS_POWERED, powered);
|
||||
+ this.entityData.set(DATA_IS_POWERED, powered);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
protected InteractionResult mobInteract(Player player, InteractionHand hand) {
|
||||
@@ -215,8 +_,9 @@
|
||||
ItemStack itemInHand = player.getItemInHand(hand);
|
||||
@@ -210,8 +_,9 @@
|
||||
this.level()
|
||||
.playSound(player, this.getX(), this.getY(), this.getZ(), soundEvent, this.getSoundSource(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F);
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -48,7 +63,7 @@
|
||||
itemInHand.shrink(1);
|
||||
} else {
|
||||
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
|
||||
@@ -232,18 +_,29 @@
|
||||
@@ -227,18 +_,29 @@
|
||||
public void explodeCreeper() {
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
float f = this.isPowered() ? 2.0F : 1.0F;
|
||||
@@ -81,7 +96,7 @@
|
||||
areaEffectCloud.setRadius(2.5F);
|
||||
areaEffectCloud.setRadiusOnUse(-0.5F);
|
||||
areaEffectCloud.setWaitTime(10);
|
||||
@@ -254,16 +_,27 @@
|
||||
@@ -250,16 +_,27 @@
|
||||
areaEffectCloud.addEffect(new MobEffectInstance(mobEffectInstance));
|
||||
}
|
||||
|
||||
@@ -92,7 +107,7 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - CreeperIgniteEvent
|
||||
+ // Paper start - Call CreeperIgniteEvent
|
||||
+ public void setIgnited(boolean ignited) {
|
||||
+ if (isIgnited() != ignited) {
|
||||
+ com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), ignited);
|
||||
@@ -101,7 +116,7 @@
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - CreeperIgniteEvent
|
||||
+ // Paper end - Call CreeperIgniteEvent
|
||||
|
||||
public boolean isIgnited() {
|
||||
return this.entityData.get(DATA_IS_IGNITED);
|
||||
@@ -109,7 +124,7 @@
|
||||
|
||||
public void ignite() {
|
||||
- this.entityData.set(DATA_IS_IGNITED, true);
|
||||
+ setIgnited(true); // Paper - CreeperIgniteEvent
|
||||
+ setIgnited(true); // Paper - Call CreeperIgniteEvent
|
||||
}
|
||||
|
||||
public boolean canDropMobsSkull() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@@ -65,7 +_,7 @@
|
||||
super.customServerAiStep(level);
|
||||
if ((this.tickCount + this.getId()) % 1200 == 0) {
|
||||
MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DIG_SLOWDOWN, 6000, 2);
|
||||
MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.MINING_FATIGUE, 6000, 2);
|
||||
- List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround(level, this, this.position(), 50.0, mobEffectInstance, 1200);
|
||||
+ List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround(level, this, this.position(), 50.0, mobEffectInstance, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent((org.bukkit.entity.ElderGuardian) this.getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper - Add ElderGuardianAppearanceEvent
|
||||
list.forEach(
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/monster/EnderMan.java
|
||||
+++ b/net/minecraft/world/entity/monster/EnderMan.java
|
||||
@@ -117,7 +_,23 @@
|
||||
@@ -116,9 +_,20 @@
|
||||
.add(Attributes.STEP_HEIGHT, 1.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(@Nullable LivingEntity livingEntity) {
|
||||
- super.setTarget(livingEntity);
|
||||
+ // CraftBukkit start - fire event
|
||||
+ this.setTarget(livingEntity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - EndermanEscapeEvent
|
||||
+ private boolean tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason reason) {
|
||||
+ return new com.destroystokyo.paper.event.entity.EndermanEscapeEvent((org.bukkit.craftbukkit.entity.CraftEnderman) this.getBukkitEntity(), reason).callEvent();
|
||||
+ }
|
||||
+ // Paper end - EndermanEscapeEvent
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean setTarget(LivingEntity livingEntity, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ if (!super.setTarget(livingEntity, reason, fireEvent)) {
|
||||
@Override
|
||||
- public void setTarget(@Nullable LivingEntity livingEntity) {
|
||||
- super.setTarget(livingEntity);
|
||||
+ // CraftBukkit start - fire event
|
||||
+ public boolean setTarget(@Nullable LivingEntity livingEntity, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) {
|
||||
+ if (!super.setTarget(livingEntity, reason)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ livingEntity = this.getTarget();
|
||||
@@ -25,7 +23,7 @@
|
||||
AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||
if (livingEntity == null) {
|
||||
this.targetChangeTime = 0;
|
||||
@@ -131,6 +_,7 @@
|
||||
@@ -132,6 +_,7 @@
|
||||
attribute.addTransientModifier(SPEED_MODIFIER_ATTACKING);
|
||||
}
|
||||
}
|
||||
@@ -33,22 +31,23 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,6 +_,14 @@
|
||||
@@ -207,6 +_,15 @@
|
||||
}
|
||||
|
||||
boolean isBeingStaredBy(Player player) {
|
||||
+ // Paper start - EndermanAttackPlayerEvent
|
||||
+ final boolean shouldAttack = isBeingStaredBy0(player);
|
||||
+ final boolean shouldAttack = this.isBeingStaredBy0(player);
|
||||
+ final com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity());
|
||||
+ event.setCancelled(!shouldAttack);
|
||||
+ return event.callEvent();
|
||||
+ }
|
||||
+ private boolean isBeingStaredBy0(Player player) {
|
||||
+
|
||||
+ boolean isBeingStaredBy0(Player player) {
|
||||
+ // Paper end - EndermanAttackPlayerEvent
|
||||
return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, new double[]{this.getEyeY()});
|
||||
}
|
||||
|
||||
@@ -251,7 +_,7 @@
|
||||
@@ -246,7 +_,7 @@
|
||||
float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue();
|
||||
if (lightLevelDependentMagicValue > 0.5F
|
||||
&& level.canSeeSky(this.blockPosition())
|
||||
@@ -57,9 +56,9 @@
|
||||
this.setTarget(null);
|
||||
this.teleport();
|
||||
}
|
||||
@@ -372,11 +_,13 @@
|
||||
@@ -369,11 +_,13 @@
|
||||
} else {
|
||||
boolean flag1 = flag && this.hurtWithCleanWater(level, damageSource, (ThrownPotion)damageSource.getDirectEntity(), amount);
|
||||
boolean flag = abstractThrownPotion1 != null && this.hurtWithCleanWater(level, damageSource, abstractThrownPotion1, amount);
|
||||
|
||||
+ if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper - EndermanEscapeEvent
|
||||
for (int i = 0; i < 64; i++) {
|
||||
@@ -69,9 +68,9 @@
|
||||
}
|
||||
+ } // Paper - EndermanEscapeEvent
|
||||
|
||||
return flag1;
|
||||
return flag;
|
||||
}
|
||||
@@ -401,6 +_,16 @@
|
||||
@@ -398,6 +_,16 @@
|
||||
this.entityData.set(DATA_STARED_AT, true);
|
||||
}
|
||||
|
||||
@@ -88,7 +87,7 @@
|
||||
@Override
|
||||
public boolean requiresCustomPersistence() {
|
||||
return super.requiresCustomPersistence() || this.getCarriedBlock() != null;
|
||||
@@ -460,16 +_,19 @@
|
||||
@@ -457,16 +_,19 @@
|
||||
int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0);
|
||||
int floor2 = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0);
|
||||
BlockPos blockPos = new BlockPos(floor, floor1, floor2);
|
||||
@@ -109,7 +108,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -567,7 +_,7 @@
|
||||
@@ -564,7 +_,7 @@
|
||||
} else {
|
||||
if (this.target != null && !this.enderman.isPassenger()) {
|
||||
if (this.enderman.isBeingStaredBy((Player)this.target)) {
|
||||
@@ -118,7 +117,7 @@
|
||||
this.enderman.teleport();
|
||||
}
|
||||
|
||||
@@ -606,15 +_,18 @@
|
||||
@@ -603,15 +_,18 @@
|
||||
int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0);
|
||||
int floor2 = Mth.floor(this.enderman.getZ() - 2.0 + random.nextDouble() * 4.0);
|
||||
BlockPos blockPos = new BlockPos(floor, floor1, floor2);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Endermite.java
|
||||
+++ b/net/minecraft/world/entity/monster/Endermite.java
|
||||
@@ -121,7 +_,7 @@
|
||||
@@ -122,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (this.life >= 2400) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Ghast.java
|
||||
+++ b/net/minecraft/world/entity/monster/Ghast.java
|
||||
@@ -63,6 +_,12 @@
|
||||
@@ -64,6 +_,12 @@
|
||||
return this.explosionPower;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
@Override
|
||||
protected boolean shouldDespawnInPeaceful() {
|
||||
return true;
|
||||
@@ -277,6 +_,7 @@
|
||||
@@ -276,6 +_,7 @@
|
||||
}
|
||||
|
||||
LargeFireball largeFireball = new LargeFireball(level, this.ghast, vec3.normalize(), this.ghast.getExplosionPower());
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/entity/monster/Phantom.java
|
||||
+++ b/net/minecraft/world/entity/monster/Phantom.java
|
||||
@@ -47,6 +_,11 @@
|
||||
Vec3 moveTargetPoint = Vec3.ZERO;
|
||||
public BlockPos anchorPoint = BlockPos.ZERO;
|
||||
@@ -48,6 +_,11 @@
|
||||
@Nullable
|
||||
public BlockPos anchorPoint;
|
||||
Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE;
|
||||
+ // Paper start
|
||||
+ @Nullable
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
public Phantom(EntityType<? extends Phantom> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -141,7 +_,7 @@
|
||||
@@ -142,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void aiStep() {
|
||||
@@ -21,42 +21,35 @@
|
||||
this.igniteForSeconds(8.0F);
|
||||
}
|
||||
|
||||
@@ -165,6 +_,15 @@
|
||||
}
|
||||
|
||||
this.setPhantomSize(compound.getInt("Size"));
|
||||
+
|
||||
@@ -163,6 +_,10 @@
|
||||
super.readAdditionalSaveData(compound);
|
||||
this.anchorPoint = compound.read("anchor_pos", BlockPos.CODEC).orElse(null);
|
||||
this.setPhantomSize(compound.getIntOr("size", 0));
|
||||
+ // Paper start
|
||||
+ if (compound.hasUUID("Paper.SpawningEntity")) {
|
||||
+ this.spawningEntity = compound.getUUID("Paper.SpawningEntity");
|
||||
+ }
|
||||
+ if (compound.contains("Paper.ShouldBurnInDay")) {
|
||||
+ this.shouldBurnInDay = compound.getBoolean("Paper.ShouldBurnInDay");
|
||||
+ }
|
||||
+ this.spawningEntity = compound.read("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC).orElse(null);
|
||||
+ this.shouldBurnInDay = compound.getBooleanOr("Paper.ShouldBurnInDay", true);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,6 +_,12 @@
|
||||
compound.putInt("AY", this.anchorPoint.getY());
|
||||
compound.putInt("AZ", this.anchorPoint.getZ());
|
||||
compound.putInt("Size", this.getPhantomSize());
|
||||
@@ -170,6 +_,10 @@
|
||||
super.addAdditionalSaveData(compound);
|
||||
compound.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint);
|
||||
compound.putInt("size", this.getPhantomSize());
|
||||
+ // Paper start
|
||||
+ if (this.spawningEntity != null) {
|
||||
+ compound.putUUID("Paper.SpawningEntity", this.spawningEntity);
|
||||
+ }
|
||||
+ compound.storeNullable("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC, this.spawningEntity);
|
||||
+ compound.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,7 +_,8 @@
|
||||
@@ -243,7 +_,8 @@
|
||||
|
||||
for (Player player : nearbyPlayers) {
|
||||
if (Phantom.this.canAttack(serverLevel, player, TargetingConditions.DEFAULT)) {
|
||||
- Phantom.this.setTarget(player);
|
||||
+ if (!level().paperConfig().entities.behavior.phantomsOnlyAttackInsomniacs || EntitySelector.IS_INSOMNIAC.test(player)) // Paper - Add phantom creative and insomniac controls
|
||||
+ Phantom.this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason
|
||||
+ Phantom.this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER); // CraftBukkit - reason
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Ravager.java
|
||||
+++ b/net/minecraft/world/entity/monster/Ravager.java
|
||||
@@ -151,12 +_,19 @@
|
||||
@@ -154,12 +_,19 @@
|
||||
BlockState blockState = serverLevel.getBlockState(blockPos);
|
||||
Block block = blockState.getBlock();
|
||||
if (block instanceof LeavesBlock) {
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +_,7 @@
|
||||
@@ -260,7 +_,7 @@
|
||||
double d = entity.getX() - this.getX();
|
||||
double d1 = entity.getZ() - this.getZ();
|
||||
double max = Math.max(d * d + d1 * d1, 0.001);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Shulker.java
|
||||
+++ b/net/minecraft/world/entity/monster/Shulker.java
|
||||
@@ -274,7 +_,13 @@
|
||||
@@ -277,7 +_,13 @@
|
||||
|
||||
@Override
|
||||
public void stopRiding() {
|
||||
@@ -15,7 +15,7 @@
|
||||
if (this.level().isClientSide) {
|
||||
this.clientOldAttachPosition = this.blockPosition();
|
||||
}
|
||||
@@ -387,6 +_,14 @@
|
||||
@@ -390,6 +_,14 @@
|
||||
&& this.level().getWorldBorder().isWithinBounds(blockPos1)
|
||||
&& this.level().noCollision(this, new AABB(blockPos1).deflate(1.0E-6))) {
|
||||
Direction direction = this.findAttachableSurface(blockPos1);
|
||||
@@ -30,16 +30,16 @@
|
||||
if (direction != null) {
|
||||
this.unRide();
|
||||
this.setAttachFace(direction);
|
||||
@@ -453,7 +_,12 @@
|
||||
@@ -454,7 +_,12 @@
|
||||
if (shulker != null) {
|
||||
shulker.setVariant(this.getVariant());
|
||||
shulker.moveTo(vec3);
|
||||
shulker.snapTo(vec3);
|
||||
- this.level().addFreshEntity(shulker);
|
||||
+ // Paper start - Shulker duplicate event
|
||||
+ // Paper start - Call ShulkerDuplicateEvent
|
||||
+ if (!new io.papermc.paper.event.entity.ShulkerDuplicateEvent((org.bukkit.entity.Shulker) shulker.getBukkitEntity(), (org.bukkit.entity.Shulker) this.getBukkitEntity()).callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Shulker duplicate event
|
||||
+ // Paper end - Call ShulkerDuplicateEvent
|
||||
+ this.level().addFreshEntity(shulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Skeleton.java
|
||||
+++ b/net/minecraft/world/entity/monster/Skeleton.java
|
||||
@@ -89,11 +_,17 @@
|
||||
@@ -93,11 +_,17 @@
|
||||
}
|
||||
|
||||
protected void doFreezeConversion() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
--- a/net/minecraft/world/entity/monster/Slime.java
|
||||
+++ b/net/minecraft/world/entity/monster/Slime.java
|
||||
@@ -56,6 +_,7 @@
|
||||
@@ -57,6 +_,7 @@
|
||||
public float squish;
|
||||
public float oSquish;
|
||||
private boolean wasOnGround;
|
||||
private boolean wasOnGround = false;
|
||||
+ private boolean canWander = true; // Paper - Slime pathfinder events
|
||||
|
||||
public Slime(EntityType<? extends Slime> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -110,6 +_,7 @@
|
||||
@@ -111,6 +_,7 @@
|
||||
super.addAdditionalSaveData(compound);
|
||||
compound.putInt("Size", this.getSize() - 1);
|
||||
compound.putBoolean("wasOnGround", this.wasOnGround);
|
||||
@@ -16,47 +16,37 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,6 +_,11 @@
|
||||
this.setSize(compound.getInt("Size") + 1, false);
|
||||
@@ -118,6 +_,7 @@
|
||||
this.setSize(compound.getIntOr("Size", 0) + 1, false);
|
||||
super.readAdditionalSaveData(compound);
|
||||
this.wasOnGround = compound.getBoolean("wasOnGround");
|
||||
+ // Paper start
|
||||
+ if (compound.contains("Paper.canWander")) {
|
||||
+ this.canWander = compound.getBoolean("Paper.canWander");
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.wasOnGround = compound.getBooleanOr("wasOnGround", false);
|
||||
+ this.canWander = compound.getBooleanOr("Paper.canWander", true); // Paper
|
||||
}
|
||||
|
||||
public boolean isTiny() {
|
||||
@@ -197,6 +_,13 @@
|
||||
@@ -197,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason reason) {
|
||||
+ // CraftBukkit start - add Bukkit remove cause
|
||||
+ this.remove(reason, null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
|
||||
+ // CraftBukkit end
|
||||
- public void remove(Entity.RemovalReason reason) {
|
||||
+ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause
|
||||
int size = this.getSize();
|
||||
if (!this.level().isClientSide && size > 1 && this.isDeadOrDying()) {
|
||||
float width = this.getDimensions(this.getPose()).width();
|
||||
@@ -204,18 +_,45 @@
|
||||
@@ -205,18 +_,43 @@
|
||||
int i = size / 2;
|
||||
int i1 = 2 + this.random.nextInt(3);
|
||||
PlayerTeam team = this.getTeam();
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), i1);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled() && event.getCount() > 0) {
|
||||
+ if (event.callEvent() && event.getCount() > 0) {
|
||||
+ i1 = event.getCount();
|
||||
+ } else {
|
||||
+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause
|
||||
+ return;
|
||||
+ }
|
||||
+ java.util.List<net.minecraft.world.entity.LivingEntity> slimes = new java.util.ArrayList<>(i1);
|
||||
+
|
||||
+ java.util.List<LivingEntity> slimes = new java.util.ArrayList<>(i1);
|
||||
+ // CraftBukkit end
|
||||
|
||||
for (int i2 = 0; i2 < i1; i2++) {
|
||||
@@ -64,9 +54,8 @@
|
||||
float f2 = (i2 / 2 - 0.5F) * f;
|
||||
- this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, team), EntitySpawnReason.TRIGGERED, mob -> {
|
||||
+ Slime converted = this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, team), EntitySpawnReason.TRIGGERED, (mob) -> { // CraftBukkit
|
||||
+ mob.aware = this.aware; // Paper - Fix nerfed slime when splitting
|
||||
mob.setSize(i, true);
|
||||
mob.moveTo(this.getX() + f1, this.getY() + 0.5, this.getZ() + f2, this.random.nextFloat() * 360.0F, 0.0F);
|
||||
mob.snapTo(this.getX() + f1, this.getY() + 0.5, this.getZ() + f2, this.random.nextFloat() * 360.0F, 0.0F);
|
||||
- });
|
||||
- }
|
||||
+ // CraftBukkit start
|
||||
@@ -78,11 +67,11 @@
|
||||
+ }
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, slimes, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
|
||||
+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause
|
||||
+ super.remove(reason, eventCause); // add Bukkit remove cause
|
||||
+ return;
|
||||
+ }
|
||||
+ for (LivingEntity living : slimes) {
|
||||
+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
|
||||
+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -92,29 +81,29 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -281,9 +_,13 @@
|
||||
@@ -282,9 +_,13 @@
|
||||
return checkMobSpawnRules(entityType, level, spawnReason, pos, random);
|
||||
}
|
||||
|
||||
+ // Paper start - Replace rules for Height in Swamp Biome
|
||||
+ // Paper start - Replace rules for Height in Swamp Biomes
|
||||
+ final double maxHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.maximum;
|
||||
+ final double minHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum;
|
||||
+ // Paper end
|
||||
+ // Paper end - Replace rules for Height in Swamp Biomes
|
||||
if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS)
|
||||
- && pos.getY() > 50
|
||||
- && pos.getY() < 70
|
||||
+ && pos.getY() > minHeightSwamp // Paper - Replace rules for Height in Swamp Biome
|
||||
+ && pos.getY() < maxHeightSwamp // Paper - Replace rules for Height in Swamp Biome
|
||||
+ && pos.getY() > minHeightSwamp // Paper - Replace rules for Height in Swamp Biomes
|
||||
+ && pos.getY() < maxHeightSwamp // Paper - Replace rules for Height in Swamp Biomes
|
||||
&& random.nextFloat() < 0.5F
|
||||
&& random.nextFloat() < level.getMoonBrightness()
|
||||
&& level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) {
|
||||
@@ -295,8 +_,11 @@
|
||||
@@ -296,8 +_,11 @@
|
||||
}
|
||||
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
- boolean flag = WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel)level).getSeed(), 987234911L).nextInt(10) == 0;
|
||||
- if (random.nextInt(10) == 0 && flag && pos.getY() < 40) {
|
||||
+ boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper
|
||||
+ boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Paper
|
||||
+ // Paper start - Replace rules for Height in Slime Chunks
|
||||
+ final double maxHeightSlimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum;
|
||||
+ if (random.nextInt(10) == 0 && flag && pos.getY() < maxHeightSlimeChunk) {
|
||||
@@ -122,7 +111,7 @@
|
||||
return checkMobSpawnRules(entityType, level, spawnReason, pos, random);
|
||||
}
|
||||
}
|
||||
@@ -355,6 +_,16 @@
|
||||
@@ -356,6 +_,16 @@
|
||||
return super.getDefaultDimensions(pose).scale(this.getSize());
|
||||
}
|
||||
|
||||
@@ -139,7 +128,7 @@
|
||||
static class SlimeAttackGoal extends Goal {
|
||||
private final Slime slime;
|
||||
private int growTiredTimer;
|
||||
@@ -367,7 +_,16 @@
|
||||
@@ -368,7 +_,16 @@
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
LivingEntity target = this.slime.getTarget();
|
||||
@@ -157,7 +146,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -379,7 +_,16 @@
|
||||
@@ -380,7 +_,16 @@
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
LivingEntity target = this.slime.getTarget();
|
||||
@@ -175,7 +164,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -398,6 +_,13 @@
|
||||
@@ -399,6 +_,13 @@
|
||||
slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage());
|
||||
}
|
||||
}
|
||||
@@ -189,7 +178,7 @@
|
||||
}
|
||||
|
||||
static class SlimeFloatGoal extends Goal {
|
||||
@@ -411,7 +_,7 @@
|
||||
@@ -412,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
@@ -198,7 +187,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -441,7 +_,7 @@
|
||||
@@ -442,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
@@ -207,7 +196,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -519,7 +_,7 @@
|
||||
@@ -520,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
@@ -216,7 +205,7 @@
|
||||
&& (this.slime.onGround() || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION))
|
||||
&& this.slime.getMoveControl() instanceof Slime.SlimeMoveControl;
|
||||
}
|
||||
@@ -529,6 +_,11 @@
|
||||
@@ -530,6 +_,11 @@
|
||||
if (--this.nextRandomizeTime <= 0) {
|
||||
this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60));
|
||||
this.chosenDegrees = this.slime.getRandom().nextInt(360);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/SpellcasterIllager.java
|
||||
+++ b/net/minecraft/world/entity/monster/SpellcasterIllager.java
|
||||
@@ -208,6 +_,11 @@
|
||||
@@ -209,6 +_,11 @@
|
||||
public void tick() {
|
||||
this.attackWarmupDelay--;
|
||||
if (this.attackWarmupDelay == 0) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Strider.java
|
||||
+++ b/net/minecraft/world/entity/monster/Strider.java
|
||||
@@ -309,7 +_,14 @@
|
||||
@@ -295,7 +_,14 @@
|
||||
|| blockStateOnLegacy.is(BlockTags.STRIDER_WARM_BLOCKS)
|
||||
|| this.getFluidHeight(FluidTags.LAVA) > 0.0;
|
||||
boolean flag1 = this.getVehicle() instanceof Strider strider && strider.isSuffocating();
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
--- a/net/minecraft/world/entity/monster/Vex.java
|
||||
+++ b/net/minecraft/world/entity/monster/Vex.java
|
||||
@@ -296,7 +_,7 @@
|
||||
@@ -286,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
- Vex.this.setTarget(Vex.this.owner.getTarget());
|
||||
+ Vex.this.setTarget(Vex.this.owner.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit
|
||||
+ Vex.this.setTarget(Vex.this.owner.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET); // CraftBukkit
|
||||
super.start();
|
||||
}
|
||||
}
|
||||
@@ -355,7 +_,10 @@
|
||||
@@ -345,7 +_,10 @@
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
BlockPos blockPos = boundOrigin.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/Vindicator.java
|
||||
+++ b/net/minecraft/world/entity/monster/Vindicator.java
|
||||
@@ -184,7 +_,7 @@
|
||||
@@ -183,7 +_,7 @@
|
||||
|
||||
static class VindicatorBreakDoorGoal extends BreakDoorGoal {
|
||||
public VindicatorBreakDoorGoal(Mob mob) {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
+ }
|
||||
+ // Paper end - WitchConsumePotionEvent
|
||||
if (mainHandItem.is(Items.POTION) && potionContents != null) {
|
||||
- potionContents.forEachEffect(this::addEffect);
|
||||
+ potionContents.forEachEffect((effect) -> this.addEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK)); // CraftBukkit
|
||||
- potionContents.forEachEffect(this::addEffect, mainHandItem.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F));
|
||||
+ potionContents.forEachEffect(effect -> this.addEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK), mainHandItem.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F)); // CraftBukkit
|
||||
}
|
||||
|
||||
this.gameEvent(GameEvent.DRINK);
|
||||
@@ -79,6 +79,6 @@
|
||||
+ }
|
||||
+ itemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion());
|
||||
+ // Paper end - WitchThrowPotionEven
|
||||
Projectile.spawnProjectileUsingShoot(ThrownPotion::new, serverLevel, itemStack, this, d, d1 + squareRoot * 0.2, d2, 0.75F, 8.0F);
|
||||
Projectile.spawnProjectileUsingShoot(ThrownSplashPotion::new, serverLevel, itemStack, this, d, d1 + squareRoot * 0.2, d2, 0.75F, 8.0F);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge");
|
||||
private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier(
|
||||
ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE
|
||||
@@ -87,13 +_,15 @@
|
||||
private static final EntityDimensions BABY_DIMENSIONS = EntityType.ZOMBIE.getDimensions().scale(0.5F).withEyeHeight(0.93F);
|
||||
private static final float BREAK_DOOR_CHANCE = 0.1F;
|
||||
public static final Predicate<Difficulty> DOOR_BREAKING_PREDICATE = difficulty -> difficulty == Difficulty.HARD;
|
||||
@@ -91,13 +_,15 @@
|
||||
private static final boolean DEFAULT_BABY = false;
|
||||
private static final boolean DEFAULT_CAN_BREAK_DOORS = false;
|
||||
private static final int DEFAULT_IN_WATER_TIME = 0;
|
||||
- private final BreakDoorGoal breakDoorGoal = new BreakDoorGoal(this, DOOR_BREAKING_PREDICATE);
|
||||
+ private final BreakDoorGoal breakDoorGoal; // Paper - move down
|
||||
private boolean canBreakDoors;
|
||||
private int inWaterTime;
|
||||
private boolean canBreakDoors = false;
|
||||
private int inWaterTime = 0;
|
||||
public int conversionTime;
|
||||
+ private boolean shouldBurnInDay = true; // Paper - Add more Zombie API
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
}
|
||||
|
||||
public Zombie(Level level) {
|
||||
@@ -102,7 +_,7 @@
|
||||
@@ -106,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
@@ -37,7 +37,7 @@
|
||||
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
||||
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
|
||||
this.addBehaviourGoals();
|
||||
@@ -114,7 +_,7 @@
|
||||
@@ -118,7 +_,7 @@
|
||||
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0));
|
||||
this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class));
|
||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
|
||||
@@ -46,7 +46,7 @@
|
||||
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
|
||||
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
|
||||
}
|
||||
@@ -168,11 +_,16 @@
|
||||
@@ -172,11 +_,16 @@
|
||||
|
||||
@Override
|
||||
protected int getBaseExperienceReward(ServerLevel level) {
|
||||
@@ -64,7 +64,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,9 +_,9 @@
|
||||
@@ -184,9 +_,9 @@
|
||||
this.getEntityData().set(DATA_BABY_ID, childZombie);
|
||||
if (this.level() != null && !this.level().isClientSide) {
|
||||
AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||
@@ -76,22 +76,21 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +_,14 @@
|
||||
@@ -255,6 +_,13 @@
|
||||
super.aiStep();
|
||||
}
|
||||
|
||||
+ // Paper start - Add more Zombie API
|
||||
+ public void stopDrowning() {
|
||||
+ this.conversionTime = -1;
|
||||
+ this.getEntityData().set(Zombie.DATA_DROWNED_CONVERSION_ID, false);
|
||||
+ this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false);
|
||||
+ }
|
||||
+ // Paper end - Add more Zombie API
|
||||
+
|
||||
public void startUnderWaterConversion(int conversionTime) {
|
||||
+ // this.lastTick = MinecraftServer.currentTick; // CraftBukkit // Paper - remove anti tick skipping measures / wall tim
|
||||
this.conversionTime = conversionTime;
|
||||
this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true);
|
||||
}
|
||||
@@ -264,31 +_,49 @@
|
||||
@@ -268,31 +_,50 @@
|
||||
}
|
||||
|
||||
protected void convertToZombieType(EntityType<? extends Zombie> entityType) {
|
||||
@@ -113,15 +112,15 @@
|
||||
@VisibleForTesting
|
||||
public boolean convertVillagerToZombieVillager(ServerLevel level, Villager villager) {
|
||||
+ // CraftBukkit start
|
||||
+ return Zombie.convertVillagerToZombieVillager(level, villager, this.blockPosition(), this.isSilent(), org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.INFECTION) != null;
|
||||
+ return convertVillagerToZombieVillager(level, villager, this.blockPosition(), this.isSilent(), org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.INFECTION) != null;
|
||||
+ }
|
||||
+
|
||||
+ public static ZombieVillager convertVillagerToZombieVillager(ServerLevel level, Villager villager, net.minecraft.core.BlockPos blockPosition, boolean silent, org.bukkit.event.entity.EntityTransformEvent.TransformReason transformReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) {
|
||||
+ public static @Nullable ZombieVillager convertVillagerToZombieVillager(ServerLevel level, Villager villager, net.minecraft.core.BlockPos blockPosition, boolean silent, org.bukkit.event.entity.EntityTransformEvent.TransformReason transformReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) {
|
||||
+ // CraftBukkit end
|
||||
ZombieVillager zombieVillager = villager.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(villager, true, true), mob -> {
|
||||
mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, new Zombie.ZombieGroupData(false, true));
|
||||
mob.setVillagerData(villager.getVillagerData());
|
||||
mob.setGossips(villager.getGossips().store(NbtOps.INSTANCE));
|
||||
mob.setGossips(villager.getGossips().copy());
|
||||
mob.setTradeOffers(villager.getOffers().copy());
|
||||
mob.setVillagerXp(villager.getVillagerXp());
|
||||
- if (!this.isSilent()) {
|
||||
@@ -142,6 +141,7 @@
|
||||
- }
|
||||
+ return this.shouldBurnInDay; // Paper - Add more Zombie API
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - Add more Zombie API
|
||||
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
|
||||
+ this.shouldBurnInDay = shouldBurnInDay;
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
@Override
|
||||
public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) {
|
||||
@@ -321,13 +_,13 @@
|
||||
@@ -325,13 +_,13 @@
|
||||
if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos)
|
||||
&& SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) {
|
||||
zombie.setPos(i1, i2, i3);
|
||||
@@ -160,30 +160,28 @@
|
||||
&& level.noCollision(zombie)
|
||||
&& (zombie.canSpawnInLiquids() || !level.containsAnyLiquid(zombie.getBoundingBox()))) {
|
||||
- zombie.setTarget(target);
|
||||
+ zombie.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
|
||||
+ zombie.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); // CraftBukkit
|
||||
zombie.finalizeSpawn(level, level.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.REINFORCEMENT, null);
|
||||
- level.addFreshEntityWithPassengers(zombie);
|
||||
+ level.addFreshEntityWithPassengers(zombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
||||
AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE);
|
||||
AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID);
|
||||
double d = modifier != null ? modifier.amount() : 0.0;
|
||||
@@ -352,7 +_,14 @@
|
||||
@@ -356,7 +_,12 @@
|
||||
if (flag) {
|
||||
float effectiveDifficulty = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
|
||||
if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) {
|
||||
- source.igniteForSeconds(2 * (int)effectiveDifficulty);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityCombustByEntityEvent event = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), source.getBukkitEntity(), (float) (2 * (int)effectiveDifficulty));
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ if (event.callEvent()) {
|
||||
+ source.igniteForSeconds(event.getDuration(), false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,6 +_,7 @@
|
||||
@@ -416,6 +_,7 @@
|
||||
compound.putBoolean("CanBreakDoors", this.canBreakDoors());
|
||||
compound.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1);
|
||||
compound.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1);
|
||||
@@ -191,15 +189,11 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -423,13 +_,19 @@
|
||||
if (compound.contains("DrownedConversionTime", 99) && compound.getInt("DrownedConversionTime") > -1) {
|
||||
this.startUnderWaterConversion(compound.getInt("DrownedConversionTime"));
|
||||
@@ -430,13 +_,15 @@
|
||||
} else {
|
||||
this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false);
|
||||
}
|
||||
+ // Paper start - Add more Zombie API
|
||||
+ if (compound.contains("Paper.ShouldBurnInDay")) {
|
||||
+ this.shouldBurnInDay = compound.getBoolean("Paper.ShouldBurnInDay");
|
||||
+ }
|
||||
+ // Paper end - Add more Zombie API
|
||||
+ this.shouldBurnInDay = compound.getBooleanOr("Paper.ShouldBurnInDay", true); // Paper - Add more Zombie API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +207,7 @@
|
||||
return flag;
|
||||
}
|
||||
|
||||
@@ -465,7 +_,7 @@
|
||||
@@ -472,7 +_,7 @@
|
||||
spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData);
|
||||
float specialMultiplier = difficulty.getSpecialMultiplier();
|
||||
if (spawnReason != EntitySpawnReason.CONVERSION) {
|
||||
@@ -222,7 +216,7 @@
|
||||
}
|
||||
|
||||
if (spawnGroupData == null) {
|
||||
@@ -492,7 +_,7 @@
|
||||
@@ -499,7 +_,7 @@
|
||||
chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null);
|
||||
chicken1.setChickenJockey(true);
|
||||
this.startRiding(chicken1);
|
||||
|
||||
@@ -1,78 +1,54 @@
|
||||
--- a/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
+++ b/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
@@ -33,6 +_,7 @@
|
||||
import net.minecraft.world.entity.SlotAccess;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.ai.village.ReputationEventType;
|
||||
+import net.minecraft.world.entity.npc.Villager;
|
||||
import net.minecraft.world.entity.npc.VillagerData;
|
||||
import net.minecraft.world.entity.npc.VillagerDataHolder;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
@@ -68,6 +_,7 @@
|
||||
@Nullable
|
||||
private MerchantOffers tradeOffers;
|
||||
private int villagerXp;
|
||||
+ private int lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit - add field
|
||||
|
||||
public ZombieVillager(EntityType<? extends ZombieVillager> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -147,6 +_,7 @@
|
||||
}
|
||||
|
||||
super.tick();
|
||||
+ this.lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,12 +_,20 @@
|
||||
@@ -160,12 +_,20 @@
|
||||
}
|
||||
|
||||
public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime) {
|
||||
+ // Paper start - missing entity behaviour api - converting without entity event
|
||||
+ // Paper start - missing entity behaviour api - converting without entity event
|
||||
+ this.startConverting(conversionStarter, villagerConversionTime, true);
|
||||
+ }
|
||||
+
|
||||
+ public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime, boolean broadcastEntityEvent) {
|
||||
+ // Paper end - missing entity behaviour api - converting without entity event
|
||||
+ // Paper end - missing entity behaviour api - converting without entity event
|
||||
this.conversionStarter = conversionStarter;
|
||||
this.villagerConversionTime = villagerConversionTime;
|
||||
this.getEntityData().set(DATA_CONVERTING_ID, true);
|
||||
- this.removeEffect(MobEffects.WEAKNESS);
|
||||
- this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)));
|
||||
- this.addEffect(new MobEffectInstance(MobEffects.STRENGTH, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)));
|
||||
- this.level().broadcastEntityEvent(this, (byte)16);
|
||||
+ // CraftBukkit start
|
||||
+ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
+ this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
+ this.addEffect(new MobEffectInstance(MobEffects.STRENGTH, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
+ // CraftBukkit end
|
||||
+ if (broadcastEntityEvent) this.level().broadcastEntityEvent(this, (byte)16); // Paper - missing entity behaviour api - converting without entity event
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +_,7 @@
|
||||
@@ -190,7 +_,7 @@
|
||||
}
|
||||
|
||||
private void finishConversion(ServerLevel serverLevel) {
|
||||
private void finishConversion(ServerLevel level) {
|
||||
- this.convertTo(
|
||||
+ Villager converted = this.convertTo( // CraftBukkit
|
||||
EntityType.VILLAGER,
|
||||
ConversionParams.single(this, false, false),
|
||||
villager -> {
|
||||
@@ -237,19 +_,24 @@
|
||||
villager.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(villager.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
villager.refreshBrain(serverLevel);
|
||||
@@ -214,19 +_,24 @@
|
||||
villager.finalizeSpawn(level, level.getCurrentDifficultyAt(villager.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
villager.refreshBrain(level);
|
||||
if (this.conversionStarter != null) {
|
||||
- Player playerByUuid = serverLevel.getPlayerByUUID(this.conversionStarter);
|
||||
+ Player playerByUuid = serverLevel.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate
|
||||
- Player playerByUuid = level.getPlayerByUUID(this.conversionStarter);
|
||||
+ Player playerByUuid = level.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate
|
||||
if (playerByUuid instanceof ServerPlayer) {
|
||||
CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer)playerByUuid, this, villager);
|
||||
serverLevel.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, playerByUuid, villager);
|
||||
level.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, playerByUuid, villager);
|
||||
}
|
||||
}
|
||||
|
||||
- villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
|
||||
+ villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit
|
||||
- villager.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));
|
||||
+ villager.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit
|
||||
if (!this.isSilent()) {
|
||||
serverLevel.levelEvent(null, 1027, this.blockPosition(), 0);
|
||||
level.levelEvent(null, 1027, this.blockPosition(), 0);
|
||||
}
|
||||
- }
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
private static final int ALERT_RANGE_Y = 10;
|
||||
private static final UniformInt ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6);
|
||||
private int ticksUntilNextAlert;
|
||||
+ private HurtByTargetGoal pathfinderGoalHurtByTarget; // Paper - fix PigZombieAngerEvent cancellation
|
||||
+ private HurtByTargetGoal hurtByTargetGoal; // Paper - fix PigZombieAngerEvent cancellation
|
||||
|
||||
public ZombifiedPiglin(EntityType<? extends ZombifiedPiglin> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -13,46 +13,43 @@
|
||||
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false));
|
||||
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0));
|
||||
- this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers());
|
||||
+ this.targetSelector.addGoal(1, this.pathfinderGoalHurtByTarget = (new HurtByTargetGoal(this)).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation
|
||||
+ this.targetSelector.addGoal(1, this.hurtByTargetGoal = (new HurtByTargetGoal(this)).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation
|
||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
|
||||
this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true));
|
||||
}
|
||||
@@ -148,7 +_,7 @@
|
||||
@@ -144,7 +_,7 @@
|
||||
.filter(zombifiedPiglin -> zombifiedPiglin != this)
|
||||
.filter(zombifiedPiglin -> zombifiedPiglin.getTarget() == null)
|
||||
.filter(zombifiedPiglin -> !zombifiedPiglin.isAlliedTo(this.getTarget()))
|
||||
- .forEach(zombifiedPiglin -> zombifiedPiglin.setTarget(this.getTarget()));
|
||||
+ .forEach(zombifiedPiglin -> zombifiedPiglin.setTarget(this.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true)); // CraftBukkit
|
||||
+ .forEach(zombifiedPiglin -> zombifiedPiglin.setTarget(this.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY)); // CraftBukkit
|
||||
}
|
||||
|
||||
private void playAngerSound() {
|
||||
@@ -156,7 +_,7 @@
|
||||
@@ -152,18 +_,27 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void setTarget(@Nullable LivingEntity livingEntity) {
|
||||
+ public boolean setTarget(@Nullable LivingEntity livingEntity, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature
|
||||
+ public boolean setTarget(@Nullable LivingEntity livingEntity, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit - signature
|
||||
if (this.getTarget() == null && livingEntity != null) {
|
||||
this.playFirstAngerSoundIn = FIRST_ANGER_SOUND_DELAY.sample(this.random);
|
||||
this.ticksUntilNextAlert = ALERT_INTERVAL.sample(this.random);
|
||||
@@ -166,12 +_,22 @@
|
||||
this.setLastHurtByPlayer((Player)livingEntity);
|
||||
}
|
||||
|
||||
- super.setTarget(livingEntity);
|
||||
+ return super.setTarget(livingEntity, reason, fireEvent); // CraftBukkit
|
||||
+ return super.setTarget(livingEntity, reason); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPersistentAngerTimer() {
|
||||
- this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random));
|
||||
+ // CraftBukkit start
|
||||
+ net.minecraft.world.entity.Entity entity = ((ServerLevel) this.level()).getEntity(this.getPersistentAngerTarget());
|
||||
+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), ZombifiedPiglin.PERSISTENT_ANGER_TIME.sample(this.random));
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ net.minecraft.world.entity.Entity entity = this.level().getEntity(this.getPersistentAngerTarget());
|
||||
+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), PERSISTENT_ANGER_TIME.sample(this.random));
|
||||
+ if (!event.callEvent()) {
|
||||
+ this.setPersistentAngerTarget(null);
|
||||
+ this.pathfinderGoalHurtByTarget.stop(); // Paper - fix PigZombieAngerEvent cancellation
|
||||
+ this.hurtByTargetGoal.stop();
|
||||
+ return;
|
||||
+ }
|
||||
+ this.setRemainingPersistentAngerTime(event.getNewAnger());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
+++ b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
@@ -190,9 +_,9 @@
|
||||
@@ -191,9 +_,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -12,7 +12,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +_,7 @@
|
||||
@@ -318,7 +_,7 @@
|
||||
}
|
||||
|
||||
this.makeSound(this.getDeathSound());
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
|
||||
public void creakingDeathEffects(DamageSource damageSource) {
|
||||
@@ -480,9 +_,9 @@
|
||||
@@ -471,9 +_,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
@@ -262,7 +_,12 @@
|
||||
@@ -265,7 +_,12 @@
|
||||
}
|
||||
|
||||
private void finishConversion() {
|
||||
- this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)));
|
||||
+ final Entity converted = this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
|
||||
- this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)));
|
||||
+ final Entity converted = this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
|
||||
+ // Paper start - Fix issues with mob conversion; reset to prevent event spam
|
||||
+ if (converted == null) {
|
||||
+ this.timeInOverworld = 0;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
--- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
@@ -99,9 +_,14 @@
|
||||
@@ -102,9 +_,14 @@
|
||||
}
|
||||
|
||||
protected void finishConversion(ServerLevel serverLevel) {
|
||||
- this.convertTo(
|
||||
- EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0))
|
||||
- EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0))
|
||||
+ net.minecraft.world.entity.Entity converted = this.convertTo( // Paper - Fix issues with mob conversion; reset to prevent event spam
|
||||
+ EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED // CraftBukkit - add spawn and transform reasons
|
||||
+ EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED // CraftBukkit - add spawn and transform reasons
|
||||
);
|
||||
+ // Paper start - Fix issues with mob conversion; reset to prevent event spam
|
||||
+ if (converted == null) {
|
||||
|
||||
@@ -1,69 +1,41 @@
|
||||
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -59,6 +_,25 @@
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+// CraftBukkit start
|
||||
+import java.util.stream.Collectors;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.nbt.ListTag;
|
||||
+import net.minecraft.nbt.StringTag;
|
||||
+import net.minecraft.nbt.Tag;
|
||||
+import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
+import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
+import net.minecraft.network.syncher.SynchedEntityData;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+import net.minecraft.sounds.SoundEvents;
|
||||
+import net.minecraft.world.item.Item;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Piglin extends AbstractPiglin implements CrossbowAttackMob, InventoryCarrier {
|
||||
private static final EntityDataAccessor<Boolean> DATA_BABY_ID = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN);
|
||||
@@ -122,6 +_,10 @@
|
||||
@@ -124,6 +_,12 @@
|
||||
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<>();
|
||||
+ public java.util.Set<Item> allowedBarterItems = new java.util.HashSet<>();
|
||||
+ public java.util.Set<Item> interestItems = new java.util.HashSet<>();
|
||||
+ private static final com.mojang.serialization.Codec<java.util.Set<net.minecraft.world.item.Item>> ITEM_SET_CODEC = net.minecraft.core.registries.BuiltInRegistries.ITEM
|
||||
+ .byNameCodec().listOf().xmap(java.util.HashSet::new, List::copyOf);
|
||||
+ // CraftBukkit end
|
||||
|
||||
public Piglin(EntityType<? extends AbstractPiglin> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -140,6 +_,14 @@
|
||||
}
|
||||
|
||||
@@ -136,6 +_,10 @@
|
||||
compound.putBoolean("IsBaby", this.isBaby());
|
||||
compound.putBoolean("CannotHunt", this.cannotHunt);
|
||||
this.writeInventoryToTag(compound, this.registryAccess());
|
||||
+ // CraftBukkit start
|
||||
+ ListTag barterList = new ListTag();
|
||||
+ this.allowedBarterItems.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).map(StringTag::valueOf).forEach(barterList::add);
|
||||
+ compound.put("Bukkit.BarterList", barterList);
|
||||
+ ListTag interestList = new ListTag();
|
||||
+ this.interestItems.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).map(StringTag::valueOf).forEach(interestList::add);
|
||||
+ compound.put("Bukkit.InterestList", interestList);
|
||||
+ compound.store("Bukkit.BarterList", ITEM_SET_CODEC, this.allowedBarterItems);
|
||||
+ compound.store("Bukkit.InterestList", ITEM_SET_CODEC, this.interestItems);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,6 +_,10 @@
|
||||
this.setBaby(compound.getBoolean("IsBaby"));
|
||||
this.setCannotHunt(compound.getBoolean("CannotHunt"));
|
||||
@@ -144,6 +_,10 @@
|
||||
this.setBaby(compound.getBooleanOr("IsBaby", false));
|
||||
this.setCannotHunt(compound.getBooleanOr("CannotHunt", false));
|
||||
this.readInventoryFromTag(compound, this.registryAccess());
|
||||
+ // CraftBukkit start
|
||||
+ this.allowedBarterItems = compound.getList("Bukkit.BarterList", 8).stream().map(Tag::getAsString).map(ResourceLocation::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new));
|
||||
+ this.interestItems = compound.getList("Bukkit.InterestList", 8).stream().map(Tag::getAsString).map(ResourceLocation::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new));
|
||||
+ this.allowedBarterItems = compound.read("Bukkit.BarterList", ITEM_SET_CODEC).orElseGet(java.util.HashSet::new);
|
||||
+ this.interestItems = compound.read("Bukkit.InterestList", ITEM_SET_CODEC).orElseGet(java.util.HashSet::new);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@VisibleForDebug
|
||||
@@ -325,7 +_,9 @@
|
||||
@@ -321,7 +_,9 @@
|
||||
@Override
|
||||
protected void finishConversion(ServerLevel serverLevel) {
|
||||
PiglinAi.cancelAdmiring(serverLevel, this);
|
||||
@@ -73,7 +45,7 @@
|
||||
super.finishConversion(serverLevel);
|
||||
}
|
||||
|
||||
@@ -400,7 +_,7 @@
|
||||
@@ -397,7 +_,7 @@
|
||||
}
|
||||
|
||||
protected void holdInOffHand(ItemStack stack) {
|
||||
@@ -82,7 +54,7 @@
|
||||
this.setItemSlot(EquipmentSlot.OFFHAND, stack);
|
||||
this.setGuaranteedDrop(EquipmentSlot.OFFHAND);
|
||||
} else {
|
||||
@@ -425,15 +_,15 @@
|
||||
@@ -422,15 +_,15 @@
|
||||
return false;
|
||||
} else {
|
||||
TagKey<Item> preferredWeaponType = this.getPreferredWeaponType();
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
@@ -70,6 +_,13 @@
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import java.util.stream.Collectors;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.entity.PiglinBarterEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class PiglinAi {
|
||||
public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8;
|
||||
@@ -328,23 +_,32 @@
|
||||
@@ -330,23 +_,32 @@
|
||||
protected static void pickUpItem(ServerLevel level, Piglin piglin, ItemEntity itemEntity) {
|
||||
stopWalking(piglin);
|
||||
ItemStack item;
|
||||
@@ -29,7 +15,7 @@
|
||||
item = itemEntity.getItem();
|
||||
- itemEntity.discard();
|
||||
- } else {
|
||||
+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
+ itemEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
+ } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, itemEntity, itemEntity.getItem().getCount() - 1, false).isCancelled()) {
|
||||
+ piglin.onItemPickup(itemEntity); // Paper - EntityPickupItemEvent fixes; moved from Piglin#pickUpItem - call prior to item entity modification
|
||||
piglin.take(itemEntity, 1);
|
||||
@@ -52,7 +38,7 @@
|
||||
if (!flag) {
|
||||
putInInventory(piglin, item);
|
||||
}
|
||||
@@ -353,7 +_,9 @@
|
||||
@@ -355,7 +_,9 @@
|
||||
|
||||
private static void holdInOffhand(ServerLevel level, Piglin piglin, ItemStack stack) {
|
||||
if (isHoldingItemInOffHand(piglin)) {
|
||||
@@ -62,16 +48,16 @@
|
||||
}
|
||||
|
||||
piglin.holdInOffHand(stack);
|
||||
@@ -363,7 +_,7 @@
|
||||
@@ -365,7 +_,7 @@
|
||||
ItemStack item = itemEntity.getItem();
|
||||
ItemStack itemStack = item.split(1);
|
||||
if (item.isEmpty()) {
|
||||
- itemEntity.discard();
|
||||
+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
+ itemEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
} else {
|
||||
itemEntity.setItem(item);
|
||||
}
|
||||
@@ -375,9 +_,14 @@
|
||||
@@ -377,9 +_,14 @@
|
||||
ItemStack itemInHand = piglin.getItemInHand(InteractionHand.OFF_HAND);
|
||||
piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
|
||||
if (piglin.isAdult()) {
|
||||
@@ -80,15 +66,15 @@
|
||||
if (barter && isBarterCurrency) {
|
||||
- throwItems(piglin, getBarterResponseItems(piglin));
|
||||
+ // CraftBukkit start
|
||||
+ PiglinBarterEvent event = CraftEventFactory.callPiglinBarterEvent(piglin, getBarterResponseItems(piglin), itemInHand);
|
||||
+ org.bukkit.event.entity.PiglinBarterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPiglinBarterEvent(piglin, getBarterResponseItems(piglin), itemInHand);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ throwItems(piglin, event.getOutcome().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList()));
|
||||
+ throwItems(piglin, event.getOutcome().stream().map(org.bukkit.craftbukkit.inventory.CraftItemStack::asNMSCopy).collect(java.util.stream.Collectors.toList()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else if (!isBarterCurrency) {
|
||||
boolean flag = !piglin.equipItemIfPossible(level, itemInHand).isEmpty();
|
||||
if (!flag) {
|
||||
@@ -388,7 +_,7 @@
|
||||
@@ -390,7 +_,7 @@
|
||||
boolean isBarterCurrency = !piglin.equipItemIfPossible(level, itemInHand).isEmpty();
|
||||
if (!isBarterCurrency) {
|
||||
ItemStack mainHandItem = piglin.getMainHandItem();
|
||||
@@ -97,7 +83,7 @@
|
||||
putInInventory(piglin, mainHandItem);
|
||||
} else {
|
||||
throwItems(piglin, Collections.singletonList(mainHandItem));
|
||||
@@ -401,7 +_,9 @@
|
||||
@@ -403,7 +_,9 @@
|
||||
|
||||
protected static void cancelAdmiring(ServerLevel level, Piglin piglin) {
|
||||
if (isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) {
|
||||
@@ -107,7 +93,7 @@
|
||||
piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
@@ -457,7 +_,7 @@
|
||||
@@ -459,7 +_,7 @@
|
||||
return false;
|
||||
} else if (isAdmiringDisabled(piglin) && piglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) {
|
||||
return false;
|
||||
@@ -116,7 +102,7 @@
|
||||
return isNotHoldingLovedItemInOffHand(piglin);
|
||||
} else {
|
||||
boolean canAddToInventory = piglin.canAddToInventory(stack);
|
||||
@@ -466,11 +_,16 @@
|
||||
@@ -468,11 +_,16 @@
|
||||
} else if (isFood(stack)) {
|
||||
return !hasEatenRecently(piglin) && canAddToInventory;
|
||||
} else {
|
||||
@@ -134,7 +120,7 @@
|
||||
protected static boolean isLovedItem(ItemStack item) {
|
||||
return item.is(ItemTags.PIGLIN_LOVED);
|
||||
}
|
||||
@@ -522,6 +_,7 @@
|
||||
@@ -524,6 +_,7 @@
|
||||
}
|
||||
|
||||
public static void angerNearbyPiglins(ServerLevel level, Player player, boolean requireLineOfSight) {
|
||||
@@ -142,7 +128,7 @@
|
||||
List<Piglin> entitiesOfClass = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0));
|
||||
entitiesOfClass.stream().filter(PiglinAi::isIdle).filter(piglin -> !requireLineOfSight || BehaviorUtils.canSee(piglin, player)).forEach(piglin -> {
|
||||
if (level.getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) {
|
||||
@@ -546,7 +_,7 @@
|
||||
@@ -548,7 +_,7 @@
|
||||
}
|
||||
|
||||
protected static boolean canAdmire(Piglin piglin, ItemStack stack) {
|
||||
@@ -151,7 +137,7 @@
|
||||
}
|
||||
|
||||
protected static void wasHurtBy(ServerLevel level, Piglin piglin, LivingEntity entity) {
|
||||
@@ -794,6 +_,11 @@
|
||||
@@ -796,6 +_,11 @@
|
||||
return piglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM);
|
||||
}
|
||||
|
||||
@@ -163,7 +149,7 @@
|
||||
private static boolean isBarterCurrency(ItemStack stack) {
|
||||
return stack.is(BARTERING_ITEM);
|
||||
}
|
||||
@@ -831,7 +_,7 @@
|
||||
@@ -833,7 +_,7 @@
|
||||
}
|
||||
|
||||
private static boolean isNotHoldingLovedItemInOffHand(Piglin piglin) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -407,7 +_,7 @@
|
||||
@@ -404,7 +_,7 @@
|
||||
|
||||
public static void applyDarknessAround(ServerLevel level, Vec3 pos, @Nullable Entity source, int radius) {
|
||||
MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false);
|
||||
@@ -9,7 +9,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -469,6 +_,15 @@
|
||||
@@ -450,6 +_,15 @@
|
||||
@VisibleForTesting
|
||||
public void increaseAngerAt(@Nullable Entity entity, int offset, boolean playListeningSound) {
|
||||
if (!this.isNoAi() && this.canTargetEntity(entity)) {
|
||||
|
||||
Reference in New Issue
Block a user