Skip to content

Commit

Permalink
Add entity_in_water()
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Mar 19, 2024
1 parent 483de30 commit 1a81140
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/MCEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ public interface MCEntity extends MCMetadatable {
void setFreezingTicks(int ticks);

int getEntityId();

boolean isInWater();
}
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,9 @@ public int getEntityId() {
return e.getEntityId();
}

@Override
public boolean isInWater() {
return e.isInWater();
}

}
28 changes: 28 additions & 0 deletions src/main/java/com/laytonsmith/core/functions/EntityManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -5317,4 +5317,32 @@ public Version since() {
}

}

@api
public static class entity_in_water extends EntityGetterFunction {

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

@Override
public String docs() {
return "boolean {entityUUID} Returns whether an entity is colliding with water."
+ " This accounts for waterlogged blocks, bubble columns, and fluid height."
+ " It does not account for water cauldrons.";
}

@Override
public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException {
MCEntity entity = Static.getEntity(args[0], t);
return CBoolean.get(entity.isInWater());
}

@Override
public Version since() {
return MSVersion.V3_3_5;
}

}
}

0 comments on commit 1a81140

Please sign in to comment.