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