mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +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) {
|
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) {
|
public TypedActionResult<CustomisedSpellType<?>> getSpellInHand(Hand hand) {
|
||||||
|
|
|
@ -47,13 +47,23 @@ public class GemstoneItem extends Item {
|
||||||
|
|
||||||
CustomisedSpellType<?> existing = charms.getEquippedSpell(hand);
|
CustomisedSpellType<?> existing = charms.getEquippedSpell(hand);
|
||||||
|
|
||||||
if (existing != null) {
|
if (!existing.isEmpty()) {
|
||||||
|
|
||||||
|
if (stack.getCount() == 1) {
|
||||||
stack = existing.traits().applyTo(enchant(stack, existing.type()));
|
stack = existing.traits().applyTo(enchant(stack, existing.type()));
|
||||||
|
} else {
|
||||||
|
user.giveItemStack(existing.traits().applyTo(enchant(stack.split(1), existing.type())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spell.getResult().isAccepted()) {
|
if (spell.getResult().isAccepted()) {
|
||||||
charms.equipSpell(hand, spell.getValue());
|
charms.equipSpell(hand, spell.getValue());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (existing.isEmpty()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
charms.equipSpell(hand, SpellType.EMPTY_KEY.withTraits());
|
charms.equipSpell(hand, SpellType.EMPTY_KEY.withTraits());
|
||||||
}
|
}
|
||||||
return TypedActionResult.success(stack, true);
|
return TypedActionResult.success(stack, true);
|
||||||
|
|
Loading…
Reference in a new issue