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
41542297
Commit
41542297
authored
Aug 27, 2022
by
AnimeGitB
Browse files
refactor HandlerWidgetDoBagReq
parent
badda362
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerWidgetDoBagReq.java
View file @
41542297
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.excels.GadgetData
;
import
emu.grasscutter.game.entity.EntityVehicle
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
...
...
@@ -14,60 +11,32 @@ import emu.grasscutter.server.packet.send.PacketWidgetDoBagRsp;
import
emu.grasscutter.server.packet.send.PacketWidgetGadgetDataNotify
;
import
emu.grasscutter.utils.Position
;
import
java.util.List
;
@Opcodes
(
PacketOpcodes
.
WidgetDoBagReq
)
public
class
HandlerWidgetDoBagReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
WidgetDoBagReqOuterClass
.
WidgetDoBagReq
req
=
WidgetDoBagReqOuterClass
.
WidgetDoBagReq
.
parseFrom
(
payload
);
var
locationInfo
=
req
.
getWidgetCreatorInfo
().
getLocationInfo
();
Position
pos
=
new
Position
(
locationInfo
.
getPos
());
Position
rot
=
new
Position
(
locationInfo
.
getRot
());
switch
(
req
.
getMaterialId
())
{
case
220026
->
{
GadgetData
gadgetData
=
GameData
.
getGadgetDataMap
().
get
(
70500025
);
Position
pos
=
new
Position
(
req
.
getWidgetCreatorInfo
().
getLocationInfo
().
getPos
());
Position
rot
=
new
Position
(
req
.
getWidgetCreatorInfo
().
getLocationInfo
().
getRot
());
GameEntity
entity
=
new
EntityVehicle
(
session
.
getPlayer
().
getScene
(),
session
.
getPlayer
(),
gadgetData
.
getId
(),
0
,
pos
,
rot
);
session
.
getPlayer
().
getScene
().
addEntity
(
entity
);
session
.
send
(
new
PacketWidgetGadgetDataNotify
(
70500025
,
entity
.
getId
()));
// ???
this
.
spawnVehicle
(
session
,
70500025
,
pos
,
rot
);
session
.
send
(
new
PacketWidgetCoolDownNotify
(
15
,
System
.
currentTimeMillis
()
+
5000L
,
true
));
session
.
send
(
new
PacketWidgetCoolDownNotify
(
15
,
System
.
currentTimeMillis
()
+
5000L
,
true
));
// Send twice, and I don't know why, Ask mhy
session
.
send
(
new
PacketWidgetDoBagRsp
());
}
case
220047
->
{
GadgetData
gadgetData
=
GameData
.
getGadgetDataMap
().
get
(
70800058
);
Position
pos
=
new
Position
(
req
.
getWidgetCreatorInfo
().
getLocationInfo
().
getPos
());
Position
rot
=
new
Position
(
req
.
getWidgetCreatorInfo
().
getLocationInfo
().
getRot
());
GameEntity
entity
=
new
EntityVehicle
(
session
.
getPlayer
().
getScene
(),
session
.
getPlayer
(),
gadgetData
.
getId
(),
0
,
pos
,
rot
);
session
.
getPlayer
().
getScene
().
addEntity
(
entity
);
session
.
send
(
new
PacketWidgetGadgetDataNotify
(
70800058
,
entity
.
getId
()));
// ???
// Send twice, and I don't know why, Ask mhy
session
.
send
(
new
PacketWidgetDoBagRsp
());
}
default
->
{
session
.
send
(
new
PacketWidgetDoBagRsp
());
}
case
220047
->
this
.
spawnVehicle
(
session
,
70800058
,
pos
,
rot
);
default
->
{}
}
session
.
send
(
new
PacketWidgetDoBagRsp
());
}
private
void
spawnVehicle
(
GameSession
session
,
int
gadgetId
,
Position
pos
,
Position
rot
)
throws
Exception
{
var
player
=
session
.
getPlayer
();
var
scene
=
player
.
getScene
();
var
entity
=
new
EntityVehicle
(
scene
,
player
,
gadgetId
,
0
,
pos
,
rot
);
scene
.
addEntity
(
entity
);
session
.
send
(
new
PacketWidgetGadgetDataNotify
(
gadgetId
,
entity
.
getId
()));
}
}
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