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
d32f706c
Commit
d32f706c
authored
Apr 27, 2022
by
KingRainbow44
Browse files
Merge branch 'development' into api
# Conflicts: # src/main/java/emu/grasscutter/plugin/api/ServerHook.java
parents
47d8fd3c
f0d728b4
Changes
308
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/database/DatabaseManager.java
View file @
d32f706c
...
@@ -13,10 +13,10 @@ import dev.morphia.mapping.MapperOptions;
...
@@ -13,10 +13,10 @@ import dev.morphia.mapping.MapperOptions;
import
dev.morphia.query.experimental.filters.Filters
;
import
dev.morphia.query.experimental.filters.Filters
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.player.Player
;
public
final
class
DatabaseManager
{
public
final
class
DatabaseManager
{
...
@@ -27,7 +27,7 @@ public final class DatabaseManager {
...
@@ -27,7 +27,7 @@ public final class DatabaseManager {
private
static
Datastore
dispatchDatastore
;
private
static
Datastore
dispatchDatastore
;
private
static
final
Class
<?>[]
mappedClasses
=
new
Class
<?>[]
{
private
static
final
Class
<?>[]
mappedClasses
=
new
Class
<?>[]
{
DatabaseCounter
.
class
,
Account
.
class
,
Genshin
Player
.
class
,
Genshin
Avatar
.
class
,
G
enshin
Item
.
class
,
Friendship
.
class
DatabaseCounter
.
class
,
Account
.
class
,
Player
.
class
,
Avatar
.
class
,
G
ame
Item
.
class
,
Friendship
.
class
};
};
public
static
Datastore
getDatastore
()
{
public
static
Datastore
getDatastore
()
{
...
...
src/main/java/emu/grasscutter/game/CoopRequest.java
View file @
d32f706c
package
emu.grasscutter.game
;
package
emu.grasscutter.game
;
import
emu.grasscutter.game.player.Player
;
public
class
CoopRequest
{
public
class
CoopRequest
{
private
final
Genshin
Player
requester
;
private
final
Player
requester
;
private
final
long
requestTime
;
private
final
long
requestTime
;
private
final
long
expireTime
;
private
final
long
expireTime
;
public
CoopRequest
(
Genshin
Player
requester
)
{
public
CoopRequest
(
Player
requester
)
{
this
.
requester
=
requester
;
this
.
requester
=
requester
;
this
.
requestTime
=
System
.
currentTimeMillis
();
this
.
requestTime
=
System
.
currentTimeMillis
();
this
.
expireTime
=
this
.
requestTime
+
10000
;
this
.
expireTime
=
this
.
requestTime
+
10000
;
}
}
public
Genshin
Player
getRequester
()
{
public
Player
getRequester
()
{
return
requester
;
return
requester
;
}
}
...
...
src/main/java/emu/grasscutter/game/avatar/
Genshin
Avatar.java
→
src/main/java/emu/grasscutter/game/avatar/Avatar.java
View file @
d32f706c
...
@@ -16,7 +16,7 @@ import dev.morphia.annotations.PostLoad;
...
@@ -16,7 +16,7 @@ import dev.morphia.annotations.PostLoad;
import
dev.morphia.annotations.PrePersist
;
import
dev.morphia.annotations.PrePersist
;
import
dev.morphia.annotations.Transient
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.common.FightPropData
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarData
;
...
@@ -35,10 +35,10 @@ import emu.grasscutter.data.def.WeaponPromoteData;
...
@@ -35,10 +35,10 @@ import emu.grasscutter.data.def.WeaponPromoteData;
import
emu.grasscutter.data.def.ItemData.WeaponProperty
;
import
emu.grasscutter.data.def.ItemData.WeaponProperty
;
import
emu.grasscutter.data.def.ProudSkillData
;
import
emu.grasscutter.data.def.ProudSkillData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FetterState
;
import
emu.grasscutter.game.props.FetterState
;
...
@@ -57,11 +57,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -57,11 +57,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
@Entity
(
value
=
"avatars"
,
useDiscriminator
=
false
)
@Entity
(
value
=
"avatars"
,
useDiscriminator
=
false
)
public
class
Genshin
Avatar
{
public
class
Avatar
{
@Id
private
ObjectId
id
;
@Id
private
ObjectId
id
;
@Indexed
private
int
ownerId
;
// Id of player that this avatar belongs to
@Indexed
private
int
ownerId
;
// Id of player that this avatar belongs to
@Transient
private
Genshin
Player
owner
;
@Transient
private
Player
owner
;
@Transient
private
AvatarData
data
;
@Transient
private
AvatarData
data
;
@Transient
private
long
guid
;
// Player unique id
@Transient
private
long
guid
;
// Player unique id
private
int
avatarId
;
// Id of avatar
private
int
avatarId
;
// Id of avatar
...
@@ -73,7 +73,7 @@ public class GenshinAvatar {
...
@@ -73,7 +73,7 @@ public class GenshinAvatar {
private
int
satiationPenalty
;
// ?
private
int
satiationPenalty
;
// ?
private
float
currentHp
;
private
float
currentHp
;
@Transient
private
final
Int2ObjectMap
<
G
enshin
Item
>
equips
;
@Transient
private
final
Int2ObjectMap
<
G
ame
Item
>
equips
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
Set
<
String
>
extraAbilityEmbryos
;
@Transient
private
Set
<
String
>
extraAbilityEmbryos
;
...
@@ -96,21 +96,21 @@ public class GenshinAvatar {
...
@@ -96,21 +96,21 @@ public class GenshinAvatar {
private
int
nameCardRewardId
;
private
int
nameCardRewardId
;
private
int
nameCardId
;
private
int
nameCardId
;
public
Genshin
Avatar
()
{
public
Avatar
()
{
// Morhpia only!
// Morhpia only!
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
this
.
proudSkillBonusMap
=
new
HashMap
<>();
this
.
proudSkillBonusMap
=
new
HashMap
<>();
this
.
fetters
=
new
ArrayList
<>();
// TODO Move to
genshin
avatar
this
.
fetters
=
new
ArrayList
<>();
// TODO Move to avatar
}
}
// On creation
// On creation
public
Genshin
Avatar
(
int
avatarId
)
{
public
Avatar
(
int
avatarId
)
{
this
(
G
enshin
Data
.
getAvatarDataMap
().
get
(
avatarId
));
this
(
G
ame
Data
.
getAvatarDataMap
().
get
(
avatarId
));
}
}
public
Genshin
Avatar
(
AvatarData
data
)
{
public
Avatar
(
AvatarData
data
)
{
this
();
this
();
this
.
avatarId
=
data
.
getId
();
this
.
avatarId
=
data
.
getId
();
this
.
nameCardRewardId
=
data
.
getNameCardRewardId
();
this
.
nameCardRewardId
=
data
.
getNameCardRewardId
();
...
@@ -143,7 +143,7 @@ public class GenshinAvatar {
...
@@ -143,7 +143,7 @@ public class GenshinAvatar {
this
.
onLoad
();
this
.
onLoad
();
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
this
.
owner
;
return
this
.
owner
;
}
}
...
@@ -163,10 +163,10 @@ public class GenshinAvatar {
...
@@ -163,10 +163,10 @@ public class GenshinAvatar {
return
ownerId
;
return
ownerId
;
}
}
public
void
setOwner
(
Genshin
Player
player
)
{
public
void
setOwner
(
Player
player
)
{
this
.
owner
=
player
;
this
.
owner
=
player
;
this
.
ownerId
=
player
.
getUid
();
this
.
ownerId
=
player
.
getUid
();
this
.
guid
=
player
.
getNextG
enshin
Guid
();
this
.
guid
=
player
.
getNextG
ame
Guid
();
}
}
public
int
getSatiation
()
{
public
int
getSatiation
()
{
...
@@ -229,19 +229,19 @@ public class GenshinAvatar {
...
@@ -229,19 +229,19 @@ public class GenshinAvatar {
this
.
promoteLevel
=
promoteLevel
;
this
.
promoteLevel
=
promoteLevel
;
}
}
public
Int2ObjectMap
<
G
enshin
Item
>
getEquips
()
{
public
Int2ObjectMap
<
G
ame
Item
>
getEquips
()
{
return
equips
;
return
equips
;
}
}
public
G
enshin
Item
getEquipBySlot
(
EquipType
slot
)
{
public
G
ame
Item
getEquipBySlot
(
EquipType
slot
)
{
return
this
.
getEquips
().
get
(
slot
.
getValue
());
return
this
.
getEquips
().
get
(
slot
.
getValue
());
}
}
private
G
enshin
Item
getEquipBySlot
(
int
slotId
)
{
private
G
ame
Item
getEquipBySlot
(
int
slotId
)
{
return
this
.
getEquips
().
get
(
slotId
);
return
this
.
getEquips
().
get
(
slotId
);
}
}
public
G
enshin
Item
getWeapon
()
{
public
G
ame
Item
getWeapon
()
{
return
this
.
getEquipBySlot
(
EquipType
.
EQUIP_WEAPON
);
return
this
.
getEquipBySlot
(
EquipType
.
EQUIP_WEAPON
);
}
}
...
@@ -270,7 +270,7 @@ public class GenshinAvatar {
...
@@ -270,7 +270,7 @@ public class GenshinAvatar {
}
}
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
if
(
G
enshin
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
if
(
G
ame
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
this
.
getProudSkillList
().
add
(
proudSkillId
);
this
.
getProudSkillList
().
add
(
proudSkillId
);
}
}
}
}
...
@@ -385,7 +385,7 @@ public class GenshinAvatar {
...
@@ -385,7 +385,7 @@ public class GenshinAvatar {
return
bornTime
;
return
bornTime
;
}
}
public
boolean
equipItem
(
G
enshin
Item
item
,
boolean
shouldRecalc
)
{
public
boolean
equipItem
(
G
ame
Item
item
,
boolean
shouldRecalc
)
{
EquipType
itemEquipType
=
item
.
getItemData
().
getEquipType
();
EquipType
itemEquipType
=
item
.
getItemData
().
getEquipType
();
if
(
itemEquipType
==
EquipType
.
EQUIP_NONE
)
{
if
(
itemEquipType
==
EquipType
.
EQUIP_NONE
)
{
return
false
;
return
false
;
...
@@ -416,7 +416,7 @@ public class GenshinAvatar {
...
@@ -416,7 +416,7 @@ public class GenshinAvatar {
}
}
public
boolean
unequipItem
(
EquipType
slot
)
{
public
boolean
unequipItem
(
EquipType
slot
)
{
G
enshin
Item
item
=
getEquips
().
remove
(
slot
.
getValue
());
G
ame
Item
item
=
getEquips
().
remove
(
slot
.
getValue
());
if
(
item
!=
null
)
{
if
(
item
!=
null
)
{
item
.
setEquipCharacter
(
0
);
item
.
setEquipCharacter
(
0
);
...
@@ -434,7 +434,7 @@ public class GenshinAvatar {
...
@@ -434,7 +434,7 @@ public class GenshinAvatar {
public
void
recalcStats
(
boolean
forceSendAbilityChange
)
{
public
void
recalcStats
(
boolean
forceSendAbilityChange
)
{
// Setup
// Setup
AvatarData
data
=
this
.
getAvatarData
();
AvatarData
data
=
this
.
getAvatarData
();
AvatarPromoteData
promoteData
=
G
enshin
Data
.
getAvatarPromoteData
(
data
.
getAvatarPromoteId
(),
this
.
getPromoteLevel
());
AvatarPromoteData
promoteData
=
G
ame
Data
.
getAvatarPromoteData
(
data
.
getAvatarPromoteId
(),
this
.
getPromoteLevel
());
Int2IntOpenHashMap
setMap
=
new
Int2IntOpenHashMap
();
Int2IntOpenHashMap
setMap
=
new
Int2IntOpenHashMap
();
// Extra ability embryos
// Extra ability embryos
...
@@ -476,21 +476,21 @@ public class GenshinAvatar {
...
@@ -476,21 +476,21 @@ public class GenshinAvatar {
// Artifacts
// Artifacts
for
(
int
slotId
=
1
;
slotId
<=
5
;
slotId
++)
{
for
(
int
slotId
=
1
;
slotId
<=
5
;
slotId
++)
{
// Get artifact
// Get artifact
G
enshin
Item
equip
=
this
.
getEquipBySlot
(
slotId
);
G
ame
Item
equip
=
this
.
getEquipBySlot
(
slotId
);
if
(
equip
==
null
)
{
if
(
equip
==
null
)
{
continue
;
continue
;
}
}
// Artifact main stat
// Artifact main stat
ReliquaryMainPropData
mainPropData
=
G
enshin
Data
.
getReliquaryMainPropDataMap
().
get
(
equip
.
getMainPropId
());
ReliquaryMainPropData
mainPropData
=
G
ame
Data
.
getReliquaryMainPropDataMap
().
get
(
equip
.
getMainPropId
());
if
(
mainPropData
!=
null
)
{
if
(
mainPropData
!=
null
)
{
ReliquaryLevelData
levelData
=
G
enshin
Data
.
getRelicLevelData
(
equip
.
getItemData
().
getRankLevel
(),
equip
.
getLevel
());
ReliquaryLevelData
levelData
=
G
ame
Data
.
getRelicLevelData
(
equip
.
getItemData
().
getRankLevel
(),
equip
.
getLevel
());
if
(
levelData
!=
null
)
{
if
(
levelData
!=
null
)
{
this
.
addFightProperty
(
mainPropData
.
getFightProp
(),
levelData
.
getPropValue
(
mainPropData
.
getFightProp
()));
this
.
addFightProperty
(
mainPropData
.
getFightProp
(),
levelData
.
getPropValue
(
mainPropData
.
getFightProp
()));
}
}
}
}
// Artifact sub stats
// Artifact sub stats
for
(
int
appendPropId
:
equip
.
getAppendPropIdList
())
{
for
(
int
appendPropId
:
equip
.
getAppendPropIdList
())
{
ReliquaryAffixData
affixData
=
G
enshin
Data
.
getReliquaryAffixDataMap
().
get
(
appendPropId
);
ReliquaryAffixData
affixData
=
G
ame
Data
.
getReliquaryAffixDataMap
().
get
(
appendPropId
);
if
(
affixData
!=
null
)
{
if
(
affixData
!=
null
)
{
this
.
addFightProperty
(
affixData
.
getFightProp
(),
affixData
.
getPropValue
());
this
.
addFightProperty
(
affixData
.
getFightProp
(),
affixData
.
getPropValue
());
}
}
...
@@ -503,7 +503,7 @@ public class GenshinAvatar {
...
@@ -503,7 +503,7 @@ public class GenshinAvatar {
// Set stuff
// Set stuff
for
(
Int2IntOpenHashMap
.
Entry
e
:
setMap
.
int2IntEntrySet
())
{
for
(
Int2IntOpenHashMap
.
Entry
e
:
setMap
.
int2IntEntrySet
())
{
ReliquarySetData
setData
=
G
enshin
Data
.
getReliquarySetDataMap
().
get
(
e
.
getIntKey
());
ReliquarySetData
setData
=
G
ame
Data
.
getReliquarySetDataMap
().
get
(
e
.
getIntKey
());
if
(
setData
==
null
)
{
if
(
setData
==
null
)
{
continue
;
continue
;
}
}
...
@@ -516,7 +516,7 @@ public class GenshinAvatar {
...
@@ -516,7 +516,7 @@ public class GenshinAvatar {
if
(
amount
>=
setData
.
getSetNeedNum
()[
setIndex
])
{
if
(
amount
>=
setData
.
getSetNeedNum
()[
setIndex
])
{
int
affixId
=
(
setData
.
getEquipAffixId
()
*
10
)
+
setIndex
;
int
affixId
=
(
setData
.
getEquipAffixId
()
*
10
)
+
setIndex
;
EquipAffixData
affix
=
G
enshin
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
EquipAffixData
affix
=
G
ame
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
if
(
affix
==
null
)
{
if
(
affix
==
null
)
{
continue
;
continue
;
}
}
...
@@ -535,17 +535,17 @@ public class GenshinAvatar {
...
@@ -535,17 +535,17 @@ public class GenshinAvatar {
}
}
// Weapon
// Weapon
G
enshin
Item
weapon
=
this
.
getWeapon
();
G
ame
Item
weapon
=
this
.
getWeapon
();
if
(
weapon
!=
null
)
{
if
(
weapon
!=
null
)
{
// Add stats
// Add stats
WeaponCurveData
curveData
=
G
enshin
Data
.
getWeaponCurveDataMap
().
get
(
weapon
.
getLevel
());
WeaponCurveData
curveData
=
G
ame
Data
.
getWeaponCurveDataMap
().
get
(
weapon
.
getLevel
());
if
(
curveData
!=
null
)
{
if
(
curveData
!=
null
)
{
for
(
WeaponProperty
weaponProperty
:
weapon
.
getItemData
().
getWeaponProperties
())
{
for
(
WeaponProperty
weaponProperty
:
weapon
.
getItemData
().
getWeaponProperties
())
{
this
.
addFightProperty
(
weaponProperty
.
getFightProp
(),
weaponProperty
.
getInitValue
()
*
curveData
.
getMultByProp
(
weaponProperty
.
getType
()));
this
.
addFightProperty
(
weaponProperty
.
getFightProp
(),
weaponProperty
.
getInitValue
()
*
curveData
.
getMultByProp
(
weaponProperty
.
getType
()));
}
}
}
}
// Weapon promotion stats
// Weapon promotion stats
WeaponPromoteData
wepPromoteData
=
G
enshin
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
WeaponPromoteData
wepPromoteData
=
G
ame
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
if
(
wepPromoteData
!=
null
)
{
if
(
wepPromoteData
!=
null
)
{
for
(
FightPropData
prop
:
wepPromoteData
.
getAddProps
())
{
for
(
FightPropData
prop
:
wepPromoteData
.
getAddProps
())
{
if
(
prop
.
getValue
()
==
0
f
||
prop
.
getProp
()
==
null
)
{
if
(
prop
.
getValue
()
==
0
f
||
prop
.
getProp
()
==
null
)
{
...
@@ -563,7 +563,7 @@ public class GenshinAvatar {
...
@@ -563,7 +563,7 @@ public class GenshinAvatar {
}
}
// Calculate affix id
// Calculate affix id
int
affixId
=
(
af
*
10
)
+
weapon
.
getRefinement
();
int
affixId
=
(
af
*
10
)
+
weapon
.
getRefinement
();
EquipAffixData
affix
=
G
enshin
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
EquipAffixData
affix
=
G
ame
Data
.
getEquipAffixDataMap
().
get
(
affixId
);
if
(
affix
==
null
)
{
if
(
affix
==
null
)
{
continue
;
continue
;
}
}
...
@@ -580,7 +580,7 @@ public class GenshinAvatar {
...
@@ -580,7 +580,7 @@ public class GenshinAvatar {
}
}
// Add proud skills and unlock them if needed
// Add proud skills and unlock them if needed
AvatarSkillDepotData
skillDepot
=
G
enshin
Data
.
getAvatarSkillDepotDataMap
().
get
(
this
.
getSkillDepotId
());
AvatarSkillDepotData
skillDepot
=
G
ame
Data
.
getAvatarSkillDepotDataMap
().
get
(
this
.
getSkillDepotId
());
this
.
getProudSkillList
().
clear
();
this
.
getProudSkillList
().
clear
();
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
if
(
openData
.
getProudSkillGroupId
()
==
0
)
{
if
(
openData
.
getProudSkillGroupId
()
==
0
)
{
...
@@ -588,7 +588,7 @@ public class GenshinAvatar {
...
@@ -588,7 +588,7 @@ public class GenshinAvatar {
}
}
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
if
(
openData
.
getNeedAvatarPromoteLevel
()
<=
this
.
getPromoteLevel
())
{
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
int
proudSkillId
=
(
openData
.
getProudSkillGroupId
()
*
100
)
+
1
;
if
(
G
enshin
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
if
(
G
ame
Data
.
getProudSkillDataMap
().
containsKey
(
proudSkillId
))
{
this
.
getProudSkillList
().
add
(
proudSkillId
);
this
.
getProudSkillList
().
add
(
proudSkillId
);
}
}
}
}
...
@@ -596,7 +596,7 @@ public class GenshinAvatar {
...
@@ -596,7 +596,7 @@ public class GenshinAvatar {
// Proud skills
// Proud skills
for
(
int
proudSkillId
:
this
.
getProudSkillList
())
{
for
(
int
proudSkillId
:
this
.
getProudSkillList
())
{
ProudSkillData
proudSkillData
=
G
enshin
Data
.
getProudSkillDataMap
().
get
(
proudSkillId
);
ProudSkillData
proudSkillData
=
G
ame
Data
.
getProudSkillDataMap
().
get
(
proudSkillId
);
if
(
proudSkillData
==
null
)
{
if
(
proudSkillData
==
null
)
{
continue
;
continue
;
}
}
...
@@ -613,7 +613,7 @@ public class GenshinAvatar {
...
@@ -613,7 +613,7 @@ public class GenshinAvatar {
// Constellations
// Constellations
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
AvatarTalentData
avatarTalentData
=
G
enshin
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
AvatarTalentData
avatarTalentData
=
G
ame
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
if
(
avatarTalentData
==
null
)
{
if
(
avatarTalentData
==
null
)
{
return
;
return
;
}
}
...
@@ -657,7 +657,7 @@ public class GenshinAvatar {
...
@@ -657,7 +657,7 @@ public class GenshinAvatar {
return
;
return
;
}
}
OpenConfigEntry
entry
=
G
enshin
Data
.
getOpenConfigEntries
().
get
(
openConfig
);
OpenConfigEntry
entry
=
G
ame
Data
.
getOpenConfigEntries
().
get
(
openConfig
);
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
if
(
forceAdd
)
{
if
(
forceAdd
)
{
// Add config string to ability skill list anyways
// Add config string to ability skill list anyways
...
@@ -684,14 +684,14 @@ public class GenshinAvatar {
...
@@ -684,14 +684,14 @@ public class GenshinAvatar {
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
if
(
this
.
getTalentIdList
().
size
()
>
0
)
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
for
(
int
talentId
:
this
.
getTalentIdList
())
{
AvatarTalentData
avatarTalentData
=
G
enshin
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
AvatarTalentData
avatarTalentData
=
G
ame
Data
.
getAvatarTalentDataMap
().
get
(
talentId
);
if
(
avatarTalentData
==
null
||
avatarTalentData
.
getOpenConfig
()
==
null
||
avatarTalentData
.
getOpenConfig
().
length
()
==
0
)
{
if
(
avatarTalentData
==
null
||
avatarTalentData
.
getOpenConfig
()
==
null
||
avatarTalentData
.
getOpenConfig
().
length
()
==
0
)
{
continue
;
continue
;
}
}
// Get open config to find which skill should be boosted
// Get open config to find which skill should be boosted
OpenConfigEntry
entry
=
G
enshin
Data
.
getOpenConfigEntries
().
get
(
avatarTalentData
.
getOpenConfig
());
OpenConfigEntry
entry
=
G
ame
Data
.
getOpenConfigEntries
().
get
(
avatarTalentData
.
getOpenConfig
());
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
continue
;
continue
;
}
}
...
@@ -712,7 +712,7 @@ public class GenshinAvatar {
...
@@ -712,7 +712,7 @@ public class GenshinAvatar {
}
}
// Get proud skill group id
// Get proud skill group id
AvatarSkillData
skillData
=
G
enshin
Data
.
getAvatarSkillDataMap
().
get
(
skillId
);
AvatarSkillData
skillData
=
G
ame
Data
.
getAvatarSkillDataMap
().
get
(
skillId
);
if
(
skillData
==
null
)
{
if
(
skillData
==
null
)
{
continue
;
continue
;
...
@@ -778,14 +778,14 @@ public class GenshinAvatar {
...
@@ -778,14 +778,14 @@ public class GenshinAvatar {
.
setCoreProudSkillLevel
(
this
.
getCoreProudSkillLevel
())
.
setCoreProudSkillLevel
(
this
.
getCoreProudSkillLevel
())
.
putAllSkillLevelMap
(
this
.
getSkillLevelMap
())
.
putAllSkillLevelMap
(
this
.
getSkillLevelMap
())
.
addAllInherentProudSkillList
(
this
.
getProudSkillList
())
.
addAllInherentProudSkillList
(
this
.
getProudSkillList
())
.
putAllProudSkillExtraLevel
(
getProudSkillBonusMap
())
.
putAllProudSkillExtraLevel
Map
(
getProudSkillBonusMap
())
.
setAvatarType
(
1
)
.
setAvatarType
(
1
)
.
setBornTime
(
this
.
getBornTime
())
.
setBornTime
(
this
.
getBornTime
())
.
setFetterInfo
(
avatarFetter
)
.
setFetterInfo
(
avatarFetter
)
.
setWearingFlycloakId
(
this
.
getFlyCloak
())
.
setWearingFlycloakId
(
this
.
getFlyCloak
())
.
setCostumeId
(
this
.
getCostume
());
.
setCostumeId
(
this
.
getCostume
());
for
(
G
enshin
Item
item
:
this
.
getEquips
().
values
())
{
for
(
G
ame
Item
item
:
this
.
getEquips
().
values
())
{
avatarInfo
.
addEquipGuidList
(
item
.
getGuid
());
avatarInfo
.
addEquipGuidList
(
item
.
getGuid
());
}
}
...
...
src/main/java/emu/grasscutter/game/avatar/AvatarProfileData.java
View file @
d32f706c
...
@@ -7,7 +7,7 @@ public class AvatarProfileData {
...
@@ -7,7 +7,7 @@ public class AvatarProfileData {
private
int
avatarId
;
private
int
avatarId
;
private
int
level
;
private
int
level
;
public
AvatarProfileData
(
Genshin
Avatar
avatar
)
{
public
AvatarProfileData
(
Avatar
avatar
)
{
this
.
update
(
avatar
);
this
.
update
(
avatar
);
}
}
...
@@ -19,7 +19,7 @@ public class AvatarProfileData {
...
@@ -19,7 +19,7 @@ public class AvatarProfileData {
return
level
;
return
level
;
}
}
public
void
update
(
Genshin
Avatar
avatar
)
{
public
void
update
(
Avatar
avatar
)
{
this
.
avatarId
=
avatar
.
getAvatarId
();
this
.
avatarId
=
avatar
.
getAvatarId
();
this
.
level
=
avatar
.
getLevel
();
this
.
level
=
avatar
.
getLevel
();
}
}
...
...
src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java
View file @
d32f706c
...
@@ -3,12 +3,12 @@ package emu.grasscutter.game.avatar;
...
@@ -3,12 +3,12 @@ package emu.grasscutter.game.avatar;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.packet.send.PacketAvatarChangeCostumeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarChangeCostumeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarFlycloakChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarFlycloakChangeNotify
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
...
@@ -16,22 +16,22 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
...
@@ -16,22 +16,22 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import
it.unimi.dsi.fastutil.longs.Long2ObjectMap
;
import
it.unimi.dsi.fastutil.longs.Long2ObjectMap
;
import
it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
;
public
class
AvatarStorage
implements
Iterable
<
Genshin
Avatar
>
{
public
class
AvatarStorage
implements
Iterable
<
Avatar
>
{
private
final
Genshin
Player
player
;
private
final
Player
player
;
private
final
Int2ObjectMap
<
Genshin
Avatar
>
avatars
;
private
final
Int2ObjectMap
<
Avatar
>
avatars
;
private
final
Long2ObjectMap
<
Genshin
Avatar
>
avatarsGuid
;
private
final
Long2ObjectMap
<
Avatar
>
avatarsGuid
;
public
AvatarStorage
(
Genshin
Player
player
)
{
public
AvatarStorage
(
Player
player
)
{
this
.
player
=
player
;
this
.
player
=
player
;
this
.
avatars
=
new
Int2ObjectOpenHashMap
<>();
this
.
avatars
=
new
Int2ObjectOpenHashMap
<>();
this
.
avatarsGuid
=
new
Long2ObjectOpenHashMap
<>();
this
.
avatarsGuid
=
new
Long2ObjectOpenHashMap
<>();
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
player
;
return
player
;
}
}
public
Int2ObjectMap
<
Genshin
Avatar
>
getAvatars
()
{
public
Int2ObjectMap
<
Avatar
>
getAvatars
()
{
return
avatars
;
return
avatars
;
}
}
...
@@ -39,11 +39,11 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -39,11 +39,11 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return
this
.
avatars
.
size
();
return
this
.
avatars
.
size
();
}
}
public
Genshin
Avatar
getAvatarById
(
int
id
)
{
public
Avatar
getAvatarById
(
int
id
)
{
return
getAvatars
().
get
(
id
);
return
getAvatars
().
get
(
id
);
}
}
public
Genshin
Avatar
getAvatarByGuid
(
long
id
)
{
public
Avatar
getAvatarByGuid
(
long
id
)
{
return
avatarsGuid
.
get
(
id
);
return
avatarsGuid
.
get
(
id
);
}
}
...
@@ -51,7 +51,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -51,7 +51,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return
getAvatars
().
containsKey
(
id
);
return
getAvatars
().
containsKey
(
id
);
}
}
public
boolean
addAvatar
(
Genshin
Avatar
avatar
)
{
public
boolean
addAvatar
(
Avatar
avatar
)
{
if
(
avatar
.
getAvatarData
()
==
null
||
this
.
hasAvatar
(
avatar
.
getAvatarId
()))
{
if
(
avatar
.
getAvatarData
()
==
null
||
this
.
hasAvatar
(
avatar
.
getAvatarId
()))
{
return
false
;
return
false
;
}
}
...
@@ -68,14 +68,14 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -68,14 +68,14 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return
true
;
return
true
;
}
}
public
void
addStartingWeapon
(
Genshin
Avatar
avatar
)
{
public
void
addStartingWeapon
(
Avatar
avatar
)
{
// Make sure avatar owner is this player
// Make sure avatar owner is this player
if
(
avatar
.
getPlayer
()
!=
this
.
getPlayer
())
{
if
(
avatar
.
getPlayer
()
!=
this
.
getPlayer
())
{
return
;
return
;
}
}
// Create weapon
// Create weapon
G
enshin
Item
weapon
=
new
G
enshin
Item
(
avatar
.
getAvatarData
().
getInitialWeapon
());
G
ame
Item
weapon
=
new
G
ame
Item
(
avatar
.
getAvatarData
().
getInitialWeapon
());
if
(
weapon
.
getItemData
()
!=
null
)
{
if
(
weapon
.
getItemData
()
!=
null
)
{
this
.
getPlayer
().
getInventory
().
addItem
(
weapon
);
this
.
getPlayer
().
getInventory
().
addItem
(
weapon
);
...
@@ -85,7 +85,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -85,7 +85,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
}
public
boolean
wearFlycloak
(
long
avatarGuid
,
int
flycloakId
)
{
public
boolean
wearFlycloak
(
long
avatarGuid
,
int
flycloakId
)
{
Genshin
Avatar
avatar
=
this
.
getAvatarByGuid
(
avatarGuid
);
Avatar
avatar
=
this
.
getAvatarByGuid
(
avatarGuid
);
if
(
avatar
==
null
||
!
getPlayer
().
getFlyCloakList
().
contains
(
flycloakId
))
{
if
(
avatar
==
null
||
!
getPlayer
().
getFlyCloakList
().
contains
(
flycloakId
))
{
return
false
;
return
false
;
...
@@ -101,7 +101,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -101,7 +101,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
}
public
boolean
changeCostume
(
long
avatarGuid
,
int
costumeId
)
{
public
boolean
changeCostume
(
long
avatarGuid
,
int
costumeId
)
{
Genshin
Avatar
avatar
=
this
.
getAvatarByGuid
(
avatarGuid
);
Avatar
avatar
=
this
.
getAvatarByGuid
(
avatarGuid
);
if
(
avatar
==
null
)
{
if
(
avatar
==
null
)
{
return
false
;
return
false
;
...
@@ -130,15 +130,15 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -130,15 +130,15 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
}
public
void
loadFromDatabase
()
{
public
void
loadFromDatabase
()
{
List
<
Genshin
Avatar
>
avatars
=
DatabaseHelper
.
getAvatars
(
getPlayer
());
List
<
Avatar
>
avatars
=
DatabaseHelper
.
getAvatars
(
getPlayer
());
for
(
Genshin
Avatar
avatar
:
avatars
)
{
for
(
Avatar
avatar
:
avatars
)
{
// Should never happen
// Should never happen
if
(
avatar
.
getObjectId
()
==
null
)
{
if
(
avatar
.
getObjectId
()
==
null
)
{
continue
;
continue
;
}
}
AvatarData
avatarData
=
G
enshin
Data
.
getAvatarDataMap
().
get
(
avatar
.
getAvatarId
());
AvatarData
avatarData
=
G
ame
Data
.
getAvatarDataMap
().
get
(
avatar
.
getAvatarId
());
if
(
avatarData
==
null
)
{
if
(
avatarData
==
null
)
{
continue
;
continue
;
}
}
...
@@ -157,7 +157,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -157,7 +157,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
}
public
void
postLoad
()
{
public
void
postLoad
()
{
for
(
Genshin
Avatar
avatar
:
this
)
{
for
(
Avatar
avatar
:
this
)
{
// Weapon check
// Weapon check
if
(
avatar
.
getWeapon
()
==
null
)
{
if
(
avatar
.
getWeapon
()
==
null
)
{
this
.
addStartingWeapon
(
avatar
);
this
.
addStartingWeapon
(
avatar
);
...
@@ -168,7 +168,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
...
@@ -168,7 +168,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
}
@Override
@Override
public
Iterator
<
Genshin
Avatar
>
iterator
()
{
public
Iterator
<
Avatar
>
iterator
()
{
return
getAvatars
().
values
().
iterator
();
return
getAvatars
().
values
().
iterator
();
}
}
}
}
src/main/java/emu/grasscutter/game/drop/DropData.java
0 → 100644
View file @
d32f706c
package
emu.grasscutter.game.drop
;
public
class
DropData
{
private
int
minWeight
;
private
int
maxWeight
;
private
int
itemId
;
private
int
minCount
;
private
int
maxCount
;
private
boolean
share
=
false
;
public
int
getItemId
()
{
return
itemId
;
}
public
void
setItemId
(
int
itemId
)
{
this
.
itemId
=
itemId
;
}
public
int
getMinCount
()
{
return
minCount
;
}
public
int
getMaxCount
()
{
return
maxCount
;
}
public
int
getMinWeight
()
{
return
minWeight
;
}
public
int
getMaxWeight
()
{
return
maxWeight
;
}
public
boolean
isShare
()
{
return
share
;
}
public
void
setIsShare
(
boolean
share
)
{
this
.
share
=
share
;
}
public
boolean
isGive
()
{
return
give
;
}
private
boolean
give
=
false
;
public
boolean
isExp
()
{
return
exp
;
}
private
boolean
exp
=
false
;
}
src/main/java/emu/grasscutter/game/drop/DropInfo.java
0 → 100644
View file @
d32f706c
package
emu.grasscutter.game.drop
;
import
java.util.List
;
public
class
DropInfo
{
public
int
getMonsterId
()
{
return
monsterId
;
}
public
List
<
DropData
>
getDropDataList
()
{
return
dropDataList
;
}
private
int
monsterId
;
private
List
<
DropData
>
dropDataList
;
}
src/main/java/emu/grasscutter/game/drop/DropManager.java
0 → 100644
View file @
d32f706c
package
emu.grasscutter.game.drop
;
import
com.google.gson.reflect.TypeToken
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.game.entity.EntityItem
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
java.io.FileReader
;
import
java.util.Collection
;
import
java.util.List
;
public
class
DropManager
{
public
GameServer
getGameServer
()
{
return
gameServer
;
}
private
final
GameServer
gameServer
;
public
Int2ObjectMap
<
List
<
DropData
>>
getDropData
()
{
return
dropData
;
}
private
final
Int2ObjectMap
<
List
<
DropData
>>
dropData
;
public
DropManager
(
GameServer
gameServer
)
{
this
.
gameServer
=
gameServer
;
this
.
dropData
=
new
Int2ObjectOpenHashMap
<>();
this
.
load
();
}
public
synchronized
void
load
()
{
try
(
FileReader
fileReader
=
new
FileReader
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"Drop.json"
))
{
getDropData
().
clear
();
List
<
DropInfo
>
banners
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
DropInfo
.
class
).
getType
());
if
(
banners
.
size
()
>
0
)
{
for
(
DropInfo
di
:
banners
)
{
getDropData
().
put
(
di
.
getMonsterId
(),
di
.
getDropDataList
());
}
Grasscutter
.
getLogger
().
info
(
"Drop data successfully loaded."
);
}
else
{
Grasscutter
.
getLogger
().
error
(
"Unable to load drop data. Drop data size is 0."
);
}
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
private
void
processDrop
(
DropData
dd
,
EntityMonster
em
,
Player
gp
)
{
int
target
=
Utils
.
randomRange
(
1
,
10000
);
if
(
target
>=
dd
.
getMinWeight
()
&&
target
<
dd
.
getMaxWeight
())
{
ItemData
itemData
=
GameData
.
getItemDataMap
().
get
(
dd
.
getItemId
());
int
num
=
Utils
.
randomRange
(
dd
.
getMinCount
(),
dd
.
getMaxCount
());
if
(!
dd
.
isGive
())
{
if
(
itemData
.
isEquip
())
{
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
float
range
=
(
5
f
+
(.
1
f
*
num
));
Position
pos
=
em
.
getPosition
().
clone
().
addX
((
float
)
(
Math
.
random
()
*
range
)
-
(
range
/
2
)).
addY
(
3
f
).
addZ
((
float
)
(
Math
.
random
()
*
range
)
-
(
range
/
2
));
EntityItem
entity
=
new
EntityItem
(
em
.
getScene
(),
gp
,
itemData
,
pos
,
num
,
dd
.
isShare
());
if
(!
dd
.
isShare
())
em
.
getScene
().
addEntityToSingleClient
(
gp
,
entity
);
else
em
.
getScene
().
addEntity
(
entity
);
}
}
else
{
Position
pos
=
em
.
getPosition
().
clone
().
addY
(
3
f
);
EntityItem
entity
=
new
EntityItem
(
em
.
getScene
(),
gp
,
itemData
,
pos
,
num
,
dd
.
isShare
());
if
(!
dd
.
isShare
())
em
.
getScene
().
addEntityToSingleClient
(
gp
,
entity
);
else
em
.
getScene
().
addEntity
(
entity
);
}
}
}
}
public
void
callDrop
(
EntityMonster
em
)
{
int
id
=
em
.
getMonsterData
().
getId
();
if
(
getDropData
().
containsKey
(
id
))
{
for
(
DropData
dd
:
getDropData
().
get
(
id
))
{
if
(
dd
.
isShare
())
processDrop
(
dd
,
em
,
null
);
else
{
for
(
Player
gp
:
em
.
getScene
().
getPlayers
())
{
processDrop
(
dd
,
em
,
gp
);
}
}
}
}
}
}
src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
View file @
d32f706c
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.G
enshin
Constants
;
import
emu.grasscutter.G
ame
Constants
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.World
;
import
emu.grasscutter.net.proto.AbilityControlBlockOuterClass.AbilityControlBlock
;
import
emu.grasscutter.net.proto.AbilityControlBlockOuterClass.AbilityControlBlock
;
import
emu.grasscutter.net.proto.AbilityEmbryoOuterClass.AbilityEmbryo
;
import
emu.grasscutter.net.proto.AbilityEmbryoOuterClass.AbilityEmbryo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
...
@@ -34,29 +34,29 @@ import emu.grasscutter.utils.Utils;
...
@@ -34,29 +34,29 @@ import emu.grasscutter.utils.Utils;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
public
class
EntityAvatar
extends
G
enshin
Entity
{
public
class
EntityAvatar
extends
G
ame
Entity
{
private
final
Genshin
Avatar
avatar
;
private
final
Avatar
avatar
;
private
PlayerDieType
killedType
;
private
PlayerDieType
killedType
;
private
int
killedBy
;
private
int
killedBy
;
public
EntityAvatar
(
Genshin
Scene
scene
,
Genshin
Avatar
avatar
)
{
public
EntityAvatar
(
Scene
scene
,
Avatar
avatar
)
{
super
(
scene
);
super
(
scene
);
this
.
avatar
=
avatar
;
this
.
avatar
=
avatar
;
this
.
id
=
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
AVATAR
);
this
.
id
=
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
AVATAR
);
G
enshin
Item
weapon
=
this
.
getAvatar
().
getWeapon
();
G
ame
Item
weapon
=
this
.
getAvatar
().
getWeapon
();
if
(
weapon
!=
null
)
{
if
(
weapon
!=
null
)
{
weapon
.
setWeaponEntityId
(
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
WEAPON
));
weapon
.
setWeaponEntityId
(
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
WEAPON
));
}
}
}
}
public
EntityAvatar
(
Genshin
Avatar
avatar
)
{
public
EntityAvatar
(
Avatar
avatar
)
{
super
(
null
);
super
(
null
);
this
.
avatar
=
avatar
;
this
.
avatar
=
avatar
;
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
avatar
.
getPlayer
();
return
avatar
.
getPlayer
();
}
}
...
@@ -70,7 +70,7 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -70,7 +70,7 @@ public class EntityAvatar extends GenshinEntity {
return
getPlayer
().
getRotation
();
return
getPlayer
().
getRotation
();
}
}
public
Genshin
Avatar
getAvatar
()
{
public
Avatar
getAvatar
()
{
return
avatar
;
return
avatar
;
}
}
...
@@ -101,13 +101,13 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -101,13 +101,13 @@ public class EntityAvatar extends GenshinEntity {
@Override
@Override
public
void
onDeath
(
int
killerId
)
{
public
void
onDeath
(
int
killerId
)
{
this
.
killedType
=
PlayerDieType
.
P
layerDieKillByMonster
;
this
.
killedType
=
PlayerDieType
.
P
LAYER_DIE_KILL_BY_MONSTER
;
this
.
killedBy
=
killerId
;
this
.
killedBy
=
killerId
;
}
}
public
SceneAvatarInfo
getSceneAvatarInfo
()
{
public
SceneAvatarInfo
getSceneAvatarInfo
()
{
SceneAvatarInfo
.
Builder
avatarInfo
=
SceneAvatarInfo
.
newBuilder
()
SceneAvatarInfo
.
Builder
avatarInfo
=
SceneAvatarInfo
.
newBuilder
()
.
set
PlayerI
d
(
this
.
getPlayer
().
getUid
())
.
set
Ui
d
(
this
.
getPlayer
().
getUid
())
.
setAvatarId
(
this
.
getAvatar
().
getAvatarId
())
.
setAvatarId
(
this
.
getAvatar
().
getAvatarId
())
.
setGuid
(
this
.
getAvatar
().
getGuid
())
.
setGuid
(
this
.
getAvatar
().
getGuid
())
.
setPeerId
(
this
.
getPlayer
().
getPeerId
())
.
setPeerId
(
this
.
getPlayer
().
getPeerId
())
...
@@ -122,7 +122,7 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -122,7 +122,7 @@ public class EntityAvatar extends GenshinEntity {
.
setCostumeId
(
this
.
getAvatar
().
getCostume
())
.
setCostumeId
(
this
.
getAvatar
().
getCostume
())
.
setBornTime
(
this
.
getAvatar
().
getBornTime
());
.
setBornTime
(
this
.
getAvatar
().
getBornTime
());
for
(
G
enshin
Item
item
:
avatar
.
getEquips
().
values
())
{
for
(
G
ame
Item
item
:
avatar
.
getEquips
().
values
())
{
if
(
item
.
getItemData
().
getEquipType
()
==
EquipType
.
EQUIP_WEAPON
)
{
if
(
item
.
getItemData
().
getEquipType
()
==
EquipType
.
EQUIP_WEAPON
)
{
avatarInfo
.
setWeapon
(
item
.
createSceneWeaponInfo
());
avatarInfo
.
setWeapon
(
item
.
createSceneWeaponInfo
());
}
else
{
}
else
{
...
@@ -145,7 +145,7 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -145,7 +145,7 @@ public class EntityAvatar extends GenshinEntity {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityAvatar
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_AVATAR
)
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
.
setEntityAuthorityInfo
(
authority
)
.
setEntityAuthorityInfo
(
authority
)
...
@@ -161,7 +161,7 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -161,7 +161,7 @@ public class EntityAvatar extends GenshinEntity {
if
(
entry
.
getIntKey
()
==
0
)
{
if
(
entry
.
getIntKey
()
==
0
)
{
continue
;
continue
;
}
}
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
setType
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
set
Prop
Type
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
entityInfo
.
addFightPropList
(
fightProp
);
entityInfo
.
addFightPropList
(
fightProp
);
}
}
...
@@ -187,17 +187,17 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -187,17 +187,17 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
.
setAbilityId
(++
embryoId
)
.
setAbilityId
(++
embryoId
)
.
setAbilityNameHash
(
id
)
.
setAbilityNameHash
(
id
)
.
setAbilityOverrideNameHash
(
G
enshin
Constants
.
DEFAULT_ABILITY_NAME
)
.
setAbilityOverrideNameHash
(
G
ame
Constants
.
DEFAULT_ABILITY_NAME
)
.
build
();
.
build
();
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
}
}
}
}
// Add default abilities
// Add default abilities
for
(
int
id
:
G
enshin
Constants
.
DEFAULT_ABILITY_HASHES
)
{
for
(
int
id
:
G
ame
Constants
.
DEFAULT_ABILITY_HASHES
)
{
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
.
setAbilityId
(++
embryoId
)
.
setAbilityId
(++
embryoId
)
.
setAbilityNameHash
(
id
)
.
setAbilityNameHash
(
id
)
.
setAbilityOverrideNameHash
(
G
enshin
Constants
.
DEFAULT_ABILITY_NAME
)
.
setAbilityOverrideNameHash
(
G
ame
Constants
.
DEFAULT_ABILITY_NAME
)
.
build
();
.
build
();
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
}
}
...
@@ -206,18 +206,18 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -206,18 +206,18 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
.
setAbilityId
(++
embryoId
)
.
setAbilityId
(++
embryoId
)
.
setAbilityNameHash
(
id
)
.
setAbilityNameHash
(
id
)
.
setAbilityOverrideNameHash
(
G
enshin
Constants
.
DEFAULT_ABILITY_NAME
)
.
setAbilityOverrideNameHash
(
G
ame
Constants
.
DEFAULT_ABILITY_NAME
)
.
build
();
.
build
();
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
}
}
// Add skill depot abilities
// Add skill depot abilities
AvatarSkillDepotData
skillDepot
=
G
enshin
Data
.
getAvatarSkillDepotDataMap
().
get
(
this
.
getAvatar
().
getSkillDepotId
());
AvatarSkillDepotData
skillDepot
=
G
ame
Data
.
getAvatarSkillDepotDataMap
().
get
(
this
.
getAvatar
().
getSkillDepotId
());
if
(
skillDepot
!=
null
&&
skillDepot
.
getAbilities
()
!=
null
)
{
if
(
skillDepot
!=
null
&&
skillDepot
.
getAbilities
()
!=
null
)
{
for
(
int
id
:
skillDepot
.
getAbilities
())
{
for
(
int
id
:
skillDepot
.
getAbilities
())
{
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
.
setAbilityId
(++
embryoId
)
.
setAbilityId
(++
embryoId
)
.
setAbilityNameHash
(
id
)
.
setAbilityNameHash
(
id
)
.
setAbilityOverrideNameHash
(
G
enshin
Constants
.
DEFAULT_ABILITY_NAME
)
.
setAbilityOverrideNameHash
(
G
ame
Constants
.
DEFAULT_ABILITY_NAME
)
.
build
();
.
build
();
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
}
}
...
@@ -228,7 +228,7 @@ public class EntityAvatar extends GenshinEntity {
...
@@ -228,7 +228,7 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
AbilityEmbryo
emb
=
AbilityEmbryo
.
newBuilder
()
.
setAbilityId
(++
embryoId
)
.
setAbilityId
(++
embryoId
)
.
setAbilityNameHash
(
Utils
.
abilityHash
(
skill
))
.
setAbilityNameHash
(
Utils
.
abilityHash
(
skill
))
.
setAbilityOverrideNameHash
(
G
enshin
Constants
.
DEFAULT_ABILITY_NAME
)
.
setAbilityOverrideNameHash
(
G
ame
Constants
.
DEFAULT_ABILITY_NAME
)
.
build
();
.
build
();
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
abilityControlBlock
.
addAbilityEmbryoList
(
emb
);
}
}
...
...
src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java
View file @
d32f706c
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.World
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.ClientGadgetInfoOuterClass
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData
;
import
emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData
;
import
emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo
;
import
emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo
;
...
@@ -23,7 +24,7 @@ import emu.grasscutter.utils.ProtoHelper;
...
@@ -23,7 +24,7 @@ import emu.grasscutter.utils.ProtoHelper;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
public
class
EntityClientGadget
extends
EntityGadget
{
public
class
EntityClientGadget
extends
EntityGadget
{
private
final
Genshin
Player
owner
;
private
final
Player
owner
;
private
final
Position
pos
;
private
final
Position
pos
;
private
final
Position
rot
;
private
final
Position
rot
;
...
@@ -35,7 +36,7 @@ public class EntityClientGadget extends EntityGadget {
...
@@ -35,7 +36,7 @@ public class EntityClientGadget extends EntityGadget {
private
int
targetEntityId
;
private
int
targetEntityId
;
private
boolean
asyncLoad
;
private
boolean
asyncLoad
;
public
EntityClientGadget
(
Genshin
Scene
scene
,
Genshin
Player
player
,
EvtCreateGadgetNotify
notify
)
{
public
EntityClientGadget
(
Scene
scene
,
Player
player
,
EvtCreateGadgetNotify
notify
)
{
super
(
scene
);
super
(
scene
);
this
.
owner
=
player
;
this
.
owner
=
player
;
this
.
id
=
notify
.
getEntityId
();
this
.
id
=
notify
.
getEntityId
();
...
@@ -54,7 +55,7 @@ public class EntityClientGadget extends EntityGadget {
...
@@ -54,7 +55,7 @@ public class EntityClientGadget extends EntityGadget {
return
configId
;
return
configId
;
}
}
public
Genshin
Player
getOwner
()
{
public
Player
getOwner
()
{
return
owner
;
return
owner
;
}
}
...
@@ -112,7 +113,7 @@ public class EntityClientGadget extends EntityGadget {
...
@@ -112,7 +113,7 @@ public class EntityClientGadget extends EntityGadget {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityGadget
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_GADGET
)
.
setMotionInfo
(
MotionInfo
.
newBuilder
().
setPos
(
getPosition
().
toProto
()).
setRot
(
getRotation
().
toProto
()).
setSpeed
(
Vector
.
newBuilder
()))
.
setMotionInfo
(
MotionInfo
.
newBuilder
().
setPos
(
getPosition
().
toProto
()).
setRot
(
getRotation
().
toProto
()).
setSpeed
(
Vector
.
newBuilder
()))
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
...
@@ -125,7 +126,7 @@ public class EntityClientGadget extends EntityGadget {
...
@@ -125,7 +126,7 @@ public class EntityClientGadget extends EntityGadget {
.
build
();
.
build
();
entityInfo
.
addPropList
(
pair
);
entityInfo
.
addPropList
(
pair
);
GadgetClientParam
clientGadget
=
GadgetClientParam
.
newBuilder
()
ClientGadgetInfoOuterClass
.
ClientGadgetInfo
clientGadget
=
ClientGadgetInfoOuterClass
.
ClientGadgetInfo
.
newBuilder
()
.
setCampId
(
this
.
getCampId
())
.
setCampId
(
this
.
getCampId
())
.
setCampType
(
this
.
getCampType
())
.
setCampType
(
this
.
getCampType
())
.
setOwnerEntityId
(
this
.
getOwnerEntityId
())
.
setOwnerEntityId
(
this
.
getOwnerEntityId
())
...
...
src/main/java/emu/grasscutter/game/entity/EntityGadget.java
View file @
d32f706c
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.
Genshin
Scene
;
import
emu.grasscutter.game.
world.
Scene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.
world.
World
;
public
abstract
class
EntityGadget
extends
G
enshin
Entity
{
public
abstract
class
EntityGadget
extends
G
ame
Entity
{
public
EntityGadget
(
Genshin
Scene
scene
)
{
public
EntityGadget
(
Scene
scene
)
{
super
(
scene
);
super
(
scene
);
}
}
...
...
src/main/java/emu/grasscutter/game/entity/EntityItem.java
View file @
d32f706c
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
...
@@ -28,16 +27,32 @@ public class EntityItem extends EntityGadget {
...
@@ -28,16 +27,32 @@ public class EntityItem extends EntityGadget {
private
final
Position
pos
;
private
final
Position
pos
;
private
final
Position
rot
;
private
final
Position
rot
;
private
final
G
enshin
Item
item
;
private
final
G
ame
Item
item
;
private
final
long
guid
;
private
final
long
guid
;
public
EntityItem
(
GenshinScene
scene
,
GenshinPlayer
player
,
ItemData
itemData
,
Position
pos
,
int
count
)
{
private
final
boolean
share
;
public
EntityItem
(
Scene
scene
,
Player
player
,
ItemData
itemData
,
Position
pos
,
int
count
)
{
super
(
scene
);
super
(
scene
);
this
.
id
=
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
GADGET
);
this
.
id
=
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
GADGET
);
this
.
pos
=
new
Position
(
pos
);
this
.
pos
=
new
Position
(
pos
);
this
.
rot
=
new
Position
();
this
.
rot
=
new
Position
();
this
.
guid
=
player
.
getNextGenshinGuid
();
this
.
guid
=
player
==
null
?
scene
.
getWorld
().
getHost
().
getNextGameGuid
()
:
player
.
getNextGameGuid
();
this
.
item
=
new
GenshinItem
(
itemData
,
count
);
this
.
item
=
new
GameItem
(
itemData
,
count
);
this
.
share
=
true
;
}
// In official game, some drop items are shared to all players, and some other items are independent to all players
// For example, if you killed a monster in MP mode, all players could get drops but rarity and number of them are different
// but if you broke regional mine, when someone picked up the drop then it disappeared
public
EntityItem
(
Scene
scene
,
Player
player
,
ItemData
itemData
,
Position
pos
,
int
count
,
boolean
share
)
{
super
(
scene
);
this
.
id
=
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
GADGET
);
this
.
pos
=
new
Position
(
pos
);
this
.
rot
=
new
Position
();
this
.
guid
=
player
==
null
?
scene
.
getWorld
().
getHost
().
getNextGameGuid
()
:
player
.
getNextGameGuid
();
this
.
item
=
new
GameItem
(
itemData
,
count
);
this
.
share
=
share
;
}
}
@Override
@Override
...
@@ -45,7 +60,7 @@ public class EntityItem extends EntityGadget {
...
@@ -45,7 +60,7 @@ public class EntityItem extends EntityGadget {
return
this
.
id
;
return
this
.
id
;
}
}
private
G
enshin
Item
getItem
()
{
private
G
ame
Item
getItem
()
{
return
this
.
item
;
return
this
.
item
;
}
}
...
@@ -81,6 +96,10 @@ public class EntityItem extends EntityGadget {
...
@@ -81,6 +96,10 @@ public class EntityItem extends EntityGadget {
return
null
;
return
null
;
}
}
public
boolean
isShare
()
{
return
share
;
}
@Override
@Override
public
SceneEntityInfo
toProto
()
{
public
SceneEntityInfo
toProto
()
{
EntityAuthorityInfo
authority
=
EntityAuthorityInfo
.
newBuilder
()
EntityAuthorityInfo
authority
=
EntityAuthorityInfo
.
newBuilder
()
...
@@ -92,7 +111,7 @@ public class EntityItem extends EntityGadget {
...
@@ -92,7 +111,7 @@ public class EntityItem extends EntityGadget {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityGadget
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_GADGET
)
.
setMotionInfo
(
MotionInfo
.
newBuilder
().
setPos
(
getPosition
().
toProto
()).
setRot
(
getRotation
().
toProto
()).
setSpeed
(
Vector
.
newBuilder
()))
.
setMotionInfo
(
MotionInfo
.
newBuilder
().
setPos
(
getPosition
().
toProto
()).
setRot
(
getRotation
().
toProto
()).
setSpeed
(
Vector
.
newBuilder
()))
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
...
@@ -108,7 +127,7 @@ public class EntityItem extends EntityGadget {
...
@@ -108,7 +127,7 @@ public class EntityItem extends EntityGadget {
SceneGadgetInfo
.
Builder
gadgetInfo
=
SceneGadgetInfo
.
newBuilder
()
SceneGadgetInfo
.
Builder
gadgetInfo
=
SceneGadgetInfo
.
newBuilder
()
.
setGadgetId
(
this
.
getItemData
().
getGadgetId
())
.
setGadgetId
(
this
.
getItemData
().
getGadgetId
())
.
setTrifleItem
(
this
.
getItem
().
toProto
())
.
setTrifleItem
(
this
.
getItem
().
toProto
())
.
setBornType
(
GadgetBornType
.
G
adgetBornInAir
)
.
setBornType
(
GadgetBornType
.
G
ADGET_BORN_IN_AIR
)
.
setAuthorityPeerId
(
this
.
getWorld
().
getHostPeerId
())
.
setAuthorityPeerId
(
this
.
getWorld
().
getHostPeerId
())
.
setIsEnableInteract
(
true
);
.
setIsEnableInteract
(
true
);
...
...
src/main/java/emu/grasscutter/game/entity/EntityMonster.java
View file @
d32f706c
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.common.PropGrowCurve
;
import
emu.grasscutter.data.common.PropGrowCurve
;
import
emu.grasscutter.data.def.MonsterCurveData
;
import
emu.grasscutter.data.def.MonsterCurveData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.World
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
...
@@ -27,7 +27,7 @@ import emu.grasscutter.utils.ProtoHelper;
...
@@ -27,7 +27,7 @@ import emu.grasscutter.utils.ProtoHelper;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
public
class
EntityMonster
extends
G
enshin
Entity
{
public
class
EntityMonster
extends
G
ame
Entity
{
private
final
MonsterData
monsterData
;
private
final
MonsterData
monsterData
;
private
final
Int2FloatOpenHashMap
fightProp
;
private
final
Int2FloatOpenHashMap
fightProp
;
...
@@ -41,7 +41,7 @@ public class EntityMonster extends GenshinEntity {
...
@@ -41,7 +41,7 @@ public class EntityMonster extends GenshinEntity {
private
int
configId
;
private
int
configId
;
private
int
poseId
;
private
int
poseId
;
public
EntityMonster
(
Genshin
Scene
scene
,
MonsterData
monsterData
,
Position
pos
,
int
level
)
{
public
EntityMonster
(
Scene
scene
,
MonsterData
monsterData
,
Position
pos
,
int
level
)
{
super
(
scene
);
super
(
scene
);
this
.
id
=
getWorld
().
getNextEntityId
(
EntityIdType
.
MONSTER
);
this
.
id
=
getWorld
().
getNextEntityId
(
EntityIdType
.
MONSTER
);
this
.
monsterData
=
monsterData
;
this
.
monsterData
=
monsterData
;
...
@@ -160,7 +160,7 @@ public class EntityMonster extends GenshinEntity {
...
@@ -160,7 +160,7 @@ public class EntityMonster extends GenshinEntity {
this
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_ICE_SUB_HURT
,
data
.
getIceSubHurt
());
this
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_ICE_SUB_HURT
,
data
.
getIceSubHurt
());
// Level curve
// Level curve
MonsterCurveData
curve
=
G
enshin
Data
.
getMonsterCurveDataMap
().
get
(
this
.
getLevel
());
MonsterCurveData
curve
=
G
ame
Data
.
getMonsterCurveDataMap
().
get
(
this
.
getLevel
());
if
(
curve
!=
null
)
{
if
(
curve
!=
null
)
{
for
(
PropGrowCurve
growCurve
:
data
.
getPropGrowCurves
())
{
for
(
PropGrowCurve
growCurve
:
data
.
getPropGrowCurves
())
{
FightProperty
prop
=
FightProperty
.
getPropByName
(
growCurve
.
getType
());
FightProperty
prop
=
FightProperty
.
getPropByName
(
growCurve
.
getType
());
...
@@ -197,7 +197,7 @@ public class EntityMonster extends GenshinEntity {
...
@@ -197,7 +197,7 @@ public class EntityMonster extends GenshinEntity {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityMonster
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_MONSTER
)
.
setMotionInfo
(
this
.
getMotionInfo
())
.
setMotionInfo
(
this
.
getMotionInfo
())
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
...
@@ -208,7 +208,7 @@ public class EntityMonster extends GenshinEntity {
...
@@ -208,7 +208,7 @@ public class EntityMonster extends GenshinEntity {
if
(
entry
.
getIntKey
()
==
0
)
{
if
(
entry
.
getIntKey
()
==
0
)
{
continue
;
continue
;
}
}
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
setType
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
set
Prop
Type
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
entityInfo
.
addFightPropList
(
fightProp
);
entityInfo
.
addFightPropList
(
fightProp
);
}
}
...
@@ -226,7 +226,7 @@ public class EntityMonster extends GenshinEntity {
...
@@ -226,7 +226,7 @@ public class EntityMonster extends GenshinEntity {
.
setAuthorityPeerId
(
getWorld
().
getHostPeerId
())
.
setAuthorityPeerId
(
getWorld
().
getHostPeerId
())
.
setPoseId
(
this
.
getPoseId
())
.
setPoseId
(
this
.
getPoseId
())
.
setBlockId
(
3001
)
.
setBlockId
(
3001
)
.
setBornType
(
MonsterBornType
.
M
onsterBornDefault
)
.
setBornType
(
MonsterBornType
.
M
ONSTER_BORN_DEFAULT
)
.
setSpecialNameId
(
40
);
.
setSpecialNameId
(
40
);
if
(
getMonsterData
().
getDescribeData
()
!=
null
)
{
if
(
getMonsterData
().
getDescribeData
()
!=
null
)
{
...
@@ -240,7 +240,7 @@ public class EntityMonster extends GenshinEntity {
...
@@ -240,7 +240,7 @@ public class EntityMonster extends GenshinEntity {
.
setAbilityInfo
(
AbilitySyncStateInfo
.
newBuilder
())
.
setAbilityInfo
(
AbilitySyncStateInfo
.
newBuilder
())
.
build
();
.
build
();
monsterInfo
.
set
WeaponList
(
weaponInfo
);
monsterInfo
.
add
WeaponList
(
weaponInfo
);
}
}
entityInfo
.
setMonster
(
monsterInfo
);
entityInfo
.
setMonster
(
monsterInfo
);
...
...
src/main/java/emu/grasscutter/game/entity/G
enshin
Entity.java
→
src/main/java/emu/grasscutter/game/entity/G
ame
Entity.java
View file @
d32f706c
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.SpawnDataEntry
;
import
emu.grasscutter.game.world.SpawnDataEntry
;
import
emu.grasscutter.game.world.World
;
import
emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo
;
import
emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo
;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
...
@@ -12,18 +12,18 @@ import emu.grasscutter.net.proto.VectorOuterClass.Vector;
...
@@ -12,18 +12,18 @@ import emu.grasscutter.net.proto.VectorOuterClass.Vector;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Position
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
public
abstract
class
G
enshin
Entity
{
public
abstract
class
G
ame
Entity
{
protected
int
id
;
protected
int
id
;
private
final
Genshin
Scene
scene
;
private
final
Scene
scene
;
private
SpawnDataEntry
spawnEntry
;
private
SpawnDataEntry
spawnEntry
;
private
MotionState
moveState
;
private
MotionState
moveState
;
private
int
lastMoveSceneTimeMs
;
private
int
lastMoveSceneTimeMs
;
private
int
lastMoveReliableSeq
;
private
int
lastMoveReliableSeq
;
public
G
enshin
Entity
(
Genshin
Scene
scene
)
{
public
G
ame
Entity
(
Scene
scene
)
{
this
.
scene
=
scene
;
this
.
scene
=
scene
;
this
.
moveState
=
MotionState
.
M
otionNone
;
this
.
moveState
=
MotionState
.
M
OTION_NONE
;
}
}
public
int
getId
()
{
public
int
getId
()
{
...
@@ -34,7 +34,7 @@ public abstract class GenshinEntity {
...
@@ -34,7 +34,7 @@ public abstract class GenshinEntity {
return
this
.
getScene
().
getWorld
();
return
this
.
getScene
().
getWorld
();
}
}
public
Genshin
Scene
getScene
()
{
public
Scene
getScene
()
{
return
this
.
scene
;
return
this
.
scene
;
}
}
...
...
src/main/java/emu/grasscutter/game/friends/FriendsList.java
View file @
d32f706c
...
@@ -3,7 +3,7 @@ package emu.grasscutter.game.friends;
...
@@ -3,7 +3,7 @@ package emu.grasscutter.game.friends;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.
player.
Player
;
import
emu.grasscutter.net.proto.DealAddFriendResultTypeOuterClass.DealAddFriendResultType
;
import
emu.grasscutter.net.proto.DealAddFriendResultTypeOuterClass.DealAddFriendResultType
;
import
emu.grasscutter.server.packet.send.PacketAskAddFriendNotify
;
import
emu.grasscutter.server.packet.send.PacketAskAddFriendNotify
;
import
emu.grasscutter.server.packet.send.PacketAskAddFriendRsp
;
import
emu.grasscutter.server.packet.send.PacketAskAddFriendRsp
;
...
@@ -14,20 +14,20 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -14,20 +14,20 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
class
FriendsList
{
public
class
FriendsList
{
private
final
Genshin
Player
player
;
private
final
Player
player
;
private
final
Int2ObjectMap
<
Friendship
>
friends
;
private
final
Int2ObjectMap
<
Friendship
>
friends
;
private
final
Int2ObjectMap
<
Friendship
>
pendingFriends
;
private
final
Int2ObjectMap
<
Friendship
>
pendingFriends
;
private
boolean
loaded
=
false
;
private
boolean
loaded
=
false
;
public
FriendsList
(
Genshin
Player
player
)
{
public
FriendsList
(
Player
player
)
{
this
.
player
=
player
;
this
.
player
=
player
;
this
.
friends
=
new
Int2ObjectOpenHashMap
<
Friendship
>();
this
.
friends
=
new
Int2ObjectOpenHashMap
<
Friendship
>();
this
.
pendingFriends
=
new
Int2ObjectOpenHashMap
<
Friendship
>();
this
.
pendingFriends
=
new
Int2ObjectOpenHashMap
<
Friendship
>();
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
player
;
return
player
;
}
}
...
@@ -83,7 +83,7 @@ public class FriendsList {
...
@@ -83,7 +83,7 @@ public class FriendsList {
return
;
return
;
}
}
Genshin
Player
target
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
targetUid
,
true
);
Player
target
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
targetUid
,
true
);
if
(
target
==
null
)
{
if
(
target
==
null
)
{
return
;
// Should never happen
return
;
// Should never happen
}
}
...
@@ -104,7 +104,7 @@ public class FriendsList {
...
@@ -104,7 +104,7 @@ public class FriendsList {
}
}
// Handle
// Handle
if
(
result
==
DealAddFriendResultType
.
D
ealAddFriendAccept
)
{
// Request accepted
if
(
result
==
DealAddFriendResultType
.
D
EAL_ADD_FRIEND_ACCEPT
)
{
// Request accepted
myFriendship
.
setIsFriend
(
true
);
myFriendship
.
setIsFriend
(
true
);
theirFriendship
.
setIsFriend
(
true
);
theirFriendship
.
setIsFriend
(
true
);
...
@@ -143,7 +143,7 @@ public class FriendsList {
...
@@ -143,7 +143,7 @@ public class FriendsList {
myFriendship
.
delete
();
myFriendship
.
delete
();
Friendship
theirFriendship
=
null
;
Friendship
theirFriendship
=
null
;
Genshin
Player
friend
=
myFriendship
.
getFriendProfile
().
getPlayer
();
Player
friend
=
myFriendship
.
getFriendProfile
().
getPlayer
();
if
(
friend
!=
null
)
{
if
(
friend
!=
null
)
{
// Friend online
// Friend online
theirFriendship
=
friend
.
getFriendsList
().
getFriendById
(
this
.
getPlayer
().
getUid
());
theirFriendship
=
friend
.
getFriendsList
().
getFriendById
(
this
.
getPlayer
().
getUid
());
...
@@ -165,7 +165,7 @@ public class FriendsList {
...
@@ -165,7 +165,7 @@ public class FriendsList {
}
}
public
synchronized
void
sendFriendRequest
(
int
targetUid
)
{
public
synchronized
void
sendFriendRequest
(
int
targetUid
)
{
Genshin
Player
target
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
targetUid
,
true
);
Player
target
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
targetUid
,
true
);
if
(
target
==
null
||
target
==
this
.
getPlayer
())
{
if
(
target
==
null
||
target
==
this
.
getPlayer
())
{
return
;
return
;
...
@@ -220,7 +220,7 @@ public class FriendsList {
...
@@ -220,7 +220,7 @@ public class FriendsList {
friendship
.
setOwner
(
getPlayer
());
friendship
.
setOwner
(
getPlayer
());
// Check if friend is online
// Check if friend is online
Genshin
Player
friend
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
friendship
.
getFriendProfile
().
getUid
());
Player
friend
=
getPlayer
().
getSession
().
getServer
().
getPlayerByUid
(
friendship
.
getFriendProfile
().
getUid
());
if
(
friend
!=
null
)
{
if
(
friend
!=
null
)
{
// Set friend to online mode
// Set friend to online mode
friendship
.
setFriendProfile
(
friend
);
friendship
.
setFriendProfile
(
friend
);
...
...
src/main/java/emu/grasscutter/game/friends/Friendship.java
View file @
d32f706c
package
emu.grasscutter.game.friends
;
package
emu.grasscutter.game.friends
;
import
emu.grasscutter.net.proto.PlatformTypeOuterClass
;
import
org.bson.types.ObjectId
;
import
org.bson.types.ObjectId
;
import
dev.morphia.annotations.*
;
import
dev.morphia.annotations.*
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.
player.
Player
;
import
emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief
;
import
emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief
;
import
emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState
;
import
emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState
;
import
emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage
;
import
emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage
;
...
@@ -13,7 +14,7 @@ import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
...
@@ -13,7 +14,7 @@ import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
public
class
Friendship
{
public
class
Friendship
{
@Id
private
ObjectId
id
;
@Id
private
ObjectId
id
;
@Transient
private
Genshin
Player
owner
;
@Transient
private
Player
owner
;
@Indexed
private
int
ownerId
;
@Indexed
private
int
ownerId
;
@Indexed
private
int
friendId
;
@Indexed
private
int
friendId
;
...
@@ -25,7 +26,7 @@ public class Friendship {
...
@@ -25,7 +26,7 @@ public class Friendship {
@Deprecated
// Morphia use only
@Deprecated
// Morphia use only
public
Friendship
()
{
}
public
Friendship
()
{
}
public
Friendship
(
Genshin
Player
owner
,
Genshin
Player
friend
,
Genshin
Player
asker
)
{
public
Friendship
(
Player
owner
,
Player
friend
,
Player
asker
)
{
this
.
setOwner
(
owner
);
this
.
setOwner
(
owner
);
this
.
ownerId
=
owner
.
getUid
();
this
.
ownerId
=
owner
.
getUid
();
this
.
friendId
=
friend
.
getUid
();
this
.
friendId
=
friend
.
getUid
();
...
@@ -33,11 +34,11 @@ public class Friendship {
...
@@ -33,11 +34,11 @@ public class Friendship {
this
.
askerId
=
asker
.
getUid
();
this
.
askerId
=
asker
.
getUid
();
}
}
public
Genshin
Player
getOwner
()
{
public
Player
getOwner
()
{
return
owner
;
return
owner
;
}
}
public
void
setOwner
(
Genshin
Player
owner
)
{
public
void
setOwner
(
Player
owner
)
{
this
.
owner
=
owner
;
this
.
owner
=
owner
;
}
}
...
@@ -69,7 +70,7 @@ public class Friendship {
...
@@ -69,7 +70,7 @@ public class Friendship {
return
profile
;
return
profile
;
}
}
public
void
setFriendProfile
(
Genshin
Player
character
)
{
public
void
setFriendProfile
(
Player
character
)
{
if
(
character
==
null
||
this
.
friendId
!=
character
.
getUid
())
return
;
if
(
character
==
null
||
this
.
friendId
!=
character
.
getUid
())
return
;
this
.
profile
=
character
.
getProfile
();
this
.
profile
=
character
.
getProfile
();
}
}
...
@@ -91,16 +92,16 @@ public class Friendship {
...
@@ -91,16 +92,16 @@ public class Friendship {
.
setUid
(
getFriendProfile
().
getUid
())
.
setUid
(
getFriendProfile
().
getUid
())
.
setNickname
(
getFriendProfile
().
getName
())
.
setNickname
(
getFriendProfile
().
getName
())
.
setLevel
(
getFriendProfile
().
getPlayerLevel
())
.
setLevel
(
getFriendProfile
().
getPlayerLevel
())
.
setAvatar
(
HeadImage
.
newBuilder
().
setAvatarId
(
getFriendProfile
().
getAvatarId
()))
.
setAvatar
Id
(
HeadImage
.
newBuilder
().
setAvatarId
(
getFriendProfile
().
getAvatarId
())
.
getAvatarId
()
)
.
setWorldLevel
(
getFriendProfile
().
getWorldLevel
())
.
setWorldLevel
(
getFriendProfile
().
getWorldLevel
())
.
setSignature
(
getFriendProfile
().
getSignature
())
.
setSignature
(
getFriendProfile
().
getSignature
())
.
setOnlineState
(
getFriendProfile
().
isOnline
()
?
FriendOnlineState
.
FRIEND_ONLINE
:
FriendOnlineState
.
FRIEND_DISCONNECT
)
.
setOnlineState
(
getFriendProfile
().
isOnline
()
?
FriendOnlineState
.
FRIEND_ONLINE
:
FriendOnlineState
.
FR
E
IEND_DISCONNECT
)
.
setIsMpModeAvailable
(
true
)
.
setIsMpModeAvailable
(
true
)
.
setLastActiveTime
(
getFriendProfile
().
getLastActiveTime
())
.
setLastActiveTime
(
getFriendProfile
().
getLastActiveTime
())
.
setNameCardId
(
getFriendProfile
().
getNameCard
())
.
setNameCardId
(
getFriendProfile
().
getNameCard
())
.
setParam
(
getFriendProfile
().
getDaysSinceLogin
())
.
setParam
(
getFriendProfile
().
getDaysSinceLogin
())
.
set
Unk1
(
1
)
.
set
IsGameSource
(
true
)
.
set
Unk2
(
3
)
.
set
PlatformType
(
PlatformTypeOuterClass
.
PlatformType
.
PC
)
.
build
();
.
build
();
return
proto
;
return
proto
;
...
...
src/main/java/emu/grasscutter/game/friends/PlayerProfile.java
View file @
d32f706c
package
emu.grasscutter.game.friends
;
package
emu.grasscutter.game.friends
;
import
dev.morphia.annotations.*
;
import
dev.morphia.annotations.*
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.
player.
Player
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
@Entity
@Entity
public
class
PlayerProfile
{
public
class
PlayerProfile
{
@Transient
private
Genshin
Player
player
;
@Transient
private
Player
player
;
@AlsoLoad
(
"id"
)
private
int
uid
;
@AlsoLoad
(
"id"
)
private
int
uid
;
private
int
nameCard
;
private
int
nameCard
;
...
@@ -22,7 +22,7 @@ public class PlayerProfile {
...
@@ -22,7 +22,7 @@ public class PlayerProfile {
@Deprecated
// Morphia only
@Deprecated
// Morphia only
public
PlayerProfile
()
{
}
public
PlayerProfile
()
{
}
public
PlayerProfile
(
Genshin
Player
player
)
{
public
PlayerProfile
(
Player
player
)
{
this
.
uid
=
player
.
getUid
();
this
.
uid
=
player
.
getUid
();
this
.
syncWithCharacter
(
player
);
this
.
syncWithCharacter
(
player
);
}
}
...
@@ -31,11 +31,11 @@ public class PlayerProfile {
...
@@ -31,11 +31,11 @@ public class PlayerProfile {
return
uid
;
return
uid
;
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
player
;
return
player
;
}
}
public
synchronized
void
setPlayer
(
Genshin
Player
player
)
{
public
synchronized
void
setPlayer
(
Player
player
)
{
this
.
player
=
player
;
this
.
player
=
player
;
}
}
...
@@ -83,7 +83,7 @@ public class PlayerProfile {
...
@@ -83,7 +83,7 @@ public class PlayerProfile {
return
this
.
getPlayer
()
!=
null
;
return
this
.
getPlayer
()
!=
null
;
}
}
public
void
syncWithCharacter
(
Genshin
Player
player
)
{
public
void
syncWithCharacter
(
Player
player
)
{
if
(
player
==
null
)
{
if
(
player
==
null
)
{
return
;
return
;
}
}
...
...
src/main/java/emu/grasscutter/game/gacha/GachaManager.java
View file @
d32f706c
...
@@ -12,13 +12,13 @@ import com.google.gson.reflect.TypeToken;
...
@@ -12,13 +12,13 @@ import com.google.gson.reflect.TypeToken;
import
com.sun.nio.file.SensitivityWatchEventModifier
;
import
com.sun.nio.file.SensitivityWatchEventModifier
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.inventory.MaterialType
;
import
emu.grasscutter.game.inventory.MaterialType
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem
;
import
emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem
;
import
emu.grasscutter.net.proto.GachaTransferItemOuterClass.GachaTransferItem
;
import
emu.grasscutter.net.proto.GachaTransferItemOuterClass.GachaTransferItem
;
import
emu.grasscutter.net.proto.GetGachaInfoRspOuterClass.GetGachaInfoRsp
;
import
emu.grasscutter.net.proto.GetGachaInfoRspOuterClass.GetGachaInfoRsp
;
...
@@ -89,7 +89,7 @@ public class GachaManager {
...
@@ -89,7 +89,7 @@ public class GachaManager {
}
}
}
}
public
synchronized
void
doPulls
(
Genshin
Player
player
,
int
gachaType
,
int
times
)
{
public
synchronized
void
doPulls
(
Player
player
,
int
gachaType
,
int
times
)
{
// Sanity check
// Sanity check
if
(
times
!=
10
&&
times
!=
1
)
{
if
(
times
!=
10
&&
times
!=
1
)
{
return
;
return
;
...
@@ -108,7 +108,7 @@ public class GachaManager {
...
@@ -108,7 +108,7 @@ public class GachaManager {
// Spend currency
// Spend currency
if
(
banner
.
getCostItem
()
>
0
)
{
if
(
banner
.
getCostItem
()
>
0
)
{
G
enshin
Item
costItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
banner
.
getCostItem
());
G
ame
Item
costItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
banner
.
getCostItem
());
if
(
costItem
==
null
||
costItem
.
getCount
()
<
times
)
{
if
(
costItem
==
null
||
costItem
.
getCount
()
<
times
)
{
return
;
return
;
}
}
...
@@ -191,7 +191,7 @@ public class GachaManager {
...
@@ -191,7 +191,7 @@ public class GachaManager {
int
stardust
=
0
,
starglitter
=
0
;
int
stardust
=
0
,
starglitter
=
0
;
for
(
int
itemId
:
wonItems
)
{
for
(
int
itemId
:
wonItems
)
{
ItemData
itemData
=
G
enshin
Data
.
getItemDataMap
().
get
(
itemId
);
ItemData
itemData
=
G
ame
Data
.
getItemDataMap
().
get
(
itemId
);
if
(
itemData
==
null
)
{
if
(
itemData
==
null
)
{
continue
;
continue
;
}
}
...
@@ -204,11 +204,11 @@ public class GachaManager {
...
@@ -204,11 +204,11 @@ public class GachaManager {
// Const check
// Const check
if
(
itemData
.
getMaterialType
()
==
MaterialType
.
MATERIAL_AVATAR
)
{
if
(
itemData
.
getMaterialType
()
==
MaterialType
.
MATERIAL_AVATAR
)
{
int
avatarId
=
(
itemData
.
getId
()
%
1000
)
+
10000000
;
int
avatarId
=
(
itemData
.
getId
()
%
1000
)
+
10000000
;
Genshin
Avatar
avatar
=
player
.
getAvatars
().
getAvatarById
(
avatarId
);
Avatar
avatar
=
player
.
getAvatars
().
getAvatarById
(
avatarId
);
if
(
avatar
!=
null
)
{
if
(
avatar
!=
null
)
{
int
constLevel
=
avatar
.
getCoreProudSkillLevel
();
int
constLevel
=
avatar
.
getCoreProudSkillLevel
();
int
constItemId
=
itemData
.
getId
()
+
100
;
int
constItemId
=
itemData
.
getId
()
+
100
;
G
enshin
Item
constItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
constItemId
);
G
ame
Item
constItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
constItemId
);
if
(
constItem
!=
null
)
{
if
(
constItem
!=
null
)
{
constLevel
+=
constItem
.
getCount
();
constLevel
+=
constItem
.
getCount
();
}
}
...
@@ -249,7 +249,7 @@ public class GachaManager {
...
@@ -249,7 +249,7 @@ public class GachaManager {
}
}
// Create item
// Create item
G
enshin
Item
item
=
new
G
enshin
Item
(
itemData
);
G
ame
Item
item
=
new
G
ame
Item
(
itemData
);
gachaItem
.
setGachaItem
(
item
.
toItemParam
());
gachaItem
.
setGachaItem
(
item
.
toItemParam
());
player
.
getInventory
().
addItem
(
item
);
player
.
getInventory
().
addItem
(
item
);
...
...
src/main/java/emu/grasscutter/game/inventory/EquipInventoryTab.java
View file @
d32f706c
...
@@ -4,26 +4,26 @@ import java.util.HashSet;
...
@@ -4,26 +4,26 @@ import java.util.HashSet;
import
java.util.Set
;
import
java.util.Set
;
public
class
EquipInventoryTab
implements
InventoryTab
{
public
class
EquipInventoryTab
implements
InventoryTab
{
private
final
Set
<
G
enshin
Item
>
items
;
private
final
Set
<
G
ame
Item
>
items
;
private
final
int
maxCapacity
;
private
final
int
maxCapacity
;
public
EquipInventoryTab
(
int
maxCapacity
)
{
public
EquipInventoryTab
(
int
maxCapacity
)
{
this
.
items
=
new
HashSet
<
G
enshin
Item
>();
this
.
items
=
new
HashSet
<
G
ame
Item
>();
this
.
maxCapacity
=
maxCapacity
;
this
.
maxCapacity
=
maxCapacity
;
}
}
@Override
@Override
public
G
enshin
Item
getItemById
(
int
id
)
{
public
G
ame
Item
getItemById
(
int
id
)
{
return
null
;
return
null
;
}
}
@Override
@Override
public
void
onAddItem
(
G
enshin
Item
item
)
{
public
void
onAddItem
(
G
ame
Item
item
)
{
this
.
items
.
add
(
item
);
this
.
items
.
add
(
item
);
}
}
@Override
@Override
public
void
onRemoveItem
(
G
enshin
Item
item
)
{
public
void
onRemoveItem
(
G
ame
Item
item
)
{
this
.
items
.
remove
(
item
);
this
.
items
.
remove
(
item
);
}
}
...
...
src/main/java/emu/grasscutter/game/inventory/G
enshin
Item.java
→
src/main/java/emu/grasscutter/game/inventory/G
ame
Item.java
View file @
d32f706c
...
@@ -13,13 +13,13 @@ import dev.morphia.annotations.Indexed;
...
@@ -13,13 +13,13 @@ import dev.morphia.annotations.Indexed;
import
dev.morphia.annotations.PostLoad
;
import
dev.morphia.annotations.PostLoad
;
import
dev.morphia.annotations.Transient
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.G
enshin
Depot
;
import
emu.grasscutter.data.G
ame
Depot
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.def.ReliquaryAffixData
;
import
emu.grasscutter.data.def.ReliquaryAffixData
;
import
emu.grasscutter.data.def.ReliquaryMainPropData
;
import
emu.grasscutter.data.def.ReliquaryMainPropData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.
player.
Player
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.EquipOuterClass.Equip
;
import
emu.grasscutter.net.proto.EquipOuterClass.Equip
;
...
@@ -35,7 +35,7 @@ import emu.grasscutter.net.proto.WeaponOuterClass.Weapon;
...
@@ -35,7 +35,7 @@ import emu.grasscutter.net.proto.WeaponOuterClass.Weapon;
import
emu.grasscutter.utils.WeightedList
;
import
emu.grasscutter.utils.WeightedList
;
@Entity
(
value
=
"items"
,
useDiscriminator
=
false
)
@Entity
(
value
=
"items"
,
useDiscriminator
=
false
)
public
class
G
enshin
Item
{
public
class
G
ame
Item
{
@Id
private
ObjectId
id
;
@Id
private
ObjectId
id
;
@Indexed
private
int
ownerId
;
@Indexed
private
int
ownerId
;
private
int
itemId
;
private
int
itemId
;
...
@@ -62,23 +62,23 @@ public class GenshinItem {
...
@@ -62,23 +62,23 @@ public class GenshinItem {
private
int
equipCharacter
;
private
int
equipCharacter
;
@Transient
private
int
weaponEntityId
;
@Transient
private
int
weaponEntityId
;
public
G
enshin
Item
()
{
public
G
ame
Item
()
{
// Morphia only
// Morphia only
}
}
public
G
enshin
Item
(
int
itemId
)
{
public
G
ame
Item
(
int
itemId
)
{
this
(
G
enshin
Data
.
getItemDataMap
().
get
(
itemId
));
this
(
G
ame
Data
.
getItemDataMap
().
get
(
itemId
));
}
}
public
G
enshin
Item
(
int
itemId
,
int
count
)
{
public
G
ame
Item
(
int
itemId
,
int
count
)
{
this
(
G
enshin
Data
.
getItemDataMap
().
get
(
itemId
),
count
);
this
(
G
ame
Data
.
getItemDataMap
().
get
(
itemId
),
count
);
}
}
public
G
enshin
Item
(
ItemData
data
)
{
public
G
ame
Item
(
ItemData
data
)
{
this
(
data
,
1
);
this
(
data
,
1
);
}
}
public
G
enshin
Item
(
ItemData
data
,
int
count
)
{
public
G
ame
Item
(
ItemData
data
,
int
count
)
{
this
.
itemId
=
data
.
getId
();
this
.
itemId
=
data
.
getId
();
this
.
itemData
=
data
;
this
.
itemData
=
data
;
...
@@ -103,7 +103,7 @@ public class GenshinItem {
...
@@ -103,7 +103,7 @@ public class GenshinItem {
this
.
level
=
1
;
this
.
level
=
1
;
this
.
appendPropIdList
=
new
ArrayList
<>();
this
.
appendPropIdList
=
new
ArrayList
<>();
// Create main property
// Create main property
ReliquaryMainPropData
mainPropData
=
G
enshin
Depot
.
getRandomRelicMainProp
(
getItemData
().
getMainPropDepotId
());
ReliquaryMainPropData
mainPropData
=
G
ame
Depot
.
getRandomRelicMainProp
(
getItemData
().
getMainPropDepotId
());
if
(
mainPropData
!=
null
)
{
if
(
mainPropData
!=
null
)
{
this
.
mainPropId
=
mainPropData
.
getId
();
this
.
mainPropId
=
mainPropData
.
getId
();
}
}
...
@@ -124,9 +124,9 @@ public class GenshinItem {
...
@@ -124,9 +124,9 @@ public class GenshinItem {
return
ownerId
;
return
ownerId
;
}
}
public
void
setOwner
(
Genshin
Player
player
)
{
public
void
setOwner
(
Player
player
)
{
this
.
ownerId
=
player
.
getUid
();
this
.
ownerId
=
player
.
getUid
();
this
.
guid
=
player
.
getNextG
enshin
Guid
();
this
.
guid
=
player
.
getNextG
ame
Guid
();
}
}
public
int
getItemId
()
{
public
int
getItemId
()
{
return
itemId
;
return
itemId
;
...
@@ -261,7 +261,7 @@ public class GenshinItem {
...
@@ -261,7 +261,7 @@ public class GenshinItem {
}
}
private
void
addNewAppendProp
()
{
private
void
addNewAppendProp
()
{
List
<
ReliquaryAffixData
>
affixList
=
G
enshin
Depot
.
getRandomRelicAffixList
(
getItemData
().
getAppendPropDepotId
());
List
<
ReliquaryAffixData
>
affixList
=
G
ame
Depot
.
getRandomRelicAffixList
(
getItemData
().
getAppendPropDepotId
());
if
(
affixList
==
null
)
{
if
(
affixList
==
null
)
{
return
;
return
;
...
@@ -269,13 +269,13 @@ public class GenshinItem {
...
@@ -269,13 +269,13 @@ public class GenshinItem {
// Build blacklist - Dont add same stat as main/sub stat
// Build blacklist - Dont add same stat as main/sub stat
Set
<
FightProperty
>
blacklist
=
new
HashSet
<>();
Set
<
FightProperty
>
blacklist
=
new
HashSet
<>();
ReliquaryMainPropData
mainPropData
=
G
enshin
Data
.
getReliquaryMainPropDataMap
().
get
(
this
.
getMainPropId
());
ReliquaryMainPropData
mainPropData
=
G
ame
Data
.
getReliquaryMainPropDataMap
().
get
(
this
.
getMainPropId
());
if
(
mainPropData
!=
null
)
{
if
(
mainPropData
!=
null
)
{
blacklist
.
add
(
mainPropData
.
getFightProp
());
blacklist
.
add
(
mainPropData
.
getFightProp
());
}
}
int
len
=
Math
.
min
(
4
,
this
.
getAppendPropIdList
().
size
());
int
len
=
Math
.
min
(
4
,
this
.
getAppendPropIdList
().
size
());
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ReliquaryAffixData
affixData
=
G
enshin
Data
.
getReliquaryAffixDataMap
().
get
((
int
)
this
.
getAppendPropIdList
().
get
(
i
));
ReliquaryAffixData
affixData
=
G
ame
Data
.
getReliquaryAffixDataMap
().
get
((
int
)
this
.
getAppendPropIdList
().
get
(
i
));
if
(
affixData
!=
null
)
{
if
(
affixData
!=
null
)
{
blacklist
.
add
(
affixData
.
getFightProp
());
blacklist
.
add
(
affixData
.
getFightProp
());
}
}
...
@@ -299,7 +299,7 @@ public class GenshinItem {
...
@@ -299,7 +299,7 @@ public class GenshinItem {
}
}
private
void
upgradeRandomAppendProp
()
{
private
void
upgradeRandomAppendProp
()
{
List
<
ReliquaryAffixData
>
affixList
=
G
enshin
Depot
.
getRandomRelicAffixList
(
getItemData
().
getAppendPropDepotId
());
List
<
ReliquaryAffixData
>
affixList
=
G
ame
Depot
.
getRandomRelicAffixList
(
getItemData
().
getAppendPropDepotId
());
if
(
affixList
==
null
)
{
if
(
affixList
==
null
)
{
return
;
return
;
...
@@ -309,7 +309,7 @@ public class GenshinItem {
...
@@ -309,7 +309,7 @@ public class GenshinItem {
Set
<
FightProperty
>
whitelist
=
new
HashSet
<>();
Set
<
FightProperty
>
whitelist
=
new
HashSet
<>();
int
len
=
Math
.
min
(
4
,
this
.
getAppendPropIdList
().
size
());
int
len
=
Math
.
min
(
4
,
this
.
getAppendPropIdList
().
size
());
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ReliquaryAffixData
affixData
=
G
enshin
Data
.
getReliquaryAffixDataMap
().
get
((
int
)
this
.
getAppendPropIdList
().
get
(
i
));
ReliquaryAffixData
affixData
=
G
ame
Data
.
getReliquaryAffixDataMap
().
get
((
int
)
this
.
getAppendPropIdList
().
get
(
i
));
if
(
affixData
!=
null
)
{
if
(
affixData
!=
null
)
{
whitelist
.
add
(
affixData
.
getFightProp
());
whitelist
.
add
(
affixData
.
getFightProp
());
}
}
...
@@ -331,7 +331,7 @@ public class GenshinItem {
...
@@ -331,7 +331,7 @@ public class GenshinItem {
@PostLoad
@PostLoad
public
void
onLoad
()
{
public
void
onLoad
()
{
if
(
this
.
itemData
==
null
)
{
if
(
this
.
itemData
==
null
)
{
this
.
itemData
=
G
enshin
Data
.
getItemDataMap
().
get
(
getItemId
());
this
.
itemData
=
G
ame
Data
.
getItemDataMap
().
get
(
getItemId
());
}
}
}
}
...
...
Prev
1
2
3
4
5
6
7
8
9
…
16
Next
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