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
a8d972c0
Commit
a8d972c0
authored
Jun 07, 2022
by
ImmuState
Committed by
Melledy
Jun 08, 2022
Browse files
Make UI for blueprint unlocking behave.
parent
4309e962
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/ForgingManager/ForgingManager.java
View file @
a8d972c0
...
@@ -48,11 +48,15 @@ public class ForgingManager {
...
@@ -48,11 +48,15 @@ public class ForgingManager {
// Determine the forging item we should unlock.
// Determine the forging item we should unlock.
int
forgeId
=
Integer
.
parseInt
(
blueprintItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
().
get
(
0
));
int
forgeId
=
Integer
.
parseInt
(
blueprintItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
().
get
(
0
));
// Remove the blueprint from the player's inventory.
// We need to do this here, before sending ForgeFormulaDataNotify, or the the forging UI won't correctly
// update when unlocking the blueprint.
player
.
getInventory
().
removeItem
(
blueprintItem
,
1
);
// Tell the client that this blueprint is now unlocked and add the unlocked item to the player.
// Tell the client that this blueprint is now unlocked and add the unlocked item to the player.
this
.
player
.
sendPacket
(
new
PacketForgeFormulaDataNotify
(
forgeId
));
this
.
player
.
getUnlockedForgingBlueprints
().
add
(
forgeId
);
this
.
player
.
getUnlockedForgingBlueprints
().
add
(
forgeId
);
this
.
player
.
sendPacket
(
new
PacketForgeFormulaDataNotify
(
forgeId
));
// Done.
return
true
;
return
true
;
}
}
...
...
src/main/java/emu/grasscutter/game/managers/InventoryManager.java
View file @
a8d972c0
...
@@ -822,6 +822,7 @@ public class InventoryManager {
...
@@ -822,6 +822,7 @@ public class InventoryManager {
}
}
int
used
=
0
;
int
used
=
0
;
boolean
useSuccess
=
false
;
// Use
// Use
switch
(
useItem
.
getItemData
().
getMaterialType
())
{
switch
(
useItem
.
getItemData
().
getMaterialType
())
{
...
@@ -853,12 +854,7 @@ public class InventoryManager {
...
@@ -853,12 +854,7 @@ public class InventoryManager {
// Handle forging blueprints.
// Handle forging blueprints.
if
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
().
equals
(
"ITEM_USE_UNLOCK_FORGE"
))
{
if
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
().
equals
(
"ITEM_USE_UNLOCK_FORGE"
))
{
// Unlock.
// Unlock.
boolean
success
=
player
.
getForgingManager
().
unlockForgingBlueprint
(
useItem
);
useSuccess
=
player
.
getForgingManager
().
unlockForgingBlueprint
(
useItem
);
// Use up the blueprint item if successful.
if
(
success
)
{
used
=
1
;
}
}
}
break
;
break
;
case
MATERIAL_CHEST:
case
MATERIAL_CHEST:
...
@@ -925,10 +921,15 @@ public class InventoryManager {
...
@@ -925,10 +921,15 @@ public class InventoryManager {
used
=
1
;
used
=
1
;
}
}
// If we used at least one item, or one of the methods called here reports using the item successfully,
// we return the item to make UseItemRsp a success.
if
(
used
>
0
)
{
if
(
used
>
0
)
{
player
.
getInventory
().
removeItem
(
useItem
,
used
);
player
.
getInventory
().
removeItem
(
useItem
,
used
);
return
useItem
;
return
useItem
;
}
}
if
(
useSuccess
)
{
return
useItem
;
}
return
null
;
return
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