Skip to content

Commit 60b5c7e

Browse files
committed
Add functions to check and set whether other entities will collide with a mob
1 parent 0e030ee commit 60b5c7e

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

src/main/java/com/laytonsmith/abstraction/MCLivingEntity.java

Lines changed: 4 additions & 0 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -106,6 +106,10 @@ public interface MCLivingEntity extends MCEntity, MCProjectileSource {
106

106

107
void setAI(Boolean ai);
107
void setAI(Boolean ai);
108

108

109+
boolean isCollidable();
110+
111+
void setCollidable(boolean collidable);
112+
109
/**
113
/**
110
* Kills the entity. In some cases, this will be equivalent to setHealth(0), but may not be, so this method should
114
* Kills the entity. In some cases, this will be equivalent to setHealth(0), but may not be, so this method should
111
* be used instead.
115
* be used instead.

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCLivingEntity.java

Lines changed: 10 additions & 0 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -355,4 +355,14 @@ public void setGliding(Boolean glide) {
355
public void setAI(Boolean ai) {
355
public void setAI(Boolean ai) {
356
le.setAI(ai);
356
le.setAI(ai);
357
}
357
}
358+
359+
@Override
360+
public boolean isCollidable() {
361+
return le.isCollidable();
362+
}
363+
364+
@Override
365+
public void setCollidable(boolean collidable) {
366+
le.setCollidable(collidable);
367+
}
358
}
368
}

src/main/java/com/laytonsmith/core/functions/MobManagement.java

Lines changed: 51 additions & 0 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -1587,4 +1587,55 @@ public Version since() {
1587
return CHVersion.V3_3_2;
1587
return CHVersion.V3_3_2;
1588
}
1588
}
1589
}
1589
}
1590+
1591+
@api
1592+
public static class is_mob_collidable extends EntityManagement.EntityGetterFunction {
1593+
1594+
@Override
1595+
public String getName() {
1596+
return "is_mob_collidable";
1597+
}
1598+
1599+
@Override
1600+
public String docs() {
1601+
return "boolean {entityID} Returns whether another entity, like an arrow, will collide with this mob.";
1602+
}
1603+
1604+
@Override
1605+
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
1606+
return CBoolean.GenerateCBoolean(Static.getLivingEntity(args[0], t).isCollidable(), t);
1607+
}
1608+
1609+
@Override
1610+
public Version since() {
1611+
return CHVersion.V3_3_3;
1612+
}
1613+
}
1614+
1615+
@api
1616+
public static class set_mob_collidable extends EntityManagement.EntitySetterFunction {
1617+
1618+
@Override
1619+
public String getName() {
1620+
return "set_mob_collidable";
1621+
}
1622+
1623+
@Override
1624+
public String docs() {
1625+
return "void {entityID, boolean} Sets whether or not other entities will collide with this mob.";
1626+
}
1627+
1628+
@Override
1629+
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
1630+
MCLivingEntity e = Static.getLivingEntity(args[0], t);
1631+
boolean collidable = Static.getBoolean(args[1], t);
1632+
e.setCollidable(collidable);
1633+
return CVoid.VOID;
1634+
}
1635+
1636+
@Override
1637+
public Version since() {
1638+
return CHVersion.V3_3_3;
1639+
}
1640+
}
1590
}
1641
}

0 commit comments

Comments
 (0)