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

The following examples show how to use net.minecraftforge.common.util.ForgeDirection#NORTH . 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: BlockPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Determine if this block can make a redstone connection on the side provided,
 * Useful to control which sides are inputs and outputs for redstone wires.
 *
 * Side:
 *  -1: UP
 *   0: NORTH
 *   1: EAST
 *   2: SOUTH
 *   3: WEST
 *
 * @param world The current world
 * @param x X Position
 * @param y Y Position
 * @param z Z Position
 * @param side The side that is trying to make the connection
 * @return True to make the connection
 */
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side){
    if(side < 0 || side > 3) return false;
    TileEntityPressureTube tube = (TileEntityPressureTube)world.getTileEntity(x, y, z);
    ForgeDirection d = ForgeDirection.NORTH;
    for(int i = 0; i < side; i++) {
        d = d.getRotation(ForgeDirection.UP);
    }
    side = d.ordinal();
    for(int i = 0; i < 6; i++) {
        if(tube.modules[i] != null) {
            if((side ^ 1) == i || i != side && tube.modules[i].isInline()) {//if we are on the same side, or when we have an 'in line' module that is not on the opposite side.
                if(tube.modules[i] instanceof TubeModuleRedstoneEmitting) return true;
            }
        }
    }
    return false;
}
 
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 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 7
Source File: TileEntityVacuumPump.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isConnectedTo(ForgeDirection side){
    int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    switch(ForgeDirection.getOrientation(meta)){
        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: TileEntityAssemblyRobot.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public ForgeDirection[] getPlatformDirection(){
    for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if(dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
            if(worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{dir, ForgeDirection.UNKNOWN};
        }
    }
    if(canMoveToDiagonalNeighbours()) {
        if(worldObj.getTileEntity(xCoord + ForgeDirection.NORTH.offsetX + ForgeDirection.WEST.offsetX, yCoord, zCoord + ForgeDirection.NORTH.offsetZ + ForgeDirection.WEST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.NORTH, ForgeDirection.WEST};
        if(worldObj.getTileEntity(xCoord + ForgeDirection.NORTH.offsetX + ForgeDirection.EAST.offsetX, yCoord, zCoord + ForgeDirection.NORTH.offsetZ + ForgeDirection.EAST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.NORTH, ForgeDirection.EAST};
        if(worldObj.getTileEntity(xCoord + ForgeDirection.SOUTH.offsetX + ForgeDirection.WEST.offsetX, yCoord, zCoord + ForgeDirection.SOUTH.offsetZ + ForgeDirection.WEST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.SOUTH, ForgeDirection.WEST};
        if(worldObj.getTileEntity(xCoord + ForgeDirection.SOUTH.offsetX + ForgeDirection.EAST.offsetX, yCoord, zCoord + ForgeDirection.SOUTH.offsetZ + ForgeDirection.EAST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.SOUTH, ForgeDirection.EAST};
    }
    return null;
}
 
Example 9
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 10
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 11
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 12
Source File: AchievementHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static void checkFor9x9(EntityPlayer player, int x, int y, int z){
    ChunkCache cache = new ChunkCache(player.worldObj, x - 8, y, z - 8, x + 8, y, z + 8, 0);
    ForgeDirection[] dirs = {ForgeDirection.NORTH, ForgeDirection.WEST};
    for(ForgeDirection dir : dirs) {
        int wallLength = 1;
        int minX = x;
        int minZ = z;
        int maxX = x;
        int maxZ = z;
        int newX = x + dir.offsetX;
        int newZ = z + dir.offsetZ;
        while(wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) {
            wallLength++;
            minX = Math.min(minX, newX);
            minZ = Math.min(minZ, newZ);
            maxX = Math.max(maxX, newX);
            maxZ = Math.max(maxZ, newZ);
            newX += dir.offsetX;
            newZ += dir.offsetZ;
        }
        newX = x - dir.offsetX;
        newZ = z - dir.offsetZ;
        while(wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) {
            wallLength++;
            minX = Math.min(minX, newX);
            minZ = Math.min(minZ, newZ);
            maxX = Math.max(maxX, newX);
            maxZ = Math.max(maxZ, newZ);
            newX -= dir.offsetX;
            newZ -= dir.offsetZ;
        }
        if(wallLength == 9) {
            if(checkFor9x9(cache, x, y, z, minX, minZ, maxX, maxZ)) {
                giveAchievement(player, "dw9x9");
                return;
            }
        }
    }
}
 
Example 13
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 14
Source File: EndRod.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
	ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));

	if (dir == ForgeDirection.DOWN || dir == ForgeDirection.UP)
		setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
	else if (dir == ForgeDirection.WEST || dir == ForgeDirection.EAST)
		setBlockBounds(0.0F, 0.375F, 0.375F, 1.0F, 0.625F, 0.625F);
	else if (dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH)
		setBlockBounds(0.375F, 0.375F, 0.0F, 0.625F, 0.625F, 1.0F);
}
 
Example 15
Source File: EtFuturumWorldGenerator.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public static void generateChorusPlant(World world, int x, int y, int z, int pass) {
	int height;
	for (height = 0; height < 4; height++) {
		if (!ChorusFlower.canPlantStay(world, x, y + height, z)) {
			world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2);
			break;
		}
		world.setBlock(x, y + height, z, ModBlocks.chorus_plant);
	}
	if (height > 1) {
		world.setBlock(x, y + height, z, ModBlocks.chorus_plant);
		boolean grew = false;

		if (pass < 5) {
			ForgeDirection[] dirs = new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.SOUTH };
			for (int j = 0; j < world.rand.nextInt(4); j++) {
				ForgeDirection dir = dirs[world.rand.nextInt(dirs.length)];
				int xx = x + dir.offsetX;
				int yy = y + height + dir.offsetY;
				int zz = z + dir.offsetZ;
				if (world.isAirBlock(xx, yy, zz) && ChorusFlower.isSpaceAroundFree(world, xx, yy, zz, dir.getOpposite())) {
					generateChorusPlant(world, xx, yy, zz, pass + 1);
					grew = true;
				}
			}
		}

		if (!grew)
			world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2);
	}
}
 
Example 16
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 17
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 18
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 19
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 20
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;
    }
}