From b5eebb969e287d5b0425b052f0707a7eef655da9 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Sun, 13 Aug 2023 00:13:16 -0700 Subject: [PATCH] Fix Rosa arcana not taking into account stacked xp orbs Closes #4406 --- .../flower/generating/RosaArcanaBlockEntity.java | 9 +++++++-- .../botania/mixin/ExperienceOrbAccessor.java | 14 ++++++++++++++ Xplat/src/main/resources/botania_xplat.mixins.json | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Xplat/src/main/java/vazkii/botania/mixin/ExperienceOrbAccessor.java diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RosaArcanaBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RosaArcanaBlockEntity.java index 5be38a23a..6d73348d3 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RosaArcanaBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RosaArcanaBlockEntity.java @@ -27,6 +27,7 @@ import vazkii.botania.common.block.BotaniaFlowerBlocks; import vazkii.botania.common.handler.BotaniaSounds; import vazkii.botania.common.helper.EntityHelper; +import vazkii.botania.mixin.ExperienceOrbAccessor; import java.util.List; import java.util.Map; @@ -68,9 +69,13 @@ public void tickFlower() { List orbs = getLevel().getEntitiesOfClass(ExperienceOrb.class, effectBounds); for (ExperienceOrb orb : orbs) { - if (orb.isAlive()) { + int count = ((ExperienceOrbAccessor) orb).botania_getCount(); + if (orb.isAlive() && count > 0) { addMana(orb.getValue() * MANA_PER_XP); - orb.discard(); + ((ExperienceOrbAccessor) orb).botania_setCount(count - 1); + if (count == 1) { + orb.discard(); + } float pitch = (level.random.nextFloat() - level.random.nextFloat()) * 0.35F + 0.9F; //Usage of vanilla sound event: Subtitle is "Experience gained", and this is about gaining experience anyways. level.playSound(null, getEffectivePos(), SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.BLOCKS, 0.07F, pitch); diff --git a/Xplat/src/main/java/vazkii/botania/mixin/ExperienceOrbAccessor.java b/Xplat/src/main/java/vazkii/botania/mixin/ExperienceOrbAccessor.java new file mode 100644 index 000000000..90083b43f --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/mixin/ExperienceOrbAccessor.java @@ -0,0 +1,14 @@ +package vazkii.botania.mixin; + +import net.minecraft.world.entity.ExperienceOrb; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ExperienceOrb.class) +public interface ExperienceOrbAccessor { + @Accessor("count") + int botania_getCount(); + + @Accessor("count") + void botania_setCount(int c); +} diff --git a/Xplat/src/main/resources/botania_xplat.mixins.json b/Xplat/src/main/resources/botania_xplat.mixins.json index eb432dd49..92943adeb 100644 --- a/Xplat/src/main/resources/botania_xplat.mixins.json +++ b/Xplat/src/main/resources/botania_xplat.mixins.json @@ -21,6 +21,7 @@ "DispenserBlockAccessor", "EntityAccessor", "EntityMixin", + "ExperienceOrbAccessor", "FarmBlockMixin", "FireBlockAccessor", "GoalSelectorAccessor", -- 2.45.2