Skip to content

Added TamableEntity #14

Merged
merged 5 commits into from May 28, 2012
View
9 src/Mob.java
@@ -26,7 +26,7 @@ public Mob(OEntityLiving locallb) {
* @deprecated Use {@link #Mob(java.lang.String, World)} instead.
*/
public Mob(String mob) {
- this(mob, etc.getServer().getDefaultWorld());
+ this((OEntityLiving) OEntityList.a(mob, etc.getMCServer().a(0)));
}
/**
@@ -172,5 +172,12 @@ public Location getLocation() {
loc.dimension = getWorld().getType().getId();
return loc;
}
+
+ public boolean isInLove(){
+ if (getEntity() instanceof OEntityAnimal){
+ return ((OEntityAnimal) getEntity()).r_();
+ }
+ return false;
+ }
}
View
40 src/Ocelot.java
@@ -0,0 +1,40 @@
+
+public class Ocelot extends TamableEntity{
+
+ /**
+ * Basic ocelot constructor.
+ *
+ * @param entity An instance of OEntityOcelot to wrap around.
+ */
+ public Ocelot(OEntityOcelot entity){
+ super(entity);
+ }
+
+ /**
+ * Set the skin of the ocelot.
+ *
+ * @param skin ID of the skin.
+ * 0 - Normal,
+ * 1 - Black,
+ * 2 - Orange,
+ * 3 - Siamese,
+ * Any other value defaults to normal.
+ */
+ public void setSkin(int skin){
+ getEntity().bY.b(18, Byte.valueOf((byte)skin));
+ }
+
+ /**
+ * Get the id of this ocelots skin.
+ *
+ * @return 0, 1, 2 or 3. See {@link Ocelot#setSkin(int)} for skin ids.
+ */
+ public int getSkin(){
+ return getEntity().bY.a(18);
+ }
+
+ public OEntityOcelot getEntity(){
+ return (OEntityOcelot) entity;
+ }
+
+}
View
90 src/TamableEntity.java
@@ -0,0 +1,90 @@
+public class TamableEntity extends Mob{
+ public TamableEntity(OEntityTamable entity){
+ super(entity);
+ }
+
+ /**
+ * If this animal is tame.
+ *
+ * @return True if tamed.
+ */
+ public boolean isTame(){
+ return getEntity().u_();
+ }
+
+ /**
+ * Sets the owner of this animal.
+ *
+ * @param player The new player who is the owner of this animal.
+ */
+ public void setOwner(Player player){
+ setOwnerName(player.getName());
+ }
+
+ /**
+ * Sets the owner of this animal.
+ *
+ * @param name The name of the player who owns this animal.
+ */
+ public void setOwnerName(String name){
+ getEntity().a(name);
+ }
+
+ /**
+ * Return the name of this animals owner.
+ *
+ * @return The name of the player who owns this animal.
+ */
+ public String getOwnerName(){
+ return getEntity().A();
+ }
+
+ /**
+ * Returns a Player instance of this animals owner.
+ *
+ * @return A Player instance of this animals owner, else null.
+ */
+ public Player getOwner(){
+ LivingEntity le = new LivingEntity(getEntity().bi.a(getOwnerName()));
+ if (le.isPlayer()){
+ return le.getPlayer();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Sets if this animal is tame.
+ *
+ * @param tame True if the animal should be tame.
+ */
+ public void setTame(boolean tame){
+ getEntity().b(tame);
+ }
+
+ /**
+ * Make this animal sit.
+ *
+ * @param sitting If this animal should be sitting.
+ */
+ public void setSitting(boolean sitting){
+ int i = getEntity().bY.a(16);
+ if (sitting)
+ getEntity().bY.b(16, Byte.valueOf((byte)(i | 0x1)));
+ else
+ getEntity().bY.b(16, Byte.valueOf((byte)(i & 0xFFFFFFFE)));
+ }
+
+ /**
+ * Returns if this animal is currently sitting.
+ *
+ * @return Sitting or not.
+ */
+ public boolean isSitting(){
+ return getEntity().v_();
+ }
+
+ public OEntityTamable getEntity() {
+ return (OEntityTamable) entity;
+ }
+}
View
96 src/Wolf.java
@@ -4,17 +4,17 @@
* @author Brian McCarthy
*
*/
-public class Wolf extends Mob{
+public class Wolf extends TamableEntity{
/**
* Basic wolf constructor.
*
* @param entity An instance of OEntityWolf to wrap around.
*/
- public Wolf(OEntityWolf entity) {
+ public Wolf(OEntityWolf entity){
super(entity);
}
-
+
/**
* If this wolf is angry.
*
@@ -38,96 +38,6 @@ public void setAngry(boolean angry){
}
}
- /**
- * Sets the owner of this wolf.
- *
- * @param player The new player who is the owner of this wolf.
- */
- public void setOwner(Player player){
- setOwnerName(player.getName());
- }
-
- /**
- * Sets the owner of this wolf.
- *
- * @param name The name of the player who owns this wolf.
- */
- public void setOwnerName(String name){
- getEntity().a(name);
- }
-
- /**
- * Return the name of this wolfs owner.
- *
- * @return The name of the player who owns this wolf.
- */
- public String getOwnerName(){
- return getEntity().A();
- }
-
- /**
- * Returns a Player instance of this wolfs owner.
- *
- * @return A Player instance of this wolfs owner, else null.
- */
- public Player getOwner(){
- LivingEntity le = new LivingEntity(getEntity().bi.a(getOwnerName()));
- if (le.isPlayer()){
- return le.getPlayer();
- } else {
- return null;
- }
- }
-
- /**
- * If this wolf is in love.
- *
- * @return True if wolf is in love.
- */
- public boolean isInLove(){
- return getEntity().r_();
- }
-
- /**
- * Sets if this wolf is tame.
- *
- * @param tame True if the wolf should be tame.
- */
- public void setTame(boolean tame){
- getEntity().b(true);
- }
-
- /**
- * If this wolf is tame.
- *
- * @return True if tamed.
- */
- public boolean isTame(){
- return getEntity().u_();
- }
-
- /**
- * Make this wolf sit.
- *
- * @param sitting If this wolf should be sitting.
- */
- public void setSitting(boolean sitting){
- int i = getEntity().bY.a(16);
- if (sitting)
- getEntity().bY.b(16, Byte.valueOf((byte)(i | 0x1)));
- else
- getEntity().bY.b(16, Byte.valueOf((byte)(i & 0xFFFFFFFE)));
- }
-
- /**
- * Returns if this wolf is currently sitting.
- *
- * @return Sitting or not.
- */
- public boolean isSitting(){
- return getEntity().v_();
- }
-
public OEntityWolf getEntity() {
return (OEntityWolf) entity;
}
Something went wrong with that request. Please try again.