Skip to content

Commit

Permalink
Add functions to check and set whether other entities will collide wi…
Browse files Browse the repository at this point in the history
…th a mob
  • Loading branch information
PseudoKnight committed Aug 17, 2018
1 parent 0e030ee commit 60b5c7e
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/MCLivingEntity.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public interface MCLivingEntity extends MCEntity, MCProjectileSource {


void setAI(Boolean ai); void setAI(Boolean ai);


boolean isCollidable();

void setCollidable(boolean collidable);

/** /**
* Kills the entity. In some cases, this will be equivalent to setHealth(0), but may not be, so this method should * Kills the entity. In some cases, this will be equivalent to setHealth(0), but may not be, so this method should
* be used instead. * be used instead.
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -355,4 +355,14 @@ public void setGliding(Boolean glide) {
public void setAI(Boolean ai) { public void setAI(Boolean ai) {
le.setAI(ai); le.setAI(ai);
} }

@Override
public boolean isCollidable() {
return le.isCollidable();
}

@Override
public void setCollidable(boolean collidable) {
le.setCollidable(collidable);
}
} }
51 changes: 51 additions & 0 deletions src/main/java/com/laytonsmith/core/functions/MobManagement.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1587,4 +1587,55 @@ public Version since() {
return CHVersion.V3_3_2; return CHVersion.V3_3_2;
} }
} }

@api
public static class is_mob_collidable extends EntityManagement.EntityGetterFunction {

@Override
public String getName() {
return "is_mob_collidable";
}

@Override
public String docs() {
return "boolean {entityID} Returns whether another entity, like an arrow, will collide with this mob.";
}

@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
return CBoolean.GenerateCBoolean(Static.getLivingEntity(args[0], t).isCollidable(), t);
}

@Override
public Version since() {
return CHVersion.V3_3_3;
}
}

@api
public static class set_mob_collidable extends EntityManagement.EntitySetterFunction {

@Override
public String getName() {
return "set_mob_collidable";
}

@Override
public String docs() {
return "void {entityID, boolean} Sets whether or not other entities will collide with this mob.";
}

@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
MCLivingEntity e = Static.getLivingEntity(args[0], t);
boolean collidable = Static.getBoolean(args[1], t);
e.setCollidable(collidable);
return CVoid.VOID;
}

@Override
public Version since() {
return CHVersion.V3_3_3;
}
}
} }

0 comments on commit 60b5c7e

Please sign in to comment.