From bb8b8a77c91b6bee227cef1cf6b6aea015ebcb9c Mon Sep 17 00:00:00 2001 From: JazzMcNade Date: Sat, 22 Nov 2025 11:07:37 -0600 Subject: [PATCH 1/5] Fixed bees forgetting that they had nectar upon entering a hive --- .../java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java b/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java index 566f7cc5fc..b263e250ae 100644 --- a/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java +++ b/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java @@ -92,7 +92,7 @@ public abstract class BeeOccupantMixin { @Inject(method = "of", at = @At("HEAD"), cancellable = true) private static void cobblemon$of(Entity entity, CallbackInfoReturnable cir) { if (entity instanceof PokemonEntity pokemonEntity) { - List IGNORED_BEE_TAGS = Arrays.asList("Air", "ArmorDropChances", "ArmorItems", "Brain", "CanPickUpLoot", "DeathTime", "FallDistance", "FallFlying", "Fire", "HandDropChances", "HandItems", "HurtByTimestamp", "HurtTime", "LeftHanded", "Motion", "NoGravity", "OnGround", "PortalCooldown", "Pos", "Rotation", "Passengers", "leash", "UUID"); + List IGNORED_BEE_TAGS = Arrays.asList("Air", "ArmorDropChances", "ArmorItems", "CanPickUpLoot", "DeathTime", "FallDistance", "FallFlying", "Fire", "HandDropChances", "HandItems", "HurtByTimestamp", "HurtTime", "LeftHanded", "Motion", "NoGravity", "OnGround", "PortalCooldown", "Pos", "Rotation", "Passengers", "leash", "UUID"); CompoundTag compoundTag = new CompoundTag(); entity.save(compoundTag); Objects.requireNonNull(compoundTag); From d6198631ba2545acddb07110e090f5ba721fa381 Mon Sep 17 00:00:00 2001 From: JazzMcNade Date: Sat, 22 Nov 2025 11:40:03 -0600 Subject: [PATCH 2/5] New Changelog --- changelogs/CHANGELOG-1.7.1.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 changelogs/CHANGELOG-1.7.1.md diff --git a/changelogs/CHANGELOG-1.7.1.md b/changelogs/CHANGELOG-1.7.1.md new file mode 100644 index 0000000000..46b73ed371 --- /dev/null +++ b/changelogs/CHANGELOG-1.7.1.md @@ -0,0 +1,13 @@ +## [1.7.1 (XXX, 2025)](#1-7-1) + +### Additions + +### Changes + +### Fixes +- Fixed Combees not depositing honey upon leaving a hive if they entered with nectar. + +### Developer + +### MoLang & Datapacks + From 3b59148151f4921e027a053a715cbe7f96d9b233 Mon Sep 17 00:00:00 2001 From: JazzMcNade Date: Sat, 22 Nov 2025 11:43:44 -0600 Subject: [PATCH 3/5] changelog again --- CHANGELOG.md | 1 + changelogs/CHANGELOG-1.7.1.md | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 changelogs/CHANGELOG-1.7.1.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 1948906807..5585cf0aa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Changes ### Fixes +- Fixed Combees not depositing honey upon leaving a hive if they entered with nectar. ### Developer diff --git a/changelogs/CHANGELOG-1.7.1.md b/changelogs/CHANGELOG-1.7.1.md deleted file mode 100644 index 46b73ed371..0000000000 --- a/changelogs/CHANGELOG-1.7.1.md +++ /dev/null @@ -1,13 +0,0 @@ -## [1.7.1 (XXX, 2025)](#1-7-1) - -### Additions - -### Changes - -### Fixes -- Fixed Combees not depositing honey upon leaving a hive if they entered with nectar. - -### Developer - -### MoLang & Datapacks - From 4e24e09924314c5b2c12c3156f8a9d53fde7acc2 Mon Sep 17 00:00:00 2001 From: JazzMcNade Date: Sat, 22 Nov 2025 16:19:30 -0600 Subject: [PATCH 4/5] Safer memory reading in hive occupant mixins --- CHANGELOG.md | 2 +- .../mod/common/mixin/BeeOccupantMixin.java | 40 +++++++++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5585cf0aa7..ca286e2cf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ### Fixes - Fixed Combees not depositing honey upon leaving a hive if they entered with nectar. - +- Safer reading of brain memories in hive mixins ### Developer ### Molang & Datapacks diff --git a/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java b/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java index b263e250ae..6601beba66 100644 --- a/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java +++ b/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java @@ -17,6 +17,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.memory.MemoryStatus; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BeehiveBlock; @@ -52,7 +53,9 @@ public abstract class BeeOccupantMixin { var facing = state.getValue(HorizontalDirectionalBlock.FACING); newPos = pos.relative(facing).getCenter(); newYaw = facing.toYRot(); - brain.setMemory(CobblemonMemories.HIVE_LOCATION, pos); // This needs to be set in the case that the hive was picked up and moved. + if (brain.checkMemory(CobblemonMemories.HIVE_LOCATION, MemoryStatus.REGISTERED)) { + brain.setMemory(CobblemonMemories.HIVE_LOCATION, pos); // This needs to be set in the case that the hive was picked up and moved. + } } else { // Block has likely been destroyed var center = pos.getCenter(); @@ -62,25 +65,29 @@ public abstract class BeeOccupantMixin { center.z + level.random.nextFloat() * 0.6 - 0.3 ); newYaw = level.random.nextFloat() * 360F; - brain.eraseMemory(CobblemonMemories.HIVE_LOCATION); + if (brain.checkMemory(CobblemonMemories.HIVE_LOCATION, MemoryStatus.REGISTERED)) { + brain.eraseMemory(CobblemonMemories.HIVE_LOCATION); + } } entity.yRotO = newYaw; entity.setPos(newPos); // Do honey logic - var hasNectar = brain.getMemory(CobblemonMemories.HAS_NECTAR).orElse(false); - if (hasNectar) { - // Remove nectar and reset got to hive cooldown - brain.eraseMemory(CobblemonMemories.HAS_NECTAR); - brain.setMemoryWithExpiry(CobblemonMemories.HIVE_COOLDOWN, true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN); - // Increment honey level of the hive - if (state.is(BlockTags.BEEHIVES, (blockStateBase) -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL))) { - int i = state.getValue(BeehiveBlock.HONEY_LEVEL); - if (i < 5) { - int j = level.random.nextInt(100) == 0 ? 2 : 1; - if (i + j > 5) { - --j; + if (brain.checkMemory(CobblemonMemories.HAS_NECTAR, MemoryStatus.REGISTERED)) { + var hasNectar = brain.getMemory(CobblemonMemories.HAS_NECTAR).orElse(false); + if (hasNectar) { + // Remove nectar and reset got to hive cooldown + brain.eraseMemory(CobblemonMemories.HAS_NECTAR); + brain.setMemoryWithExpiry(CobblemonMemories.HIVE_COOLDOWN, true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN); + // Increment honey level of the hive + if (state.is(BlockTags.BEEHIVES, (blockStateBase) -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL))) { + int i = state.getValue(BeehiveBlock.HONEY_LEVEL); + if (i < 5) { + int j = level.random.nextInt(100) == 0 ? 2 : 1; + if (i + j > 5) { + --j; + } + level.setBlockAndUpdate(pos, state.setValue(BeehiveBlock.HONEY_LEVEL, i + j)); } - level.setBlockAndUpdate(pos, state.setValue(BeehiveBlock.HONEY_LEVEL, i + j)); } } } @@ -97,7 +104,8 @@ public abstract class BeeOccupantMixin { entity.save(compoundTag); Objects.requireNonNull(compoundTag); IGNORED_BEE_TAGS.forEach(compoundTag::remove); - Boolean hasNectar = pokemonEntity.getBrain().getMemory(CobblemonMemories.HAS_NECTAR).orElse(false); + boolean hasNectar = pokemonEntity.getBrain().checkMemory(CobblemonMemories.HAS_NECTAR, MemoryStatus.REGISTERED) + && pokemonEntity.getBrain().getMemory(CobblemonMemories.HAS_NECTAR).orElse(false); cir.setReturnValue(new BeehiveBlockEntity.Occupant(CustomData.of(compoundTag), 0, hasNectar ? 2400 : 600)); cir.cancel(); } From b191f4e9fbb00b700bb18dd40fca6a74abd2cfab Mon Sep 17 00:00:00 2001 From: JazzMcNade Date: Sun, 23 Nov 2025 15:42:56 -0600 Subject: [PATCH 5/5] Check hivecooldown memory registration --- .../java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java b/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java index 6601beba66..5a992f9670 100644 --- a/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java +++ b/common/src/main/java/com/cobblemon/mod/common/mixin/BeeOccupantMixin.java @@ -77,7 +77,9 @@ public abstract class BeeOccupantMixin { if (hasNectar) { // Remove nectar and reset got to hive cooldown brain.eraseMemory(CobblemonMemories.HAS_NECTAR); - brain.setMemoryWithExpiry(CobblemonMemories.HIVE_COOLDOWN, true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN); + if (brain.checkMemory(CobblemonMemories.HIVE_LOCATION, MemoryStatus.REGISTERED)) { + brain.setMemoryWithExpiry(CobblemonMemories.HIVE_COOLDOWN, true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN); + } // Increment honey level of the hive if (state.is(BlockTags.BEEHIVES, (blockStateBase) -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL))) { int i = state.getValue(BeehiveBlock.HONEY_LEVEL);