001 /** 002 * Mob.java - Interface for mobs 003 * 004 * @author James 005 */ 006 public class Mob extends LivingEntity { 007 /** 008 * Creates a mob interface 009 * 010 * @param locallb name of mob 011 */ 012 public Mob(mj locallb) { 013 super(locallb); 014 } 015 016 /** 017 * Creates a mob interface 018 * 019 * @param mob 020 * name of mob 021 */ 022 public Mob(String mob) { 023 this((mj) jn.a(mob, etc.getMCServer().e)); 024 } 025 026 /** 027 * Creates a mob interface 028 * 029 * @param mobName name of mob 030 * @param location location of mob 031 */ 032 public Mob(String mobName, Location location) { 033 this(mobName); 034 teleportTo(location); 035 } 036 037 /** 038 * Spawns this mob 039 */ 040 public void spawn() { 041 spawn(null); 042 } 043 044 /** 045 * Spawns this mob with a rider 046 * 047 * @param rider 048 */ 049 public void spawn(Mob rider) { 050 fv localff = etc.getMCServer().e; 051 052 entity.c(getX() + 0.5f, getY(), getZ() + 0.5f, getRotation(), 0f); 053 localff.a(entity); 054 055 if (rider != null) { 056 mj mob2 = rider.getMob(); 057 mob2.c(getX(), getY(), getZ(), getRotation(), 0f); 058 localff.a(mob2); 059 mob2.e(entity); 060 } 061 } 062 063 /** 064 * Returns this mob's name 065 * 066 * @return name 067 */ 068 public String getName() { 069 return jn.b(entity); 070 } 071 072 /** 073 * Drops this mob's loot. Automatically called if health is set to 0. 074 */ 075 public void dropLoot() { 076 getEntity().f(null); 077 } 078 079 public void setHealth(int health) { 080 super.setHealth(health); 081 if (health <= 0) { 082 dropLoot(); 083 } 084 } 085 086 /** 087 * Returns the actual mob 088 * 089 * @return 090 */ 091 public mj getMob() { 092 return getEntity(); 093 } 094 095 /** 096 * Checks to see if the mob is a valid mob 097 * 098 * @param mob 099 * the mob to check 100 * @return true of mob is valid 101 */ 102 public static boolean isValid(String mob) { 103 if (mob == null) { 104 return false; 105 } 106 return jn.a(mob, etc.getMCServer().e) instanceof mj; 107 } 108 }