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
02d2d728
Commit
02d2d728
authored
Apr 25, 2022
by
Melledy
Browse files
Dont deregister scenes if the player is going to tp back into them
parent
b8614d63
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/GenshinScene.java
View file @
02d2d728
...
...
@@ -47,6 +47,7 @@ public class GenshinScene {
private
final
Set
<
SpawnDataEntry
>
spawnedEntities
;
private
final
Set
<
SpawnDataEntry
>
deadSpawnedEntities
;
private
boolean
dontDestroyWhenEmpty
;
private
int
time
;
private
ClimateType
climate
;
...
...
@@ -121,6 +122,14 @@ public class GenshinScene {
this
.
weather
=
weather
;
}
public
boolean
dontDestroyWhenEmpty
()
{
return
dontDestroyWhenEmpty
;
}
public
void
setDontDestroyWhenEmpty
(
boolean
dontDestroyWhenEmpty
)
{
this
.
dontDestroyWhenEmpty
=
dontDestroyWhenEmpty
;
}
public
Set
<
SpawnDataEntry
>
getSpawnedEntities
()
{
return
spawnedEntities
;
}
...
...
@@ -166,7 +175,7 @@ public class GenshinScene {
}
// Deregister scene if not in use
if
(
this
.
getEntities
().
size
()
<=
0
)
{
if
(
this
.
getEntities
().
size
()
<=
0
&&
!
this
.
dontDestroyWhenEmpty
()
)
{
this
.
getWorld
().
deregisterScene
(
this
);
}
}
...
...
src/main/java/emu/grasscutter/game/World.java
View file @
02d2d728
...
...
@@ -212,19 +212,29 @@ public class World implements Iterable<GenshinPlayer> {
return
false
;
}
Integer
oldScene
Id
=
null
;
GenshinScene
oldScene
=
null
;
if
(
player
.
getScene
()
!=
null
)
{
oldSceneId
=
player
.
getScene
().
getId
();
player
.
getScene
().
removePlayer
(
player
);
oldScene
=
player
.
getScene
();
// Dont deregister scenes if the player is going to tp back into them
if
(
oldScene
.
getId
()
==
sceneId
)
{
oldScene
.
setDontDestroyWhenEmpty
(
true
);
}
GenshinScene
scene
=
this
.
getSceneById
(
sceneId
);
scene
.
addPlayer
(
player
);
oldScene
.
removePlayer
(
player
);
}
GenshinScene
newScene
=
this
.
getSceneById
(
sceneId
);
newScene
.
addPlayer
(
player
);
player
.
getPos
().
set
(
pos
);
if
(
oldScene
!=
null
)
{
oldScene
.
setDontDestroyWhenEmpty
(
false
);
}
// Teleport packet
if
(
oldScene
Id
.
equals
(
s
cene
Id
)
)
{
if
(
oldScene
==
newS
cene
)
{
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
EnterGoto
,
EnterReason
.
TransPoint
,
sceneId
,
pos
));
}
else
{
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
EnterJump
,
EnterReason
.
TransPoint
,
sceneId
,
pos
));
...
...
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