Java Code Examples for net.minecraftforge.common.util.ForgeDirection#SOUTH

The following examples show how to use net.minecraftforge.common.util.ForgeDirection#SOUTH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockArcaneDropper.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
    int metadata = world.getBlockMetadata(x, y, z);

    ForgeDirection direction = ForgeDirection.getOrientation(metadata & 7);
    boolean flipped = (metadata & 8) == 8;

    if(direction == ForgeDirection.SOUTH
            || direction == ForgeDirection.NORTH) {
        flipped = !flipped;
    }

    ForgeDirection rotated = direction.getRotation(flipped ? ForgeDirection.getOrientation((direction.ordinal() + 4) % 6) : ForgeDirection.getOrientation((direction.ordinal() + 2) % 6));

    return direction != side && rotated != side && rotated.getOpposite() != side;
}
 
Example 2
Source File: TileEntityVortexTube.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public ForgeDirection getTubeDirection(){
    ForgeDirection d;

    switch(getRotation()){
        case DOWN:
        case NORTH:
        case UP:
            d = ForgeDirection.WEST;
            break;
        case SOUTH:
            d = ForgeDirection.EAST;
            break;
        case WEST:
            d = ForgeDirection.SOUTH;
            break;
        case EAST:
            d = ForgeDirection.NORTH;
            break;
        default:
            d = ForgeDirection.SOUTH;
    }
    for(int i = 0; i < roll; i++) {
        d = d.getRotation(getRotation());
    }
    return d;
}
 
Example 3
Source File: PneumaticCraftUtils.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the ForgeDirection of the facing of the entity given.
 * @param entity
 * @param includeUpAndDown false when UP/DOWN should not be included.
 * @return
 */
public static ForgeDirection getDirectionFacing(EntityLivingBase entity, boolean includeUpAndDown){
    double yaw = entity.rotationYaw;
    while(yaw < 0)
        yaw += 360;
    yaw = yaw % 360;
    if(includeUpAndDown) {
        if(entity.rotationPitch > 45) return ForgeDirection.DOWN;
        else if(entity.rotationPitch < -45) return ForgeDirection.UP;
    }
    if(yaw < 45) return ForgeDirection.SOUTH;
    else if(yaw < 135) return ForgeDirection.WEST;
    else if(yaw < 225) return ForgeDirection.NORTH;
    else if(yaw < 315) return ForgeDirection.EAST;

    else return ForgeDirection.SOUTH;
}
 
Example 4
Source File: BlockPresent.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public AxisAlignedBB getBoundingBox(TileEntityPresent me) {
	if (me == null) {
		return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
	}
	int x = me.xCoord, y = me.yCoord, z = me.zCoord;
	if (me.isConnected()) {
		ForgeDirection dir = me.getConnectionDir();
		// warning: magic below! Do not change this conditional
		if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH) || (!me.isParent() && dir == ForgeDirection.SOUTH)) {
			return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX + dir.offsetX, y + maxY, z + maxZ + dir.offsetZ);
		} else {
			return AxisAlignedBB.getBoundingBox(x + dir.offsetX + minX, y + minY, z + dir.offsetZ + minZ, x + maxX, y + maxY, z + maxZ);
		}
	}
	return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
}
 
Example 5
Source File: RectangularMultiblockTileEntityBase.java    From BeefCore with MIT License 5 votes vote down vote up
public void recalculateOutwardsDirection(CoordTriplet minCoord, CoordTriplet maxCoord) {
	outwards = ForgeDirection.UNKNOWN;
	position = PartPosition.Unknown;

	int facesMatching = 0;
	if(maxCoord.x == this.xCoord || minCoord.x == this.xCoord) { facesMatching++; }
	if(maxCoord.y == this.yCoord || minCoord.y == this.yCoord) { facesMatching++; }
	if(maxCoord.z == this.zCoord || minCoord.z == this.zCoord) { facesMatching++; }
	
	if(facesMatching <= 0) { position = PartPosition.Interior; }
	else if(facesMatching >= 3) { position = PartPosition.FrameCorner; }
	else if(facesMatching == 2) { position = PartPosition.Frame; }
	else {
		// 1 face matches
		if(maxCoord.x == this.xCoord) {
			position = PartPosition.EastFace;
			outwards = ForgeDirection.EAST;
		}
		else if(minCoord.x == this.xCoord) {
			position = PartPosition.WestFace;
			outwards = ForgeDirection.WEST;
		}
		else if(maxCoord.z == this.zCoord) {
			position = PartPosition.SouthFace;
			outwards = ForgeDirection.SOUTH;
		}
		else if(minCoord.z == this.zCoord) {
			position = PartPosition.NorthFace;
			outwards = ForgeDirection.NORTH;
		}
		else if(maxCoord.y == this.yCoord) {
			position = PartPosition.TopFace;
			outwards = ForgeDirection.UP;
		}
		else {
			position = PartPosition.BottomFace;
			outwards = ForgeDirection.DOWN;
		}
	}
}
 
