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
184eec82
Commit
184eec82
authored
May 30, 2022
by
Melledy
Browse files
Limit spawn amount if too many entities are in the world
Can be controlled in the config with `sceneEntityLimit`
parent
18721758
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/SpawnCommand.java
View file @
184eec82
...
...
@@ -20,6 +20,7 @@ import javax.swing.text.html.parser.Entity;
import
java.util.List
;
import
java.util.Random
;
import
static
emu
.
grasscutter
.
Configuration
.*;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"spawn"
,
usage
=
"spawn <entityId> [amount] [level(monster only)]"
,
permission
=
"server.spawn"
,
permissionTargeted
=
"server.spawn.others"
,
description
=
"commands.spawn.description"
)
...
...
@@ -54,7 +55,7 @@ public final class SpawnCommand implements CommandHandler {
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.spawn.usage"
));
return
;
}
MonsterData
monsterData
=
GameData
.
getMonsterDataMap
().
get
(
id
);
GadgetData
gadgetData
=
GameData
.
getGadgetDataMap
().
get
(
id
);
ItemData
itemData
=
GameData
.
getItemDataMap
().
get
(
id
);
...
...
@@ -62,7 +63,16 @@ public final class SpawnCommand implements CommandHandler {
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.generic.invalid.entityId"
));
return
;
}
Scene
scene
=
targetPlayer
.
getScene
();
if
(
scene
.
getEntities
().
size
()
+
amount
>
GAME_OPTIONS
.
sceneEntityLimit
)
{
amount
=
Math
.
max
(
Math
.
min
(
GAME_OPTIONS
.
sceneEntityLimit
-
scene
.
getEntities
().
size
(),
amount
),
0
);
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.spawn.limit_reached"
,
amount
));
if
(
amount
<=
0
)
{
return
;
}
}
double
maxRadius
=
Math
.
sqrt
(
amount
*
0.2
/
Math
.
PI
);
for
(
int
i
=
0
;
i
<
amount
;
i
++)
{
...
...
src/main/java/emu/grasscutter/utils/ConfigContainer.java
View file @
184eec82
...
...
@@ -171,7 +171,7 @@ public class ConfigContainer {
public
static
class
GameOptions
{
public
InventoryLimits
inventoryLimits
=
new
InventoryLimits
();
public
AvatarLimits
avatarLimits
=
new
AvatarLimits
();
public
int
world
EntityLimit
=
1000
;
// Unenforced. TODO: Implement.
public
int
scene
EntityLimit
=
1000
;
// Unenforced. TODO: Implement.
public
boolean
watchGachaConfig
=
false
;
public
boolean
enableShopItems
=
true
;
...
...
src/main/resources/languages/en-US.json
View file @
184eec82
...
...
@@ -306,6 +306,7 @@
"spawn"
:
{
"usage"
:
"Usage: spawn <entityID> [amount] [level(monster only)]"
,
"success"
:
"Spawned %s of %s."
,
"limit_reached"
:
"Scene spawn limit reached. Spawning %s entities instead."
,
"description"
:
"Spawns an entity near you"
},
"stop"
:
{
...
...
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