@@ -48,19 +48,14 @@ public ForgeDirection calculateRotation(ForgeDirection direction, ForgeDirection
return null;
}

@Override
public ForgeDirection mapWorldToBlockSide(ForgeDirection localNorth, ForgeDirection side) {
return side;
}

@Override
protected BlockTextureTransform.Builder setupTextureTransform(BlockTextureTransform.Builder builder) {
return builder.mirrorU(ForgeDirection.NORTH).mirrorU(ForgeDirection.EAST);
}

@Override
public Orientation getBlockOrientation(ForgeDirection direction) {
return Orientation.ET;
return Orientation.XP_YP;
}
},
/**
@@ -138,19 +133,6 @@ public ForgeDirection calculateRotation(ForgeDirection direction, ForgeDirection
}
}

@Override
public ForgeDirection mapWorldToBlockSide(ForgeDirection localNorth, ForgeDirection side) {
switch (localNorth) {
case NORTH:
case SOUTH:
default:
return side;
case EAST:
case WEST:
return side.getRotation(ForgeDirection.UP);
}
}

@Override
protected BlockTextureTransform.Builder setupTextureTransform(BlockTextureTransform.Builder builder) {
return builder.mirrorU(ForgeDirection.NORTH).mirrorU(ForgeDirection.EAST);
@@ -162,10 +144,10 @@ public Orientation getBlockOrientation(ForgeDirection localNorth) {
case NORTH:
case SOUTH:
default:
return Orientation.TS;
return Orientation.XP_YP;
case EAST:
case WEST:
return Orientation.TE;
return Orientation.ZN_YP;
}
}

@@ -251,22 +233,6 @@ public ForgeDirection calculateRotation(ForgeDirection direction, ForgeDirection
}
}

@Override
public ForgeDirection mapWorldToBlockSide(ForgeDirection localTop, ForgeDirection side) {
switch (localTop) {
case NORTH:
case SOUTH:
return side.getRotation(ForgeDirection.WEST);
case EAST:
case WEST:
return side.getRotation(ForgeDirection.SOUTH);
case UP:
case DOWN:
default:
return side;
}
}

@Override
protected BlockTextureTransform.Builder setupTextureTransform(BlockTextureTransform.Builder builder) {
return builder.mirrorU(ForgeDirection.NORTH).mirrorU(ForgeDirection.EAST).mirrorU(ForgeDirection.DOWN);
@@ -277,14 +243,14 @@ public Orientation getBlockOrientation(ForgeDirection localTop) {
switch (localTop) {
case NORTH:
case SOUTH:
return Orientation.NT;
return Orientation.XP_ZN;
case EAST:
case WEST:
return Orientation.WS;
return Orientation.YP_XN;
case UP:
case DOWN:
default:
return Orientation.TS;
return Orientation.XP_YP;
}
}
},
@@ -360,21 +326,6 @@ public ForgeDirection calculateRotation(ForgeDirection direction, ForgeDirection
}
}

@Override
public ForgeDirection mapWorldToBlockSide(ForgeDirection localNorth, ForgeDirection side) {
switch (localNorth) {
case NORTH:
default:
return side;
case EAST:
return side.getRotation(ForgeDirection.DOWN);
case SOUTH:
return side.getRotation(ForgeDirection.UP).getRotation(ForgeDirection.UP);
case WEST:
return side.getRotation(ForgeDirection.UP);
}
}

@Override
protected BlockTextureTransform.Builder setupTextureTransform(BlockTextureTransform.Builder builder) {
return builder.mirrorU(ForgeDirection.NORTH).mirrorU(ForgeDirection.EAST);
@@ -385,13 +336,13 @@ public Orientation getBlockOrientation(ForgeDirection localNorth) {
switch (localNorth) {
case NORTH:
default:
return Orientation.TS;
return Orientation.XP_YP;
case EAST:
return Orientation.TW;
return Orientation.ZP_YP;
case SOUTH:
return Orientation.TN;
return Orientation.XN_YP;
case WEST:
return Orientation.TE;
return Orientation.ZN_YP;
}
}
},
@@ -426,25 +377,6 @@ public ForgeDirection calculateRotation(ForgeDirection direction, ForgeDirection
return axis;
}

@Override
public ForgeDirection mapWorldToBlockSide(ForgeDirection localTop, ForgeDirection side) {
switch (localTop) {
case DOWN:
return side.getRotation(ForgeDirection.SOUTH).getRotation(ForgeDirection.SOUTH);
case EAST:
return side.getRotation(ForgeDirection.NORTH);
case NORTH:
return side.getRotation(ForgeDirection.WEST);
case SOUTH:
return side.getRotation(ForgeDirection.EAST);
case WEST:
return side.getRotation(ForgeDirection.SOUTH);
case UP:
default:
return side;
}
}

@Override
protected BlockTextureTransform.Builder setupTextureTransform(BlockTextureTransform.Builder builder) {
return builder.mirrorU(ForgeDirection.NORTH).mirrorU(ForgeDirection.EAST).mirrorU(ForgeDirection.DOWN);
@@ -454,26 +386,26 @@ protected BlockTextureTransform.Builder setupTextureTransform(BlockTextureTransf
public Orientation getBlockOrientation(ForgeDirection localTop) {
switch (localTop) {
case DOWN:
return Orientation.BS;
return Orientation.XN_YN;
case EAST:
return Orientation.ES;
return Orientation.YN_XP;
case NORTH:
return Orientation.NT;
return Orientation.XP_ZN;
case SOUTH:
return Orientation.SB;
return Orientation.XP_ZP;
case WEST:
return Orientation.WS;
return Orientation.YP_XN;
case UP:
default:
return Orientation.TS;
return Orientation.XP_YP;
}
}
};

private BlockRotationMode(ForgeDirection[] rotations, IRendererSetup rendererSetup, int bitCount, ForgeDirection... allowedDirections) {
private BlockRotationMode(ForgeDirection[] rotations, IRendererSetup rendererSetup, int bitCount, ForgeDirection... validDirections) {
this.rotations = rotations;
this.rendererSetup = rendererSetup;
this.allowedDirections = ImmutableSet.copyOf(allowedDirections);
this.validDirections = ImmutableSet.copyOf(validDirections);
this.bitCount = bitCount;
this.mask = (1 << bitCount) - 1;

@@ -484,7 +416,7 @@ private BlockRotationMode(ForgeDirection[] rotations, IRendererSetup rendererSet

public final IRendererSetup rendererSetup;

private final Set<ForgeDirection> allowedDirections;
public final Set<ForgeDirection> validDirections;

public final int bitCount;

@@ -493,7 +425,7 @@ private BlockRotationMode(ForgeDirection[] rotations, IRendererSetup rendererSet
public final BlockTextureTransform textureTransform;

public boolean isValid(ForgeDirection dir) {
return allowedDirections.contains(dir);
return validDirections.contains(dir);
}

protected abstract BlockTextureTransform.Builder setupTextureTransform(BlockTextureTransform.Builder builder);
@@ -508,7 +440,9 @@ public boolean isValid(ForgeDirection dir) {

public abstract ForgeDirection calculateRotation(ForgeDirection direction, ForgeDirection axis);

public abstract ForgeDirection mapWorldToBlockSide(ForgeDirection rotation, ForgeDirection side);

public abstract Orientation getBlockOrientation(ForgeDirection direction);

public ForgeDirection mapWorldToBlockSide(ForgeDirection rotation, ForgeDirection side) {
return getBlockOrientation(rotation).globalToLocalDirection(side);
}
}
@@ -132,7 +132,13 @@ protected void setRenderMode(RenderMode renderMode) {
}

public ForgeDirection getRotation(int metadata) {
return blockRotationMode.fromValue(metadata & blockRotationMode.mask);
final BlockRotationMode rotationMode = getRotationMode();
return rotationMode.fromValue(metadata & rotationMode.mask);
}

public Orientation getOrientation(int metadata) {
final ForgeDirection rotation = getRotation(metadata);
return getRotationMode().getBlockOrientation(rotation);
}

@SideOnly(Side.CLIENT)
@@ -426,7 +432,7 @@ public <U extends TileEntity> U getTileEntity(IBlockAccess world, int x, int y,
}

public boolean canPlaceBlock(World world, EntityPlayer player, ItemStack stack, int x, int y, int z, ForgeDirection sideDir, ForgeDirection blockDirection, float hitX, float hitY, float hitZ, int newMeta) {
return blockRotationMode.isValid(blockDirection);
return getRotationMode().isValid(blockDirection);
}

@Override
@@ -445,7 +451,7 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase p
* This is called if your ItemBlock extends ItemOpenBlock
*/
public void afterBlockPlaced(World world, EntityPlayer player, ItemStack stack, int x, int y, int z, ForgeDirection side, ForgeDirection blockDir, float hitX, float hitY, float hitZ, int itemMeta) {
int blockMeta = blockRotationMode.toValue(blockDir);
int blockMeta = getRotationMode().toValue(blockDir);

// silently set meta, since we want to notify TE before neighbors
world.setBlockMetadataWithNotify(x, y, z, blockMeta, BlockNotifyFlags.NONE);
@@ -464,15 +470,15 @@ protected void notifyTileEntity(World world, EntityPlayer player, ItemStack stac
}

protected void setRotationMeta(World world, int x, int y, int z, ForgeDirection blockDir) {
int blockMeta = blockRotationMode.toValue(blockDir);
int blockMeta = getRotationMode().toValue(blockDir);
world.setBlockMetadataWithNotify(x, y, z, blockMeta, BlockNotifyFlags.ALL);
}

public ForgeDirection calculateSide(EntityPlayer player, ForgeDirection side) {
if (blockPlacementMode == BlockPlacementMode.SURFACE) {
return blockRotationMode.getPlacementDirectionFromSurface(side);
return getRotationMode().getPlacementDirectionFromSurface(side);
} else {
return blockRotationMode.getPlacementDirectionFromEntity(player);
return getRotationMode().getPlacementDirectionFromEntity(player);
}
}

@@ -601,12 +607,12 @@ public boolean canRotateWithTool() {

@Override
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
return canRotateWithTool() && RotationHelper.rotate(blockRotationMode, worldObj, x, y, z, axis);
return canRotateWithTool() && RotationHelper.rotate(getRotationMode(), worldObj, x, y, z, axis);
}

@Override
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z) {
if (!canRotateWithTool()) return RotationAxis.NO_AXIS;
return blockRotationMode.rotations;
return getRotationMode().rotations;
}
}
@@ -23,17 +23,17 @@ public Class<?> define(byte[] data) {
private static Matrix3d createTranformMatrix(Orientation o) {
// basis change matrix - local east (X), up (Y), south (Z) are new basis vectors
final Matrix3d mat = new Matrix3d();
mat.m00 = o.x.offsetX;
mat.m01 = o.x.offsetY;
mat.m02 = o.x.offsetZ;
mat.m00 = o.x.x;
mat.m01 = o.x.y;
mat.m02 = o.x.z;

mat.m10 = o.y.offsetX;
mat.m11 = o.y.offsetY;
mat.m12 = o.y.offsetZ;
mat.m10 = o.y.x;
mat.m11 = o.y.y;
mat.m12 = o.y.z;

mat.m20 = o.z.offsetX;
mat.m21 = o.z.offsetY;
mat.m22 = o.z.offsetZ;
mat.m20 = o.z.x;
mat.m21 = o.z.y;
mat.m22 = o.z.z;
return mat;
}