Skip to content

Commit

Permalink
Allow forcing adult status on randomly generated /spawnmob mobs.
Browse files Browse the repository at this point in the history
  • Loading branch information
khobbits committed Jul 6, 2014
1 parent e05658e commit 58bc611
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Essentials/src/com/earth2me/essentials/MobData.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public enum MobData
{
BABY_AGEABLE("baby", Ageable.class, Data.BABY, true),
ADULT_AGEABLE("adult", Ageable.class, Data.ADULT, true),
BABY_PIG("piglet", EntityType.PIG, Data.BABY, false),
BABY_WOLF("puppy", EntityType.WOLF, Data.BABY, false),
BABY_CHICKEN("chick", EntityType.CHICKEN, Data.BABY, false),
Expand Down Expand Up @@ -83,6 +84,7 @@ public enum MobData
TUXEDO_CAT("tuxedo", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, false),
VILLAGER_ZOMBIE("villager", EntityType.ZOMBIE.getEntityClass(), Data.VILLAGER, true),
BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, true),
ADULT_ZOMBIE("adult", EntityType.ZOMBIE.getEntityClass(), Data.ADULTZOMBIE, true),
DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true),
GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), Material.GOLD_SWORD, true),
IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true),
Expand Down Expand Up @@ -113,8 +115,10 @@ public enum MobData

public enum Data
{
ADULT,
BABY,
CHEST,
ADULTZOMBIE,
BABYZOMBIE,
VILLAGER,
HORSESADDLE,
Expand Down Expand Up @@ -214,10 +218,18 @@ public void setData(final Entity spawned, final Player target, final String rawD
{
((Wolf)spawned).setAngry(true);
}
else if (this.value.equals(Data.ADULT))
{
((Ageable)spawned).setAdult();
}
else if (this.value.equals(Data.BABY))
{
((Ageable)spawned).setBaby();
}
else if (this.value.equals(Data.ADULTZOMBIE))
{
((Zombie)spawned).setBaby(false);
}
else if (this.value.equals(Data.BABYZOMBIE))
{
((Zombie)spawned).setBaby(true);
Expand Down
19 changes: 17 additions & 2 deletions Essentials/src/com/earth2me/essentials/SpawnMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ private static void changeMobData(final CommandSource sender, final EntityType t
{
sender.sendMessage(tl("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned))));
}

if (spawned instanceof Zombie)
{
((Zombie)spawned).setBaby(false);
}
else if(spawned instanceof Ageable)
{
((Ageable)spawned).setAdult();
}

if (spawned instanceof Zombie || type == EntityType.SKELETON)
{
Expand Down Expand Up @@ -285,7 +294,10 @@ private static void defaultMobData(final EntityType type, final Entity spawned)

if (type == EntityType.PIG_ZOMBIE)
{
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
final PigZombie zombie = ((PigZombie)spawned);
zombie.setVillager(false);

final EntityEquipment invent = zombie.getEquipment();
invent.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
invent.setItemInHandDropChance(0.1f);

Expand All @@ -295,7 +307,10 @@ private static void defaultMobData(final EntityType type, final Entity spawned)

if (type == EntityType.ZOMBIE)
{
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
final Zombie zombie = ((Zombie)spawned);
zombie.setVillager(false);

final EntityEquipment invent = zombie.getEquipment();
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f);
}
Expand Down

0 comments on commit 58bc611

Please sign in to comment.