Java Code Examples for net.minecraft.util.EnumFacing#NORTH

The following examples show how to use net.minecraft.util.EnumFacing#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: Shredder.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
Example 2
Source File: SolarGlass.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
Example 3
Source File: PuzzleTESR.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
private void setupRotation(IBlockState state) {
    EnumFacing facing = state.getValue(BlockPuzzle.FACING);
    if (facing == EnumFacing.UP) {
        GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(0.0F, 0.0F, -0.68F);
    } else if (facing == EnumFacing.DOWN) {
        GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(0.0F, 0.0F, -.184F);
    } else {
        float rotY = 0.0F;
        if (facing == EnumFacing.NORTH) {
            rotY = 180.0F;
        } else if (facing == EnumFacing.WEST) {
            rotY = 90.0F;
        } else if (facing == EnumFacing.EAST) {
            rotY = -90.0F;
        }
        GlStateManager.rotate(-rotY, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.2500F, -0.4375F);
    }
}
 
Example 4
Source File: BlockMethods.java    From pycode-minecraft with MIT License 5 votes vote down vote up
public void put(PyObject[] args, String[] kws) {
    if (this.world == null || this.world.isRemote) return;
    ArgParser r = new ArgParser("put", s("pos", "blockname"), PyRegistry.BLOCK_VARIATIONS);
    r.parse(args, kws);
    MyBlockPos mpos = (MyBlockPos)r.get("pos").__tojava__(MyBlockPos.class);
    BlockPos pos = mpos.blockPos;
    EnumFacing facing = EnumFacing.NORTH;
    IBlockState state = PyRegistry.getBlockVariant(r, pos, facing, (WorldServer)this.world);
    this.put(pos, state, facing);
}
 
Example 5
Source File: TeleportEntityNetherPortal.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected EnumFacing getPortalOrientation(World world, BlockPos portalPos)
{
    if (world.getBlockState(portalPos.west()).getBlock() == Blocks.PORTAL ||
        world.getBlockState(portalPos.east()).getBlock() == Blocks.PORTAL)
    {
        return EnumFacing.EAST;
    }
    else if (world.getBlockState(portalPos.north()).getBlock() == Blocks.PORTAL ||
             world.getBlockState(portalPos.south()).getBlock() == Blocks.PORTAL)
    {
        return EnumFacing.SOUTH;
    }

    return EnumFacing.NORTH;
}
 
Example 6
Source File: BlockBlueprintArchive.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 7
Source File: BlockPassengerChair.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 8
Source File: BlockBeaconLarge.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 9
Source File: BlockTFCompressor.java    From TofuCraftReload with MIT License 5 votes vote down vote up
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.north());
        IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
        IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
        IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
        EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

        if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock())
        {
            enumfacing = EnumFacing.SOUTH;
        }
        else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock())
        {
            enumfacing = EnumFacing.NORTH;
        }
        else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock())
        {
            enumfacing = EnumFacing.EAST;
        }
        else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock())
        {
            enumfacing = EnumFacing.WEST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
    }
}
 
Example 10
Source File: GTModelMortar.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected BlockPartFace createWallFaceNS(EnumFacing side) {
	if (side == EnumFacing.UP || side == EnumFacing.DOWN) {
		return new BlockPartFace((EnumFacing) null, -1, "", new BlockFaceUV(new float[] { 0.0F, 0.0F, 12.0F,
				2.0F }, 0));
	}
	if (side == EnumFacing.NORTH || side == EnumFacing.SOUTH) {
		return new BlockPartFace((EnumFacing) null, -1, "", new BlockFaceUV(new float[] { 0.0F, 0.0F, 10.0F,
				5.0F }, 0));
	}
	return new BlockPartFace((EnumFacing) null, -1, "", new BlockFaceUV(new float[] { 0.0F, 0.0F, 2.0F, 5.0F }, 0));
}
 
