Skip to content

Commit 7402c5c

Browse files
committed
Support all living entity type names in spawn_mob(). (CMDHELPER-2894)
spawn_mob(entity_type(@uuid)) should always work now, as long as the entity type is living.
1 parent 9fdbe02 commit 7402c5c

File tree

5 files changed

+76
-39
lines changed

5 files changed

+76
-39
lines changed

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCWorld.java

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
485485
case CREEPER:
486486
mobType = Creeper.class;
487487
break;
488+
case DONKEY:
489+
mobType = Donkey.class;
490+
break;
488491
case ELDERGUARDIAN:
489492
mobType = ElderGuardian.class;
490493
break;
@@ -537,6 +540,9 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
537540
}
538541
}
539542
break;
543+
case HUSK:
544+
mobType = Husk.class;
545+
break;
540546
case ILLUSIONER:
541547
mobType = Illusioner.class;
542548
break;
@@ -550,8 +556,12 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
550556
mobType = MagmaCube.class;
551557
break;
552558
case MOOSHROOM:
559+
case MUSHROOMCOW:
553560
mobType = MushroomCow.class;
554561
break;
562+
case MULE:
563+
mobType = Mule.class;
564+
break;
555565
case OCELOT:
556566
mobType = Ocelot.class;
557567
break;
@@ -598,10 +608,14 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
598608
subClass = "";
599609
}
600610
break;
611+
case SKELETONHORSE:
612+
mobType = SkeletonHorse.class;
613+
break;
601614
case SLIME:
602615
mobType = Slime.class;
603616
break;
604617
case SNOWGOLEM:
618+
case SNOWMAN:
605619
mobType = Snowman.class;
606620
break;
607621
case SPIDER:
@@ -613,24 +627,30 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
613627
case SQUID:
614628
mobType = Squid.class;
615629
break;
616-
case VEX:
617-
mobType = Vex.class;
618-
break;
619-
case VILLAGER:
620-
mobType = Villager.class;
621-
break;
622-
case VINDICATOR:
623-
mobType = Vindicator.class;
630+
case STRAY:
631+
mobType = Stray.class;
624632
break;
625633
case WITCH:
626634
mobType = Witch.class;
627635
break;
628636
case WITHER:
629637
mobType = Wither.class;
630638
break;
639+
case WITHERSKELETON:
640+
mobType = WitherSkeleton.class;
641+
break;
631642
case WOLF:
632643
mobType = Wolf.class;
633644
break;
645+
case VEX:
646+
mobType = Vex.class;
647+
break;
648+
case VILLAGER:
649+
mobType = Villager.class;
650+
break;
651+
case VINDICATOR:
652+
mobType = Vindicator.class;
653+
break;
634654
case ZOMBIE:
635655
mobType = Zombie.class;
636656
if(!subClass.isEmpty() && version.gte(MCVersion.MC1_11)) {
@@ -666,6 +686,12 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
666686
}
667687
}
668688
break;
689+
case ZOMBIEHORSE:
690+
mobType = ZombieHorse.class;
691+
break;
692+
case ZOMBIEVILLAGER:
693+
mobType = ZombieVillager.class;
694+
break;
669695
}
670696
} catch (NoClassDefFoundError e) {
671697
throw new CREFormatException("No mob of type " + name + " exists", t);

src/main/java/com/laytonsmith/abstraction/enums/MCEntityType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ public enum MCVanillaEntityType {
196196
THROWN_EXP_BOTTLE(true),
197197
TIPPED_ARROW(true, MCVersion.MC1_9),
198198
VEX(true, MCVersion.MC1_11),
199+
VILLAGER(true),
199200
VINDICATOR(true, MCVersion.MC1_11),
200201
WEATHER(false),
201202
WITCH(true, MCVersion.MC1_4_5),
202203
WITHER(true, MCVersion.MC1_4),
203204
WITHER_SKELETON(true, MCVersion.MC1_11),
204205
WITHER_SKULL(true, MCVersion.MC1_4),
205206
WOLF(true),
206-
VILLAGER(true),
207207
ZOMBIE(true),
208208
ZOMBIE_HORSE(true, MCVersion.MC1_11),
209209
ZOMBIE_VILLAGER(true, MCVersion.MC1_11),

src/main/java/com/laytonsmith/abstraction/enums/MCMobs.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.laytonsmith.annotations.MEnum;
44

55
/**
6-
* These don't directly map to entity types, because this is mostly used for spawining mobs.
7-
*
6+
* Not all of these directly map to entity types.
7+
* These should be considered aliases for the spawn_mob() function and all living entity types.
88
*/
99
@MEnum("Mobs")
1010
public enum MCMobs {
@@ -14,20 +14,24 @@ public enum MCMobs {
1414
CHICKEN,
1515
COW,
1616
CREEPER,
17+
DONKEY,
1718
ELDERGUARDIAN,
1819
ENDERDRAGON,
1920
ENDERMAN,
2021
ENDERMITE,
2122
EVOKER,
2223
GHAST,
23-
GUARDIAN,
2424
GIANT,
25+
GUARDIAN,
2526
HORSE,
27+
HUSK,
2628
ILLUSIONER,
2729
IRONGOLEM,
2830
LLAMA,
2931
MAGMACUBE,
3032
MOOSHROOM,
33+
MULE,
34+
MUSHROOMCOW,
3135
OCELOT,
3236
PARROT,
3337
PIG,
@@ -38,17 +42,22 @@ public enum MCMobs {
3842
SHULKER,
3943
SILVERFISH,
4044
SKELETON,
45+
SKELETONHORSE,
4146
SLIME,
4247
SNOWGOLEM,
48+
SNOWMAN,
4349
SPIDER,
4450
SPIDERJOCKEY,
4551
SQUID,
46-
VEX,
47-
VILLAGER,
48-
VINDICATOR,
52+
STRAY,
4953
WITCH,
5054
WITHER,
51-
WITHER_SKULL,
55+
WITHERSKELETON,
5256
WOLF,
53-
ZOMBIE
57+
VEX,
58+
VILLAGER,
59+
VINDICATOR,
60+
ZOMBIE,
61+
ZOMBIEHORSE,
62+
ZOMBIEVILLAGER
5463
}

src/main/java/com/laytonsmith/core/functions/MobManagement.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.laytonsmith.abstraction.enums.MCOcelotType;
2121
import com.laytonsmith.abstraction.enums.MCPigType;
2222
import com.laytonsmith.abstraction.enums.MCProfession;
23-
import com.laytonsmith.abstraction.enums.MCSkeletonType;
2423
import com.laytonsmith.abstraction.enums.MCWolfType;
2524
import com.laytonsmith.abstraction.enums.MCZombieType;
2625
import com.laytonsmith.annotations.api;
@@ -84,25 +83,28 @@ public Integer[] numArgs() {
8483

8584
@Override
8685
public String docs() {
87-
return "array {mobType, [qty], [location]} Spawns qty mob of one of the following types at location. qty defaults to 1, and location defaults"
88-
+ " to the location of the player. An array of the entity IDs spawned is returned."
86+
return "array {mobType, [qty], [location]} Spawns qty mob of one of the following types at location."
87+
+ " qty defaults to 1, and location defaults to the location of the player."
88+
+ " An array of the entity UUIDs spawned is returned."
8989
+ " ---- mobType can be one of: " + StringUtils.Join(MCMobs.values(), ", ", ", or ", " or ") + "."
90-
+ " Spelling matters, but capitalization doesn't. At this time, the function is limited to spawning a maximum of 50 at a time."
91-
+ " Further, subtypes can be applied by specifying MOBTYPE:SUBTYPE, for example the sheep subtype can be any of the dye colors: "
92-
+ StringUtils.Join(MCDyeColor.values(), ", ", ", or ", " or ") + ". COLOR defaults to white if not specified. For mobs with multiple"
93-
+ " subtypes, separate each type with a \"-\", currently only zombies which, using ZOMBIE:TYPE1-TYPE2 can be any non-conflicting two of: "
94-
+ StringUtils.Join(MCZombieType.values(), ", ", ", or ", " or ") + ", but default to normal zombies. Ocelots may be one of: "
95-
+ StringUtils.Join(MCOcelotType.values(), ", ", ", or ", " or ") + ", defaulting to the wild variety. Villagers can have a profession as a subtype: "
96-
+ StringUtils.Join(MCProfession.values(), ", ", ", or ", " or ") + ", defaulting to farmer if not specified. Skeletons can be "
97-
+ StringUtils.Join(MCSkeletonType.values(), ", ", ", or ", " or ") + ". PigZombies' subtype represents their anger,"
98-
+ " and accepts an integer, where 0 is neutral and 400 is the normal response to being attacked. Defaults to 0. Similarly, Slime"
99-
+ " and MagmaCube size can be set by integer, otherwise will be a random natural size. If a material is specified as the subtype"
100-
+ " for Endermen, they will hold that material, otherwise they will hold nothing. Creepers can be set to "
101-
+ StringUtils.Join(MCCreeperType.values(), ", ", ", or ", " or ") + ", wolves can be " + StringUtils.Join(MCWolfType.values(), ", ", ", or ", " or ")
102-
+ ", and pigs can be " + StringUtils.Join(MCPigType.values(), ", ", ", or ", " or ") + "."
103-
+ " Horses can have three different subTypes, the variant: " + StringUtils.Join(MCHorse.MCHorseVariant.values(), ", ", ", or ", " or ") + ","
104-
+ " the color: " + StringUtils.Join(MCHorse.MCHorseColor.values(), ", ", ", or ", " or ") + ","
105-
+ " and the pattern: " + StringUtils.Join(MCHorse.MCHorsePattern.values(), ", ", ", or ", " or ") + "."
90+
+ " Further, subtypes can be applied by specifying MOBTYPE:SUBTYPE,"
91+
+ " for example the sheep subtype can be any of the dye colors: "
92+
+ StringUtils.Join(MCDyeColor.values(), ", ", ", or ", " or ") + "."
93+
+ " COLOR defaults to white if not specified."
94+
+ " For mobs with multiple subtypes, separate each type with a \"-\"."
95+
+ " Zombies can be any non-conflicting two of: " + StringUtils.Join(MCZombieType.values(), ", ", ", or ", " or ") + "."
96+
+ " Ocelots may be one of: " + StringUtils.Join(MCOcelotType.values(), ", ", ", or ", " or ") + "."
97+
+ " Villagers can have a profession as a subtype: " + StringUtils.Join(MCProfession.values(), ", ", ", or ", " or ")
98+
+ ", defaulting to farmer if not specified. PigZombies' subtype represents their anger,"
99+
+ " and accepts an integer, where 0 is neutral and 400 is the normal response to being attacked."
100+
+ " Defaults to 0. Similarly, Slime and MagmaCube size can be set by integer,"
101+
+ " otherwise will be a random natural size. If a material is specified as the subtype for Endermen,"
102+
+ " they will hold that material, otherwise they will hold nothing."
103+
+ " Creepers can be set to " + StringUtils.Join(MCCreeperType.values(), ", ", ", or ", " or ") + "."
104+
+ " Wolves can be " + StringUtils.Join(MCWolfType.values(), ", ", ", or ", " or ") + "."
105+
+ " Pigs can be " + StringUtils.Join(MCPigType.values(), ", ", ", or ", " or ") + "."
106+
+ " Horses can have a color: " + StringUtils.Join(MCHorse.MCHorseColor.values(), ", ", ", or ", " or ") + ","
107+
+ " and a pattern: " + StringUtils.Join(MCHorse.MCHorsePattern.values(), ", ", ", or ", " or ") + "."
106108
+ " If qty is larger than " + spawn_mob.SPAWN_LIMIT + ", a RangeException will be thrown.";
107109
}
108110

@@ -159,7 +161,7 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance
159161
}
160162

161163
try {
162-
return l.getWorld().spawnMob(MCMobs.valueOf(mob.toUpperCase().replaceAll(" ", "")), secondary, qty, l, t);
164+
return l.getWorld().spawnMob(MCMobs.valueOf(mob.toUpperCase().replaceAll("[ _]", "")), secondary, qty, l, t);
163165
} catch (IllegalArgumentException e) {
164166
throw new CREFormatException("Invalid mob name: " + mob, t);
165167
}

src/main/resources/functionDocs/entity_spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ without knowing the rotations on the other axis or of other body parts beforehan
209209
|
210210
* %KEY_SKELETON_TYPE%: The type of the skeleton (can be %SKELETON_TYPE%). (deprecated)
211211
|-
212-
| SKELTONHORSE, ZOMBIEHORSE
212+
| SKELTON_HORSE, ZOMBI_HORSE
213213
|
214214
* %KEY_HORSE_DOMESTICATION%: The domestication level of the horse (can't be higher than the maximum domestication level).
215215
* %KEY_HORSE_JUMP%: The jump strength (between 1.0 and 2.0).
@@ -254,7 +254,7 @@ without knowing the rotations on the other axis or of other body parts beforehan
254254
* %KEY_ZOMBIE_BABY%: Whether the zombie is a baby.
255255
* %KEY_ZOMBIE_VILLAGER%: Whether the zombie is a villager. (deprecated)
256256
|-
257-
| ZOMBIEVILLAGER
257+
| ZOMBIE_VILLAGER
258258
|
259259
* %KEY_ZOMBIE_BABY%: Whether the zombie is a baby.
260260
* %KEY_VILLAGER_PROFESSION%: The profession of the villager (can be %PROFESSION%).

0 commit comments

Comments
 (0)