aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Bee.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Bee.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Bee.java.patch128
1 files changed, 128 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Bee.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Bee.java.patch
new file mode 100644
index 0000000000..26d2dc069c
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Bee.java.patch
@@ -0,0 +1,128 @@
+--- a/net/minecraft/world/entity/animal/Bee.java
++++ b/net/minecraft/world/entity/animal/Bee.java
+@@ -88,6 +89,11 @@
+ import net.minecraft.world.level.pathfinder.BlockPathTypes;
+ import net.minecraft.world.level.pathfinder.Path;
+ import net.minecraft.world.phys.Vec3;
++// CraftBukkit start
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.event.entity.EntityPotionEffectEvent;
++import org.bukkit.event.entity.EntityTargetEvent;
++// CraftBukkit end
+
+ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
+ public static final float FLAP_DEGREES_PER_TICK = 120.32113F;
+@@ -184,13 +192,20 @@
+
+ @Override
+ public void addAdditionalSaveData(CompoundTag compound) {
+- super.addAdditionalSaveData(compound);
+- if (this.hasHive()) {
+- compound.put("HivePos", NbtUtils.writeBlockPos(this.getHivePos()));
++ // CraftBukkit start - selectively save data
++ addAdditionalSaveData(compound, true);
++ }
++
++ @Override
++ public void addAdditionalSaveData(CompoundTag nbttagcompound, boolean includeAll) {
++ // CraftBukkit end
++ super.addAdditionalSaveData(nbttagcompound);
++ if (includeAll && this.hasHive()) { // CraftBukkit - selectively save hive
++ nbttagcompound.put("HivePos", NbtUtils.writeBlockPos(this.getHivePos()));
+ }
+
+- if (this.hasSavedFlowerPos()) {
+- compound.put("FlowerPos", NbtUtils.writeBlockPos(this.getSavedFlowerPos()));
++ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save flower
++ nbttagcompound.put("FlowerPos", NbtUtils.writeBlockPos(this.getSavedFlowerPos()));
+ }
+
+ compound.putBoolean("HasNectar", this.hasNectar());
+@@ -236,8 +253,8 @@
+ i = 18;
+ }
+
+- if (i > 0) {
+- ((LivingEntity)entity).addEffect(new MobEffectInstance(MobEffects.POISON, i * 20, 0), this);
++ if (b0 > 0) {
++ ((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
+ }
+ }
+
+@@ -632,11 +652,14 @@
+ if (this.isInvulnerableTo(source)) {
+ return false;
+ } else {
+- if (!this.level().isClientSide) {
++ // CraftBukkit start - Only stop pollinating if entity was damaged
++ boolean result = super.hurt(source, amount);
++ if (result && !this.level().isClientSide) {
++ // CraftBukkit end
+ this.beePollinateGoal.stopPollinating();
+ }
+
+- return super.hurt(source, amount);
++ return result; // CraftBukkit
+ }
+ }
+
+@@ -760,7 +1013,10 @@
+ private int ticksStuck;
+
+ BeeGoToHiveGoal() {
+- this.setFlags(EnumSet.of(Goal.Flag.MOVE));
++ super();
++ this.travellingTicks = Bee.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(Goal.Type.MOVE));
+ }
+
+ @Override
+@@ -873,7 +1130,9 @@
+ int travellingTicks = Bee.this.level().random.nextInt(10);
+
+ BeeGoToKnownFlowerGoal() {
+- this.setFlags(EnumSet.of(Goal.Flag.MOVE));
++ super();
++ this.travellingTicks = Bee.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(Goal.Type.MOVE));
+ }
+
+ @Override
+@@ -965,9 +1231,9 @@
+ ((BonemealableBlock)blockState.getBlock()).performBonemeal((ServerLevel)Bee.this.level(), Bee.this.random, blockPos, blockState);
+ }
+
+- if (blockState1 != null) {
+- Bee.this.level().levelEvent(2005, blockPos, 0);
+- Bee.this.level().setBlockAndUpdate(blockPos, blockState1);
++ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(Bee.this, blockposition, iblockdata1)) { // CraftBukkit
++ Bee.this.level().levelEvent(2005, blockposition, 0);
++ Bee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
+ Bee.this.incrementNumCropsGrownSincePollination();
+ }
+ }
+@@ -1105,20 +1302,9 @@
+ }
+
+ @Override
+- public boolean canBeeContinueToUse() {
+- if (!this.pollinating) {
+- return false;
+- } else if (!Bee.this.hasSavedFlowerPos()) {
+- return false;
+- } else if (Bee.this.level().isRaining()) {
+- return false;
+- } else if (this.hasPollinatedLongEnough()) {
+- return Bee.this.random.nextFloat() < 0.2F;
+- } else if (Bee.this.tickCount % 20 == 0 && !Bee.this.isFlowerValid(Bee.this.savedFlowerPos)) {
+- Bee.this.savedFlowerPos = null;
+- return false;
+- } else {
+- return true;
++ protected void alertOther(Mob mob, LivingEntity target) {
++ if (mob instanceof Bee && this.mob.hasLineOfSight(target)) {
++ mob.setTarget(target, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
+ }
+ }
+