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
7a247e70
Commit
7a247e70
authored
Jun 15, 2022
by
Akka
Committed by
Melledy
Jun 17, 2022
Browse files
npc/animals arrangement & support enter room scene
parent
e16633e3
Changes
9
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/home/GameHome.java
View file @
7a247e70
...
@@ -65,6 +65,6 @@ public class GameHome {
...
@@ -65,6 +65,6 @@ public class GameHome {
player
.
getSession
().
send
(
new
PacketPlayerHomeCompInfoNotify
(
player
));
player
.
getSession
().
send
(
new
PacketPlayerHomeCompInfoNotify
(
player
));
player
.
getSession
().
send
(
new
PacketHomeComfortInfoNotify
(
player
));
player
.
getSession
().
send
(
new
PacketHomeComfortInfoNotify
(
player
));
player
.
getSession
().
send
(
new
PacketFurnitureCurModuleArrangeCountNotify
());
player
.
getSession
().
send
(
new
PacketFurnitureCurModuleArrangeCountNotify
());
player
.
getSession
().
send
(
new
Packet
UnlockedFurnitureFormulaDataNotify
(
));
player
.
getSession
().
send
(
new
Packet
HomeMarkPointNotify
(
player
,
this
));
}
}
}
}
src/main/java/emu/grasscutter/game/home/HomeAnimalItem.java
0 → 100644
View file @
7a247e70
package
emu.grasscutter.game.home
;
import
dev.morphia.annotations.Entity
;
import
emu.grasscutter.net.proto.HomeAnimalDataOuterClass
;
import
emu.grasscutter.net.proto.HomeFurnitureDataOuterClass
;
import
emu.grasscutter.utils.Position
;
import
lombok.AccessLevel
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.experimental.FieldDefaults
;
@Entity
@Data
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@Builder
(
builderMethodName
=
"of"
)
public
class
HomeAnimalItem
{
int
furnitureId
;
Position
spawnPos
;
Position
spawnRot
;
public
HomeAnimalDataOuterClass
.
HomeAnimalData
toProto
(){
return
HomeAnimalDataOuterClass
.
HomeAnimalData
.
newBuilder
()
.
setFurnitureId
(
furnitureId
)
.
setSpawnPos
(
spawnPos
.
toProto
())
.
setSpawnRot
(
spawnRot
.
toProto
())
.
build
();
}
public
static
HomeAnimalItem
parseFrom
(
HomeAnimalDataOuterClass
.
HomeAnimalData
homeAnimalData
)
{
return
HomeAnimalItem
.
of
()
.
furnitureId
(
homeAnimalData
.
getFurnitureId
())
.
spawnPos
(
new
Position
(
homeAnimalData
.
getSpawnPos
()))
.
spawnRot
(
new
Position
(
homeAnimalData
.
getSpawnRot
()))
.
build
();
}
}
src/main/java/emu/grasscutter/game/home/HomeBlockItem.java
View file @
7a247e70
...
@@ -16,13 +16,12 @@ import java.util.List;
...
@@ -16,13 +16,12 @@ import java.util.List;
@Builder
(
builderMethodName
=
"of"
)
@Builder
(
builderMethodName
=
"of"
)
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
HomeBlockItem
{
public
class
HomeBlockItem
{
@Id
@Id
int
blockId
;
int
blockId
;
boolean
unlocked
;
boolean
unlocked
;
List
<
HomeFurnitureItem
>
deployFurnitureList
;
List
<
HomeFurnitureItem
>
deployFurnitureList
;
List
<
HomeAnimalItem
>
deployAnimalList
;
List
<
HomeNPCItem
>
deployNPCList
;
public
void
update
(
HomeBlockArrangementInfo
homeBlockArrangementInfo
)
{
public
void
update
(
HomeBlockArrangementInfo
homeBlockArrangementInfo
)
{
this
.
blockId
=
homeBlockArrangementInfo
.
getBlockId
();
this
.
blockId
=
homeBlockArrangementInfo
.
getBlockId
();
...
@@ -30,6 +29,14 @@ public class HomeBlockItem {
...
@@ -30,6 +29,14 @@ public class HomeBlockItem {
this
.
deployFurnitureList
=
homeBlockArrangementInfo
.
getDeployFurniureListList
().
stream
()
this
.
deployFurnitureList
=
homeBlockArrangementInfo
.
getDeployFurniureListList
().
stream
()
.
map
(
HomeFurnitureItem:
:
parseFrom
)
.
map
(
HomeFurnitureItem:
:
parseFrom
)
.
toList
();
.
toList
();
this
.
deployAnimalList
=
homeBlockArrangementInfo
.
getDeployAnimalListList
().
stream
()
.
map
(
HomeAnimalItem:
:
parseFrom
)
.
toList
();
this
.
deployNPCList
=
homeBlockArrangementInfo
.
getDeployNpcListList
().
stream
()
.
map
(
HomeNPCItem:
:
parseFrom
)
.
toList
();
}
}
public
int
calComfort
(){
public
int
calComfort
(){
...
@@ -45,6 +52,8 @@ public class HomeBlockItem {
...
@@ -45,6 +52,8 @@ public class HomeBlockItem {
.
setComfortValue
(
calComfort
());
.
setComfortValue
(
calComfort
());
this
.
deployFurnitureList
.
forEach
(
f
->
proto
.
addDeployFurniureList
(
f
.
toProto
()));
this
.
deployFurnitureList
.
forEach
(
f
->
proto
.
addDeployFurniureList
(
f
.
toProto
()));
this
.
deployAnimalList
.
forEach
(
f
->
proto
.
addDeployAnimalList
(
f
.
toProto
()));
this
.
deployNPCList
.
forEach
(
f
->
proto
.
addDeployNpcList
(
f
.
toProto
()));
return
proto
.
build
();
return
proto
.
build
();
}
}
...
@@ -59,6 +68,8 @@ public class HomeBlockItem {
...
@@ -59,6 +68,8 @@ public class HomeBlockItem {
homeBlock
.
getFurnitures
().
stream
()
homeBlock
.
getFurnitures
().
stream
()
.
map
(
HomeFurnitureItem:
:
parseFrom
)
.
map
(
HomeFurnitureItem:
:
parseFrom
)
.
toList
())
.
toList
())
.
deployAnimalList
(
List
.
of
())
.
deployNPCList
(
List
.
of
())
.
build
();
.
build
();
}
}
}
}
src/main/java/emu/grasscutter/game/home/HomeFurnitureItem.java
View file @
7a247e70
...
@@ -5,6 +5,7 @@ import emu.grasscutter.data.GameData;
...
@@ -5,6 +5,7 @@ import emu.grasscutter.data.GameData;
import
emu.grasscutter.data.binout.HomeworldDefaultSaveData
;
import
emu.grasscutter.data.binout.HomeworldDefaultSaveData
;
import
emu.grasscutter.data.excels.ItemData
;
import
emu.grasscutter.data.excels.ItemData
;
import
emu.grasscutter.net.proto.HomeFurnitureDataOuterClass
;
import
emu.grasscutter.net.proto.HomeFurnitureDataOuterClass
;
import
emu.grasscutter.net.proto.HomeMarkPointFurnitureDataOuterClass
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Position
;
import
lombok.AccessLevel
;
import
lombok.AccessLevel
;
import
lombok.Builder
;
import
lombok.Builder
;
...
@@ -32,6 +33,16 @@ public class HomeFurnitureItem {
...
@@ -32,6 +33,16 @@ public class HomeFurnitureItem {
.
build
();
.
build
();
}
}
public
HomeMarkPointFurnitureDataOuterClass
.
HomeMarkPointFurnitureData
toMarkPointProto
(
int
type
){
return
HomeMarkPointFurnitureDataOuterClass
.
HomeMarkPointFurnitureData
.
newBuilder
()
.
setFurnitureId
(
furnitureId
)
.
setGuid
(
guid
)
.
setFurnitureType
(
type
)
.
setPos
(
spawnPos
.
toProto
())
// TODO NPC and farm
.
build
();
}
public
static
HomeFurnitureItem
parseFrom
(
HomeFurnitureDataOuterClass
.
HomeFurnitureData
homeFurnitureData
)
{
public
static
HomeFurnitureItem
parseFrom
(
HomeFurnitureDataOuterClass
.
HomeFurnitureData
homeFurnitureData
)
{
return
HomeFurnitureItem
.
of
()
return
HomeFurnitureItem
.
of
()
.
furnitureId
(
homeFurnitureData
.
getFurnitureId
())
.
furnitureId
(
homeFurnitureData
.
getFurnitureId
())
...
...
src/main/java/emu/grasscutter/game/home/HomeNPCItem.java
0 → 100644
View file @
7a247e70
package
emu.grasscutter.game.home
;
import
dev.morphia.annotations.Entity
;
import
emu.grasscutter.net.proto.HomeAnimalDataOuterClass
;
import
emu.grasscutter.net.proto.HomeNpcDataOuterClass
;
import
emu.grasscutter.utils.Position
;
import
lombok.AccessLevel
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.experimental.FieldDefaults
;
@Entity
@Data
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@Builder
(
builderMethodName
=
"of"
)
public
class
HomeNPCItem
{
int
avatarId
;
Position
spawnPos
;
Position
spawnRot
;
int
costumeId
;
public
HomeNpcDataOuterClass
.
HomeNpcData
toProto
(){
return
HomeNpcDataOuterClass
.
HomeNpcData
.
newBuilder
()
.
setAvatarId
(
avatarId
)
.
setSpawnPos
(
spawnPos
.
toProto
())
.
setSpawnRot
(
spawnRot
.
toProto
())
.
setCostumeId
(
costumeId
)
.
build
();
}
public
static
HomeNPCItem
parseFrom
(
HomeNpcDataOuterClass
.
HomeNpcData
homeNpcData
)
{
return
HomeNPCItem
.
of
()
.
avatarId
(
homeNpcData
.
getAvatarId
())
.
spawnPos
(
new
Position
(
homeNpcData
.
getSpawnPos
()))
.
spawnRot
(
new
Position
(
homeNpcData
.
getSpawnRot
()))
.
costumeId
(
homeNpcData
.
getCostumeId
())
.
build
();
}
}
src/main/java/emu/grasscutter/game/home/HomeSceneItem.java
View file @
7a247e70
...
@@ -2,6 +2,7 @@ package emu.grasscutter.game.home;
...
@@ -2,6 +2,7 @@ package emu.grasscutter.game.home;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Id
;
import
dev.morphia.annotations.Id
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.binout.HomeworldDefaultSaveData
;
import
emu.grasscutter.data.binout.HomeworldDefaultSaveData
;
import
emu.grasscutter.net.proto.HomeBasicInfoOuterClass.HomeBasicInfo
;
import
emu.grasscutter.net.proto.HomeBasicInfoOuterClass.HomeBasicInfo
;
import
emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo
;
import
emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo
;
...
@@ -45,7 +46,7 @@ public class HomeSceneItem {
...
@@ -45,7 +46,7 @@ public class HomeSceneItem {
for
(
var
blockItem
:
arrangementInfo
.
getBlockArrangementInfoListList
()){
for
(
var
blockItem
:
arrangementInfo
.
getBlockArrangementInfoListList
()){
var
block
=
this
.
blockItems
.
get
(
blockItem
.
getBlockId
());
var
block
=
this
.
blockItems
.
get
(
blockItem
.
getBlockId
());
if
(
block
==
null
){
if
(
block
==
null
){
System
.
out
.
println
(
111
);
Grasscutter
.
getLogger
().
warn
(
"Could not found the Home Block {}"
,
blockItem
.
getBlockId
()
);
continue
;
continue
;
}
}
block
.
update
(
blockItem
);
block
.
update
(
blockItem
);
...
@@ -79,6 +80,7 @@ public class HomeSceneItem {
...
@@ -79,6 +80,7 @@ public class HomeSceneItem {
.
setBornPos
(
bornPos
.
toProto
())
.
setBornPos
(
bornPos
.
toProto
())
.
setBornRot
(
bornRot
.
toProto
())
.
setBornRot
(
bornRot
.
toProto
())
.
setDjinnPos
(
djinnPos
.
toProto
())
.
setDjinnPos
(
djinnPos
.
toProto
())
.
setIsSetBornPos
(
true
)
.
setSceneId
(
sceneId
)
.
setSceneId
(
sceneId
)
.
setTmpVersion
(
1
);
.
setTmpVersion
(
1
);
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeSceneJumpReq.java
View file @
7a247e70
package
emu.grasscutter.server.packet.recv
;
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.HomeSceneJumpReqOuterClass
;
import
emu.grasscutter.net.proto.HomeSceneJumpReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketHomeSceneJumpRsp
;
import
emu.grasscutter.server.packet.send.PacketHomeSceneJumpRsp
;
import
emu.grasscutter.utils.Position
;
@Opcodes
(
PacketOpcodes
.
HomeSceneJumpReq
)
@Opcodes
(
PacketOpcodes
.
HomeSceneJumpReq
)
public
class
HandlerHomeSceneJumpReq
extends
PacketHandler
{
public
class
HandlerHomeSceneJumpReq
extends
PacketHandler
{
...
@@ -20,21 +22,14 @@ public class HandlerHomeSceneJumpReq extends PacketHandler {
...
@@ -20,21 +22,14 @@ public class HandlerHomeSceneJumpReq extends PacketHandler {
var
homeScene
=
home
.
getHomeSceneItem
(
realmId
);
var
homeScene
=
home
.
getHomeSceneItem
(
realmId
);
home
.
save
();
home
.
save
();
if
(
req
.
getIsEnterRoomScene
()){
Scene
scene
=
session
.
getPlayer
().
getWorld
().
getSceneById
(
req
.
getIsEnterRoomScene
()
?
homeScene
.
getRoomSceneId
()
:
realmId
);
var
roomScene
=
home
.
getHomeSceneItem
(
homeScene
.
getRoomSceneId
())
;
Position
pos
=
scene
.
getScriptManager
().
getConfig
().
born_pos
;
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
session
.
getPlayer
(),
homeScene
.
getRoomSceneId
(),
req
.
getIsEnterRoomScene
()
?
homeScene
.
getRoomSceneId
()
:
realmId
,
roomScene
.
getBornPos
()
pos
);
);
}
else
{
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
realmId
,
homeScene
.
getBornPos
()
);
}
session
.
send
(
new
PacketHomeSceneJumpRsp
(
req
.
getIsEnterRoomScene
()));
session
.
send
(
new
PacketHomeSceneJumpRsp
(
req
.
getIsEnterRoomScene
()));
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java
View file @
7a247e70
...
@@ -30,13 +30,18 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
...
@@ -30,13 +30,18 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
int
realmId
=
2000
+
session
.
getPlayer
().
getCurrentRealmId
();
int
realmId
=
2000
+
session
.
getPlayer
().
getCurrentRealmId
();
var
home
=
session
.
getPlayer
().
getHome
();
var
home
=
session
.
getPlayer
().
getHome
();
// prepare the default arrangement for first come in
var
homeScene
=
home
.
getHomeSceneItem
(
realmId
);
var
homeScene
=
home
.
getHomeSceneItem
(
realmId
);
home
.
save
();
home
.
save
();
Scene
scene
=
session
.
getPlayer
().
getWorld
().
getSceneById
(
realmId
);
Position
pos
=
scene
.
getScriptManager
().
getConfig
().
born_pos
;
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
session
.
getPlayer
(),
realmId
,
realmId
,
homeScene
.
getBornPos
()
pos
);
);
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketHomeMarkPointNotify.java
View file @
7a247e70
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.home.GameHome
;
import
emu.grasscutter.game.home.GameHome
;
import
emu.grasscutter.game.home.HomeBlockItem
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.HomeMarkPointNotifyOuterClass
;
import
emu.grasscutter.net.proto.HomeMarkPointNotifyOuterClass
;
import
emu.grasscutter.net.proto.HomeMarkPointSceneDataOuterClass
;
import
java.util.Collection
;
public
class
PacketHomeMarkPointNotify
extends
BasePacket
{
public
class
PacketHomeMarkPointNotify
extends
BasePacket
{
...
@@ -13,6 +17,26 @@ public class PacketHomeMarkPointNotify extends BasePacket {
...
@@ -13,6 +17,26 @@ public class PacketHomeMarkPointNotify extends BasePacket {
var
proto
=
HomeMarkPointNotifyOuterClass
.
HomeMarkPointNotify
.
newBuilder
();
var
proto
=
HomeMarkPointNotifyOuterClass
.
HomeMarkPointNotify
.
newBuilder
();
for
(
var
moduleId
:
player
.
getRealmList
()){
var
homeScene
=
home
.
getHomeSceneItem
(
moduleId
+
2000
);
var
markPointData
=
HomeMarkPointSceneDataOuterClass
.
HomeMarkPointSceneData
.
newBuilder
()
.
setModuleId
(
moduleId
)
.
setSceneId
(
moduleId
+
2000
)
.
setTeapotSpiritPos
(
homeScene
.
getDjinnPos
().
toProto
());
// Now it only supports the teleport point
// TODO add more types
var
marks
=
homeScene
.
getBlockItems
().
values
().
stream
()
.
map
(
HomeBlockItem:
:
getDeployFurnitureList
)
.
flatMap
(
Collection:
:
stream
)
.
filter
(
i
->
i
.
getFurnitureId
()
==
373501
)
.
map
(
x
->
x
.
toMarkPointProto
(
3
))
.
toList
();
markPointData
.
addAllFurnitureList
(
marks
);
proto
.
addMarkPointDataList
(
markPointData
);
}
this
.
setData
(
proto
);
this
.
setData
(
proto
);
}
}
...
...
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