MCPcopy Create free account
hub / github.com/demoth/jake2 / SpawnNewEntity

Method SpawnNewEntity

game/src/main/java/jake2/game/GameSpawn.java:1037–1070  ·  view source on GitHub ↗
(SubgameEntity creator, List<String> args, GameExportsImpl gameExports)

Source from the content-addressed store, hash-verified

1035 }
1036
1037 static void SpawnNewEntity(SubgameEntity creator, List<String> args, GameExportsImpl gameExports) {
1038 String className;
1039 if (args.size() >= 2)
1040 className = args.get(1);
1041 else {
1042 gameExports.gameImports.dprintf("usage: spawn <classname>\n");
1043 return;
1044 }
1045
1046 if (gameExports.gameCvars.deathmatch.value != 0 && gameExports.gameCvars.sv_cheats.value == 0) {
1047 gameExports.gameImports.cprintf(creator, Defines.PRINT_HIGH,
1048 "You must run the server with '+set cheats 1' to enable this command.\n");
1049 return;
1050 }
1051
1052 gameExports.gameImports.dprintf("Spawning " + className + " at " + Lib.vtofs(creator.s.origin) + ", " + Lib.vtofs(creator.s.angles) + "\n");
1053
1054 var spawn = spawns.get(className);
1055 GameItem gitem_t = GameItems.FindItemByClassname(className, gameExports);
1056 if (spawn != null || gitem_t != null) {
1057 SubgameEntity newThing = gameExports.G_Spawn();
1058
1059 putInFrontOfCreator(creator, newThing);
1060
1061 newThing.classname = className;
1062 gameExports.gameImports.linkentity(newThing);
1063 if (spawn != null)
1064 spawn.spawn(newThing, gameExports);
1065 else
1066 GameItems.SpawnItem(newThing, gitem_t, gameExports);
1067
1068 gameExports.gameImports.dprintf("Spawned!\n");
1069 }
1070 }
1071
1072 private static void putInFrontOfCreator(SubgameEntity creator, SubgameEntity newThing) {
1073 float[] location = creator.s.origin;

Callers 2

SpawnRandomMonsterMethod · 0.95
ClientCommandMethod · 0.95

Calls 11

vtofsMethod · 0.95
FindItemByClassnameMethod · 0.95
putInFrontOfCreatorMethod · 0.95
SpawnItemMethod · 0.95
sizeMethod · 0.80
G_SpawnMethod · 0.80
spawnMethod · 0.80
dprintfMethod · 0.65
cprintfMethod · 0.65
linkentityMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected