mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fix duplication bug when equipping/unequipping spells
This commit is contained in:
parent
4b8b5ba78b
commit
22f28c098c
2 changed files with 13 additions and 3 deletions
|
@ -55,7 +55,7 @@ public class PlayerCharmTracker implements Tickable, NbtSerialisable {
|
|||
}
|
||||
|
||||
public CustomisedSpellType<?> getEquippedSpell(Hand hand) {
|
||||
return handSpells[hand.ordinal()];
|
||||
return handSpells[hand.ordinal()] == null ? SpellType.EMPTY_KEY.withTraits() : handSpells[hand.ordinal()];
|
||||
}
|
||||
|
||||
public TypedActionResult<CustomisedSpellType<?>> getSpellInHand(Hand hand) {
|
||||
|
|
|
@ -47,13 +47,23 @@ public class GemstoneItem extends Item {
|
|||
|
||||
CustomisedSpellType<?> existing = charms.getEquippedSpell(hand);
|
||||
|
||||
if (existing != null) {
|
||||
stack = existing.traits().applyTo(enchant(stack, existing.type()));
|
||||
if (!existing.isEmpty()) {
|
||||
|
||||
if (stack.getCount() == 1) {
|
||||
stack = existing.traits().applyTo(enchant(stack, existing.type()));
|
||||
} else {
|
||||
user.giveItemStack(existing.traits().applyTo(enchant(stack.split(1), existing.type())));
|
||||
}
|
||||
}
|
||||
|
||||
if (spell.getResult().isAccepted()) {
|
||||
charms.equipSpell(hand, spell.getValue());
|
||||
} else {
|
||||
|
||||
if (existing.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
charms.equipSpell(hand, SpellType.EMPTY_KEY.withTraits());
|
||||
}
|
||||
return TypedActionResult.success(stack, true);
|
||||
|
|
Loading…
Reference in a new issue