PaperMC/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch
CraftBukkit/Spigot eed041d629 Update to Minecraft 1.21
By: md_5 <git@md-5.net>
2024-06-14 01:05:00 +10:00

119 lines
5.5 KiB
Diff

--- a/net/minecraft/world/entity/animal/EntityBee.java
+++ b/net/minecraft/world/entity/animal/EntityBee.java
@@ -87,6 +87,12 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityPotionEffectEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird {
public static final float FLAP_DEGREES_PER_TICK = 120.32113F;
@@ -186,12 +192,19 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
+ // CraftBukkit start - selectively save data
+ addAdditionalSaveData(nbttagcompound, true);
+ }
+
+ @Override
+ public void addAdditionalSaveData(NBTTagCompound nbttagcompound, boolean includeAll) {
+ // CraftBukkit end
super.addAdditionalSaveData(nbttagcompound);
- if (this.hasHive()) {
+ if (includeAll && this.hasHive()) { // CraftBukkit - selectively save hive
nbttagcompound.put("hive_pos", GameProfileSerializer.writeBlockPos(this.getHivePos()));
}
- if (this.hasSavedFlowerPos()) {
+ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save flower
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos()));
}
@@ -205,8 +218,8 @@
@Override
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
- this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse((Object) null);
- this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null);
+ this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse(null); // CraftBukkit - decompile error
+ this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error
super.readAdditionalSaveData(nbttagcompound);
this.setHasNectar(nbttagcompound.getBoolean("HasNectar"));
this.setHasStung(nbttagcompound.getBoolean("HasStung"));
@@ -243,7 +256,7 @@
}
if (b0 > 0) {
- entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this);
+ entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}
@@ -636,11 +649,14 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
- if (!this.level().isClientSide) {
+ // CraftBukkit start - Only stop pollinating if entity was damaged
+ boolean result = super.hurt(damagesource, f);
+ if (result && !this.level().isClientSide) {
+ // CraftBukkit end
this.beePollinateGoal.stopPollinating();
}
- return super.hurt(damagesource, f);
+ return result; // CraftBukkit
}
}
@@ -992,7 +1008,7 @@
e() {
super();
- this.travellingTicks = EntityBee.this.level().random.nextInt(10);
+ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
this.blacklistedTargets = Lists.newArrayList();
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
}
@@ -1109,7 +1125,7 @@
f() {
super();
- this.travellingTicks = EntityBee.this.level().random.nextInt(10);
+ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
}
@@ -1209,7 +1225,7 @@
}
}
- if (iblockdata1 != null) {
+ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1)) { // CraftBukkit
EntityBee.this.level().levelEvent(2011, blockposition, 15);
EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
EntityBee.this.incrementNumCropsGrownSincePollination();
@@ -1282,7 +1298,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
- entityinsentient.setTarget(entityliving);
+ entityinsentient.setTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
}
}
@@ -1291,7 +1307,7 @@
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
c(EntityBee entitybee) {
- Objects.requireNonNull(entitybee);
+ // Objects.requireNonNull(entitybee); // CraftBukkit - decompile error
super(entitybee, EntityHuman.class, 10, true, false, entitybee::isAngryAt);
}