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
1c36f078
Commit
1c36f078
authored
Apr 26, 2022
by
Melledy
Browse files
Renamed all references to a certain game
parent
6b8902be
Changes
270
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java
View file @
1c36f078
...
@@ -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.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
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/entity/EntityAvatar.java
View file @
1c36f078
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.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.
Genshin
Scene
;
import
emu.grasscutter.game.Scene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.EquipType
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
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
;
...
@@ -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
;
}
}
...
@@ -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
{
...
@@ -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 @
1c36f078
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.
Genshin
Scene
;
import
emu.grasscutter.game.Scene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
...
@@ -24,7 +24,7 @@ import emu.grasscutter.utils.ProtoHelper;
...
@@ -24,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
;
...
@@ -36,7 +36,7 @@ public class EntityClientGadget extends EntityGadget {
...
@@ -36,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
();
...
@@ -55,7 +55,7 @@ public class EntityClientGadget extends EntityGadget {
...
@@ -55,7 +55,7 @@ public class EntityClientGadget extends EntityGadget {
return
configId
;
return
configId
;
}
}
public
Genshin
Player
getOwner
()
{
public
Player
getOwner
()
{
return
owner
;
return
owner
;
}
}
...
...
src/main/java/emu/grasscutter/game/entity/EntityGadget.java
View file @
1c36f078
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.
Genshin
Scene
;
import
emu.grasscutter.game.Scene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.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 @
1c36f078
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.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.
Genshin
Scene
;
import
emu.grasscutter.game.Scene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
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.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
...
@@ -28,16 +28,16 @@ public class EntityItem extends EntityGadget {
...
@@ -28,16 +28,16 @@ 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
(
Genshin
Scene
scene
,
Genshin
Player
player
,
ItemData
itemData
,
Position
pos
,
int
count
)
{
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
.
getNextG
enshin
Guid
();
this
.
guid
=
player
.
getNextG
ame
Guid
();
this
.
item
=
new
G
enshin
Item
(
itemData
,
count
);
this
.
item
=
new
G
ame
Item
(
itemData
,
count
);
}
}
@Override
@Override
...
@@ -45,7 +45,7 @@ public class EntityItem extends EntityGadget {
...
@@ -45,7 +45,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
;
}
}
...
...
src/main/java/emu/grasscutter/game/entity/EntityMonster.java
View file @
1c36f078
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.
Genshin
Scene
;
import
emu.grasscutter.game.Scene
;
import
emu.grasscutter.game.World
;
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
;
...
@@ -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
());
...
...
src/main/java/emu/grasscutter/game/entity/G
enshin
Entity.java
→
src/main/java/emu/grasscutter/game/entity/G
ame
Entity.java
View file @
1c36f078
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.
Genshin
Scene
;
import
emu.grasscutter.game.Scene
;
import
emu.grasscutter.game.World
;
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
;
...
@@ -12,16 +12,16 @@ import emu.grasscutter.net.proto.VectorOuterClass.Vector;
...
@@ -12,16 +12,16 @@ 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
.
MOTION_NONE
;
this
.
moveState
=
MotionState
.
MOTION_NONE
;
}
}
...
@@ -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 @
1c36f078
...
@@ -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
;
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
}
}
...
@@ -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 @
1c36f078
...
@@ -5,7 +5,7 @@ import org.bson.types.ObjectId;
...
@@ -5,7 +5,7 @@ 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
;
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
;
...
@@ -14,7 +14,7 @@ import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
...
@@ -14,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
;
...
@@ -26,7 +26,7 @@ public class Friendship {
...
@@ -26,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
();
...
@@ -34,11 +34,11 @@ public class Friendship {
...
@@ -34,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
;
}
}
...
@@ -70,7 +70,7 @@ public class Friendship {
...
@@ -70,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
();
}
}
...
...
src/main/java/emu/grasscutter/game/friends/PlayerProfile.java
View file @
1c36f078
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
;
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 @
1c36f078
...
@@ -12,11 +12,11 @@ import com.google.gson.reflect.TypeToken;
...
@@ -12,11 +12,11 @@ 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.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
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.net.proto.GachaItemOuterClass.GachaItem
;
import
emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem
;
...
@@ -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 @
1c36f078
...
@@ -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 @
1c36f078
...
@@ -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
;
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
());
}
}
}
}
...
...
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
1c36f078
...
@@ -5,17 +5,17 @@ import java.util.Iterator;
...
@@ -5,17 +5,17 @@ import java.util.Iterator;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
emu.grasscutter.G
enshin
Constants
;
import
emu.grasscutter.G
ame
Constants
;
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.AvatarCostumeData
;
import
emu.grasscutter.data.def.AvatarCostumeData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarFlycloakData
;
import
emu.grasscutter.data.def.AvatarFlycloakData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.avatar.AvatarStorage
;
import
emu.grasscutter.game.avatar.AvatarStorage
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
...
@@ -28,13 +28,13 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
...
@@ -28,13 +28,13 @@ 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
Inventory
implements
Iterable
<
G
enshin
Item
>
{
public
class
Inventory
implements
Iterable
<
G
ame
Item
>
{
private
final
Genshin
Player
player
;
private
final
Player
player
;
private
final
Long2ObjectMap
<
G
enshin
Item
>
store
;
private
final
Long2ObjectMap
<
G
ame
Item
>
store
;
private
final
Int2ObjectMap
<
InventoryTab
>
inventoryTypes
;
private
final
Int2ObjectMap
<
InventoryTab
>
inventoryTypes
;
public
Inventory
(
Genshin
Player
player
)
{
public
Inventory
(
Player
player
)
{
this
.
player
=
player
;
this
.
player
=
player
;
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
...
@@ -45,7 +45,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -45,7 +45,7 @@ public class Inventory implements Iterable<GenshinItem> {
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
InventoryLimitFurniture
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
InventoryLimitFurniture
));
}
}
public
Genshin
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
player
;
return
player
;
}
}
...
@@ -53,7 +53,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -53,7 +53,7 @@ public class Inventory implements Iterable<GenshinItem> {
return
this
.
getPlayer
().
getAvatars
();
return
this
.
getPlayer
().
getAvatars
();
}
}
public
Long2ObjectMap
<
G
enshin
Item
>
getItems
()
{
public
Long2ObjectMap
<
G
ame
Item
>
getItems
()
{
return
store
;
return
store
;
}
}
...
@@ -69,7 +69,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -69,7 +69,7 @@ public class Inventory implements Iterable<GenshinItem> {
this
.
getInventoryTypes
().
put
(
type
.
getValue
(),
tab
);
this
.
getInventoryTypes
().
put
(
type
.
getValue
(),
tab
);
}
}
public
G
enshin
Item
getItemByGuid
(
long
id
)
{
public
G
ame
Item
getItemByGuid
(
long
id
)
{
return
this
.
getItems
().
get
(
id
);
return
this
.
getItems
().
get
(
id
);
}
}
...
@@ -78,19 +78,19 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -78,19 +78,19 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
public
boolean
addItem
(
int
itemId
,
int
count
)
{
public
boolean
addItem
(
int
itemId
,
int
count
)
{
ItemData
itemData
=
G
enshin
Data
.
getItemDataMap
().
get
(
itemId
);
ItemData
itemData
=
G
ame
Data
.
getItemDataMap
().
get
(
itemId
);
if
(
itemData
==
null
)
{
if
(
itemData
==
null
)
{
return
false
;
return
false
;
}
}
G
enshin
Item
item
=
new
G
enshin
Item
(
itemData
,
count
);
G
ame
Item
item
=
new
G
ame
Item
(
itemData
,
count
);
return
addItem
(
item
);
return
addItem
(
item
);
}
}
public
boolean
addItem
(
G
enshin
Item
item
)
{
public
boolean
addItem
(
G
ame
Item
item
)
{
G
enshin
Item
result
=
putItem
(
item
);
G
ame
Item
result
=
putItem
(
item
);
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
getPlayer
().
sendPacket
(
new
PacketStoreItemChangeNotify
(
result
));
getPlayer
().
sendPacket
(
new
PacketStoreItemChangeNotify
(
result
));
...
@@ -100,7 +100,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -100,7 +100,7 @@ public class Inventory implements Iterable<GenshinItem> {
return
false
;
return
false
;
}
}
public
boolean
addItem
(
G
enshin
Item
item
,
ActionReason
reason
)
{
public
boolean
addItem
(
G
ame
Item
item
,
ActionReason
reason
)
{
boolean
result
=
addItem
(
item
);
boolean
result
=
addItem
(
item
);
if
(
result
&&
reason
!=
null
)
{
if
(
result
&&
reason
!=
null
)
{
...
@@ -110,15 +110,15 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -110,15 +110,15 @@ public class Inventory implements Iterable<GenshinItem> {
return
result
;
return
result
;
}
}
public
void
addItems
(
Collection
<
G
enshin
Item
>
items
)
{
public
void
addItems
(
Collection
<
G
ame
Item
>
items
)
{
this
.
addItems
(
items
,
null
);
this
.
addItems
(
items
,
null
);
}
}
public
void
addItems
(
Collection
<
G
enshin
Item
>
items
,
ActionReason
reason
)
{
public
void
addItems
(
Collection
<
G
ame
Item
>
items
,
ActionReason
reason
)
{
List
<
G
enshin
Item
>
changedItems
=
new
LinkedList
<>();
List
<
G
ame
Item
>
changedItems
=
new
LinkedList
<>();
for
(
G
enshin
Item
item
:
items
)
{
for
(
G
ame
Item
item
:
items
)
{
G
enshin
Item
result
=
putItem
(
item
);
G
ame
Item
result
=
putItem
(
item
);
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
changedItems
.
add
(
result
);
changedItems
.
add
(
result
);
}
}
...
@@ -136,10 +136,10 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -136,10 +136,10 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
public
void
addItemParams
(
Collection
<
ItemParam
>
items
)
{
public
void
addItemParams
(
Collection
<
ItemParam
>
items
)
{
addItems
(
items
.
stream
().
map
(
param
->
new
G
enshin
Item
(
param
.
getItemId
(),
param
.
getCount
())).
toList
(),
null
);
addItems
(
items
.
stream
().
map
(
param
->
new
G
ame
Item
(
param
.
getItemId
(),
param
.
getCount
())).
toList
(),
null
);
}
}
private
synchronized
G
enshin
Item
putItem
(
G
enshin
Item
item
)
{
private
synchronized
G
ame
Item
putItem
(
G
ame
Item
item
)
{
// Dont add items that dont have a valid item definition.
// Dont add items that dont have a valid item definition.
if
(
item
.
getItemData
()
==
null
)
{
if
(
item
.
getItemData
()
==
null
)
{
return
null
;
return
null
;
...
@@ -163,23 +163,23 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -163,23 +163,23 @@ public class Inventory implements Iterable<GenshinItem> {
// Get avatar id
// Get avatar id
int
avatarId
=
(
item
.
getItemId
()
%
1000
)
+
10000000
;
int
avatarId
=
(
item
.
getItemId
()
%
1000
)
+
10000000
;
// Dont let people give themselves extra main characters
// Dont let people give themselves extra main characters
if
(
avatarId
==
G
enshin
Constants
.
MAIN_CHARACTER_MALE
||
avatarId
==
G
enshin
Constants
.
MAIN_CHARACTER_FEMALE
)
{
if
(
avatarId
==
G
ame
Constants
.
MAIN_CHARACTER_MALE
||
avatarId
==
G
ame
Constants
.
MAIN_CHARACTER_FEMALE
)
{
return
null
;
return
null
;
}
}
// Add avatar
// Add avatar
AvatarData
avatarData
=
G
enshin
Data
.
getAvatarDataMap
().
get
(
avatarId
);
AvatarData
avatarData
=
G
ame
Data
.
getAvatarDataMap
().
get
(
avatarId
);
if
(
avatarData
!=
null
&&
!
player
.
getAvatars
().
hasAvatar
(
avatarId
))
{
if
(
avatarData
!=
null
&&
!
player
.
getAvatars
().
hasAvatar
(
avatarId
))
{
this
.
getPlayer
().
addAvatar
(
new
Genshin
Avatar
(
avatarData
));
this
.
getPlayer
().
addAvatar
(
new
Avatar
(
avatarData
));
}
}
return
null
;
return
null
;
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_FLYCLOAK
)
{
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_FLYCLOAK
)
{
AvatarFlycloakData
flycloakData
=
G
enshin
Data
.
getAvatarFlycloakDataMap
().
get
(
item
.
getItemId
());
AvatarFlycloakData
flycloakData
=
G
ame
Data
.
getAvatarFlycloakDataMap
().
get
(
item
.
getItemId
());
if
(
flycloakData
!=
null
&&
!
player
.
getFlyCloakList
().
contains
(
item
.
getItemId
()))
{
if
(
flycloakData
!=
null
&&
!
player
.
getFlyCloakList
().
contains
(
item
.
getItemId
()))
{
getPlayer
().
addFlycloak
(
item
.
getItemId
());
getPlayer
().
addFlycloak
(
item
.
getItemId
());
}
}
return
null
;
return
null
;
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_COSTUME
)
{
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_COSTUME
)
{
AvatarCostumeData
costumeData
=
G
enshin
Data
.
getAvatarCostumeDataItemIdMap
().
get
(
item
.
getItemId
());
AvatarCostumeData
costumeData
=
G
ame
Data
.
getAvatarCostumeDataItemIdMap
().
get
(
item
.
getItemId
());
if
(
costumeData
!=
null
&&
!
player
.
getCostumeList
().
contains
(
costumeData
.
getId
()))
{
if
(
costumeData
!=
null
&&
!
player
.
getCostumeList
().
contains
(
costumeData
.
getId
()))
{
getPlayer
().
addCostume
(
costumeData
.
getId
());
getPlayer
().
addCostume
(
costumeData
.
getId
());
}
}
...
@@ -190,7 +190,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -190,7 +190,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
return
null
;
return
null
;
}
else
if
(
tab
!=
null
)
{
}
else
if
(
tab
!=
null
)
{
G
enshin
Item
existingItem
=
tab
.
getItemById
(
item
.
getItemId
());
G
ame
Item
existingItem
=
tab
.
getItemById
(
item
.
getItemId
());
if
(
existingItem
==
null
)
{
if
(
existingItem
==
null
)
{
// Item type didnt exist before, we will add it to main inventory map if there is enough space
// Item type didnt exist before, we will add it to main inventory map if there is enough space
if
(
tab
.
getSize
()
>=
tab
.
getMaxCapacity
())
{
if
(
tab
.
getSize
()
>=
tab
.
getMaxCapacity
())
{
...
@@ -213,7 +213,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -213,7 +213,7 @@ public class Inventory implements Iterable<GenshinItem> {
return
item
;
return
item
;
}
}
private
synchronized
void
putItem
(
G
enshin
Item
item
,
InventoryTab
tab
)
{
private
synchronized
void
putItem
(
G
ame
Item
item
,
InventoryTab
tab
)
{
// Set owner and guid FIRST!
// Set owner and guid FIRST!
item
.
setOwner
(
getPlayer
());
item
.
setOwner
(
getPlayer
());
// Put in item store
// Put in item store
...
@@ -242,9 +242,9 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -242,9 +242,9 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
}
}
public
void
removeItems
(
List
<
G
enshin
Item
>
items
)
{
public
void
removeItems
(
List
<
G
ame
Item
>
items
)
{
// TODO Bulk delete
// TODO Bulk delete
for
(
G
enshin
Item
item
:
items
)
{
for
(
G
ame
Item
item
:
items
)
{
this
.
removeItem
(
item
,
item
.
getCount
());
this
.
removeItem
(
item
,
item
.
getCount
());
}
}
}
}
...
@@ -254,7 +254,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -254,7 +254,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
public
synchronized
boolean
removeItem
(
long
guid
,
int
count
)
{
public
synchronized
boolean
removeItem
(
long
guid
,
int
count
)
{
G
enshin
Item
item
=
this
.
getItemByGuid
(
guid
);
G
ame
Item
item
=
this
.
getItemByGuid
(
guid
);
if
(
item
==
null
)
{
if
(
item
==
null
)
{
return
false
;
return
false
;
...
@@ -263,11 +263,11 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -263,11 +263,11 @@ public class Inventory implements Iterable<GenshinItem> {
return
removeItem
(
item
,
count
);
return
removeItem
(
item
,
count
);
}
}
public
synchronized
boolean
removeItem
(
G
enshin
Item
item
)
{
public
synchronized
boolean
removeItem
(
G
ame
Item
item
)
{
return
removeItem
(
item
,
item
.
getCount
());
return
removeItem
(
item
,
item
.
getCount
());
}
}
public
synchronized
boolean
removeItem
(
G
enshin
Item
item
,
int
count
)
{
public
synchronized
boolean
removeItem
(
G
ame
Item
item
,
int
count
)
{
// Sanity check
// Sanity check
if
(
count
<=
0
||
item
==
null
)
{
if
(
count
<=
0
||
item
==
null
)
{
return
false
;
return
false
;
...
@@ -296,7 +296,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -296,7 +296,7 @@ public class Inventory implements Iterable<GenshinItem> {
return
true
;
return
true
;
}
}
private
void
deleteItem
(
G
enshin
Item
item
,
InventoryTab
tab
)
{
private
void
deleteItem
(
G
ame
Item
item
,
InventoryTab
tab
)
{
getItems
().
remove
(
item
.
getGuid
());
getItems
().
remove
(
item
.
getGuid
());
if
(
tab
!=
null
)
{
if
(
tab
!=
null
)
{
tab
.
onRemoveItem
(
item
);
tab
.
onRemoveItem
(
item
);
...
@@ -304,8 +304,8 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -304,8 +304,8 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
public
boolean
equipItem
(
long
avatarGuid
,
long
equipGuid
)
{
public
boolean
equipItem
(
long
avatarGuid
,
long
equipGuid
)
{
Genshin
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
avatarGuid
);
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
avatarGuid
);
G
enshin
Item
item
=
this
.
getItemByGuid
(
equipGuid
);
G
ame
Item
item
=
this
.
getItemByGuid
(
equipGuid
);
if
(
avatar
!=
null
&&
item
!=
null
)
{
if
(
avatar
!=
null
&&
item
!=
null
)
{
return
avatar
.
equipItem
(
item
,
true
);
return
avatar
.
equipItem
(
item
,
true
);
...
@@ -315,7 +315,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -315,7 +315,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
public
boolean
unequipItem
(
long
avatarGuid
,
int
slot
)
{
public
boolean
unequipItem
(
long
avatarGuid
,
int
slot
)
{
Genshin
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
avatarGuid
);
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarByGuid
(
avatarGuid
);
EquipType
equipType
=
EquipType
.
getTypeByValue
(
slot
);
EquipType
equipType
=
EquipType
.
getTypeByValue
(
slot
);
if
(
avatar
!=
null
&&
equipType
!=
EquipType
.
EQUIP_WEAPON
)
{
if
(
avatar
!=
null
&&
equipType
!=
EquipType
.
EQUIP_WEAPON
)
{
...
@@ -330,15 +330,15 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -330,15 +330,15 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
public
void
loadFromDatabase
()
{
public
void
loadFromDatabase
()
{
List
<
G
enshin
Item
>
items
=
DatabaseHelper
.
getInventoryItems
(
getPlayer
());
List
<
G
ame
Item
>
items
=
DatabaseHelper
.
getInventoryItems
(
getPlayer
());
for
(
G
enshin
Item
item
:
items
)
{
for
(
G
ame
Item
item
:
items
)
{
// Should never happen
// Should never happen
if
(
item
.
getObjectId
()
==
null
)
{
if
(
item
.
getObjectId
()
==
null
)
{
continue
;
continue
;
}
}
ItemData
itemData
=
G
enshin
Data
.
getItemDataMap
().
get
(
item
.
getItemId
());
ItemData
itemData
=
G
ame
Data
.
getItemDataMap
().
get
(
item
.
getItemId
());
if
(
itemData
==
null
)
{
if
(
itemData
==
null
)
{
continue
;
continue
;
}
}
...
@@ -354,7 +354,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -354,7 +354,7 @@ public class Inventory implements Iterable<GenshinItem> {
// Equip to a character if possible
// Equip to a character if possible
if
(
item
.
isEquipped
())
{
if
(
item
.
isEquipped
())
{
Genshin
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarById
(
item
.
getEquipCharacter
());
Avatar
avatar
=
getPlayer
().
getAvatars
().
getAvatarById
(
item
.
getEquipCharacter
());
boolean
hasEquipped
=
false
;
boolean
hasEquipped
=
false
;
if
(
avatar
!=
null
)
{
if
(
avatar
!=
null
)
{
...
@@ -370,7 +370,7 @@ public class Inventory implements Iterable<GenshinItem> {
...
@@ -370,7 +370,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
@Override
@Override
public
Iterator
<
G
enshin
Item
>
iterator
()
{
public
Iterator
<
G
ame
Item
>
iterator
()
{
return
this
.
getItems
().
values
().
iterator
();
return
this
.
getItems
().
values
().
iterator
();
}
}
}
}
src/main/java/emu/grasscutter/game/inventory/InventoryTab.java
View file @
1c36f078
package
emu.grasscutter.game.inventory
;
package
emu.grasscutter.game.inventory
;
public
interface
InventoryTab
{
public
interface
InventoryTab
{
public
G
enshin
Item
getItemById
(
int
id
);
public
G
ame
Item
getItemById
(
int
id
);
public
void
onAddItem
(
G
enshin
Item
item
);
public
void
onAddItem
(
G
ame
Item
item
);
public
void
onRemoveItem
(
G
enshin
Item
item
);
public
void
onRemoveItem
(
G
ame
Item
item
);
public
int
getSize
();
public
int
getSize
();
...
...
src/main/java/emu/grasscutter/game/inventory/MaterialInventoryTab.java
View file @
1c36f078
...
@@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
class
MaterialInventoryTab
implements
InventoryTab
{
public
class
MaterialInventoryTab
implements
InventoryTab
{
private
final
Int2ObjectMap
<
G
enshin
Item
>
items
;
private
final
Int2ObjectMap
<
G
ame
Item
>
items
;
private
final
int
maxCapacity
;
private
final
int
maxCapacity
;
public
MaterialInventoryTab
(
int
maxCapacity
)
{
public
MaterialInventoryTab
(
int
maxCapacity
)
{
...
@@ -13,17 +13,17 @@ public class MaterialInventoryTab implements InventoryTab {
...
@@ -13,17 +13,17 @@ public class MaterialInventoryTab implements InventoryTab {
}
}
@Override
@Override
public
G
enshin
Item
getItemById
(
int
id
)
{
public
G
ame
Item
getItemById
(
int
id
)
{
return
this
.
items
.
get
(
id
);
return
this
.
items
.
get
(
id
);
}
}
@Override
@Override
public
void
onAddItem
(
G
enshin
Item
item
)
{
public
void
onAddItem
(
G
ame
Item
item
)
{
this
.
items
.
put
(
item
.
getItemId
(),
item
);
this
.
items
.
put
(
item
.
getItemId
(),
item
);
}
}
@Override
@Override
public
void
onRemoveItem
(
G
enshin
Item
item
)
{
public
void
onRemoveItem
(
G
ame
Item
item
)
{
this
.
items
.
remove
(
item
.
getItemId
());
this
.
items
.
remove
(
item
.
getItemId
());
}
}
...
...
src/main/java/emu/grasscutter/game/managers/ChatManager.java
View file @
1c36f078
package
emu.grasscutter.game.managers
;
package
emu.grasscutter.game.managers
;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.packet.send.PacketPlayerChatNotify
;
import
emu.grasscutter.server.packet.send.PacketPlayerChatNotify
;
import
emu.grasscutter.server.packet.send.PacketPrivateChatNotify
;
import
emu.grasscutter.server.packet.send.PacketPrivateChatNotify
;
...
@@ -23,7 +23,7 @@ public class ChatManager {
...
@@ -23,7 +23,7 @@ public class ChatManager {
return
server
;
return
server
;
}
}
public
void
sendPrivateMessage
(
Genshin
Player
player
,
int
targetUid
,
String
message
)
{
public
void
sendPrivateMessage
(
Player
player
,
int
targetUid
,
String
message
)
{
// Sanity checks
// Sanity checks
if
(
message
==
null
||
message
.
length
()
==
0
)
{
if
(
message
==
null
||
message
.
length
()
==
0
)
{
return
;
return
;
...
@@ -36,35 +36,35 @@ public class ChatManager {
...
@@ -36,35 +36,35 @@ public class ChatManager {
}
}
// Get target
// Get target
Genshin
Player
target
=
getServer
().
getPlayerByUid
(
targetUid
);
Player
target
=
getServer
().
getPlayerByUid
(
targetUid
);
if
(
target
==
null
)
{
if
(
target
==
null
)
{
return
;
return
;
}
}
// Create chat packet
// Create chat packet
Genshin
Packet
packet
=
new
PacketPrivateChatNotify
(
player
.
getUid
(),
target
.
getUid
(),
message
);
Base
Packet
packet
=
new
PacketPrivateChatNotify
(
player
.
getUid
(),
target
.
getUid
(),
message
);
player
.
sendPacket
(
packet
);
player
.
sendPacket
(
packet
);
target
.
sendPacket
(
packet
);
target
.
sendPacket
(
packet
);
}
}
public
void
sendPrivateMessage
(
Genshin
Player
player
,
int
targetUid
,
int
emote
)
{
public
void
sendPrivateMessage
(
Player
player
,
int
targetUid
,
int
emote
)
{
// Get target
// Get target
Genshin
Player
target
=
getServer
().
getPlayerByUid
(
targetUid
);
Player
target
=
getServer
().
getPlayerByUid
(
targetUid
);
if
(
target
==
null
)
{
if
(
target
==
null
)
{
return
;
return
;
}
}
// Create chat packet
// Create chat packet
Genshin
Packet
packet
=
new
PacketPrivateChatNotify
(
player
.
getUid
(),
target
.
getUid
(),
emote
);
Base
Packet
packet
=
new
PacketPrivateChatNotify
(
player
.
getUid
(),
target
.
getUid
(),
emote
);
player
.
sendPacket
(
packet
);
player
.
sendPacket
(
packet
);
target
.
sendPacket
(
packet
);
target
.
sendPacket
(
packet
);
}
}
public
void
sendTeamMessage
(
Genshin
Player
player
,
int
channel
,
String
message
)
{
public
void
sendTeamMessage
(
Player
player
,
int
channel
,
String
message
)
{
// Sanity checks
// Sanity checks
if
(
message
==
null
||
message
.
length
()
==
0
)
{
if
(
message
==
null
||
message
.
length
()
==
0
)
{
return
;
return
;
...
@@ -80,7 +80,7 @@ public class ChatManager {
...
@@ -80,7 +80,7 @@ public class ChatManager {
player
.
getWorld
().
broadcastPacket
(
new
PacketPlayerChatNotify
(
player
,
channel
,
message
));
player
.
getWorld
().
broadcastPacket
(
new
PacketPlayerChatNotify
(
player
,
channel
,
message
));
}
}
public
void
sendTeamMessage
(
Genshin
Player
player
,
int
channel
,
int
icon
)
{
public
void
sendTeamMessage
(
Player
player
,
int
channel
,
int
icon
)
{
// Create and send chat packet
// Create and send chat packet
player
.
getWorld
().
broadcastPacket
(
new
PacketPlayerChatNotify
(
player
,
channel
,
icon
));
player
.
getWorld
().
broadcastPacket
(
new
PacketPlayerChatNotify
(
player
,
channel
,
icon
));
}
}
...
...
src/main/java/emu/grasscutter/game/managers/InventoryManager.java
View file @
1c36f078
...
@@ -5,7 +5,7 @@ import java.util.List;
...
@@ -5,7 +5,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.def.AvatarPromoteData
;
import
emu.grasscutter.data.def.AvatarPromoteData
;
...
@@ -15,9 +15,9 @@ import emu.grasscutter.data.def.WeaponPromoteData;
...
@@ -15,9 +15,9 @@ import emu.grasscutter.data.def.WeaponPromoteData;
import
emu.grasscutter.data.def.AvatarSkillDepotData.InherentProudSkillOpens
;
import
emu.grasscutter.data.def.AvatarSkillDepotData.InherentProudSkillOpens
;
import
emu.grasscutter.data.def.AvatarTalentData
;
import
emu.grasscutter.data.def.AvatarTalentData
;
import
emu.grasscutter.data.def.ProudSkillData
;
import
emu.grasscutter.data.def.ProudSkillData
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.avatar.
Genshin
Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
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.net.proto.ItemParamOuterClass.ItemParam
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
...
@@ -72,8 +72,8 @@ public class InventoryManager {
...
@@ -72,8 +72,8 @@ public class InventoryManager {
return
server
;
return
server
;
}
}
public
void
lockEquip
(
Genshin
Player
player
,
long
targetEquipGuid
,
boolean
isLocked
)
{
public
void
lockEquip
(
Player
player
,
long
targetEquipGuid
,
boolean
isLocked
)
{
G
enshin
Item
equip
=
player
.
getInventory
().
getItemByGuid
(
targetEquipGuid
);
G
ame
Item
equip
=
player
.
getInventory
().
getItemByGuid
(
targetEquipGuid
);
if
(
equip
==
null
||
!
equip
.
getItemData
().
isEquip
())
{
if
(
equip
==
null
||
!
equip
.
getItemData
().
isEquip
())
{
return
;
return
;
...
@@ -86,8 +86,8 @@ public class InventoryManager {
...
@@ -86,8 +86,8 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketSetEquipLockStateRsp
(
equip
));
player
.
sendPacket
(
new
PacketSetEquipLockStateRsp
(
equip
));
}
}
public
void
upgradeRelic
(
Genshin
Player
player
,
long
targetGuid
,
List
<
Long
>
foodRelicList
,
List
<
ItemParam
>
list
)
{
public
void
upgradeRelic
(
Player
player
,
long
targetGuid
,
List
<
Long
>
foodRelicList
,
List
<
ItemParam
>
list
)
{
G
enshin
Item
relic
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
G
ame
Item
relic
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
if
(
relic
==
null
||
relic
.
getItemType
()
!=
ItemType
.
ITEM_RELIQUARY
)
{
if
(
relic
==
null
||
relic
.
getItemType
()
!=
ItemType
.
ITEM_RELIQUARY
)
{
return
;
return
;
...
@@ -98,7 +98,7 @@ public class InventoryManager {
...
@@ -98,7 +98,7 @@ public class InventoryManager {
for
(
long
guid
:
foodRelicList
)
{
for
(
long
guid
:
foodRelicList
)
{
// Add to delete queue
// Add to delete queue
G
enshin
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
G
ame
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
continue
;
continue
;
}
}
...
@@ -111,7 +111,7 @@ public class InventoryManager {
...
@@ -111,7 +111,7 @@ public class InventoryManager {
}
}
}
}
for
(
ItemParam
itemParam
:
list
)
{
for
(
ItemParam
itemParam
:
list
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
itemParam
.
getItemId
());
G
ame
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
itemParam
.
getItemId
());
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_RELIQUARY_MATERIAL
)
{
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_RELIQUARY_MATERIAL
)
{
continue
;
continue
;
}
}
...
@@ -139,14 +139,14 @@ public class InventoryManager {
...
@@ -139,14 +139,14 @@ public class InventoryManager {
// Consume food items
// Consume food items
for
(
long
guid
:
foodRelicList
)
{
for
(
long
guid
:
foodRelicList
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
G
ame
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
continue
;
continue
;
}
}
player
.
getInventory
().
removeItem
(
food
);
player
.
getInventory
().
removeItem
(
food
);
}
}
for
(
ItemParam
itemParam
:
list
)
{
for
(
ItemParam
itemParam
:
list
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
itemParam
.
getItemId
());
G
ame
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
itemParam
.
getItemId
());
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_RELIQUARY_MATERIAL
)
{
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_RELIQUARY_MATERIAL
)
{
continue
;
continue
;
}
}
...
@@ -169,7 +169,7 @@ public class InventoryManager {
...
@@ -169,7 +169,7 @@ public class InventoryManager {
int
oldLevel
=
level
;
int
oldLevel
=
level
;
int
exp
=
relic
.
getExp
();
int
exp
=
relic
.
getExp
();
int
totalExp
=
relic
.
getTotalExp
();
int
totalExp
=
relic
.
getTotalExp
();
int
reqExp
=
G
enshin
Data
.
getRelicExpRequired
(
relic
.
getItemData
().
getRankLevel
(),
level
);
int
reqExp
=
G
ame
Data
.
getRelicExpRequired
(
relic
.
getItemData
().
getRankLevel
(),
level
);
int
upgrades
=
0
;
int
upgrades
=
0
;
List
<
Integer
>
oldAppendPropIdList
=
relic
.
getAppendPropIdList
();
List
<
Integer
>
oldAppendPropIdList
=
relic
.
getAppendPropIdList
();
...
@@ -189,7 +189,7 @@ public class InventoryManager {
...
@@ -189,7 +189,7 @@ public class InventoryManager {
upgrades
+=
1
;
upgrades
+=
1
;
}
}
// Set req exp
// Set req exp
reqExp
=
G
enshin
Data
.
getRelicExpRequired
(
relic
.
getItemData
().
getRankLevel
(),
level
);
reqExp
=
G
ame
Data
.
getRelicExpRequired
(
relic
.
getItemData
().
getRankLevel
(),
level
);
}
}
}
}
...
@@ -209,7 +209,7 @@ public class InventoryManager {
...
@@ -209,7 +209,7 @@ public class InventoryManager {
// Avatar
// Avatar
if
(
oldLevel
!=
level
)
{
if
(
oldLevel
!=
level
)
{
Genshin
Avatar
avatar
=
relic
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
relic
.
getEquipCharacter
())
:
null
;
Avatar
avatar
=
relic
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
relic
.
getEquipCharacter
())
:
null
;
if
(
avatar
!=
null
)
{
if
(
avatar
!=
null
)
{
avatar
.
recalcStats
();
avatar
.
recalcStats
();
}
}
...
@@ -220,15 +220,15 @@ public class InventoryManager {
...
@@ -220,15 +220,15 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketReliquaryUpgradeRsp
(
relic
,
rate
,
oldLevel
,
oldAppendPropIdList
));
player
.
sendPacket
(
new
PacketReliquaryUpgradeRsp
(
relic
,
rate
,
oldLevel
,
oldAppendPropIdList
));
}
}
public
List
<
ItemParam
>
calcWeaponUpgradeReturnItems
(
Genshin
Player
player
,
long
targetGuid
,
List
<
Long
>
foodWeaponGuidList
,
List
<
ItemParam
>
itemParamList
)
{
public
List
<
ItemParam
>
calcWeaponUpgradeReturnItems
(
Player
player
,
long
targetGuid
,
List
<
Long
>
foodWeaponGuidList
,
List
<
ItemParam
>
itemParamList
)
{
G
enshin
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
G
ame
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
// Sanity checks
// Sanity checks
if
(
weapon
==
null
||
weapon
.
getItemType
()
!=
ItemType
.
ITEM_WEAPON
)
{
if
(
weapon
==
null
||
weapon
.
getItemType
()
!=
ItemType
.
ITEM_WEAPON
)
{
return
null
;
return
null
;
}
}
WeaponPromoteData
promoteData
=
G
enshin
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
WeaponPromoteData
promoteData
=
G
ame
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
if
(
promoteData
==
null
)
{
if
(
promoteData
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -236,7 +236,7 @@ public class InventoryManager {
...
@@ -236,7 +236,7 @@ public class InventoryManager {
// Get exp gain
// Get exp gain
int
expGain
=
0
;
int
expGain
=
0
;
for
(
long
guid
:
foodWeaponGuidList
)
{
for
(
long
guid
:
foodWeaponGuidList
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
G
ame
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
if
(
food
==
null
)
{
if
(
food
==
null
)
{
continue
;
continue
;
}
}
...
@@ -246,7 +246,7 @@ public class InventoryManager {
...
@@ -246,7 +246,7 @@ public class InventoryManager {
}
}
}
}
for
(
ItemParam
param
:
itemParamList
)
{
for
(
ItemParam
param
:
itemParamList
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
param
.
getItemId
());
G
ame
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
param
.
getItemId
());
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_WEAPON_EXP_STONE
)
{
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_WEAPON_EXP_STONE
)
{
continue
;
continue
;
}
}
...
@@ -264,7 +264,7 @@ public class InventoryManager {
...
@@ -264,7 +264,7 @@ public class InventoryManager {
int
maxLevel
=
promoteData
.
getUnlockMaxLevel
();
int
maxLevel
=
promoteData
.
getUnlockMaxLevel
();
int
level
=
weapon
.
getLevel
();
int
level
=
weapon
.
getLevel
();
int
exp
=
weapon
.
getExp
();
int
exp
=
weapon
.
getExp
();
int
reqExp
=
G
enshin
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
int
reqExp
=
G
ame
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
// Do calculations
// Do calculations
...
@@ -277,7 +277,7 @@ public class InventoryManager {
...
@@ -277,7 +277,7 @@ public class InventoryManager {
exp
=
0
;
exp
=
0
;
level
+=
1
;
level
+=
1
;
// Set req exp
// Set req exp
reqExp
=
G
enshin
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
reqExp
=
G
ame
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
}
}
}
}
...
@@ -285,15 +285,15 @@ public class InventoryManager {
...
@@ -285,15 +285,15 @@ public class InventoryManager {
}
}
public
void
upgradeWeapon
(
Genshin
Player
player
,
long
targetGuid
,
List
<
Long
>
foodWeaponGuidList
,
List
<
ItemParam
>
itemParamList
)
{
public
void
upgradeWeapon
(
Player
player
,
long
targetGuid
,
List
<
Long
>
foodWeaponGuidList
,
List
<
ItemParam
>
itemParamList
)
{
G
enshin
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
G
ame
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
// Sanity checks
// Sanity checks
if
(
weapon
==
null
||
weapon
.
getItemType
()
!=
ItemType
.
ITEM_WEAPON
)
{
if
(
weapon
==
null
||
weapon
.
getItemType
()
!=
ItemType
.
ITEM_WEAPON
)
{
return
;
return
;
}
}
WeaponPromoteData
promoteData
=
G
enshin
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
WeaponPromoteData
promoteData
=
G
ame
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
if
(
promoteData
==
null
)
{
if
(
promoteData
==
null
)
{
return
;
return
;
}
}
...
@@ -302,7 +302,7 @@ public class InventoryManager {
...
@@ -302,7 +302,7 @@ public class InventoryManager {
int
expGain
=
0
,
moraCost
=
0
;
int
expGain
=
0
,
moraCost
=
0
;
for
(
long
guid
:
foodWeaponGuidList
)
{
for
(
long
guid
:
foodWeaponGuidList
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
G
ame
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
continue
;
continue
;
}
}
...
@@ -313,7 +313,7 @@ public class InventoryManager {
...
@@ -313,7 +313,7 @@ public class InventoryManager {
}
}
}
}
for
(
ItemParam
param
:
itemParamList
)
{
for
(
ItemParam
param
:
itemParamList
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
param
.
getItemId
());
G
ame
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
param
.
getItemId
());
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_WEAPON_EXP_STONE
)
{
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_WEAPON_EXP_STONE
)
{
continue
;
continue
;
}
}
...
@@ -344,14 +344,14 @@ public class InventoryManager {
...
@@ -344,14 +344,14 @@ public class InventoryManager {
// Consume weapon/items used to feed
// Consume weapon/items used to feed
for
(
long
guid
:
foodWeaponGuidList
)
{
for
(
long
guid
:
foodWeaponGuidList
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
G
ame
Item
food
=
player
.
getInventory
().
getItemByGuid
(
guid
);
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
if
(
food
==
null
||
!
food
.
isDestroyable
())
{
continue
;
continue
;
}
}
player
.
getInventory
().
removeItem
(
food
);
player
.
getInventory
().
removeItem
(
food
);
}
}
for
(
ItemParam
param
:
itemParamList
)
{
for
(
ItemParam
param
:
itemParamList
)
{
G
enshin
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
param
.
getItemId
());
G
ame
Item
food
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
param
.
getItemId
());
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_WEAPON_EXP_STONE
)
{
if
(
food
==
null
||
food
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_WEAPON_EXP_STONE
)
{
continue
;
continue
;
}
}
...
@@ -365,7 +365,7 @@ public class InventoryManager {
...
@@ -365,7 +365,7 @@ public class InventoryManager {
int
oldLevel
=
level
;
int
oldLevel
=
level
;
int
exp
=
weapon
.
getExp
();
int
exp
=
weapon
.
getExp
();
int
totalExp
=
weapon
.
getTotalExp
();
int
totalExp
=
weapon
.
getTotalExp
();
int
reqExp
=
G
enshin
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
int
reqExp
=
G
ame
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
// Do calculations
// Do calculations
...
@@ -379,7 +379,7 @@ public class InventoryManager {
...
@@ -379,7 +379,7 @@ public class InventoryManager {
exp
=
0
;
exp
=
0
;
level
+=
1
;
level
+=
1
;
// Set req exp
// Set req exp
reqExp
=
G
enshin
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
reqExp
=
G
ame
Data
.
getWeaponExpRequired
(
weapon
.
getItemData
().
getRankLevel
(),
level
);
}
}
}
}
...
@@ -393,7 +393,7 @@ public class InventoryManager {
...
@@ -393,7 +393,7 @@ public class InventoryManager {
// Avatar
// Avatar
if
(
oldLevel
!=
level
)
{
if
(
oldLevel
!=
level
)
{
Genshin
Avatar
avatar
=
weapon
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
weapon
.
getEquipCharacter
())
:
null
;
Avatar
avatar
=
weapon
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
weapon
.
getEquipCharacter
())
:
null
;
if
(
avatar
!=
null
)
{
if
(
avatar
!=
null
)
{
avatar
.
recalcStats
();
avatar
.
recalcStats
();
}
}
...
@@ -429,9 +429,9 @@ public class InventoryManager {
...
@@ -429,9 +429,9 @@ public class InventoryManager {
return
leftoverOreList
;
return
leftoverOreList
;
}
}
public
void
refineWeapon
(
Genshin
Player
player
,
long
targetGuid
,
long
feedGuid
)
{
public
void
refineWeapon
(
Player
player
,
long
targetGuid
,
long
feedGuid
)
{
G
enshin
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
G
ame
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
G
enshin
Item
feed
=
player
.
getInventory
().
getItemByGuid
(
feedGuid
);
G
ame
Item
feed
=
player
.
getInventory
().
getItemByGuid
(
feedGuid
);
// Sanity checks
// Sanity checks
if
(
weapon
==
null
||
feed
==
null
||
!
feed
.
isDestroyable
())
{
if
(
weapon
==
null
||
feed
==
null
||
!
feed
.
isDestroyable
())
{
...
@@ -478,7 +478,7 @@ public class InventoryManager {
...
@@ -478,7 +478,7 @@ public class InventoryManager {
weapon
.
save
();
weapon
.
save
();
// Avatar
// Avatar
Genshin
Avatar
avatar
=
weapon
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
weapon
.
getEquipCharacter
())
:
null
;
Avatar
avatar
=
weapon
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
weapon
.
getEquipCharacter
())
:
null
;
if
(
avatar
!=
null
)
{
if
(
avatar
!=
null
)
{
avatar
.
recalcStats
();
avatar
.
recalcStats
();
}
}
...
@@ -488,16 +488,16 @@ public class InventoryManager {
...
@@ -488,16 +488,16 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketWeaponAwakenRsp
(
avatar
,
weapon
,
feed
,
oldRefineLevel
));
player
.
sendPacket
(
new
PacketWeaponAwakenRsp
(
avatar
,
weapon
,
feed
,
oldRefineLevel
));
}
}
public
void
promoteWeapon
(
Genshin
Player
player
,
long
targetGuid
)
{
public
void
promoteWeapon
(
Player
player
,
long
targetGuid
)
{
G
enshin
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
G
ame
Item
weapon
=
player
.
getInventory
().
getItemByGuid
(
targetGuid
);
if
(
weapon
==
null
||
weapon
.
getItemType
()
!=
ItemType
.
ITEM_WEAPON
)
{
if
(
weapon
==
null
||
weapon
.
getItemType
()
!=
ItemType
.
ITEM_WEAPON
)
{
return
;
return
;
}
}
int
nextPromoteLevel
=
weapon
.
getPromoteLevel
()
+
1
;
int
nextPromoteLevel
=
weapon
.
getPromoteLevel
()
+
1
;
WeaponPromoteData
currentPromoteData
=
G
enshin
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
WeaponPromoteData
currentPromoteData
=
G
ame
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
weapon
.
getPromoteLevel
());
WeaponPromoteData
nextPromoteData
=
G
enshin
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
nextPromoteLevel
);
WeaponPromoteData
nextPromoteData
=
G
ame
Data
.
getWeaponPromoteData
(
weapon
.
getItemData
().
getWeaponPromoteId
(),
nextPromoteLevel
);
if
(
currentPromoteData
==
null
||
nextPromoteData
==
null
)
{
if
(
currentPromoteData
==
null
||
nextPromoteData
==
null
)
{
return
;
return
;
}
}
...
@@ -509,7 +509,7 @@ public class InventoryManager {
...
@@ -509,7 +509,7 @@ public class InventoryManager {
// Make sure player has promote items
// Make sure player has promote items
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
G
enshin
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
G
ame
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
if
(
feedItem
==
null
||
feedItem
.
getCount
()
<
cost
.
getCount
())
{
if
(
feedItem
==
null
||
feedItem
.
getCount
()
<
cost
.
getCount
())
{
return
;
return
;
}
}
...
@@ -524,7 +524,7 @@ public class InventoryManager {
...
@@ -524,7 +524,7 @@ public class InventoryManager {
// Consume promote filler items
// Consume promote filler items
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
G
enshin
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
G
ame
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
player
.
getInventory
().
removeItem
(
feedItem
,
cost
.
getCount
());
player
.
getInventory
().
removeItem
(
feedItem
,
cost
.
getCount
());
}
}
...
@@ -533,7 +533,7 @@ public class InventoryManager {
...
@@ -533,7 +533,7 @@ public class InventoryManager {
weapon
.
save
();
weapon
.
save
();
// Avatar
// Avatar
Genshin
Avatar
avatar
=
weapon
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
weapon
.
getEquipCharacter
())
:
null
;
Avatar
avatar
=
weapon
.
getEquipCharacter
()
>
0
?
player
.
getAvatars
().
getAvatarById
(
weapon
.
getEquipCharacter
())
:
null
;
if
(
avatar
!=
null
)
{
if
(
avatar
!=
null
)
{
avatar
.
recalcStats
();
avatar
.
recalcStats
();
}
}
...
@@ -543,8 +543,8 @@ public class InventoryManager {
...
@@ -543,8 +543,8 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketWeaponPromoteRsp
(
weapon
,
oldPromoteLevel
));
player
.
sendPacket
(
new
PacketWeaponPromoteRsp
(
weapon
,
oldPromoteLevel
));
}
}
public
void
promoteAvatar
(
Genshin
Player
player
,
long
guid
)
{
public
void
promoteAvatar
(
Player
player
,
long
guid
)
{
Genshin
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
// Sanity checks
// Sanity checks
if
(
avatar
==
null
)
{
if
(
avatar
==
null
)
{
...
@@ -552,8 +552,8 @@ public class InventoryManager {
...
@@ -552,8 +552,8 @@ public class InventoryManager {
}
}
int
nextPromoteLevel
=
avatar
.
getPromoteLevel
()
+
1
;
int
nextPromoteLevel
=
avatar
.
getPromoteLevel
()
+
1
;
AvatarPromoteData
currentPromoteData
=
G
enshin
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
avatar
.
getPromoteLevel
());
AvatarPromoteData
currentPromoteData
=
G
ame
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
avatar
.
getPromoteLevel
());
AvatarPromoteData
nextPromoteData
=
G
enshin
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
nextPromoteLevel
);
AvatarPromoteData
nextPromoteData
=
G
ame
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
nextPromoteLevel
);
if
(
currentPromoteData
==
null
||
nextPromoteData
==
null
)
{
if
(
currentPromoteData
==
null
||
nextPromoteData
==
null
)
{
return
;
return
;
}
}
...
@@ -565,7 +565,7 @@ public class InventoryManager {
...
@@ -565,7 +565,7 @@ public class InventoryManager {
// Make sure player has cost items
// Make sure player has cost items
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
G
enshin
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
G
ame
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
if
(
feedItem
==
null
||
feedItem
.
getCount
()
<
cost
.
getCount
())
{
if
(
feedItem
==
null
||
feedItem
.
getCount
()
<
cost
.
getCount
())
{
return
;
return
;
}
}
...
@@ -580,7 +580,7 @@ public class InventoryManager {
...
@@ -580,7 +580,7 @@ public class InventoryManager {
// Consume promote filler items
// Consume promote filler items
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
for
(
ItemParamData
cost
:
nextPromoteData
.
getCostItems
())
{
G
enshin
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
G
ame
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
player
.
getInventory
().
removeItem
(
feedItem
,
cost
.
getCount
());
player
.
getInventory
().
removeItem
(
feedItem
,
cost
.
getCount
());
}
}
...
@@ -588,7 +588,7 @@ public class InventoryManager {
...
@@ -588,7 +588,7 @@ public class InventoryManager {
avatar
.
setPromoteLevel
(
nextPromoteLevel
);
avatar
.
setPromoteLevel
(
nextPromoteLevel
);
// Update proud skills
// Update proud skills
AvatarSkillDepotData
skillDepot
=
G
enshin
Data
.
getAvatarSkillDepotDataMap
().
get
(
avatar
.
getSkillDepotId
());
AvatarSkillDepotData
skillDepot
=
G
ame
Data
.
getAvatarSkillDepotDataMap
().
get
(
avatar
.
getSkillDepotId
());
if
(
skillDepot
!=
null
&&
skillDepot
.
getInherentProudSkillOpens
()
!=
null
)
{
if
(
skillDepot
!=
null
&&
skillDepot
.
getInherentProudSkillOpens
()
!=
null
)
{
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
for
(
InherentProudSkillOpens
openData
:
skillDepot
.
getInherentProudSkillOpens
())
{
...
@@ -597,7 +597,7 @@ public class InventoryManager {
...
@@ -597,7 +597,7 @@ public class InventoryManager {
}
}
if
(
openData
.
getNeedAvatarPromoteLevel
()
==
avatar
.
getPromoteLevel
())
{
if
(
openData
.
getNeedAvatarPromoteLevel
()
==
avatar
.
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
))
{
avatar
.
getProudSkillList
().
add
(
proudSkillId
);
avatar
.
getProudSkillList
().
add
(
proudSkillId
);
player
.
sendPacket
(
new
PacketProudSkillChangeNotify
(
avatar
));
player
.
sendPacket
(
new
PacketProudSkillChangeNotify
(
avatar
));
}
}
...
@@ -614,20 +614,20 @@ public class InventoryManager {
...
@@ -614,20 +614,20 @@ public class InventoryManager {
avatar
.
save
();
avatar
.
save
();
}
}
public
void
upgradeAvatar
(
Genshin
Player
player
,
long
guid
,
int
itemId
,
int
count
)
{
public
void
upgradeAvatar
(
Player
player
,
long
guid
,
int
itemId
,
int
count
)
{
Genshin
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
// Sanity checks
// Sanity checks
if
(
avatar
==
null
)
{
if
(
avatar
==
null
)
{
return
;
return
;
}
}
AvatarPromoteData
promoteData
=
G
enshin
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
avatar
.
getPromoteLevel
());
AvatarPromoteData
promoteData
=
G
ame
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
avatar
.
getPromoteLevel
());
if
(
promoteData
==
null
)
{
if
(
promoteData
==
null
)
{
return
;
return
;
}
}
G
enshin
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
itemId
);
G
ame
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
itemId
);
if
(
feedItem
==
null
||
feedItem
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_EXP_FRUIT
||
feedItem
.
getCount
()
<
count
)
{
if
(
feedItem
==
null
||
feedItem
.
getItemData
().
getMaterialType
()
!=
MaterialType
.
MATERIAL_EXP_FRUIT
||
feedItem
.
getCount
()
<
count
)
{
return
;
return
;
...
@@ -660,8 +660,8 @@ public class InventoryManager {
...
@@ -660,8 +660,8 @@ public class InventoryManager {
upgradeAvatar
(
player
,
avatar
,
promoteData
,
expGain
);
upgradeAvatar
(
player
,
avatar
,
promoteData
,
expGain
);
}
}
public
void
upgradeAvatar
(
Genshin
Player
player
,
Genshin
Avatar
avatar
,
int
expGain
)
{
public
void
upgradeAvatar
(
Player
player
,
Avatar
avatar
,
int
expGain
)
{
AvatarPromoteData
promoteData
=
G
enshin
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
avatar
.
getPromoteLevel
());
AvatarPromoteData
promoteData
=
G
ame
Data
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
avatar
.
getPromoteLevel
());
if
(
promoteData
==
null
)
{
if
(
promoteData
==
null
)
{
return
;
return
;
}
}
...
@@ -669,12 +669,12 @@ public class InventoryManager {
...
@@ -669,12 +669,12 @@ public class InventoryManager {
upgradeAvatar
(
player
,
avatar
,
promoteData
,
expGain
);
upgradeAvatar
(
player
,
avatar
,
promoteData
,
expGain
);
}
}
public
void
upgradeAvatar
(
Genshin
Player
player
,
Genshin
Avatar
avatar
,
AvatarPromoteData
promoteData
,
int
expGain
)
{
public
void
upgradeAvatar
(
Player
player
,
Avatar
avatar
,
AvatarPromoteData
promoteData
,
int
expGain
)
{
int
maxLevel
=
promoteData
.
getUnlockMaxLevel
();
int
maxLevel
=
promoteData
.
getUnlockMaxLevel
();
int
level
=
avatar
.
getLevel
();
int
level
=
avatar
.
getLevel
();
int
oldLevel
=
level
;
int
oldLevel
=
level
;
int
exp
=
avatar
.
getExp
();
int
exp
=
avatar
.
getExp
();
int
reqExp
=
G
enshin
Data
.
getAvatarLevelExpRequired
(
level
);
int
reqExp
=
G
ame
Data
.
getAvatarLevelExpRequired
(
level
);
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
// Do calculations
// Do calculations
...
@@ -687,7 +687,7 @@ public class InventoryManager {
...
@@ -687,7 +687,7 @@ public class InventoryManager {
exp
=
0
;
exp
=
0
;
level
+=
1
;
level
+=
1
;
// Set req exp
// Set req exp
reqExp
=
G
enshin
Data
.
getAvatarLevelExpRequired
(
level
);
reqExp
=
G
ame
Data
.
getAvatarLevelExpRequired
(
level
);
}
}
}
}
...
@@ -711,12 +711,12 @@ public class InventoryManager {
...
@@ -711,12 +711,12 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketAvatarUpgradeRsp
(
avatar
,
oldLevel
,
oldPropMap
));
player
.
sendPacket
(
new
PacketAvatarUpgradeRsp
(
avatar
,
oldLevel
,
oldPropMap
));
}
}
public
void
upgradeAvatarFetterLevel
(
Genshin
Player
player
,
Genshin
Avatar
avatar
,
int
expGain
)
{
public
void
upgradeAvatarFetterLevel
(
Player
player
,
Avatar
avatar
,
int
expGain
)
{
// May work. Not test.
// May work. Not test.
int
maxLevel
=
10
;
// Keep it until I think of a more "elegant" way
int
maxLevel
=
10
;
// Keep it until I think of a more "elegant" way
int
level
=
avatar
.
getFetterLevel
();
int
level
=
avatar
.
getFetterLevel
();
int
exp
=
avatar
.
getFetterExp
();
int
exp
=
avatar
.
getFetterExp
();
int
reqExp
=
G
enshin
Data
.
getAvatarFetterLevelExpRequired
(
level
);
int
reqExp
=
G
ame
Data
.
getAvatarFetterLevelExpRequired
(
level
);
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
int
toGain
=
Math
.
min
(
expGain
,
reqExp
-
exp
);
int
toGain
=
Math
.
min
(
expGain
,
reqExp
-
exp
);
...
@@ -725,7 +725,7 @@ public class InventoryManager {
...
@@ -725,7 +725,7 @@ public class InventoryManager {
if
(
exp
>=
reqExp
)
{
if
(
exp
>=
reqExp
)
{
exp
=
0
;
exp
=
0
;
level
+=
1
;
level
+=
1
;
reqExp
=
G
enshin
Data
.
getAvatarFetterLevelExpRequired
(
level
);
reqExp
=
G
ame
Data
.
getAvatarFetterLevelExpRequired
(
level
);
}
}
}
}
...
@@ -736,9 +736,9 @@ public class InventoryManager {
...
@@ -736,9 +736,9 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketAvatarPropNotify
(
avatar
));
player
.
sendPacket
(
new
PacketAvatarPropNotify
(
avatar
));
}
}
public
void
upgradeAvatarSkill
(
Genshin
Player
player
,
long
guid
,
int
skillId
)
{
public
void
upgradeAvatarSkill
(
Player
player
,
long
guid
,
int
skillId
)
{
// Sanity checks
// Sanity checks
Genshin
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
if
(
avatar
==
null
)
{
if
(
avatar
==
null
)
{
return
;
return
;
}
}
...
@@ -748,7 +748,7 @@ public class InventoryManager {
...
@@ -748,7 +748,7 @@ public class InventoryManager {
return
;
return
;
}
}
AvatarSkillData
skillData
=
G
enshin
Data
.
getAvatarSkillDataMap
().
get
(
skillId
);
AvatarSkillData
skillData
=
G
ame
Data
.
getAvatarSkillDataMap
().
get
(
skillId
);
if
(
skillData
==
null
)
{
if
(
skillData
==
null
)
{
return
;
return
;
}
}
...
@@ -764,7 +764,7 @@ public class InventoryManager {
...
@@ -764,7 +764,7 @@ public class InventoryManager {
}
}
// Proud skill data
// Proud skill data
ProudSkillData
proudSkill
=
G
enshin
Data
.
getProudSkillDataMap
().
get
(
proudSkillId
);
ProudSkillData
proudSkill
=
G
ame
Data
.
getProudSkillDataMap
().
get
(
proudSkillId
);
if
(
proudSkill
==
null
)
{
if
(
proudSkill
==
null
)
{
return
;
return
;
}
}
...
@@ -779,7 +779,7 @@ public class InventoryManager {
...
@@ -779,7 +779,7 @@ public class InventoryManager {
if
(
cost
.
getId
()
==
0
)
{
if
(
cost
.
getId
()
==
0
)
{
continue
;
continue
;
}
}
G
enshin
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
G
ame
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
if
(
feedItem
==
null
||
feedItem
.
getCount
()
<
cost
.
getCount
())
{
if
(
feedItem
==
null
||
feedItem
.
getCount
()
<
cost
.
getCount
())
{
return
;
return
;
}
}
...
@@ -797,7 +797,7 @@ public class InventoryManager {
...
@@ -797,7 +797,7 @@ public class InventoryManager {
if
(
cost
.
getId
()
==
0
)
{
if
(
cost
.
getId
()
==
0
)
{
continue
;
continue
;
}
}
G
enshin
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
G
ame
Item
feedItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
cost
.
getId
());
player
.
getInventory
().
removeItem
(
feedItem
,
cost
.
getCount
());
player
.
getInventory
().
removeItem
(
feedItem
,
cost
.
getCount
());
}
}
...
@@ -810,9 +810,9 @@ public class InventoryManager {
...
@@ -810,9 +810,9 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketAvatarSkillUpgradeRsp
(
avatar
,
skillId
,
currentLevel
,
nextLevel
));
player
.
sendPacket
(
new
PacketAvatarSkillUpgradeRsp
(
avatar
,
skillId
,
currentLevel
,
nextLevel
));
}
}
public
void
unlockAvatarConstellation
(
Genshin
Player
player
,
long
guid
)
{
public
void
unlockAvatarConstellation
(
Player
player
,
long
guid
)
{
// Sanity checks
// Sanity checks
Genshin
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
Avatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
if
(
avatar
==
null
)
{
if
(
avatar
==
null
)
{
return
;
return
;
}
}
...
@@ -826,13 +826,13 @@ public class InventoryManager {
...
@@ -826,13 +826,13 @@ public class InventoryManager {
nextTalentId
=
40
+
currentTalentLevel
+
1
;
nextTalentId
=
40
+
currentTalentLevel
+
1
;
}
}
AvatarTalentData
talentData
=
G
enshin
Data
.
getAvatarTalentDataMap
().
get
(
nextTalentId
);
AvatarTalentData
talentData
=
G
ame
Data
.
getAvatarTalentDataMap
().
get
(
nextTalentId
);
if
(
talentData
==
null
)
{
if
(
talentData
==
null
)
{
return
;
return
;
}
}
G
enshin
Item
costItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
talentData
.
getMainCostItemId
());
G
ame
Item
costItem
=
player
.
getInventory
().
getInventoryTab
(
ItemType
.
ITEM_MATERIAL
).
getItemById
(
talentData
.
getMainCostItemId
());
if
(
costItem
==
null
||
costItem
.
getCount
()
<
talentData
.
getMainCostItemCount
())
{
if
(
costItem
==
null
||
costItem
.
getCount
()
<
talentData
.
getMainCostItemCount
())
{
return
;
return
;
}
}
...
@@ -849,7 +849,7 @@ public class InventoryManager {
...
@@ -849,7 +849,7 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketUnlockAvatarTalentRsp
(
avatar
,
nextTalentId
));
player
.
sendPacket
(
new
PacketUnlockAvatarTalentRsp
(
avatar
,
nextTalentId
));
// Proud skill bonus map (Extra skills)
// Proud skill bonus map (Extra skills)
OpenConfigEntry
entry
=
G
enshin
Data
.
getOpenConfigEntries
().
get
(
talentData
.
getOpenConfig
());
OpenConfigEntry
entry
=
G
ame
Data
.
getOpenConfigEntries
().
get
(
talentData
.
getOpenConfig
());
if
(
entry
!=
null
&&
entry
.
getExtraTalentIndex
()
>
0
)
{
if
(
entry
!=
null
&&
entry
.
getExtraTalentIndex
()
>
0
)
{
avatar
.
recalcProudSkillBonusMap
();
avatar
.
recalcProudSkillBonusMap
();
player
.
sendPacket
(
new
PacketProudSkillExtraLevelNotify
(
avatar
,
entry
.
getExtraTalentIndex
()));
player
.
sendPacket
(
new
PacketProudSkillExtraLevelNotify
(
avatar
,
entry
.
getExtraTalentIndex
()));
...
@@ -860,7 +860,7 @@ public class InventoryManager {
...
@@ -860,7 +860,7 @@ public class InventoryManager {
avatar
.
save
();
avatar
.
save
();
}
}
public
void
destroyMaterial
(
Genshin
Player
player
,
List
<
MaterialInfo
>
list
)
{
public
void
destroyMaterial
(
Player
player
,
List
<
MaterialInfo
>
list
)
{
// Return materials
// Return materials
Int2IntOpenHashMap
returnMaterialMap
=
new
Int2IntOpenHashMap
();
Int2IntOpenHashMap
returnMaterialMap
=
new
Int2IntOpenHashMap
();
...
@@ -870,7 +870,7 @@ public class InventoryManager {
...
@@ -870,7 +870,7 @@ public class InventoryManager {
continue
;
continue
;
}
}
G
enshin
Item
item
=
player
.
getInventory
().
getItemByGuid
(
info
.
getGuid
());
G
ame
Item
item
=
player
.
getInventory
().
getItemByGuid
(
info
.
getGuid
());
if
(
item
==
null
||
!
item
.
isDestroyable
())
{
if
(
item
==
null
||
!
item
.
isDestroyable
())
{
continue
;
continue
;
}
}
...
@@ -890,7 +890,7 @@ public class InventoryManager {
...
@@ -890,7 +890,7 @@ public class InventoryManager {
// Give back items
// Give back items
if
(
returnMaterialMap
.
size
()
>
0
)
{
if
(
returnMaterialMap
.
size
()
>
0
)
{
for
(
Int2IntMap
.
Entry
e
:
returnMaterialMap
.
int2IntEntrySet
())
{
for
(
Int2IntMap
.
Entry
e
:
returnMaterialMap
.
int2IntEntrySet
())
{
player
.
getInventory
().
addItem
(
new
G
enshin
Item
(
e
.
getIntKey
(),
e
.
getIntValue
()));
player
.
getInventory
().
addItem
(
new
G
ame
Item
(
e
.
getIntKey
(),
e
.
getIntValue
()));
}
}
}
}
...
@@ -898,9 +898,9 @@ public class InventoryManager {
...
@@ -898,9 +898,9 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketDestroyMaterialRsp
(
returnMaterialMap
));
player
.
sendPacket
(
new
PacketDestroyMaterialRsp
(
returnMaterialMap
));
}
}
public
G
enshin
Item
useItem
(
Genshin
Player
player
,
long
targetGuid
,
long
itemGuid
,
int
count
)
{
public
G
ame
Item
useItem
(
Player
player
,
long
targetGuid
,
long
itemGuid
,
int
count
)
{
Genshin
Avatar
target
=
player
.
getAvatars
().
getAvatarByGuid
(
targetGuid
);
Avatar
target
=
player
.
getAvatars
().
getAvatarByGuid
(
targetGuid
);
G
enshin
Item
useItem
=
player
.
getInventory
().
getItemByGuid
(
itemGuid
);
G
ame
Item
useItem
=
player
.
getInventory
().
getItemByGuid
(
itemGuid
);
if
(
useItem
==
null
)
{
if
(
useItem
==
null
)
{
return
null
;
return
null
;
...
...
src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java
View file @
1c36f078
package
emu.grasscutter.game.managers
;
package
emu.grasscutter.game.managers
;
import
emu.grasscutter.game.CoopRequest
;
import
emu.grasscutter.game.CoopRequest
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.game.Player
;
import
emu.grasscutter.game.
Genshin
Player.SceneLoadState
;
import
emu.grasscutter.game.Player.SceneLoadState
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason
;
import
emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason
;
...
@@ -24,8 +24,8 @@ public class MultiplayerManager {
...
@@ -24,8 +24,8 @@ public class MultiplayerManager {
return
server
;
return
server
;
}
}
public
void
applyEnterMp
(
Genshin
Player
player
,
int
targetUid
)
{
public
void
applyEnterMp
(
Player
player
,
int
targetUid
)
{
Genshin
Player
target
=
getServer
().
getPlayerByUid
(
targetUid
);
Player
target
=
getServer
().
getPlayerByUid
(
targetUid
);
if
(
target
==
null
)
{
if
(
target
==
null
)
{
player
.
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
targetUid
,
""
,
false
,
PlayerApplyEnterMpResultNotifyOuterClass
.
PlayerApplyEnterMpResultNotify
.
Reason
.
PLAYER_CANNOT_ENTER_MP
));
player
.
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
targetUid
,
""
,
false
,
PlayerApplyEnterMpResultNotifyOuterClass
.
PlayerApplyEnterMpResultNotify
.
Reason
.
PLAYER_CANNOT_ENTER_MP
));
return
;
return
;
...
@@ -59,7 +59,7 @@ public class MultiplayerManager {
...
@@ -59,7 +59,7 @@ public class MultiplayerManager {
target
.
sendPacket
(
new
PacketPlayerApplyEnterMpNotify
(
player
));
target
.
sendPacket
(
new
PacketPlayerApplyEnterMpNotify
(
player
));
}
}
public
void
applyEnterMpReply
(
Genshin
Player
hostPlayer
,
int
applyUid
,
boolean
isAgreed
)
{
public
void
applyEnterMpReply
(
Player
hostPlayer
,
int
applyUid
,
boolean
isAgreed
)
{
// Checks
// Checks
CoopRequest
request
=
hostPlayer
.
getCoopRequests
().
get
(
applyUid
);
CoopRequest
request
=
hostPlayer
.
getCoopRequests
().
get
(
applyUid
);
if
(
request
==
null
||
request
.
isExpired
())
{
if
(
request
==
null
||
request
.
isExpired
())
{
...
@@ -67,7 +67,7 @@ public class MultiplayerManager {
...
@@ -67,7 +67,7 @@ public class MultiplayerManager {
}
}
// Remove now that we are handling it
// Remove now that we are handling it
Genshin
Player
requester
=
request
.
getRequester
();
Player
requester
=
request
.
getRequester
();
hostPlayer
.
getCoopRequests
().
remove
(
applyUid
);
hostPlayer
.
getCoopRequests
().
remove
(
applyUid
);
// Sanity checks - Dont let the requesting player join if they are already in multiplayer
// Sanity checks - Dont let the requesting player join if they are already in multiplayer
...
@@ -108,14 +108,14 @@ public class MultiplayerManager {
...
@@ -108,14 +108,14 @@ public class MultiplayerManager {
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
hostPlayer
,
EnterType
.
ENTER_OTHER
,
EnterReason
.
TeamJoin
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
hostPlayer
,
EnterType
.
ENTER_OTHER
,
EnterReason
.
TeamJoin
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
}
}
public
boolean
leaveCoop
(
Genshin
Player
player
)
{
public
boolean
leaveCoop
(
Player
player
)
{
// Make sure player's world is multiplayer
// Make sure player's world is multiplayer
if
(!
player
.
getWorld
().
isMultiplayer
())
{
if
(!
player
.
getWorld
().
isMultiplayer
())
{
return
false
;
return
false
;
}
}
// Make sure everyone's scene is loaded
// Make sure everyone's scene is loaded
for
(
Genshin
Player
p
:
player
.
getWorld
().
getPlayers
())
{
for
(
Player
p
:
player
.
getWorld
().
getPlayers
())
{
if
(
p
.
getSceneLoadState
()
!=
SceneLoadState
.
LOADED
)
{
if
(
p
.
getSceneLoadState
()
!=
SceneLoadState
.
LOADED
)
{
return
false
;
return
false
;
}
}
...
@@ -131,14 +131,14 @@ public class MultiplayerManager {
...
@@ -131,14 +131,14 @@ public class MultiplayerManager {
return
true
;
return
true
;
}
}
public
boolean
kickPlayer
(
Genshin
Player
player
,
int
targetUid
)
{
public
boolean
kickPlayer
(
Player
player
,
int
targetUid
)
{
// Make sure player's world is multiplayer and that player is owner
// Make sure player's world is multiplayer and that player is owner
if
(!
player
.
getWorld
().
isMultiplayer
()
||
player
.
getWorld
().
getHost
()
!=
player
)
{
if
(!
player
.
getWorld
().
isMultiplayer
()
||
player
.
getWorld
().
getHost
()
!=
player
)
{
return
false
;
return
false
;
}
}
// Get victim and sanity checks
// Get victim and sanity checks
Genshin
Player
victim
=
player
.
getServer
().
getPlayerByUid
(
targetUid
);
Player
victim
=
player
.
getServer
().
getPlayerByUid
(
targetUid
);
if
(
victim
==
null
||
victim
==
player
)
{
if
(
victim
==
null
||
victim
==
player
)
{
return
false
;
return
false
;
...
...
src/main/java/emu/grasscutter/net/packet/
Genshin
Packet.java
→
src/main/java/emu/grasscutter/net/packet/
Base
Packet.java
View file @
1c36f078
...
@@ -7,7 +7,7 @@ import com.google.protobuf.GeneratedMessageV3;
...
@@ -7,7 +7,7 @@ import com.google.protobuf.GeneratedMessageV3;
import
emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead
;
import
emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead
;
import
emu.grasscutter.utils.Crypto
;
import
emu.grasscutter.utils.Crypto
;
public
class
Genshin
Packet
{
public
class
Base
Packet
{
private
static
final
int
const1
=
17767
;
// 0x4567
private
static
final
int
const1
=
17767
;
// 0x4567
private
static
final
int
const2
=
-
30293
;
// 0x89ab
private
static
final
int
const2
=
-
30293
;
// 0x89ab
...
@@ -21,16 +21,16 @@ public class GenshinPacket {
...
@@ -21,16 +21,16 @@ public class GenshinPacket {
private
boolean
useDispatchKey
;
private
boolean
useDispatchKey
;
public
boolean
shouldEncrypt
=
true
;
public
boolean
shouldEncrypt
=
true
;
public
Genshin
Packet
(
int
opcode
)
{
public
Base
Packet
(
int
opcode
)
{
this
.
opcode
=
opcode
;
this
.
opcode
=
opcode
;
}
}
public
Genshin
Packet
(
int
opcode
,
int
clientSequence
)
{
public
Base
Packet
(
int
opcode
,
int
clientSequence
)
{
this
.
opcode
=
opcode
;
this
.
opcode
=
opcode
;
this
.
buildHeader
(
clientSequence
);
this
.
buildHeader
(
clientSequence
);
}
}
public
Genshin
Packet
(
int
opcode
,
boolean
buildHeader
)
{
public
Base
Packet
(
int
opcode
,
boolean
buildHeader
)
{
this
.
opcode
=
opcode
;
this
.
opcode
=
opcode
;
this
.
shouldBuildHeader
=
buildHeader
;
this
.
shouldBuildHeader
=
buildHeader
;
}
}
...
@@ -80,7 +80,7 @@ public class GenshinPacket {
...
@@ -80,7 +80,7 @@ public class GenshinPacket {
this
.
data
=
proto
.
build
().
toByteArray
();
this
.
data
=
proto
.
build
().
toByteArray
();
}
}
public
Genshin
Packet
buildHeader
(
int
clientSequence
)
{
public
Base
Packet
buildHeader
(
int
clientSequence
)
{
if
(
this
.
getHeader
()
!=
null
&&
clientSequence
==
0
)
{
if
(
this
.
getHeader
()
!=
null
&&
clientSequence
==
0
)
{
return
this
;
return
this
;
}
}
...
...
Prev
1
2
3
4
5
6
7
8
9
…
14
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