Example 6
Source File: CoordTriplet.java    From BeefCore with MIT License 5 votes vote down vote up
public ForgeDirection getOppositeDirectionFromSourceCoords(int x, int y, int z) {
	if(this.x < x) { return ForgeDirection.EAST; }
	else if(this.x > x) { return ForgeDirection.WEST; }
	else if(this.y < y) { return ForgeDirection.UP; }
	else if(this.y > y) { return ForgeDirection.DOWN; }
	else if(this.z < z) { return ForgeDirection.NORTH; }
	else if(this.z > z) { return ForgeDirection.SOUTH; }
	else { return ForgeDirection.UNKNOWN; }
}
 
Example 7
Source File: TileEntityPressureChamberValve.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isConnectedTo(ForgeDirection side){
    switch(ForgeDirection.getOrientation(getBlockMetadata())){
        case UP:
        case DOWN:
            return side == ForgeDirection.UP || side == ForgeDirection.DOWN;
        case NORTH:
        case SOUTH:
            return side == ForgeDirection.NORTH || side == ForgeDirection.SOUTH;
        case EAST:
        case WEST:
            return side == ForgeDirection.EAST || side == ForgeDirection.WEST;
    }
    return false;
}
 
Example 8
Source File: BlockUVLightBox.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z){
    ForgeDirection facing = ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z));
    if(facing == ForgeDirection.NORTH || facing == ForgeDirection.SOUTH) {
        setBlockBounds(BBConstants.UV_LIGHT_BOX_LENGTH_MIN, 0, BBConstants.UV_LIGHT_BOX_WIDTH_MIN, 1 - BBConstants.UV_LIGHT_BOX_LENGTH_MIN, BBConstants.UV_LIGHT_BOX_TOP_MAX, 1 - BBConstants.UV_LIGHT_BOX_WIDTH_MIN);
    } else {
        setBlockBounds(BBConstants.UV_LIGHT_BOX_WIDTH_MIN, 0, BBConstants.UV_LIGHT_BOX_LENGTH_MIN, 1 - BBConstants.UV_LIGHT_BOX_WIDTH_MIN, BBConstants.UV_LIGHT_BOX_TOP_MAX, 1 - BBConstants.UV_LIGHT_BOX_LENGTH_MIN);
    }
}
 
Example 9
Source File: BlockKeroseneLamp.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z){
    ForgeDirection facing = ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z));
    if(facing == ForgeDirection.NORTH || facing == ForgeDirection.SOUTH) {
        setBlockBounds(BBConstants.KEROSENE_LAMP_LENGTH_MIN, 0, BBConstants.KEROSENE_LAMP_WIDTH_MIN, 1 - BBConstants.KEROSENE_LAMP_LENGTH_MIN, BBConstants.KEROSENE_LAMP_TOP_MAX, 1 - BBConstants.KEROSENE_LAMP_WIDTH_MIN);
    } else {
        setBlockBounds(BBConstants.KEROSENE_LAMP_WIDTH_MIN, 0, BBConstants.KEROSENE_LAMP_LENGTH_MIN, 1 - BBConstants.KEROSENE_LAMP_WIDTH_MIN, BBConstants.KEROSENE_LAMP_TOP_MAX, 1 - BBConstants.KEROSENE_LAMP_LENGTH_MIN);
    }
}
 
Example 10
Source File: WorldCoord.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Will Return NULL if it's at some diagonal!
 */
public ForgeDirection directionTo(WorldCoord loc)
{
	int ox = x - loc.x;
	int oy = y - loc.y;
	int oz = z - loc.z;

	int xlen = Math.abs( ox );
	int ylen = Math.abs( oy );
	int zlen = Math.abs( oz );

	if ( loc.isEqual( this.copy().add( ForgeDirection.EAST, xlen ) ) )
		return ForgeDirection.EAST;

	if ( loc.isEqual( this.copy().add( ForgeDirection.WEST, xlen ) ) )
		return ForgeDirection.WEST;

	if ( loc.isEqual( this.copy().add( ForgeDirection.NORTH, zlen ) ) )
		return ForgeDirection.NORTH;

	if ( loc.isEqual( this.copy().add( ForgeDirection.SOUTH, zlen ) ) )
		return ForgeDirection.SOUTH;

	if ( loc.isEqual( this.copy().add( ForgeDirection.UP, ylen ) ) )
		return ForgeDirection.UP;

	if ( loc.isEqual( this.copy().add( ForgeDirection.DOWN, ylen ) ) )
		return ForgeDirection.DOWN;

	return null;
}
 