Example 11
Source File: FacingHelper.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public static EnumFacing intToFacing(int id) {
    switch(id) {
        case 1:
            return EnumFacing.NORTH;
        case 2:
            return EnumFacing.EAST;
        case 3:
            return EnumFacing.SOUTH;
        case 4:
            return EnumFacing.WEST;
        default:
            return EnumFacing.NORTH;
    }
}
 
Example 12
Source File: BlockLiftLever.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
@Nonnull
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, enumfacing);
}
 
Example 13
Source File: BlockBeacon.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 14
Source File: IslandData.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void enablePortal(EnumFacing facing)
{
	if(facing == EnumFacing.NORTH)
		northPortalState = PortalEnumType.Enabled;
	else if(facing == EnumFacing.SOUTH)
		southPortalState = PortalEnumType.Enabled;
	else if(facing == EnumFacing.EAST)
		eastPortalState = PortalEnumType.Enabled;
	else if(facing == EnumFacing.WEST)
		westPortalState = PortalEnumType.Enabled;
}
 
Example 15
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * Initiates construction of the Structure Component picked, at the current Location of StructGen
 */
public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand) {
    int i = this.getComponentType();
    int j = rand.nextInt(4);
    EnumFacing enumfacing = this.getCoordBaseMode();

    if (enumfacing != null) {
        switch (enumfacing) {
            case NORTH:
            default:

                if (j <= 1) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ - 1, enumfacing, i);
                } else if (j == 2) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, EnumFacing.WEST, i);
                } else {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, EnumFacing.EAST, i);
                }

                break;
            case SOUTH:

                if (j <= 1) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ + 1, enumfacing, i);
                } else if (j == 2) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ - 3, EnumFacing.WEST, i);
                } else {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ - 3, EnumFacing.EAST, i);
                }

                break;
            case WEST:

                if (j <= 1) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, enumfacing, i);
                } else if (j == 2) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
                } else {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
                }

                break;
            case EAST:

                if (j <= 1) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, enumfacing, i);
                } else if (j == 2) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
                } else {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
                }
        }
    }

    if (i < 8) {
        if (enumfacing != EnumFacing.NORTH && enumfacing != EnumFacing.SOUTH) {
            for (int i1 = this.boundingBox.minX + 3; i1 + 3 <= this.boundingBox.maxX; i1 += 5) {
                int j1 = rand.nextInt(5);

                if (j1 == 0) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, i1, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, i + 1);
                } else if (j1 == 1) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, i1, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i + 1);
                }
            }
        } else {
            for (int k = this.boundingBox.minZ + 3; k + 3 <= this.boundingBox.maxZ; k += 5) {
                int l = rand.nextInt(5);

                if (l == 0) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, k, EnumFacing.WEST, i + 1);
                } else if (l == 1) {
                    StructureTofuMineshaftPieces.generateAndAddPiece(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, k, EnumFacing.EAST, i + 1);
                }
            }
        }
    }
}
 
Example 16
Source File: BlockMap.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private void parsePaleteBlockParameter(String blockname, String propertyString, PaletteEntry entry) {
	String[] aProp = propertyString.split(":");

	if (aProp.length != 2) {
		return;
	}

	IProperty prop = null;
  	EnumFacing value = null;

	if ("facing".equals(aProp[0])) {
		// 

		// prop = PropertyDirection.create("facing", new Predicate() {
		// };<EnumFacing><EnumFacing>();

		
		if(blockname.equals("minecraft:torch")){
			prop = PropertyDirection.create("facing", new Predicate<EnumFacing>() {
				public boolean apply(EnumFacing p_apply_1_) {
					return p_apply_1_ != EnumFacing.DOWN;
				}
			});
			//FIXME
			//return;
		}else{
			prop = BlockHorizontal.FACING;
		}
		
		
	} // PropertyDirection

	if ("north".equals(aProp[1])) {
		value = EnumFacing.NORTH;
	} else if ("south".equals(aProp[1])) {
		value = EnumFacing.SOUTH;
	}
	
	

	if (value == null || prop == null) {
		return;
	}

	System.out.println("adding property [" + aProp[0] + "] [" + aProp[1] + "]");

	entry.block = entry.block.withProperty(prop, value);
}
 
