use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityBreakerSwitch method onDirectionalPlacement.
@Override
public void onDirectionalPlacement(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer) {
EnumFacing f = EnumFacing.SOUTH;
if (side.getAxis() == Axis.Y) {
float xFromMid = hitX - .5f;
float zFromMid = hitZ - .5f;
float max = Math.max(Math.abs(xFromMid), Math.abs(zFromMid));
if (max == Math.abs(xFromMid))
f = xFromMid < 0 ? EnumFacing.WEST : EnumFacing.EAST;
else
f = zFromMid < 0 ? EnumFacing.NORTH : EnumFacing.SOUTH;
if ((side == EnumFacing.UP && f.getAxis() == Axis.Z) || side == EnumFacing.DOWN)
f = f.getOpposite();
}
rotation = f.getHorizontalIndex();
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityBreakerSwitch method notifyNeighbours.
public void notifyNeighbours() {
markDirty();
worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType());
for (EnumFacing f : EnumFacing.VALUES) worldObj.notifyNeighborsOfStateChange(getPos().offset(f), getBlockType());
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityBreakerSwitch method calculateLeftConn.
protected void calculateLeftConn(Matrix4 transform) {
Vec3d leftVec = transform.apply(new Vec3d(-1, .5, .5)).subtract(0, .5, .5);
EnumFacing dir = EnumFacing.getFacingFromVector((float) leftVec.xCoord, (float) leftVec.yCoord, (float) leftVec.zCoord);
int maxDiff = Integer.MIN_VALUE;
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
if (conns != null)
for (Connection c : conns) {
Vec3i diff = pos.equals(c.start) ? c.end.subtract(pos) : c.start.subtract(pos);
int val = 0;
switch(dir.getAxis()) {
case X:
val = diff.getX();
break;
case Y:
val = diff.getY();
break;
case Z:
val = diff.getZ();
}
val *= dir.getAxisDirection().getOffset();
if (val > maxDiff) {
maxDiff = val;
endOfLeftConnection = pos == c.end ? c.start : c.end;
}
}
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityBottlingMachine method getBlockBounds.
@Override
public float[] getBlockBounds() {
if (pos == 4)
return new float[] { 0, 0, 0, 1, .5f, 1 };
if (pos < 6 || pos == 11)
return new float[] { 0, 0, 0, 1, 1, 1 };
if (pos >= 6 && pos <= 8)
return new float[] { 0, 0, 0, 1, .125f, 1 };
if (pos == 9)
return new float[] { .0625f, 0, .0625f, .9375f, 1, .9375f };
if (pos == 10) {
EnumFacing f = mirrored ? facing.rotateYCCW() : facing.rotateY();
float xMin = f == EnumFacing.EAST ? -.0625f : f == EnumFacing.WEST ? .25f : facing == EnumFacing.WEST ? .125f : facing == EnumFacing.EAST ? .25f : 0;
float zMin = facing == EnumFacing.NORTH ? .125f : facing == EnumFacing.SOUTH ? .25f : f == EnumFacing.SOUTH ? -.0625f : f == EnumFacing.NORTH ? .25f : 0;
float xMax = f == EnumFacing.EAST ? .75f : f == EnumFacing.WEST ? 1.0625f : facing == EnumFacing.WEST ? .75f : facing == EnumFacing.EAST ? .875f : 1;
float zMax = facing == EnumFacing.NORTH ? .75f : facing == EnumFacing.SOUTH ? .875f : f == EnumFacing.SOUTH ? .75f : f == EnumFacing.NORTH ? 1.0625f : 1;
return new float[] { xMin, .0625f, zMin, xMax, .6875f, zMax };
}
if (pos == 13) {
float xMin = facing == EnumFacing.WEST ? 0 : .21875f;
float zMin = facing == EnumFacing.NORTH ? 0 : .21875f;
float xMax = facing == EnumFacing.EAST ? 1 : .78125f;
float zMax = facing == EnumFacing.SOUTH ? 1 : .78125f;
return new float[] { xMin, -.4375f, zMin, xMax, .5625f, zMax };
}
if (pos == 16) {
float xMin = facing == EnumFacing.WEST ? .8125f : facing == EnumFacing.EAST ? 0 : .125f;
float zMin = facing == EnumFacing.NORTH ? .8125f : facing == EnumFacing.SOUTH ? 0 : .125f;
float xMax = facing == EnumFacing.WEST ? 1 : facing == EnumFacing.EAST ? .1875f : .875f;
float zMax = facing == EnumFacing.NORTH ? 1 : facing == EnumFacing.SOUTH ? .1875f : .875f;
return new float[] { xMin, -1, zMin, xMax, .25f, zMax };
}
return new float[] { 0, 0, 0, 1, 1, 1 };
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityConnectorRedstone method getConnectionOffset.
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = facing.getOpposite();
double conRadius = con.cableType.getRenderDiameter() / 2;
return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ());
}
Aggregations