Example 11
Source File: StaticUtils.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * @param entity The entity whose facing you wish to query.
 * @return The ForgeDirection which entity is facing (north/south/east/west)
 */
protected ForgeDirection getFacingDirection(Entity entity) {
	int facingAngle = (MathHelper.floor_double((entity.rotationYaw * 4F) / 360F + 0.5D) & 3);
	switch(facingAngle) {
	case 1:
		return ForgeDirection.EAST;
	case 2:
		return ForgeDirection.SOUTH;
	case 3:
		return ForgeDirection.WEST;
	default:
		return ForgeDirection.NORTH;
	}
}
 
Example 12
Source File: CoordTriplet.java    From BeefCore with MIT License 5 votes vote down vote up
public ForgeDirection getDirectionFromSourceCoords(int x, int y, int z) {
	if(this.x < x) { return ForgeDirection.WEST; }
	else if(this.x > x) { return ForgeDirection.EAST; }
	else if(this.y < y) { return ForgeDirection.DOWN; }
	else if(this.y > y) { return ForgeDirection.UP; }
	else if(this.z < z) { return ForgeDirection.SOUTH; }
	else if(this.z > z) { return ForgeDirection.NORTH; }
	else { return ForgeDirection.UNKNOWN; }
}
 
Example 13
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canOutputTo(ForgeDirection direction) {
    if(isMultiblockFormed() && multiblockYIndex == 1) { //The middle one
        return direction == ForgeDirection.SOUTH ||
                direction == ForgeDirection.NORTH ||
                direction == ForgeDirection.EAST ||
                direction == ForgeDirection.WEST;
    }
    return false;
}
 
Example 14
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canInputFrom(ForgeDirection direction) {
    if(isMultiblockFormed() && multiblockYIndex == 1) { //The middle one
        return direction == ForgeDirection.SOUTH ||
                direction == ForgeDirection.NORTH ||
                direction == ForgeDirection.EAST ||
                direction == ForgeDirection.WEST;
    }
    return false;
}
 
Example 15
Source File: TileStickyJar.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ForgeDirection changeDirection(ForgeDirection face) {
    if(placedOn == ForgeDirection.UP) {
        if(face == ForgeDirection.UP || face == ForgeDirection.DOWN) {
            return face.getOpposite();
        }
        return face;
    }

    if(placedOn == ForgeDirection.DOWN) {
        return face;
    }


    if(face == ForgeDirection.UP) {
        return ForgeDirection.NORTH;
    }
    if(face == ForgeDirection.DOWN) {
        return ForgeDirection.SOUTH;
    }
    if(face == placedOn) {
        return ForgeDirection.DOWN;
    }
    if(face == placedOn.getOpposite()) {
        return ForgeDirection.UP;
    }


    switch (placedOn) {
        case EAST: return face == ForgeDirection.NORTH ? ForgeDirection.WEST : ForgeDirection.EAST;
        case SOUTH: return face.getOpposite();
        case WEST: return face == ForgeDirection.SOUTH ? ForgeDirection.WEST : ForgeDirection.EAST;
    }

    return face;
}
 
Example 16
Source File: RenderBabyChest.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity pTileEntity, double pX, double pY, double pZ, float pTick)
{
    if (pTileEntity instanceof TileEntityBabyChest)
    {
        TileEntityBabyChest tTileEntityBabyChest = (TileEntityBabyChest) pTileEntity;
        ForgeDirection tDirection = null;

        if (tTileEntityBabyChest.getWorldObj() != null) {
            tDirection = tTileEntityBabyChest.getOrientation();
        }

        World tWorld = tTileEntityBabyChest.getWorldObj();
        Block tBlock = tWorld.getBlock(tTileEntityBabyChest.xCoord, tTileEntityBabyChest.yCoord, tTileEntityBabyChest.zCoord);

        if (tBlock instanceof BlockBabyChest)
        {
            BlockBabyChest blockBabyChest = (BlockBabyChest) tBlock;
            bindTexture(new ResourceLocation("minecraft:textures/entity/chest/normal.png"));
        }

        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) pX, (float) pY + 1.0F, (float) pZ + 1.0F);
        GL11.glScalef(0.5F, -0.5F, -0.5F);
        GL11.glTranslatef(0.5F, 1F, 0.5F);
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        short tAngle = 0;

        if (tDirection != null) {
            if (tDirection == ForgeDirection.NORTH) {
                tAngle = 180;
            } else if (tDirection == ForgeDirection.SOUTH) {
                tAngle = 0;
            } else if (tDirection == ForgeDirection.WEST) {
                tAngle = 90;
            } else if (tDirection == ForgeDirection.EAST) {
                tAngle = -90;
            }
        }

        GL11.glRotatef(tAngle, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float adjustedLidAngle = tTileEntityBabyChest._mPrevLidAngle + (tTileEntityBabyChest._mLidAngle - tTileEntityBabyChest._mPrevLidAngle) * pTick;
        adjustedLidAngle = 1.0F - adjustedLidAngle;
        adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle;
        _mModelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F);
        _mModelChest.renderAll();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}
 
