Java Code Examples for net.minecraft.util.EnumFacing#equals()

The following examples show how to use net.minecraft.util.EnumFacing#equals() . 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: ItemSeedBase.java    From ExNihiloAdscensio with MIT License 6 votes vote down vote up
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
       if (!facing.equals(EnumFacing.UP))
       	return EnumActionResult.PASS;
       	
       if (player.canPlayerEdit(pos, facing, stack) && player.canPlayerEdit(pos.add(0, 1, 0), facing, stack)) {
           IBlockState soil = world.getBlockState(pos);

           if (soil != null && soil.getBlock().canSustainPlant(soil, world, pos, EnumFacing.UP, this) 
           		&& world.isAirBlock(pos.add(0, 1, 0)) 
           		&& this.getPlant(world, pos) != null)
           {
               world.setBlockState(pos.add(0, 1, 0), this.getPlant(world, pos));
               --stack.stackSize;
               return EnumActionResult.SUCCESS;
           }
       }
       
       return EnumActionResult.PASS;
   }
 
Example 2
Source File: PositionHelper.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adjust the position so that the given Entity's bounding box is against the block bound
 * of a block on the given side. Note that the entity may still be colliding on other sides.
 * @param entity
 * @param side
 */
public void adjustPositionToTouchFace(Entity entity, EnumFacing facing)
{
    this.posX += (facing.getXOffset() * entity.width / 2);
    this.posZ += (facing.getZOffset() * entity.width / 2);

    // Bottom side
    if (facing.equals(EnumFacing.DOWN))
    {
        this.posY -= entity.height;
    }
}
 
Example 3
Source File: TileEntitySprinkler.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
public boolean canConnectTo(EnumFacing side, IAgriConnectable component) {
    return side.equals(EnumFacing.UP) && component instanceof IAgriFluidComponent;
}