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
f15262dd
Commit
f15262dd
authored
Jul 22, 2022
by
Melledy
Browse files
Refactor excel datas (Mainly item data)
parent
c0418067
Changes
15
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/common/ItemUseData.java
View file @
f15262dd
package
emu.grasscutter.data.common
;
import
java.util.List
;
import
emu.grasscutter.game.props.ItemUseOp
;
public
class
ItemUseData
{
private
String
useOp
;
private
List
<
String
>
useParam
;
private
ItemUseOp
useOp
;
private
String
[]
useParam
;
public
String
getUseOp
()
{
public
ItemUseOp
getUseOp
()
{
return
useOp
;
}
public
void
setUseOp
(
String
useOp
)
{
this
.
useOp
=
useOp
;
}
public
List
<
String
>
getUseParam
()
{
public
String
[]
getUseParam
()
{
return
useParam
;
}
public
void
setUseParam
(
List
<
String
>
useParam
)
{
this
.
useParam
=
useParam
;
}
}
src/main/java/emu/grasscutter/data/excels/AvatarSkillData.java
View file @
f15262dd
...
...
@@ -17,13 +17,8 @@ public class AvatarSkillData extends GameResource {
private
boolean
isAttackCameraLock
;
private
int
proudSkillGroupId
;
private
ElementType
costElemType
;
private
List
<
Float
>
lockWeightParams
;
private
long
nameTextMapHash
;
private
String
abilityName
;
private
String
lockShape
;
private
String
globalValueKey
;
@Override
public
int
getId
(){
...
...
@@ -58,10 +53,6 @@ public class AvatarSkillData extends GameResource {
return
costElemType
;
}
public
List
<
Float
>
getLockWeightParams
()
{
return
lockWeightParams
;
}
public
long
getNameTextMapHash
()
{
return
nameTextMapHash
;
}
...
...
@@ -69,14 +60,6 @@ public class AvatarSkillData extends GameResource {
public
String
getAbilityName
()
{
return
abilityName
;
}
public
String
getLockShape
()
{
return
lockShape
;
}
public
String
getGlobalValueKey
()
{
return
globalValueKey
;
}
@Override
public
void
onLoad
()
{
...
...
src/main/java/emu/grasscutter/data/excels/GadgetData.java
View file @
f15262dd
...
...
@@ -13,10 +13,8 @@ public class GadgetData extends GameResource {
private
boolean
isInteractive
;
private
String
[]
tags
;
private
String
itemJsonName
;
private
String
inteeIconName
;
private
long
nameTextMapHash
;
private
int
campID
;
private
String
LODPatternName
;
@Override
public
int
getId
()
{
...
...
@@ -43,10 +41,6 @@ public class GadgetData extends GameResource {
return
itemJsonName
;
}
public
String
getInteeIconName
()
{
return
inteeIconName
;
}
public
long
getNameTextMapHash
()
{
return
nameTextMapHash
;
}
...
...
@@ -55,8 +49,6 @@ public class GadgetData extends GameResource {
return
campID
;
}
public
String
getLODPatternName
()
{
return
LODPatternName
;
}
@Override
public
void
onLoad
()
{
...
...
src/main/java/emu/grasscutter/data/excels/ItemData.java
View file @
f15262dd
package
emu.grasscutter.data.excels
;
import
java.util.Arrays
;
import
java.util.List
;
import
com.google.gson.annotations.SerializedName
;
...
...
@@ -8,6 +9,7 @@ import emu.grasscutter.data.ResourceType;
import
emu.grasscutter.data.common.ItemUseData
;
import
emu.grasscutter.game.inventory.*
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.ItemUseTarget
;
import
it.unimi.dsi.fastutil.ints.IntOpenHashSet
;
import
it.unimi.dsi.fastutil.ints.IntSet
;
import
lombok.Getter
;
...
...
@@ -17,103 +19,75 @@ import lombok.Getter;
"ReliquaryExcelConfigData.json"
,
"HomeWorldFurnitureExcelConfigData.json"
})
@Getter
public
class
ItemData
extends
GameResource
{
// Main
private
int
id
;
@Getter
private
int
stackLimit
=
1
;
@Getter
private
int
maxUseCount
;
@Getter
private
int
rankLevel
;
@Getter
private
String
effectName
;
@Getter
private
int
[]
satiationParams
;
@Getter
private
int
rank
;
@Getter
private
int
weight
;
@Getter
private
int
gadgetId
;
@Getter
private
int
[]
destroyReturnMaterial
;
@Getter
private
int
[]
destroyReturnMaterialCount
;
@Getter
private
List
<
ItemUseData
>
itemUse
;
// Food
@Getter
private
String
foodQuality
;
@Getter
private
String
useTarget
;
private
String
[]
iseParam
;
// String enums
private
String
itemType
;
private
String
materialType
;
private
String
equipType
;
private
int
stackLimit
=
1
;
private
int
maxUseCount
;
private
int
rankLevel
;
private
String
effectName
;
private
int
rank
;
private
int
weight
;
private
int
gadgetId
;
private
int
[]
destroyReturnMaterial
;
private
int
[]
destroyReturnMaterialCount
;
// Enums
private
ItemType
itemType
=
ItemType
.
ITEM_NONE
;
private
MaterialType
materialType
=
MaterialType
.
MATERIAL_NONE
;
private
EquipType
equipType
=
EquipType
.
EQUIP_NONE
;
private
String
effectType
;
private
String
destroyRule
;
// Post load enum forms of above
private
transient
MaterialType
materialEnumType
;
private
transient
ItemType
itemEnumType
;
private
transient
EquipType
equipEnumType
;
// Food
private
String
foodQuality
;
private
int
[]
satiationParams
;
// Usable item
private
ItemUseTarget
useTarget
;
private
List
<
ItemUseData
>
itemUse
;
// Relic
@Getter
private
int
mainPropDepotId
;
@Getter
private
int
appendPropDepotId
;
@Getter
private
int
appendPropNum
;
@Getter
private
int
setId
;
private
int
mainPropDepotId
;
private
int
appendPropDepotId
;
private
int
appendPropNum
;
private
int
setId
;
private
int
[]
addPropLevels
;
@Getter
private
int
baseConvExp
;
@Getter
private
int
maxLevel
;
private
int
baseConvExp
;
private
int
maxLevel
;
// Weapon
@Getter
private
int
weaponPromoteId
;
@Getter
private
int
weaponBaseExp
;
@Getter
private
int
storyId
;
@Getter
private
int
avatarPromoteId
;
@Getter
private
int
awakenMaterial
;
@Getter
private
int
[]
awakenCosts
;
@Getter
private
int
[]
skillAffix
;
private
int
weaponPromoteId
;
private
int
weaponBaseExp
;
private
int
storyId
;
private
int
avatarPromoteId
;
private
int
awakenMaterial
;
private
int
[]
awakenCosts
;
private
int
[]
skillAffix
;
private
WeaponProperty
[]
weaponProp
;
// Hash
@Getter
private
String
icon
;
@Getter
private
long
nameTextMapHash
;
@Getter
private
IntSet
addPropLevelSet
;
private
long
nameTextMapHash
;
// Furniture
@Getter
private
int
comfort
;
@Getter
private
List
<
Integer
>
furnType
;
@Getter
private
List
<
Integer
>
furnitureGadgetID
;
private
int
comfort
;
private
List
<
Integer
>
furnType
;
private
List
<
Integer
>
furnitureGadgetID
;
@SerializedName
(
"JFDLJGDFIGL"
)
@Getter
private
int
roomSceneId
;
private
int
roomSceneId
;
// Custom
private
transient
IntSet
addPropLevelSet
;
@Override
public
int
getId
(){
return
this
.
id
;
}
public
String
getMaterialTypeString
(){
return
this
.
materialType
;
}
public
String
[]
getUseParam
(){
return
this
.
iseParam
;
}
public
String
getItemTypeString
(){
return
this
.
itemType
;
}
public
WeaponProperty
[]
getWeaponProperties
()
{
return
weaponProp
;
}
public
ItemType
getItemType
()
{
return
this
.
itemEnumType
;
}
public
MaterialType
getMaterialType
()
{
return
this
.
materialEnumType
;
}
public
EquipType
getEquipType
()
{
return
this
.
equipEnumType
;
public
WeaponProperty
[]
getWeaponProperties
()
{
return
this
.
weaponProp
;
}
public
boolean
canAddRelicProp
(
int
level
)
{
...
...
@@ -121,48 +95,37 @@ public class ItemData extends GameResource {
}
public
boolean
isEquip
()
{
return
this
.
item
Enum
Type
==
ItemType
.
ITEM_RELIQUARY
||
this
.
item
Enum
Type
==
ItemType
.
ITEM_WEAPON
;
return
this
.
itemType
==
ItemType
.
ITEM_RELIQUARY
||
this
.
itemType
==
ItemType
.
ITEM_WEAPON
;
}
@Override
public
void
onLoad
()
{
this
.
itemEnumType
=
ItemType
.
getTypeByName
(
getItemTypeString
());
this
.
materialEnumType
=
MaterialType
.
getTypeByName
(
getMaterialTypeString
());
if
(
this
.
itemEnumType
==
ItemType
.
ITEM_RELIQUARY
)
{
this
.
equipEnumType
=
EquipType
.
getTypeByName
(
this
.
equipType
);
if
(
this
.
itemType
==
ItemType
.
ITEM_RELIQUARY
)
{
if
(
this
.
addPropLevels
!=
null
&&
this
.
addPropLevels
.
length
>
0
)
{
this
.
addPropLevelSet
=
new
IntOpenHashSet
(
this
.
addPropLevels
);
}
}
else
if
(
this
.
item
Enum
Type
==
ItemType
.
ITEM_WEAPON
)
{
this
.
equip
Enum
Type
=
EquipType
.
EQUIP_WEAPON
;
}
else
if
(
this
.
itemType
==
ItemType
.
ITEM_WEAPON
)
{
this
.
equipType
=
EquipType
.
EQUIP_WEAPON
;
}
else
{
this
.
equip
Enum
Type
=
EquipType
.
EQUIP_NONE
;
this
.
equipType
=
EquipType
.
EQUIP_NONE
;
}
if
(
this
.
getWeaponProperties
()
!=
null
)
{
for
(
WeaponProperty
weaponProperty
:
this
.
getWeaponProperties
())
{
weaponProperty
.
onLoad
();
}
if
(
this
.
weaponProp
!=
null
)
{
this
.
weaponProp
=
Arrays
.
stream
(
this
.
weaponProp
).
filter
(
prop
->
prop
.
getPropType
()
!=
null
).
toArray
(
WeaponProperty
[]::
new
);
}
if
(
this
.
getFurnType
()
!=
null
){
if
(
this
.
getFurnType
()
!=
null
)
{
this
.
furnType
=
this
.
furnType
.
stream
().
filter
(
x
->
x
>
0
).
toList
();
}
if
(
this
.
getFurnitureGadgetID
()
!=
null
){
if
(
this
.
getFurnitureGadgetID
()
!=
null
)
{
this
.
furnitureGadgetID
=
this
.
furnitureGadgetID
.
stream
().
filter
(
x
->
x
>
0
).
toList
();
}
}
@Getter
public
static
class
WeaponProperty
{
@Getter
private
FightProperty
fightProp
;
@Getter
private
String
propType
;
@Getter
private
float
initValue
;
@Getter
private
String
type
;
public
void
onLoad
()
{
this
.
fightProp
=
FightProperty
.
getPropByName
(
propType
);
}
private
FightProperty
propType
;
private
float
initValue
;
private
String
type
;
}
}
src/main/java/emu/grasscutter/data/excels/MonsterDescribeData.java
View file @
f15262dd
...
...
@@ -10,7 +10,6 @@ public class MonsterDescribeData extends GameResource {
private
long
nameTextMapHash
;
private
int
titleID
;
private
int
specialNameLabID
;
private
String
icon
;
@Override
public
int
getId
()
{
...
...
@@ -29,10 +28,6 @@ public class MonsterDescribeData extends GameResource {
return
specialNameLabID
;
}
public
String
getIcon
()
{
return
icon
;
}
@Override
public
void
onLoad
()
{
...
...
src/main/java/emu/grasscutter/game/avatar/Avatar.java
View file @
f15262dd
...
...
@@ -632,7 +632,7 @@ public class Avatar {
WeaponCurveData
curveData
=
GameData
.
getWeaponCurveDataMap
().
get
(
weapon
.
getLevel
());
if
(
curveData
!=
null
)
{
for
(
WeaponProperty
weaponProperty
:
weapon
.
getItemData
().
getWeaponProperties
())
{
this
.
addFightProperty
(
weaponProperty
.
get
Fight
Prop
(),
weaponProperty
.
getInitValue
()
*
curveData
.
getMultByProp
(
weaponProperty
.
getType
()));
this
.
addFightProperty
(
weaponProperty
.
getProp
Type
(),
weaponProperty
.
getInitValue
()
*
curveData
.
getMultByProp
(
weaponProperty
.
getType
()));
}
}
// Weapon promotion stats
...
...
src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java
View file @
f15262dd
...
...
@@ -29,6 +29,7 @@ import emu.grasscutter.game.player.BasePlayerDataManager;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.BattlePassMissionRefreshType
;
import
emu.grasscutter.game.props.BattlePassMissionStatus
;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.game.props.WatcherTriggerType
;
import
emu.grasscutter.net.proto.BattlePassCycleOuterClass.BattlePassCycle
;
import
emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus
;
...
...
@@ -195,7 +196,7 @@ public class BattlePassManager extends BasePlayerDataManager {
}
// Get possible item choices.
String
[]
choices
=
rewardItemData
.
getItemUse
().
get
(
0
).
getUseParam
()
.
get
(
0
)
.
split
(
","
);
String
[]
choices
=
rewardItemData
.
getItemUse
().
get
(
0
).
getUseParam
()
[
0
]
.
split
(
","
);
if
(
choices
.
length
<
index
)
{
return
;
}
...
...
@@ -205,7 +206,7 @@ public class BattlePassManager extends BasePlayerDataManager {
int
chosenId
=
Integer
.
parseInt
(
choices
[
index
-
1
]);
// For ITEM_USE_ADD_SELECT_ITEM chests, we can directly add the item specified in the chest's data.
if
(
rewardItemData
.
getItemUse
().
get
(
0
).
getUseOp
()
.
equals
(
"
ITEM_USE_ADD_SELECT_ITEM
"
)
)
{
if
(
rewardItemData
.
getItemUse
().
get
(
0
).
getUseOp
()
==
ItemUseOp
.
ITEM_USE_ADD_SELECT_ITEM
)
{
GameItem
rewardItem
=
new
GameItem
(
GameData
.
getItemDataMap
().
get
(
chosenId
),
entry
.
getItemCount
());
rewardItems
.
add
(
rewardItem
);
}
...
...
src/main/java/emu/grasscutter/game/combine/CombineManger.java
View file @
f15262dd
...
...
@@ -10,6 +10,7 @@ import emu.grasscutter.game.inventory.Inventory;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.net.proto.RetcodeOuterClass
;
import
emu.grasscutter.net.proto.RetcodeOuterClass.Retcode
;
import
emu.grasscutter.server.game.BaseGameSystem
;
...
...
@@ -55,12 +56,12 @@ public class CombineManger extends BaseGameSystem {
public
boolean
unlockCombineDiagram
(
Player
player
,
GameItem
diagramItem
)
{
// Make sure this is actually a diagram.
if
(
!
diagramItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
.
equals
(
"
ITEM_USE_UNLOCK_COMBINE
"
)
)
{
if
(
diagramItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
!=
ItemUseOp
.
ITEM_USE_UNLOCK_COMBINE
)
{
return
false
;
}
// Determine the combine item we should unlock.
int
combineId
=
Integer
.
parseInt
(
diagramItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
()
.
get
(
0
)
);
int
combineId
=
Integer
.
parseInt
(
diagramItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
()
[
0
]
);
// Remove the diagram from the player's inventory.
// We need to do this here, before sending CombineFormulaDataNotify, or the the combine UI won't correctly
...
...
src/main/java/emu/grasscutter/game/inventory/MaterialType.java
View file @
f15262dd
...
...
@@ -8,35 +8,45 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
MaterialType
{
MATERIAL_NONE
(
0
),
MATERIAL_FOOD
(
1
),
MATERIAL_QUEST
(
2
),
MATERIAL_EXCHANGE
(
4
),
MATERIAL_CONSUME
(
5
),
MATERIAL_EXP_FRUIT
(
6
),
MATERIAL_AVATAR
(
7
),
MATERIAL_ADSORBATE
(
8
),
MATERIAL_CRICKET
(
9
),
MATERIAL_ELEM_CRYSTAL
(
10
),
MATERIAL_WEAPON_EXP_STONE
(
11
),
MATERIAL_CHEST
(
12
),
MATERIAL_RELIQUARY_MATERIAL
(
13
),
MATERIAL_AVATAR_MATERIAL
(
14
),
MATERIAL_NOTICE_ADD_HP
(
15
),
MATERIAL_SEA_LAMP
(
16
),
MATERIAL_SELECTABLE_CHEST
(
17
),
MATERIAL_FLYCLOAK
(
18
),
MATERIAL_NAMECARD
(
19
),
MATERIAL_TALENT
(
20
),
MATERIAL_WIDGET
(
21
),
MATERIAL_CHEST_BATCH_USE
(
22
),
MATERIAL_FAKE_ABSORBATE
(
23
),
MATERIAL_CONSUME_BATCH_USE
(
24
),
MATERIAL_WOOD
(
25
),
MATERIAL_FURNITURE_FORMULA
(
27
),
MATERIAL_CHANNELLER_SLAB_BUFF
(
28
),
MATERIAL_FURNITURE_SUITE_FORMULA
(
29
),
MATERIAL_COSTUME
(
30
);
MATERIAL_NONE
(
0
),
MATERIAL_FOOD
(
1
),
MATERIAL_QUEST
(
2
),
MATERIAL_EXCHANGE
(
4
),
MATERIAL_CONSUME
(
5
),
MATERIAL_EXP_FRUIT
(
6
),
MATERIAL_AVATAR
(
7
),
MATERIAL_ADSORBATE
(
8
),
MATERIAL_CRICKET
(
9
),
MATERIAL_ELEM_CRYSTAL
(
10
),
MATERIAL_WEAPON_EXP_STONE
(
11
),
MATERIAL_CHEST
(
12
),
MATERIAL_RELIQUARY_MATERIAL
(
13
),
MATERIAL_AVATAR_MATERIAL
(
14
),
MATERIAL_NOTICE_ADD_HP
(
15
),
MATERIAL_SEA_LAMP
(
16
),
MATERIAL_SELECTABLE_CHEST
(
17
),
MATERIAL_FLYCLOAK
(
18
),
MATERIAL_NAMECARD
(
19
),
MATERIAL_TALENT
(
20
),
MATERIAL_WIDGET
(
21
),
MATERIAL_CHEST_BATCH_USE
(
22
),
MATERIAL_FAKE_ABSORBATE
(
23
),
MATERIAL_CONSUME_BATCH_USE
(
24
),
MATERIAL_WOOD
(
25
),
MATERIAL_FURNITURE_FORMULA
(
27
),
MATERIAL_CHANNELLER_SLAB_BUFF
(
28
),
MATERIAL_FURNITURE_SUITE_FORMULA
(
29
),
MATERIAL_COSTUME
(
30
),
MATERIAL_HOME_SEED
(
31
),
MATERIAL_FISH_BAIT
(
32
),
MATERIAL_FISH_ROD
(
33
),
MATERIAL_SUMO_BUFF
(
34
),
MATERIAL_FIREWORKS
(
35
),
MATERIAL_BGM
(
36
),
MATERIAL_SPICE_FOOD
(
37
),
MATERIAL_ACTIVITY_ROBOT
(
38
),
MATERIAL_ACTIVITY_GEAR
(
39
),
MATERIAL_ACTIVITY_JIGSAW
(
40
);
private
final
int
value
;
private
static
final
Int2ObjectMap
<
MaterialType
>
map
=
new
Int2ObjectOpenHashMap
<>();
...
...
src/main/java/emu/grasscutter/game/managers/CookingManager.java
View file @
f15262dd
...
...
@@ -13,6 +13,7 @@ import emu.grasscutter.game.inventory.GameItem;
import
emu.grasscutter.game.player.BasePlayerManager
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.net.proto.CookRecipeDataOuterClass
;
import
emu.grasscutter.net.proto.PlayerCookArgsReqOuterClass.PlayerCookArgsReq
;
import
emu.grasscutter.net.proto.PlayerCookReqOuterClass.PlayerCookReq
;
...
...
@@ -47,12 +48,12 @@ public class CookingManager extends BasePlayerManager {
********************/
public
synchronized
boolean
unlockRecipe
(
GameItem
recipeItem
)
{
// Make sure this is actually a cooking recipe.
if
(
!
recipeItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
.
equals
(
"
ITEM_USE_UNLOCK_COOK_RECIPE
"
)
)
{
if
(
recipeItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
!=
ItemUseOp
.
ITEM_USE_UNLOCK_COOK_RECIPE
)
{
return
false
;
}
// Determine the recipe we should unlock.
int
recipeId
=
Integer
.
parseInt
(
recipeItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
()
.
get
(
0
)
);
int
recipeId
=
Integer
.
parseInt
(
recipeItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
()
[
0
]
);
// Remove the item from the player's inventory.
// We need to do this here, before sending CookRecipeDataNotify, or the the UI won't correctly update.
...
...
src/main/java/emu/grasscutter/game/managers/FurnitureManager.java
View file @
f15262dd
...
...
@@ -6,6 +6,7 @@ import emu.grasscutter.game.home.FurnitureMakeSlotItem;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.player.BasePlayerManager
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.net.proto.ItemParamOuterClass
;
import
emu.grasscutter.net.proto.RetcodeOuterClass.Retcode
;
import
emu.grasscutter.server.packet.send.*
;
...
...
@@ -34,18 +35,19 @@ public class FurnitureManager extends BasePlayerManager {
}
public
synchronized
boolean
unlockFurnitureOrSuite
(
GameItem
useItem
)
{
ItemUseOp
itemUseOp
=
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
();
// Check
if
(!
List
.
of
(
"ITEM_USE_UNLOCK_FURNITURE_FORMULA"
,
"ITEM_USE_UNLOCK_FURNITURE_SUITE"
)
.
contains
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()))
{
if
(
itemUseOp
!=
ItemUseOp
.
ITEM_USE_UNLOCK_FURNITURE_SUITE
&&
itemUseOp
!=
ItemUseOp
.
ITEM_USE_UNLOCK_FURNITURE_FORMULA
)
{
return
false
;
}
int
furnitureIdOrSuiteId
=
Integer
.
parseInt
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
()
.
get
(
0
)
);
int
furnitureIdOrSuiteId
=
Integer
.
parseInt
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseParam
()
[
0
]
);
// Remove first
player
.
getInventory
().
removeItem
(
useItem
,
1
);
if
(
"ITEM_USE_UNLOCK_FURNITURE_FORMULA"
.
equals
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
)
)
{
if
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
==
ItemUseOp
.
ITEM_USE_UNLOCK_FURNITURE_FORMULA
)
{
player
.
getUnlockedFurniture
().
add
(
furnitureIdOrSuiteId
);
notifyUnlockFurniture
();
}
else
{
...
...
src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java
View file @
f15262dd
...
...
@@ -14,6 +14,7 @@ import emu.grasscutter.game.inventory.GameItem;
import
emu.grasscutter.game.player.BasePlayerManager
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.game.props.WatcherTriggerType
;
import
emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData
;
import
emu.grasscutter.net.proto.ForgeQueueManipulateReqOuterClass.ForgeQueueManipulateReq
;
...
...
@@ -39,12 +40,12 @@ public class ForgingManager extends BasePlayerManager {
**********/
public
synchronized
boolean
unlockForgingBlueprint
(
GameItem
blueprintItem
)
{
// Make sure this is actually a forging blueprint.
if
(
!
blueprintItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
.
equals
(
"
ITEM_USE_UNLOCK_FORGE
"
)
)
{
if
(
blueprintItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
()
!=
ItemUseOp
.
ITEM_USE_UNLOCK_FORGE
)
{
return
false
;
}
// 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
()
[
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
...
...
src/main/java/emu/grasscutter/game/props/ItemUseOp.java
0 → 100644
View file @
f15262dd
package
emu.grasscutter.game.props
;
import
java.util.stream.Stream
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
ItemUseOp
{
ITEM_USE_NONE
(
0
),
ITEM_USE_ACCEPT_QUEST
(
1
),
ITEM_USE_TRIGGER_ABILITY
(
2
),
ITEM_USE_GAIN_AVATAR
(
3
),
ITEM_USE_ADD_EXP
(
4
),
ITEM_USE_RELIVE_AVATAR
(
5
),
ITEM_USE_ADD_BIG_TALENT_POINT
(
6
),
ITEM_USE_ADD_PERSIST_STAMINA
(
7
),
ITEM_USE_ADD_TEMPORARY_STAMINA
(
8
),
ITEM_USE_ADD_CUR_STAMINA
(
9
),
ITEM_USE_ADD_CUR_HP
(
10
),
ITEM_USE_ADD_ELEM_ENERGY
(
11
),
ITEM_USE_ADD_ALL_ENERGY
(
12
),
ITEM_USE_ADD_DUNGEON_COND_TIME
(
13
),
ITEM_USE_ADD_WEAPON_EXP
(
14
),
ITEM_USE_ADD_SERVER_BUFF
(
15
),
ITEM_USE_DEL_SERVER_BUFF
(
16
),
ITEM_USE_UNLOCK_COOK_RECIPE
(
17
),
ITEM_USE_OPEN_RANDOM_CHEST
(
20
),
ITEM_USE_MAKE_GADGET
(
24
),
ITEM_USE_ADD_ITEM
(
25
),
ITEM_USE_GRANT_SELECT_REWARD
(
26
),
ITEM_USE_ADD_SELECT_ITEM
(
27
),
ITEM_USE_GAIN_FLYCLOAK
(
28
),
ITEM_USE_GAIN_NAME_CARD
(
29
),
ITEM_USE_UNLOCK_PAID_BATTLE_PASS_NORMAL
(
30
),
ITEM_USE_GAIN_CARD_PRODUCT
(
31
),
ITEM_USE_UNLOCK_FORGE
(
32
),
ITEM_USE_UNLOCK_COMBINE
(
33
),
ITEM_USE_UNLOCK_CODEX
(
34
),
ITEM_USE_CHEST_SELECT_ITEM
(
35
),
ITEM_USE_GAIN_RESIN_CARD_PRODUCT
(
36
),
ITEM_USE_ADD_RELIQUARY_EXP
(
37
),
ITEM_USE_UNLOCK_FURNITURE_FORMULA
(
38
),
ITEM_USE_UNLOCK_FURNITURE_SUITE
(
39
),
ITEM_USE_ADD_CHANNELLER_SLAB_BUFF
(
40
),
ITEM_USE_GAIN_COSTUME
(
41
),
ITEM_USE_ADD_TREASURE_MAP_BONUS_REGION_FRAGMENT
(
42
),
ITEM_USE_COMBINE_ITEM
(
43
),
ITEM_USE_UNLOCK_HOME_MODULE
(
44
),
ITEM_USE_UNLOCK_HOME_BGM
(
45
),
ITEM_USE_ADD_REGIONAL_PLAY_VAR
(
46
);
private
final
int
value
;
private
static
final
Int2ObjectMap
<
ItemUseOp
>
map
=
new
Int2ObjectOpenHashMap
<>();
static
{
Stream
.
of
(
values
()).
forEach
(
e
->
{
map
.
put
(
e
.
getValue
(),
e
);
});
}
private
ItemUseOp
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
public
static
ItemUseOp
getTypeByValue
(
int
value
)
{
return
map
.
getOrDefault
(
value
,
ITEM_USE_NONE
);
}
}
src/main/java/emu/grasscutter/game/props/ItemUseTarget.java
0 → 100644
View file @
f15262dd
package
emu.grasscutter.game.props
;
import
java.util.stream.Stream
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
ItemUseTarget
{
ITEM_USE_TARGET_NONE
(
0
),
ITEM_USE_TARGET_CUR_AVATAR
(
1
),
ITEM_USE_TARGET_CUR_TEAM
(
2
),
ITEM_USE_TARGET_SPECIFY_AVATAR
(
3
),
ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR
(
4
),
ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR
(
5
);
private
final
int
value
;
private
static
final
Int2ObjectMap
<
ItemUseTarget
>
map
=
new
Int2ObjectOpenHashMap
<>();
static
{
Stream
.
of
(
values
()).
forEach
(
e
->
{
map
.
put
(
e
.
getValue
(),
e
);
});
}
private
ItemUseTarget
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
public
static
ItemUseTarget
getTypeByValue
(
int
value
)
{
return
map
.
getOrDefault
(
value
,
ITEM_USE_TARGET_NONE
);
}
}
src/main/java/emu/grasscutter/game/systems/InventorySystem.java
View file @
f15262dd
...
...
@@ -23,6 +23,8 @@ import emu.grasscutter.game.inventory.GameItem;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ItemUseOp
;
import
emu.grasscutter.game.props.ItemUseTarget
;
import
emu.grasscutter.game.shop.ShopChestBatchUseTable
;
import
emu.grasscutter.game.shop.ShopChestTable
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
...
...
@@ -813,7 +815,7 @@ public class InventorySystem extends BaseGameSystem {
// Use
switch
(
useItem
.
getItemData
().
getMaterialType
())
{
case
MATERIAL_FOOD:
if
(
useItem
.
getItemData
().
getUseTarget
()
.
equals
(
"
ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR
"
)
)
{
if
(
useItem
.
getItemData
().
getUseTarget
()
==
ItemUseTarget
.
ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR
)
{
if
(
target
==
null
)
{
break
;
}
...
...
@@ -822,7 +824,7 @@ public class InventorySystem extends BaseGameSystem {
}
break
;
case
MATERIAL_NOTICE_ADD_HP:
if
(
useItem
.
getItemData
().
getUseTarget
()
.
equals
(
"
ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR
"
)
)
{
if
(
useItem
.
getItemData
().
getUseTarget
()
==
ItemUseTarget
.
ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR
)
{
if
(
target
==
null
)
{
break
;
}
...
...
@@ -836,22 +838,16 @@ public class InventorySystem extends BaseGameSystem {
if
(
useItem
.
getItemData
().
getItemUse
()
==
null
)
{
break
;
}
// Handle forging blueprints.
if
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
().
equals
(
"ITEM_USE_UNLOCK_FORGE"
))
{
// Unlock.
useSuccess
=
player
.
getForgingManager
().
unlockForgingBlueprint
(
useItem
);
}
// Handle combine diagrams.
if
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
().
equals
(
"ITEM_USE_UNLOCK_COMBINE"
))
{
// Unlock.
useSuccess
=
player
.
getServer
().
getCombineSystem
().
unlockCombineDiagram
(
player
,
useItem
);
}
// Handle cooking recipies.
if
(
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
().
equals
(
"ITEM_USE_UNLOCK_COOK_RECIPE"
))
{
// Unlock.
useSuccess
=
player
.
getCookingManager
().
unlockRecipe
(
useItem
);
}
ItemUseOp
useOp
=
useItem
.
getItemData
().
getItemUse
().
get
(
0
).
getUseOp
();
// Unlock item based on use operation
useSuccess
=
switch
(
useOp
)
{
case
ITEM_USE_UNLOCK_FORGE
->
player
.
getForgingManager
().
unlockForgingBlueprint
(
useItem
);
case
ITEM_USE_UNLOCK_COMBINE
->
player
.
getServer
().
getCombineSystem
().
unlockCombineDiagram
(
player
,
useItem
);
case
ITEM_USE_UNLOCK_COOK_RECIPE
->
player
.
getCookingManager
().
unlockRecipe
(
useItem
);
default
->
useSuccess
;
};
break
;
case
MATERIAL_FURNITURE_FORMULA:
case
MATERIAL_FURNITURE_SUITE_FORMULA:
...
...
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