2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/animal/EntityBee.java
+++ b/net/minecraft/world/entity/animal/EntityBee.java
2024-06-14 01:05:00 +10:00
@@ -87,6 +87,12 @@
2023-06-24 17:15:05 +10:00
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;
2024-06-14 01:05:00 +10:00
@@ -186,12 +192,19 @@
2023-11-19 19:03:35 +13:00
@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
2024-04-24 01:15:00 +10:00
nbttagcompound.put("hive_pos", GameProfileSerializer.writeBlockPos(this.getHivePos()));
2023-11-19 19:03:35 +13:00
}
- if (this.hasSavedFlowerPos()) {
+ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save flower
2024-04-24 01:15:00 +10:00
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos()));
2023-11-19 19:03:35 +13:00
}
2024-06-14 01:05:00 +10:00
@@ -205,8 +218,8 @@
2024-04-24 01:15:00 +10:00
@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"));
2024-06-14 01:05:00 +10:00
@@ -243,7 +256,7 @@
2020-02-02 11:16:01 +11:00
}
if (b0 > 0) {
2024-06-14 01:05:00 +10:00
- entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this);
+ entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
2020-02-02 11:16:01 +11:00
}
2019-12-11 09:00:00 +11:00
}
2024-06-14 01:05:00 +10:00
@@ -636,11 +649,14 @@
2021-11-22 09:00:00 +11:00
if (this.isInvulnerableTo(damagesource)) {
2021-06-11 15:00:00 +10:00
return false;
2019-12-19 12:25:11 +11:00
} else {
2023-06-08 01:30:00 +10:00
- if (!this.level().isClientSide) {
2023-06-24 17:15:05 +10:00
+ // CraftBukkit start - Only stop pollinating if entity was damaged
2021-11-22 09:00:00 +11:00
+ boolean result = super.hurt(damagesource, f);
2023-06-08 01:30:00 +10:00
+ if (result && !this.level().isClientSide) {
2023-06-24 17:15:05 +10:00
+ // CraftBukkit end
2021-11-22 09:00:00 +11:00
this.beePollinateGoal.stopPollinating();
2019-12-19 12:25:11 +11:00
}
2021-11-22 09:00:00 +11:00
- return super.hurt(damagesource, f);
2023-06-24 17:15:05 +10:00
+ return result; // CraftBukkit
2019-12-19 12:25:11 +11:00
}
}
2024-06-14 01:05:00 +10:00
@@ -992,7 +1008,7 @@
2023-10-03 11:56:23 +02:00
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));
}
2024-06-14 01:05:00 +10:00
@@ -1109,7 +1125,7 @@
2023-10-03 11:56:23 +02:00
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));
}
2024-06-14 01:05:00 +10:00
@@ -1209,7 +1225,7 @@
2020-01-21 14:33:44 +11:00
}
}
2023-06-08 01:30:00 +10:00
- if (iblockdata1 != null) {
2023-06-24 17:15:05 +10:00
+ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1)) { // CraftBukkit
2024-04-24 01:15:00 +10:00
EntityBee.this.level().levelEvent(2011, blockposition, 15);
2023-06-08 01:30:00 +10:00
EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
2021-11-22 09:00:00 +11:00
EntityBee.this.incrementNumCropsGrownSincePollination();
2024-06-14 01:05:00 +10:00
@@ -1282,7 +1298,7 @@
2019-12-11 09:00:00 +11:00
@Override
2021-11-22 09:00:00 +11:00
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
2021-06-11 15:00:00 +10:00
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
2021-11-22 09:00:00 +11:00
- entityinsentient.setTarget(entityliving);
2023-06-24 17:15:05 +10:00
+ entityinsentient.setTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
2019-12-11 09:00:00 +11:00
}
}
2024-06-14 01:05:00 +10:00
@@ -1291,7 +1307,7 @@
2021-06-11 15:00:00 +10:00
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
c(EntityBee entitybee) {
- Objects.requireNonNull(entitybee);
+ // Objects.requireNonNull(entitybee); // CraftBukkit - decompile error
2021-11-22 09:00:00 +11:00
super(entitybee, EntityHuman.class, 10, true, false, entitybee::isAngryAt);
2021-06-11 15:00:00 +10:00
}