aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/api/objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/api/objects')
-rw-r--r--src/Java/gtPlusPlus/api/objects/data/AutoMap.java40
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/AABB.java65
2 files changed, 105 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java
index fe2caa466d..3583a04a74 100644
--- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java
+++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java
@@ -31,6 +31,46 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect
mInternalNameMap = new LinkedHashMap<String, Integer>();
}
+ /**
+ * Generates an AutoMap from the List.
+ * @param aList - Data to be inserted into the AutoMap.
+ */
+ public AutoMap(List<V> aList) {
+ mInternalMap = new LinkedHashMap<Integer, V>();
+ mInternalNameMap = new LinkedHashMap<String, Integer>();
+ if (aList != null && aList.size() > 0) {
+ for (V obj : aList) {
+ add(obj);
+ }
+ }
+ }
+ /**
+ * Generates an AutoMap from a Set.
+ * @param aList - Data to be inserted into the AutoMap.
+ */
+ public AutoMap(Set<V> aList) {
+ mInternalMap = new LinkedHashMap<Integer, V>();
+ mInternalNameMap = new LinkedHashMap<String, Integer>();
+ if (aList != null && aList.size() > 0) {
+ for (V obj : aList) {
+ add(obj);
+ }
+ }
+ }
+ /**
+ * Generates an AutoMap from a Collection.
+ * @param aList - Data to be inserted into the AutoMap.
+ */
+ public AutoMap(Collection<V> aList) {
+ mInternalMap = new LinkedHashMap<Integer, V>();
+ mInternalNameMap = new LinkedHashMap<String, Integer>();
+ if (aList != null && aList.size() > 0) {
+ for (V obj : aList) {
+ add(obj);
+ }
+ }
+ }
+
@Override
public Iterator<V> iterator() {
return values().iterator();
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/AABB.java b/src/Java/gtPlusPlus/api/objects/minecraft/AABB.java
new file mode 100644
index 0000000000..722ac00b64
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/AABB.java
@@ -0,0 +1,65 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import gtPlusPlus.core.util.minecraft.EntityUtils;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.World;
+
+/**
+ * Generates an AABB around an entity.
+ * @author Alkalus
+ *
+ */
+public class AABB {
+
+ private final AxisAlignedBB mAabb;
+ private final World mWorld;
+
+ /**
+ * Creates a AxisAlignedBB based around an Entity.
+ * @param aEntity - The Entity to work with.
+ * @param x - Maximum X from origin.
+ * @param y - Maximum Y from origin.
+ * @param z - Maximum Z from origin.
+ */
+ public AABB(Entity aEntity, int x, int y, int z) {
+ if (aEntity == null) {
+ mAabb = null;
+ mWorld = null;
+ }
+ else {
+ mWorld = aEntity.worldObj;
+ BlockPos aEntityLocation = EntityUtils.findBlockPosUnderEntity(aEntity);
+ int xMin, xMax, yMin, yMax, zMin, zMax;
+ xMin = aEntityLocation.xPos;
+ yMin = aEntityLocation.yPos;
+ zMin = aEntityLocation.zPos;
+ xMax = aEntityLocation.xPos + x;
+ yMax = aEntityLocation.yPos + y;
+ zMax = aEntityLocation.zPos + z;
+ mAabb = AxisAlignedBB.getBoundingBox(xMin, yMin, zMin, xMax, yMax, zMax);
+ }
+
+ }
+
+ /**
+ * Used to get the AxisAlignedBB from this class.
+ * @return
+ */
+ public AxisAlignedBB get() {
+ return mAabb;
+ }
+
+ /**
+ * Used to determine if this object is valid or not.
+ * @return
+ */
+ public boolean valid() {
+ return mAabb != null && mWorld != null;
+ }
+
+ public World world() {
+ return mWorld;
+ }
+
+}