From c2e5789aa1c612697993e2b30bd1ef3e862d0e6f Mon Sep 17 00:00:00 2001 From: WeAthFolD Date: Sun, 25 Oct 2015 15:04:57 +0800 Subject: [PATCH] build 1.0 --- src/main/java/cn/liutils/util/mc/WorldUtils.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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; + } + }