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
06a50365
Commit
06a50365
authored
Apr 19, 2022
by
Melledy
Browse files
Merge branch 'dev-scene'
parents
2d2013df
d9fc1595
Changes
64
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/entity/EntityItem.java
View file @
06a50365
...
...
@@ -2,6 +2,7 @@ package emu.grasscutter.game.entity;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.props.EntityIdType
;
...
...
@@ -30,12 +31,12 @@ public class EntityItem extends EntityGadget {
private
final
GenshinItem
item
;
private
final
long
guid
;
public
EntityItem
(
World
world
,
GenshinPlayer
player
,
ItemData
itemData
,
Position
pos
,
int
count
)
{
super
(
world
);
this
.
id
=
w
orld
.
getNextEntityId
(
EntityIdType
.
GADGET
);
public
EntityItem
(
GenshinScene
scene
,
GenshinPlayer
player
,
ItemData
itemData
,
Position
pos
,
int
count
)
{
super
(
scene
);
this
.
id
=
getScene
().
getW
orld
()
.
getNextEntityId
(
EntityIdType
.
GADGET
);
this
.
pos
=
new
Position
(
pos
);
this
.
rot
=
new
Position
();
this
.
guid
=
player
.
getNextGuid
();
this
.
guid
=
player
.
getNextG
enshinG
uid
();
this
.
item
=
new
GenshinItem
(
itemData
,
count
);
}
...
...
src/main/java/emu/grasscutter/game/entity/EntityMonster.java
View file @
06a50365
...
...
@@ -4,6 +4,7 @@ import emu.grasscutter.data.GenshinData;
import
emu.grasscutter.data.common.PropGrowCurve
;
import
emu.grasscutter.data.def.MonsterCurveData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FightProperty
;
...
...
@@ -36,9 +37,9 @@ public class EntityMonster extends GenshinEntity {
private
final
int
level
;
private
int
weaponEntityId
;
public
EntityMonster
(
World
world
,
MonsterData
monsterData
,
Position
pos
,
int
level
)
{
super
(
world
);
this
.
id
=
w
orld
.
getNextEntityId
(
EntityIdType
.
MONSTER
);
public
EntityMonster
(
GenshinScene
scene
,
MonsterData
monsterData
,
Position
pos
,
int
level
)
{
super
(
scene
);
this
.
id
=
getW
orld
()
.
getNextEntityId
(
EntityIdType
.
MONSTER
);
this
.
monsterData
=
monsterData
;
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
pos
=
new
Position
(
pos
);
...
...
@@ -48,7 +49,7 @@ public class EntityMonster extends GenshinEntity {
// Monster weapon
if
(
getMonsterWeaponId
()
>
0
)
{
this
.
weaponEntityId
=
w
orld
.
getNextEntityId
(
EntityIdType
.
WEAPON
);
this
.
weaponEntityId
=
getW
orld
()
.
getNextEntityId
(
EntityIdType
.
WEAPON
);
}
this
.
recalcStats
();
...
...
src/main/java/emu/grasscutter/game/entity/GenshinEntity.java
View file @
06a50365
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.GenshinScene
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.LifeState
;
...
...
@@ -12,14 +13,14 @@ import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public
abstract
class
GenshinEntity
{
protected
int
id
;
private
final
World
world
;
private
final
GenshinScene
scene
;
private
MotionState
moveState
;
private
int
lastMoveSceneTimeMs
;
private
int
lastMoveReliableSeq
;
public
GenshinEntity
(
World
world
)
{
this
.
world
=
world
;
public
GenshinEntity
(
GenshinScene
scene
)
{
this
.
scene
=
scene
;
this
.
moveState
=
MotionState
.
MotionNone
;
}
...
...
@@ -28,7 +29,11 @@ public abstract class GenshinEntity {
}
public
World
getWorld
()
{
return
world
;
return
this
.
getScene
().
getWorld
();
}
public
GenshinScene
getScene
()
{
return
this
.
scene
;
}
public
boolean
isAlive
()
{
...
...
src/main/java/emu/grasscutter/game/friends/FriendsList.java
View file @
06a50365
...
...
@@ -79,11 +79,11 @@ public class FriendsList {
}
// Make sure asker cant do anything
if
(
myFriendship
.
getAskerId
()
==
this
.
getPlayer
().
get
I
d
())
{
if
(
myFriendship
.
getAskerId
()
==
this
.
getPlayer
().
get
Ui
d
())
{
return
;
}
GenshinPlayer
target
=
getPlayer
().
getSession
().
getServer
().
forceG
etPlayerBy
I
d
(
targetUid
);
GenshinPlayer
target
=
getPlayer
().
getSession
().
getServer
().
g
etPlayerBy
Ui
d
(
targetUid
,
true
);
if
(
target
==
null
)
{
return
;
// Should never happen
}
...
...
@@ -91,7 +91,7 @@ public class FriendsList {
// Get target's friendship
Friendship
theirFriendship
=
null
;
if
(
target
.
isOnline
())
{
theirFriendship
=
target
.
getFriendsList
().
getPendingFriendById
(
this
.
getPlayer
().
get
I
d
());
theirFriendship
=
target
.
getFriendsList
().
getPendingFriendById
(
this
.
getPlayer
().
get
Ui
d
());
}
else
{
theirFriendship
=
DatabaseHelper
.
getReverseFriendship
(
myFriendship
);
}
...
...
@@ -112,7 +112,7 @@ public class FriendsList {
this
.
addFriend
(
myFriendship
);
if
(
target
.
isOnline
())
{
target
.
getFriendsList
().
getPendingFriends
().
remove
(
this
.
getPlayer
().
get
I
d
());
target
.
getFriendsList
().
getPendingFriends
().
remove
(
this
.
getPlayer
().
get
Ui
d
());
target
.
getFriendsList
().
addFriend
(
theirFriendship
);
}
...
...
@@ -124,7 +124,7 @@ public class FriendsList {
myFriendship
.
delete
();
// Delete from target uid
if
(
target
.
isOnline
())
{
theirFriendship
=
target
.
getFriendsList
().
getPendingFriendById
(
this
.
getPlayer
().
get
I
d
());
theirFriendship
=
target
.
getFriendsList
().
getPendingFriendById
(
this
.
getPlayer
().
get
Ui
d
());
}
theirFriendship
.
delete
();
}
...
...
@@ -146,7 +146,7 @@ public class FriendsList {
GenshinPlayer
friend
=
myFriendship
.
getFriendProfile
().
getPlayer
();
if
(
friend
!=
null
)
{
// Friend online
theirFriendship
=
friend
.
getFriendsList
().
getFriendById
(
this
.
getPlayer
().
get
I
d
());
theirFriendship
=
friend
.
getFriendsList
().
getFriendById
(
this
.
getPlayer
().
get
Ui
d
());
if
(
theirFriendship
!=
null
)
{
friend
.
getFriendsList
().
getFriends
().
remove
(
theirFriendship
.
getFriendId
());
theirFriendship
.
delete
();
...
...
@@ -165,7 +165,7 @@ public class FriendsList {
}
public
synchronized
void
sendFriendRequest
(
int
targetUid
)
{
GenshinPlayer
target
=
getPlayer
().
getSession
().
getServer
().
forceG
etPlayerBy
I
d
(
targetUid
);
GenshinPlayer
target
=
getPlayer
().
getSession
().
getServer
().
g
etPlayerBy
Ui
d
(
targetUid
,
true
);
if
(
target
==
null
||
target
==
this
.
getPlayer
())
{
return
;
...
...
@@ -220,14 +220,14 @@ public class FriendsList {
friendship
.
setOwner
(
getPlayer
());
// Check if friend is online
GenshinPlayer
friend
=
getPlayer
().
getSession
().
getServer
().
getPlayerBy
I
d
(
friendship
.
getFriendProfile
().
getId
());
GenshinPlayer
friend
=
getPlayer
().
getSession
().
getServer
().
getPlayerBy
Ui
d
(
friendship
.
getFriendProfile
().
getId
());
if
(
friend
!=
null
)
{
// Set friend to online mode
friendship
.
setFriendProfile
(
friend
);
// Update our status on friend's client if theyre online
if
(
friend
.
getFriendsList
().
hasLoaded
())
{
Friendship
theirFriendship
=
friend
.
getFriendsList
().
getFriendshipById
(
getPlayer
().
get
I
d
());
Friendship
theirFriendship
=
friend
.
getFriendsList
().
getFriendshipById
(
getPlayer
().
get
Ui
d
());
if
(
theirFriendship
!=
null
)
{
// Update friend profile
theirFriendship
.
setFriendProfile
(
getPlayer
());
...
...
src/main/java/emu/grasscutter/game/friends/Friendship.java
View file @
06a50365
...
...
@@ -27,10 +27,10 @@ public class Friendship {
public
Friendship
(
GenshinPlayer
owner
,
GenshinPlayer
friend
,
GenshinPlayer
asker
)
{
this
.
setOwner
(
owner
);
this
.
ownerId
=
owner
.
get
I
d
();
this
.
friendId
=
friend
.
get
I
d
();
this
.
ownerId
=
owner
.
get
Ui
d
();
this
.
friendId
=
friend
.
get
Ui
d
();
this
.
profile
=
friend
.
getProfile
();
this
.
askerId
=
asker
.
get
I
d
();
this
.
askerId
=
asker
.
get
Ui
d
();
}
public
GenshinPlayer
getOwner
()
{
...
...
@@ -70,7 +70,7 @@ public class Friendship {
}
public
void
setFriendProfile
(
GenshinPlayer
character
)
{
if
(
character
==
null
||
this
.
friendId
!=
character
.
get
I
d
())
return
;
if
(
character
==
null
||
this
.
friendId
!=
character
.
get
Ui
d
())
return
;
this
.
profile
=
character
.
getProfile
();
}
...
...
src/main/java/emu/grasscutter/game/friends/PlayerProfile.java
View file @
06a50365
...
...
@@ -22,7 +22,7 @@ public class PlayerProfile {
public
PlayerProfile
()
{
}
public
PlayerProfile
(
GenshinPlayer
player
)
{
this
.
id
=
player
.
get
I
d
();
this
.
id
=
player
.
get
Ui
d
();
this
.
syncWithCharacter
(
player
);
}
...
...
src/main/java/emu/grasscutter/game/inventory/GenshinItem.java
View file @
06a50365
...
...
@@ -125,8 +125,8 @@ public class GenshinItem {
}
public
void
setOwner
(
GenshinPlayer
player
)
{
this
.
ownerId
=
player
.
get
I
d
();
this
.
guid
=
player
.
getNextGuid
();
this
.
ownerId
=
player
.
get
Ui
d
();
this
.
guid
=
player
.
getNextG
enshinG
uid
();
}
public
int
getItemId
()
{
return
itemId
;
...
...
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
06a50365
...
...
@@ -6,6 +6,7 @@ import java.util.LinkedList;
import
java.util.List
;
import
emu.grasscutter.GenshinConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.def.AvatarCostumeData
;
import
emu.grasscutter.data.def.AvatarData
;
...
...
@@ -36,10 +37,10 @@ public class Inventory implements Iterable<GenshinItem> {
this
.
store
=
new
Long2ObjectOpenHashMap
<>();
this
.
inventoryTypes
=
new
Int2ObjectOpenHashMap
<>();
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
G
enshinConstants
.
LIMIT_WEAPON
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
G
enshinConstants
.
LIMIT_RELIC
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
G
enshinConstants
.
LIMIT_MATERIAL
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
G
enshinConstants
.
LIMIT_FURNITURE
));
this
.
createInventoryTab
(
ItemType
.
ITEM_WEAPON
,
new
EquipInventoryTab
(
G
rasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitWeapon
));
this
.
createInventoryTab
(
ItemType
.
ITEM_RELIQUARY
,
new
EquipInventoryTab
(
G
rasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitRelic
));
this
.
createInventoryTab
(
ItemType
.
ITEM_MATERIAL
,
new
MaterialInventoryTab
(
G
rasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitMaterial
));
this
.
createInventoryTab
(
ItemType
.
ITEM_FURNITURE
,
new
MaterialInventoryTab
(
G
rasscutter
.
getConfig
().
getServerOptions
().
InventoryLimitFurniture
));
}
public
GenshinPlayer
getPlayer
()
{
...
...
src/main/java/emu/grasscutter/game/managers/ChatManager.java
View file @
06a50365
...
...
@@ -36,14 +36,14 @@ public class ChatManager {
}
// Get target
GenshinPlayer
target
=
getServer
().
getPlayerBy
I
d
(
targetUid
);
GenshinPlayer
target
=
getServer
().
getPlayerBy
Ui
d
(
targetUid
);
if
(
target
==
null
)
{
return
;
}
// Create chat packet
GenshinPacket
packet
=
new
PacketPrivateChatNotify
(
player
.
get
I
d
(),
target
.
get
I
d
(),
message
);
GenshinPacket
packet
=
new
PacketPrivateChatNotify
(
player
.
get
Ui
d
(),
target
.
get
Ui
d
(),
message
);
player
.
sendPacket
(
packet
);
target
.
sendPacket
(
packet
);
...
...
@@ -51,14 +51,14 @@ public class ChatManager {
public
void
sendPrivateMessage
(
GenshinPlayer
player
,
int
targetUid
,
int
emote
)
{
// Get target
GenshinPlayer
target
=
getServer
().
getPlayerBy
I
d
(
targetUid
);
GenshinPlayer
target
=
getServer
().
getPlayerBy
Ui
d
(
targetUid
);
if
(
target
==
null
)
{
return
;
}
// Create chat packet
GenshinPacket
packet
=
new
PacketPrivateChatNotify
(
player
.
get
I
d
(),
target
.
get
I
d
(),
emote
);
GenshinPacket
packet
=
new
PacketPrivateChatNotify
(
player
.
get
Ui
d
(),
target
.
get
Ui
d
(),
emote
);
player
.
sendPacket
(
packet
);
target
.
sendPacket
(
packet
);
...
...
src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java
View file @
06a50365
...
...
@@ -24,7 +24,7 @@ public class MultiplayerManager {
}
public
void
applyEnterMp
(
GenshinPlayer
player
,
int
targetUid
)
{
GenshinPlayer
target
=
getServer
().
getPlayerBy
I
d
(
targetUid
);
GenshinPlayer
target
=
getServer
().
getPlayerBy
Ui
d
(
targetUid
);
if
(
target
==
null
)
{
player
.
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
targetUid
,
""
,
false
,
PlayerApplyEnterMpReason
.
PlayerCannotEnterMp
));
return
;
...
...
@@ -35,13 +35,15 @@ public class MultiplayerManager {
return
;
}
/*
if (target.getWorld().isDungeon()) {
player.sendPacket(new PacketPlayerApplyEnterMpResultNotify(targetUid, "", false, PlayerApplyEnterMpReason.SceneCannotEnter));
return;
}
*/
// Get request
CoopRequest
request
=
target
.
getCoopRequests
().
get
(
player
.
get
I
d
());
CoopRequest
request
=
target
.
getCoopRequests
().
get
(
player
.
get
Ui
d
());
if
(
request
!=
null
&&
!
request
.
isExpired
())
{
// Join request already exists
...
...
@@ -50,31 +52,31 @@ public class MultiplayerManager {
// Put request in
request
=
new
CoopRequest
(
player
);
target
.
getCoopRequests
().
put
(
player
.
get
I
d
(),
request
);
target
.
getCoopRequests
().
put
(
player
.
get
Ui
d
(),
request
);
// Packet
target
.
sendPacket
(
new
PacketPlayerApplyEnterMpNotify
(
player
));
}
public
void
applyEnterMpReply
(
GenshinPlayer
p
layer
,
int
applyUid
,
boolean
isAgreed
)
{
public
void
applyEnterMpReply
(
GenshinPlayer
hostP
layer
,
int
applyUid
,
boolean
isAgreed
)
{
// Checks
CoopRequest
request
=
p
layer
.
getCoopRequests
().
get
(
applyUid
);
CoopRequest
request
=
hostP
layer
.
getCoopRequests
().
get
(
applyUid
);
if
(
request
==
null
||
request
.
isExpired
())
{
return
;
}
// Remove now that we are handling it
GenshinPlayer
requester
=
request
.
getRequester
();
p
layer
.
getCoopRequests
().
remove
(
applyUid
);
hostP
layer
.
getCoopRequests
().
remove
(
applyUid
);
// Sanity checks - Dont let player join if already in multiplayer
// Sanity checks - Dont let
the requesting
player join if
they are
already in multiplayer
if
(
requester
.
getWorld
().
isMultiplayer
())
{
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
p
layer
,
false
,
PlayerApplyEnterMpReason
.
PlayerCannotEnterMp
));
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostP
layer
,
false
,
PlayerApplyEnterMpReason
.
PlayerCannotEnterMp
));
return
;
}
// Response packet
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
p
layer
,
isAgreed
,
PlayerApplyEnterMpReason
.
PlayerJudge
));
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostP
layer
,
isAgreed
,
PlayerApplyEnterMpReason
.
PlayerJudge
));
// Declined
if
(!
isAgreed
)
{
...
...
@@ -82,24 +84,27 @@ public class MultiplayerManager {
}
// Success
if
(!
p
layer
.
getWorld
().
isMultiplayer
())
{
if
(!
hostP
layer
.
getWorld
().
isMultiplayer
())
{
// Player not in multiplayer, create multiplayer world
World
world
=
new
World
(
p
layer
,
true
);
World
world
=
new
World
(
hostP
layer
,
true
);
// Add
world
.
addPlayer
(
p
layer
);
world
.
addPlayer
(
hostP
layer
);
// Rejoin packet
p
layer
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
p
layer
,
p
layer
,
EnterType
.
EnterSelf
,
EnterReason
.
HostFromSingleToMp
,
p
layer
.
get
World
().
get
Scene
Id
(),
p
layer
.
getPos
()));
hostP
layer
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
hostP
layer
,
hostP
layer
,
EnterType
.
EnterSelf
,
EnterReason
.
HostFromSingleToMp
,
hostP
layer
.
get
Scene
().
getId
(),
hostP
layer
.
getPos
()));
}
// Set scene pos and id of requester to the host player's
requester
.
getPos
().
set
(
hostPlayer
.
getPos
());
requester
.
getRotation
().
set
(
hostPlayer
.
getRotation
());
requester
.
setSceneId
(
hostPlayer
.
getSceneId
());
// Make requester join
p
layer
.
getWorld
().
addPlayer
(
requester
);
hostP
layer
.
getWorld
().
addPlayer
(
requester
);
// Packet
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
player
,
EnterType
.
EnterOther
,
EnterReason
.
TeamJoin
,
player
.
getWorld
().
getSceneId
(),
player
.
getPos
()));
requester
.
getPos
().
set
(
player
.
getPos
());
requester
.
getRotation
().
set
(
player
.
getRotation
());
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
hostPlayer
,
EnterType
.
EnterOther
,
EnterReason
.
TeamJoin
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
}
public
boolean
leaveCoop
(
GenshinPlayer
player
)
{
...
...
@@ -120,7 +125,7 @@ public class MultiplayerManager {
world
.
addPlayer
(
player
);
// Packet
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
EnterSelf
,
EnterReason
.
TeamBack
,
player
.
get
World
().
get
Scene
Id
(),
player
.
getPos
()));
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
EnterSelf
,
EnterReason
.
TeamBack
,
player
.
get
Scene
().
getId
(),
player
.
getPos
()));
return
true
;
}
...
...
@@ -132,7 +137,7 @@ public class MultiplayerManager {
}
// Get victim and sanity checks
GenshinPlayer
victim
=
player
.
getServer
().
getPlayerBy
I
d
(
targetUid
);
GenshinPlayer
victim
=
player
.
getServer
().
getPlayerBy
Ui
d
(
targetUid
);
if
(
victim
==
null
||
victim
==
player
)
{
return
false
;
...
...
@@ -147,7 +152,7 @@ public class MultiplayerManager {
World
world
=
new
World
(
victim
);
world
.
addPlayer
(
victim
);
victim
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
victim
,
EnterType
.
EnterSelf
,
EnterReason
.
TeamKick
,
victim
.
get
World
().
get
Scene
Id
(),
victim
.
getPos
()));
victim
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
victim
,
EnterType
.
EnterSelf
,
EnterReason
.
TeamKick
,
victim
.
get
Scene
().
getId
(),
victim
.
getPos
()));
return
true
;
}
}
src/main/java/emu/grasscutter/game/props/SceneType.java
0 → 100644
View file @
06a50365
package
emu.grasscutter.game.props
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Stream
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
SceneType
{
SCENE_NONE
(
0
),
SCENE_WORLD
(
1
),
SCENE_DUNGEON
(
2
),
SCENE_ROOM
(
3
),
SCENE_HOME_WORLD
(
4
),
SCENE_HOME_ROOM
(
5
),
SCENE_ACTIVITY
(
6
);
private
final
int
value
;
private
static
final
Int2ObjectMap
<
SceneType
>
map
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Map
<
String
,
SceneType
>
stringMap
=
new
HashMap
<>();
static
{
Stream
.
of
(
values
()).
forEach
(
e
->
{
map
.
put
(
e
.
getValue
(),
e
);
stringMap
.
put
(
e
.
name
(),
e
);
});
}
private
SceneType
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
public
static
SceneType
getTypeByValue
(
int
value
)
{
return
map
.
getOrDefault
(
value
,
SCENE_NONE
);
}
public
static
SceneType
getTypeByName
(
String
name
)
{
return
stringMap
.
getOrDefault
(
name
,
SCENE_NONE
);
}
}
src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java
View file @
06a50365
...
...
@@ -958,6 +958,7 @@ public class PacketOpcodes {
public
static
final
int
SceneTimeNotify
=
229
;
public
static
final
int
SceneTransToPointReq
=
256
;
public
static
final
int
SceneTransToPointRsp
=
283
;
public
static
final
int
SceneUnlockInfoNotify
=
3386
;
public
static
final
int
SceneWeatherForcastReq
=
3167
;
public
static
final
int
SceneWeatherForcastRsp
=
3023
;
public
static
final
int
SeaLampCoinNotify
=
2028
;
...
...
src/main/java/emu/grasscutter/server/game/GameServer.java
View file @
06a50365
...
...
@@ -104,21 +104,25 @@ public final class GameServer extends MihoyoKcpServer {
}
public
void
registerPlayer
(
GenshinPlayer
player
)
{
getPlayers
().
put
(
player
.
get
I
d
(),
player
);
getPlayers
().
put
(
player
.
get
Ui
d
(),
player
);
}
public
GenshinPlayer
getPlayerBy
I
d
(
int
id
)
{
return
this
.
getPlayer
s
().
get
(
id
);
public
GenshinPlayer
getPlayerBy
Ui
d
(
int
id
)
{
return
this
.
getPlayer
ByUid
(
id
,
false
);
}
public
GenshinPlayer
forceG
etPlayerBy
I
d
(
int
id
)
{
public
GenshinPlayer
g
etPlayerBy
Ui
d
(
int
id
,
boolean
allowOfflinePlayers
)
{
// Console check
if
(
id
==
GenshinConstants
.
SERVER_CONSOLE_UID
)
{
return
null
;
}
// Get from online players
GenshinPlayer
player
=
this
.
getPlayerById
(
id
);
GenshinPlayer
player
=
this
.
getPlayerByUid
(
id
);
if
(!
allowOfflinePlayers
)
{
return
player
;
}
// Check database if character isnt here
if
(
player
==
null
)
{
...
...
@@ -128,9 +132,9 @@ public final class GameServer extends MihoyoKcpServer {
return
player
;
}
public
SocialDetail
.
Builder
getSocialDetailBy
I
d
(
int
id
)
{
public
SocialDetail
.
Builder
getSocialDetailBy
Ui
d
(
int
id
)
{
// Get from online players
GenshinPlayer
player
=
this
.
forceG
etPlayerBy
I
d
(
id
);
GenshinPlayer
player
=
this
.
g
etPlayerBy
Ui
d
(
id
,
true
);
if
(
player
==
null
)
{
return
null
;
...
...
src/main/java/emu/grasscutter/server/game/GameSession.java
View file @
06a50365
...
...
@@ -123,7 +123,7 @@ public class GameSession extends MihoyoKcpChannel {
// Save
getPlayer
().
onLogout
();
// Remove from gameserver
getServer
().
getPlayers
().
remove
(
getPlayer
().
get
I
d
());
getServer
().
getPlayers
().
remove
(
getPlayer
().
get
Ui
d
());
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerChangeGameTimeReq.java
View file @
06a50365
...
...
@@ -14,8 +14,8 @@ public class HandlerChangeGameTimeReq extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
ChangeGameTimeReq
req
=
ChangeGameTimeReq
.
parseFrom
(
payload
);
session
.
getPlayer
().
get
World
().
changeTime
(
req
.
getGameTime
());
session
.
getPlayer
().
sendPacket
(
new
PacketChangeGameTimeRsp
(
session
.
getPlayer
()
.
getWorld
()
));
session
.
getPlayer
().
get
Scene
().
changeTime
(
req
.
getGameTime
());
session
.
getPlayer
().
sendPacket
(
new
PacketChangeGameTimeRsp
(
session
.
getPlayer
()));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java
View file @
06a50365
...
...
@@ -22,12 +22,12 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
case
CombatEvtBeingHit:
// Handle damage
EvtBeingHitInfo
hitInfo
=
EvtBeingHitInfo
.
parseFrom
(
entry
.
getCombatData
());
session
.
getPlayer
().
get
World
().
handleAttack
(
hitInfo
.
getAttackResult
());
session
.
getPlayer
().
get
Scene
().
handleAttack
(
hitInfo
.
getAttackResult
());
break
;
case
EntityMove:
// Handle movement
EntityMoveInfo
moveInfo
=
EntityMoveInfo
.
parseFrom
(
entry
.
getCombatData
());
GenshinEntity
entity
=
session
.
getPlayer
().
get
World
().
getEntityById
(
moveInfo
.
getEntityId
());
GenshinEntity
entity
=
session
.
getPlayer
().
get
Scene
().
getEntityById
(
moveInfo
.
getEntityId
());
if
(
entity
!=
null
)
{
entity
.
getPosition
().
set
(
moveInfo
.
getMotionInfo
().
getPos
());
entity
.
getRotation
().
set
(
moveInfo
.
getMotionInfo
().
getRot
());
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEnterSceneDoneReq.java
View file @
06a50365
...
...
@@ -24,10 +24,10 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
session
.
send
(
new
PacketPlayerTimeNotify
(
session
.
getPlayer
()));
// Probably not the right place
// Spawn player in world
session
.
getPlayer
().
get
World
().
spawnPlayer
(
session
.
getPlayer
());
session
.
getPlayer
().
get
Scene
().
spawnPlayer
(
session
.
getPlayer
());
// Spawn other entites already in world
session
.
getPlayer
().
get
World
().
showOtherEntities
(
session
.
getPlayer
());
session
.
getPlayer
().
get
Scene
().
showOtherEntities
(
session
.
getPlayer
());
// Locations
session
.
send
(
new
PacketWorldPlayerLocationNotify
(
session
.
getPlayer
().
getWorld
()));
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEntityAiSyncNotify.java
View file @
06a50365
...
...
@@ -15,7 +15,7 @@ public class HandlerEntityAiSyncNotify extends PacketHandler {
EntityAiSyncNotify
notify
=
EntityAiSyncNotify
.
parseFrom
(
payload
);
if
(
notify
.
getLocalAvatarAlertedMonsterListCount
()
>
0
)
{
session
.
getPlayer
().
get
World
().
broadcastPacket
(
new
PacketEntityAiSyncNotify
(
notify
));
session
.
getPlayer
().
get
Scene
().
broadcastPacket
(
new
PacketEntityAiSyncNotify
(
notify
));
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtCreateGadgetNotify.java
View file @
06a50365
...
...
@@ -20,13 +20,13 @@ public class HandlerEvtCreateGadgetNotify extends PacketHandler {
}
// Sanity check - dont add duplicate entities
if
(
session
.
getPlayer
().
get
World
().
getEntityById
(
notify
.
getEntityId
())
!=
null
)
{
if
(
session
.
getPlayer
().
get
Scene
().
getEntityById
(
notify
.
getEntityId
())
!=
null
)
{
return
;
}
// Create entity and summon in world
EntityClientGadget
gadget
=
new
EntityClientGadget
(
session
.
getPlayer
().
get
World
(),
session
.
getPlayer
(),
notify
);
session
.
getPlayer
().
get
World
().
onPlayerCreateGadget
(
gadget
);
EntityClientGadget
gadget
=
new
EntityClientGadget
(
session
.
getPlayer
().
get
Scene
(),
session
.
getPlayer
(),
notify
);
session
.
getPlayer
().
get
Scene
().
onPlayerCreateGadget
(
gadget
);
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDestroyGadgetNotify.java
View file @
06a50365
...
...
@@ -18,7 +18,7 @@ public class HandlerEvtDestroyGadgetNotify extends PacketHandler {
return
;
}
session
.
getPlayer
().
get
World
().
onPlayerDestroyGadget
(
notify
.
getEntityId
());
session
.
getPlayer
().
get
Scene
().
onPlayerDestroyGadget
(
notify
.
getEntityId
());
}
}
Prev
1
2
3
4
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