When stealing a player's equipped spell, actually remove it from the slot

This commit is contained in:
Sollace 2023-08-28 13:58:46 +01:00
parent 514ce8f984
commit 77c993bfa7
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 4 additions and 2 deletions

View file

@ -50,10 +50,12 @@ public class PlayerCharmTracker implements NbtSerialisable {
.orElse(getEquippedSpell(hand).toAction()); .orElse(getEquippedSpell(hand).toAction());
} }
public void equipSpell(Hand hand, CustomisedSpellType<?> spell) { public CustomisedSpellType<?> equipSpell(Hand hand, CustomisedSpellType<?> spell) {
CustomisedSpellType<?> previous = handSpells[hand.ordinal()];
handSpells[hand.ordinal()] = spell; handSpells[hand.ordinal()] = spell;
pony.asEntity().playSound(USounds.GUI_SPELL_EQUIP.value(), 0.25F, 1.75F); pony.asEntity().playSound(USounds.GUI_SPELL_EQUIP.value(), 0.25F, 1.75F);
pony.setDirty(); pony.setDirty();
return previous;
} }
@Override @Override

View file

@ -48,7 +48,7 @@ public class EnchantedStaffItem extends StaffItem implements EnchantableItem, Ch
return cast.getSpellSlot().get(c -> !SpellPredicate.IS_PLACED.test(c), true).map(Spell::getType).orElse(SpellType.empty()); return cast.getSpellSlot().get(c -> !SpellPredicate.IS_PLACED.test(c), true).map(Spell::getType).orElse(SpellType.empty());
} }
if (entity instanceof PlayerEntity player) { if (entity instanceof PlayerEntity player) {
return Pony.of(player).getCharms().getEquippedSpell(Hand.MAIN_HAND).type(); return Pony.of(player).getCharms().equipSpell(Hand.MAIN_HAND, SpellType.EMPTY_KEY.withTraits()).type();
} }
return ENTITY_TYPE_TO_SPELL.getOrDefault(entity.getType(), SpellType.empty()); return ENTITY_TYPE_TO_SPELL.getOrDefault(entity.getType(), SpellType.empty());
} }