Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
3d529641
Commit
3d529641
authored
May 04, 2022
by
Melledy
Browse files
Fix equip swapping
parent
787f3fd4
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/avatar/Avatar.java
View file @
3d529641
...
...
@@ -401,15 +401,32 @@ public class Avatar {
}
public
boolean
equipItem
(
GameItem
item
,
boolean
shouldRecalc
)
{
// Sanity check equip type
EquipType
itemEquipType
=
item
.
getItemData
().
getEquipType
();
if
(
itemEquipType
==
EquipType
.
EQUIP_NONE
)
{
return
false
;
}
// Check if other avatars have this item equipped
Avatar
otherAvatar
=
getPlayer
().
getAvatars
().
getAvatarById
(
item
.
getEquipCharacter
());
if
(
otherAvatar
!=
null
)
{
// Unequip other avatar's item
if
(
otherAvatar
.
unequipItem
(
item
.
getItemData
().
getEquipType
()))
{
getPlayer
().
sendPacket
(
new
PacketAvatarEquipChangeNotify
(
otherAvatar
,
item
.
getItemData
().
getEquipType
()));
}
// Swap with other avatar
if
(
getEquips
().
containsKey
(
itemEquipType
.
getValue
()))
{
GameItem
toSwap
=
this
.
getEquipBySlot
(
itemEquipType
);
otherAvatar
.
equipItem
(
toSwap
,
false
);
}
// Recalc
otherAvatar
.
recalcStats
();
}
else
if
(
getEquips
().
containsKey
(
itemEquipType
.
getValue
()))
{
// Unequip item in current slot if it exists
unequipItem
(
itemEquipType
);
}
// Set equip
getEquips
().
put
(
itemEquipType
.
getValue
(),
item
);
if
(
itemEquipType
==
EquipType
.
EQUIP_WEAPON
&&
getPlayer
().
getWorld
()
!=
null
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment