Added converter to forge Orientation in Orientations and made adjustments for ISidedInventory

This commit is contained in:
Krapht 2012-08-11 18:25:41 +02:00
parent 60cb683d27
commit 970045b231
4 changed files with 31 additions and 8 deletions

View file

@ -9,6 +9,9 @@
package buildcraft.api.core;
import net.minecraftforge.common.Orientation;
@Deprecated //- Convert to the forge orientation once proper support is added
public enum Orientations {
YNeg, // 0
YPos, // 1
@ -36,6 +39,26 @@ public enum Orientations {
return Orientations.Unknown;
}
}
public Orientation toOrientation(){
switch(this){
case YNeg:
return Orientation.DOWN;
case YPos:
return Orientation.UP;
case ZNeg:
return Orientation.NORTH;
case ZPos:
return Orientation.SOUTH;
case XNeg:
return Orientation.WEST;
case XPos:
return Orientation.EAST;
default:
return Orientation.UNKNOWN;
}
}
public Orientations rotateLeft() {
switch (this) {

View file

@ -105,8 +105,8 @@ public class StackUtil {
IInventory inv = Utils.getInventory(inventory);
ISidedInventory sidedInv = (ISidedInventory) inv;
int first = sidedInv.getStartInventorySide(from.ordinal());
int last = first + sidedInv.getSizeInventorySide(from.ordinal()) - 1;
int first = sidedInv.getStartInventorySide(from.toOrientation());
int last = first + sidedInv.getSizeInventorySide(from.toOrientation()) - 1;
for (int j = first; j <= last; ++j)
if (tryAdding(inv, j, add, false)) {
@ -161,8 +161,8 @@ public class StackUtil {
IInventory inv = Utils.getInventory(inventory);
ISidedInventory sidedInv = (ISidedInventory) inv;
int first = sidedInv.getStartInventorySide(from.ordinal());
int last = first + sidedInv.getSizeInventorySide(from.ordinal()) - 1;
int first = sidedInv.getStartInventorySide(from.toOrientation());
int last = first + sidedInv.getSizeInventorySide(from.toOrientation()) - 1;
for (int j = first; j <= last; ++j)
if (tryAdding(inv, j, add, true)) {

View file

@ -22,12 +22,12 @@ public class SidedInventoryAdapter implements IInventory {
public SidedInventoryAdapter(ISidedInventory sidedInventory, Orientations side) {
_sidedInventory = sidedInventory;
_side = side;
_slotOffset = _sidedInventory.getStartInventorySide(side.ordinal());
_slotOffset = _sidedInventory.getStartInventorySide(side.toOrientation());
}
@Override
public int getSizeInventory() {
return _sidedInventory.getSizeInventorySide(_side.ordinal());
return _sidedInventory.getSizeInventorySide(_side.toOrientation());
}
@Override

View file

@ -137,8 +137,8 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
if (inventory instanceof ISidedInventory) {
ISidedInventory sidedInv = (ISidedInventory) inventory;
int first = sidedInv.getStartInventorySide(from.ordinal());
int last = first + sidedInv.getSizeInventorySide(from.ordinal()) - 1;
int first = sidedInv.getStartInventorySide(from.toOrientation());
int last = first + sidedInv.getSizeInventorySide(from.toOrientation()) - 1;
IInventory inv = Utils.getInventory(inventory);