Example 17
Source File: WorldCoord.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Will Return NULL if it's at some diagonal!
 */
public ForgeDirection directionTo( WorldCoord loc )
{
	int ox = this.x - loc.x;
	int oy = this.y - loc.y;
	int oz = this.z - loc.z;

	int xlen = Math.abs( ox );
	int ylen = Math.abs( oy );
	int zlen = Math.abs( oz );

	if( loc.isEqual( this.copy().add( ForgeDirection.EAST, xlen ) ) )
	{
		return ForgeDirection.EAST;
	}

	if( loc.isEqual( this.copy().add( ForgeDirection.WEST, xlen ) ) )
	{
		return ForgeDirection.WEST;
	}

	if( loc.isEqual( this.copy().add( ForgeDirection.NORTH, zlen ) ) )
	{
		return ForgeDirection.NORTH;
	}

	if( loc.isEqual( this.copy().add( ForgeDirection.SOUTH, zlen ) ) )
	{
		return ForgeDirection.SOUTH;
	}

	if( loc.isEqual( this.copy().add( ForgeDirection.UP, ylen ) ) )
	{
		return ForgeDirection.UP;
	}

	if( loc.isEqual( this.copy().add( ForgeDirection.DOWN, ylen ) ) )
	{
		return ForgeDirection.DOWN;
	}

	return null;
}
 
Example 18
Source File: TileEntityTicketMachine.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public IIcon getIcon(ForgeDirection rotatedDir) {
	if (rotatedDir == ForgeDirection.SOUTH) return hasTicket.getValue()? BlockTicketMachine.iconFrontTicket : BlockTicketMachine.iconFrontEmpty;
	return null;
}
 
Example 19
Source File: BlockStickyJar.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void flipBlockBounds(TileStickyJar stickyJar) {
    ForgeDirection placedOn = stickyJar.placedOn;

    if (placedOn != ForgeDirection.DOWN) {
        float minX = (float) getBlockBoundsMinX();
        float minY = (float) getBlockBoundsMinY();
        float minZ = (float) getBlockBoundsMinZ();
        float maxX = (float) getBlockBoundsMaxX();
        float maxY = (float) getBlockBoundsMaxY();
        float maxZ = (float) getBlockBoundsMaxZ();

        float temp;
        if (placedOn == ForgeDirection.NORTH || placedOn == ForgeDirection.SOUTH) {
            temp = minZ;
            minZ = minY;
            minY = temp;

            temp = maxZ;
            maxZ = maxY;
            maxY = temp;
        } else if (placedOn == ForgeDirection.WEST || placedOn == ForgeDirection.EAST) {
            temp = minX;
            minX = minY;
            minY = temp;

            temp = maxX;
            maxX = maxY;
            maxY = temp;
        }

        if (placedOn == ForgeDirection.UP || placedOn == ForgeDirection.SOUTH || placedOn == ForgeDirection.EAST) {
            minX = 1 - minX;
            minY = 1 - minY;
            minZ = 1 - minZ;
            maxX = 1 - maxX;
            maxY = 1 - maxY;
            maxZ = 1 - maxZ;

            temp = minX;
            minX = maxX;
            maxX = temp;

            temp = minY;
            minY = maxY;
            maxY = temp;

            temp = minZ;
            minZ = maxZ;
            maxZ = temp;
        }

        this.minX = minX;
        this.minY = minY;
        this.minZ = minZ;
        this.maxX = maxX;
        this.maxY = maxY;
        this.maxZ = maxZ;
    }
}
 
Example 20
Source File: TileEntityBabyChest.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
public TileEntityBabyChest()
{
    _mInventory = new ItemStack[1];
    _mOrientation = ForgeDirection.SOUTH;
    _mSides = new int[] {0};
}