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
d05b3207
Commit
d05b3207
authored
Aug 04, 2022
by
Magix
Committed by
GitHub
Aug 04, 2022
Browse files
Add more events
Merge pull request #1516 from Grasscutters/more-events
parents
9a104f6f
a3e0f7f5
Changes
23
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneTransToPointReq.java
View file @
d05b3207
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.binout.ScenePointEntry
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SceneTransToPointReqOuterClass.SceneTransToPointReq
;
import
emu.grasscutter.net.proto.SceneTransToPointRspOuterClass.SceneTransToPointRsp
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketSceneTransToPointRsp
;
import
emu.grasscutter.utils.Position
;
@Opcodes
(
PacketOpcodes
.
SceneTransToPointReq
)
public
class
HandlerSceneTransToPointReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SceneTransToPointReq
req
=
SceneTransToPointReq
.
parseFrom
(
payload
);
String
code
=
req
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
code
);
if
(
scenePointEntry
!=
null
)
{
float
x
=
scenePointEntry
.
getPointData
().
getTranPos
().
getX
();
float
y
=
scenePointEntry
.
getPointData
().
getTranPos
().
getY
();
float
z
=
scenePointEntry
.
getPointData
().
getTranPos
().
getZ
();
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
req
.
getSceneId
(),
new
Position
(
x
,
y
,
z
));
session
.
send
(
new
PacketSceneTransToPointRsp
(
session
.
getPlayer
(),
req
.
getPointId
(),
req
.
getSceneId
()));
}
else
{
session
.
send
(
new
PacketSceneTransToPointRsp
());
}
}
}
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.binout.ScenePointEntry
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SceneTransToPointReqOuterClass.SceneTransToPointReq
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketSceneTransToPointRsp
;
import
emu.grasscutter.utils.Position
;
@Opcodes
(
PacketOpcodes
.
SceneTransToPointReq
)
public
class
HandlerSceneTransToPointReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SceneTransToPointReq
req
=
SceneTransToPointReq
.
parseFrom
(
payload
);
String
code
=
req
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
code
);
if
(
scenePointEntry
!=
null
)
{
float
x
=
scenePointEntry
.
getPointData
().
getTranPos
().
getX
();
float
y
=
scenePointEntry
.
getPointData
().
getTranPos
().
getY
();
float
z
=
scenePointEntry
.
getPointData
().
getTranPos
().
getZ
();
if
(
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
req
.
getSceneId
(),
TeleportType
.
WAYPOINT
,
new
Position
(
x
,
y
,
z
)))
{
session
.
send
(
new
PacketSceneTransToPointRsp
(
session
.
getPlayer
(),
req
.
getPointId
(),
req
.
getSceneId
()));
}
}
else
{
session
.
send
(
new
PacketSceneTransToPointRsp
());
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java
View file @
d05b3207
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.home.GameHome
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.TryEnterHomeReqOuterClass
;
import
emu.grasscutter.s
cripts.data.SceneConfig
;
import
emu.grasscutter.s
erver.event.player.PlayerTeleportEvent.TeleportType
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketTryEnterHomeRsp
;
import
emu.grasscutter.utils.Position
;
...
...
@@ -38,13 +35,10 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
Scene
scene
=
session
.
getPlayer
().
getWorld
().
getSceneById
(
realmId
);
Position
pos
=
scene
.
getScriptManager
().
getConfig
().
born_pos
;
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
realmId
,
pos
boolean
result
=
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
realmId
,
TeleportType
.
WAYPOINT
,
pos
);
session
.
send
(
new
PacketTryEnterHomeRsp
(
req
.
getTargetUid
()));
if
(
result
)
session
.
send
(
new
PacketTryEnterHomeRsp
(
req
.
getTargetUid
()));
}
}
src/main/java/emu/grasscutter/utils/Location.java
0 → 100644
View file @
d05b3207
package
emu.grasscutter.utils
;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.game.world.Scene
;
import
lombok.Getter
;
import
lombok.Setter
;
@Entity
public
class
Location
extends
Position
{
@Transient
@Getter
@Setter
private
Scene
scene
;
public
Location
(
Scene
scene
,
Position
position
)
{
this
.
set
(
position
);
this
.
scene
=
scene
;
}
public
Location
(
Scene
scene
,
float
x
,
float
y
)
{
this
.
set
(
x
,
y
);
this
.
scene
=
scene
;
}
public
Location
(
Scene
scene
,
float
x
,
float
y
,
float
z
)
{
this
.
set
(
x
,
y
,
z
);
this
.
scene
=
scene
;
}
@Override
public
Location
clone
()
{
return
new
Location
(
this
.
scene
,
super
.
clone
());
}
@Override
public
String
toString
()
{
return
String
.
format
(
"%s:%s,%s,%s"
,
this
.
scene
.
getId
(),
this
.
getX
(),
this
.
getY
(),
this
.
getZ
());
}
}
\ No newline at end of file
Prev
1
2
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