Example 17
Source File: TeleportEntityNetherPortal.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TeleportEntityNetherPortal()
{
    this.portalAxis = EnumFacing.NORTH;
}
 
Example 18
Source File: OpenTileEntity.java    From OpenModsLib with MIT License 4 votes vote down vote up
public EnumFacing getFront(IBlockState state) {
	final Block block = state.getBlock();
	if (!(block instanceof OpenBlock)) return EnumFacing.NORTH;
	final OpenBlock openBlock = (OpenBlock)block;
	return openBlock.getFront(state);
}
 
Example 19
Source File: WorldGenFallenTree.java    From Traverse-Legacy-1-12-2 with MIT License 4 votes vote down vote up
public boolean generate(World worldIn, Random rand, BlockPos position) {
    int num = rand.nextInt(5);
    EnumFacing orientation;
    if (num == 0) {
        orientation = EnumFacing.EAST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.WEST;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
    } else if (num == 1) {
        orientation = EnumFacing.SOUTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    } else {
        orientation = EnumFacing.NORTH;
        stateWood = stateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z);
    }
    int i = rand.nextInt(2) + this.minTreeLength;
    boolean flag = true;

    if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 1;

            if (j == position.getY()) {
                k = 0;
            }

            if (j >= position.getY() + 1 + i - 2) {
                k = 2;
            }

            BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();

            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < worldIn.getHeight()) {
                        if (!this.isReplaceable(worldIn, mutablePos.setPos(l, j, i1))) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }

        if (!flag) {
            return false;
        } else {
            IBlockState state = worldIn.getBlockState(position.down());

            if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
                state.getBlock().onPlantGrow(state, worldIn, position.down(), position);

                for (int j3 = 0; j3 < i; ++j3) {
                    BlockPos offsetPos = position.offset(orientation, j3);
                    state = worldIn.getBlockState(offsetPos);

                    if (state.getBlock().isAir(state, worldIn, offsetPos) || state.getBlock().isLeaves(state, worldIn, offsetPos) || state.getMaterial() == Material.VINE) {
                        this.setBlockAndNotifyAdequately(worldIn, position.offset(orientation, j3), this.stateWood);
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
}
 
Example 20
Source File: BlockTofuPortal.java    From TofuCraftReload with MIT License 2 votes vote down vote up
public Size(World worldIn, BlockPos p_i45694_2_, EnumFacing.Axis p_i45694_3_) {

            this.world = worldIn;

            this.axis = p_i45694_3_;


            if (p_i45694_3_ == EnumFacing.Axis.X) {

                this.leftDir = EnumFacing.EAST;

                this.rightDir = EnumFacing.WEST;

            } else {

                this.leftDir = EnumFacing.NORTH;

                this.rightDir = EnumFacing.SOUTH;

            }


            for (BlockPos blockpos = p_i45694_2_; p_i45694_2_.getY() > blockpos.getY() - 21 && p_i45694_2_.getY() > 0 &&

                    this.isEmptyBlock(worldIn.getBlockState(p_i45694_2_.down())); p_i45694_2_ = p_i45694_2_.down()) {

            }


            int i = this.getDistanceUntilEdge(p_i45694_2_, this.leftDir) - 1;


            if (i >= 0) {

                this.bottomLeft = p_i45694_2_.offset(this.leftDir, i);

                this.width = this.getDistanceUntilEdge(this.bottomLeft, this.rightDir);


                if (this.width < 2 || this.width > 21) {

                    this.bottomLeft = null;

                    this.width = 0;

                }

            }


            if (this.bottomLeft != null) {

                this.height = this.calculatePortalHeight();

            }

        }