diff --git a/src/main/java/cn/liutils/util/mc/WorldUtils.java b/src/main/java/cn/liutils/util/mc/WorldUtils.java index c15487a..68d7337 100644 --- a/src/main/java/cn/liutils/util/mc/WorldUtils.java +++ b/src/main/java/cn/liutils/util/mc/WorldUtils.java @@ -181,4 +181,13 @@ public static List getEntities(World world, AxisAlignedBB box, IEntitySe return world.getEntitiesWithinAABBExcludingEntity(null, box, filter); } + /** + * Get the tile entity at the given position and check if it is the specified type. + * Return the tile entity if is of the type, null otherwise. + */ + public static T getTileEntity(World world, int x, int y, int z, Class type) { + TileEntity te = world.getTileEntity(x, y, z); + return type.isInstance(te) ? (T) te : null; + } + }