mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-22 21:19:49 +00:00
Added documentation and groomed code.
This commit is contained in:
1 parent
e22c5c5744
commit
a54c471f14
34 files changed
+771
-97
No files matched your search
@@ -1,5 +1,9 @@
|
||||
package codechicken.multipart;
|
||||
|
||||
/**
|
||||
* Defines what each slot in a multipart tile corresponds to and provides some utility functions.
|
||||
* For performance reasons, it is recommended that integer constants be useds as opposed to this enum
|
||||
*/
|
||||
public enum PartMap
|
||||
{
|
||||
BOTTOM(0),
|
||||
@@ -38,22 +42,36 @@ public enum PartMap
|
||||
this.i = i;
|
||||
mask = 1<<i;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Don't actually use this.
|
||||
*/
|
||||
public static PartMap face(int i)
|
||||
{
|
||||
return values()[i];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Don't actually use this.
|
||||
*/
|
||||
public static PartMap edge(int i)
|
||||
{
|
||||
return values()[i+15];
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't actually use this.
|
||||
*/
|
||||
public static PartMap corner(int i)
|
||||
{
|
||||
return values()[i+7];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a 3 bit mask of the axis xzy that are variable in this edge.
|
||||
* For example, the first 4 edges (15-18) are along the Y axis, variable in x and z, so the mask is 110b. Note axis y is 1<<0, z is 1<<1 and x is 1<<2
|
||||
* Note the parameter e is relative to the first edge slot and can range from 0-11
|
||||
*/
|
||||
public static int edgeAxisMask(int e)
|
||||
{
|
||||
switch(e>>2)
|
||||
@@ -65,6 +83,11 @@ public enum PartMap
|
||||
throw new IllegalArgumentException("Switch Falloff");
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks an edge index, to a mask where high values indicate positive positions in that axis.
|
||||
* Note the parameter e is relative to the first edge slot and can range from 0-11
|
||||
* For example, edge 1 (slot 16), is EDGE_NYP so the mask returned would be 010 as z is positive.
|
||||
*/
|
||||
public static int unpackEdgeBits(int e)
|
||||
{
|
||||
switch(e>>2)
|
||||
@@ -76,6 +99,10 @@ public enum PartMap
|
||||
throw new IllegalArgumentException("Switch Falloff");
|
||||
}
|
||||
|
||||
/**
|
||||
* Repacks a mask of axis bits indicating positive positions, into an edge in along the same axis as e.
|
||||
* Note the parameter e is relative to the first edge slot and can range from 0-11
|
||||
*/
|
||||
public static int packEdgeBits(int e, int bits)
|
||||
{
|
||||
switch(e>>2)
|
||||
@@ -93,6 +120,9 @@ public enum PartMap
|
||||
-1, -1,-1, -1, 0, 2,
|
||||
-1, -1,-1, -1, 1, 3};
|
||||
|
||||
/**
|
||||
* Returns the slot of the edge between 2 sides.
|
||||
*/
|
||||
public static int edgeBetween(int s1, int s2)
|
||||
{
|
||||
if(s2 < s1)
|
||||
|
||||
Reference in new issue
Block a user