2021-12-30 20:44:39 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 21 Aug 2021 21:54:16 -0700
Subject: [PATCH] Fix bees aging inside hives
Fixes bees incorrectly being aged up due to upstream's
resetting the ticks inside hive on a failed release
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
2024-01-21 19:37:09 +01:00
index d36373cb1fda4d4f2b41dd181306ea697a2fe7a8..56b328c64bea0ffd51930d8ba15fb87a36e6d8a1 100644
2021-12-30 20:44:39 +01:00
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
2022-06-08 14:33:46 +02:00
@@ -328,7 +328,7 @@ public class BeehiveBlockEntity extends BlockEntity {
2021-12-30 20:44:39 +01:00
for (Iterator iterator = bees.iterator(); iterator.hasNext(); ++tileentitybeehive_hivebee.ticksInHive) {
tileentitybeehive_hivebee = (BeehiveBlockEntity.BeeData) iterator.next();
- if (tileentitybeehive_hivebee.ticksInHive > tileentitybeehive_hivebee.minOccupationTicks) {
2024-01-18 22:00:40 +01:00
+ if (tileentitybeehive_hivebee.exitTickCounter > tileentitybeehive_hivebee.minOccupationTicks) { // Paper - Fix bees aging inside hives; use exitTickCounter
2021-12-30 20:44:39 +01:00
BeehiveBlockEntity.BeeReleaseStatus tileentitybeehive_releasestatus = tileentitybeehive_hivebee.entityData.getBoolean("HasNectar") ? BeehiveBlockEntity.BeeReleaseStatus.HONEY_DELIVERED : BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED;
if (BeehiveBlockEntity.releaseOccupant(world, pos, state, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, flowerPos)) {
2022-06-08 14:33:46 +02:00
@@ -336,10 +336,11 @@ public class BeehiveBlockEntity extends BlockEntity {
2021-12-30 20:44:39 +01:00
iterator.remove();
// CraftBukkit start
} else {
- tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
2024-01-18 22:00:40 +01:00
+ tileentitybeehive_hivebee.exitTickCounter = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable // Paper - Fix bees aging inside hives; use exitTickCounter to keep actual bee life
2021-12-30 20:44:39 +01:00
// CraftBukkit end
}
}
2024-01-18 22:00:40 +01:00
+ tileentitybeehive_hivebee.exitTickCounter++; // Paper - Fix bees aging inside hives
2021-12-30 20:44:39 +01:00
}
if (flag) {
2022-06-08 14:33:46 +02:00
@@ -428,12 +429,14 @@ public class BeehiveBlockEntity extends BlockEntity {
2021-12-30 20:44:39 +01:00
final CompoundTag entityData;
int ticksInHive;
2024-01-18 22:00:40 +01:00
+ int exitTickCounter; // Paper - Fix bees aging inside hives; separate counter for checking if bee should exit to reduce exit attempts
2021-12-30 20:44:39 +01:00
final int minOccupationTicks;
BeeData(CompoundTag entityData, int ticksInHive, int minOccupationTicks) {
BeehiveBlockEntity.removeIgnoredBeeTags(entityData);
this.entityData = entityData;
this.ticksInHive = ticksInHive;
2024-01-18 22:00:40 +01:00
+ this.exitTickCounter = ticksInHive; // Paper - Fix bees aging inside hives
2021-12-30 20:44:39 +01:00
this.minOccupationTicks = minOccupationTicks;
}
}