Allow forcing adult status on randomly generated /spawnmob mobs.

This commit is contained in:
KHobbits 2014-07-06 18:25:00 +01:00
parent 2ba2ebaa43
commit 02fe58161c
2 changed files with 29 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import org.bukkit.material.Colorable;
public enum MobData public enum MobData
{ {
BABY_AGEABLE("baby", Ageable.class, Data.BABY, true), 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_PIG("piglet", EntityType.PIG, Data.BABY, false),
BABY_WOLF("puppy", EntityType.WOLF, Data.BABY, false), BABY_WOLF("puppy", EntityType.WOLF, Data.BABY, false),
BABY_CHICKEN("chick", EntityType.CHICKEN, Data.BABY, false), BABY_CHICKEN("chick", EntityType.CHICKEN, Data.BABY, false),
@ -83,6 +84,7 @@ public enum MobData
TUXEDO_CAT("tuxedo", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, false), TUXEDO_CAT("tuxedo", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, false),
VILLAGER_ZOMBIE("villager", EntityType.ZOMBIE.getEntityClass(), Data.VILLAGER, true), VILLAGER_ZOMBIE("villager", EntityType.ZOMBIE.getEntityClass(), Data.VILLAGER, true),
BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, 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), DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true),
GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), Material.GOLD_SWORD, true), GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), Material.GOLD_SWORD, true),
IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true), IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true),
@ -113,8 +115,10 @@ public enum MobData
public enum Data public enum Data
{ {
ADULT,
BABY, BABY,
CHEST, CHEST,
ADULTZOMBIE,
BABYZOMBIE, BABYZOMBIE,
VILLAGER, VILLAGER,
HORSESADDLE, HORSESADDLE,
@ -214,10 +218,18 @@ public enum MobData
{ {
((Wolf)spawned).setAngry(true); ((Wolf)spawned).setAngry(true);
} }
else if (this.value.equals(Data.ADULT))
{
((Ageable)spawned).setAdult();
}
else if (this.value.equals(Data.BABY)) else if (this.value.equals(Data.BABY))
{ {
((Ageable)spawned).setBaby(); ((Ageable)spawned).setBaby();
} }
else if (this.value.equals(Data.ADULTZOMBIE))
{
((Zombie)spawned).setBaby(false);
}
else if (this.value.equals(Data.BABYZOMBIE)) else if (this.value.equals(Data.BABYZOMBIE))
{ {
((Zombie)spawned).setBaby(true); ((Zombie)spawned).setBaby(true);

View File

@ -217,6 +217,15 @@ public class SpawnMob
sender.sendMessage(tl("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned)))); 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) if (spawned instanceof Zombie || type == EntityType.SKELETON)
{ {
if (inputData.contains("armor") || inputData.contains("armour")) if (inputData.contains("armor") || inputData.contains("armour"))
@ -285,7 +294,10 @@ public class SpawnMob
if (type == EntityType.PIG_ZOMBIE) 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.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
invent.setItemInHandDropChance(0.1f); invent.setItemInHandDropChance(0.1f);
@ -295,7 +307,10 @@ public class SpawnMob
if (type == EntityType.ZOMBIE) 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.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f); invent.setBootsDropChance(0.0f);
} }